adjusted what Address means in config
There are (so far) two sorts of addresses that peers care about: - peer network addresses, local to listen, saved to bootstrap. `config.Identity.Address` - peer RPC network address, local RPC tcp endpoint `config.RPCAddress` @whyrusleeping @perfmode
Juan Batiz-Benet committed
Sep 21, 2014 at 03:29 UTC
1653304129f49d0da0f12359c3385a1a86ea7603
4 files changed
+24
-9
cmd/ipfs/init.go
+1
-1
@@ -71,7 +71,7 @@ func initCmd(c *commander.Command, inp []string) error {
71
72
cfg.Identity = new(config.Identity)
73
// This needs thought
74
- // cfg.Identity.Address = ""
74
+ cfg.Identity.Address = "/ip4/127.0.0.1/tcp/4001"
75
76
nbits, ok := c.Flag.Lookup("b").Value.Get().(int)
77
if !ok {
cmd/ipfs/mount_unix.go
+8
-1
@@ -7,6 +7,8 @@ import (
7
8
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/gonuts/flag"
9
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/commander"
10
+ ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
11
+
12
"github.com/jbenet/go-ipfs/daemon"
13
rofs "github.com/jbenet/go-ipfs/fuse/readonly"
14
u "github.com/jbenet/go-ipfs/util"
@@ -42,7 +44,12 @@ func mountCmd(c *commander.Command, inp []string) error {
44
return err
45
}
46
45
- dl, err := daemon.NewDaemonListener(n, "localhost:12345")
47
+ maddr, err := ma.NewMultiaddr(n.Config.RPCAddress)
48
+ if err != nil {
49
+ return err
50
+ }
51
+
52
+ dl, err := daemon.NewDaemonListener(n, maddr)
53
if err != nil {
54
return err
55
}
config/config.go
+4
-3
@@ -30,9 +30,10 @@ type SavedPeer struct {
30
31
// Config is used to load IPFS config files.
32
type Config struct {
33
- Identity *Identity
34
- Datastore Datastore
35
- Peers []*SavedPeer
33
+ Identity *Identity // local node's peer identity
34
+ Datastore Datastore // local node's storage
35
+ RPCAddress string // local node's RPC address
36
+ Peers []*SavedPeer // local nodes's bootstrap peers
37
}
38
39
const DefaultPathRoot = "~/.go-ipfs"
daemon/daemon.go
+11
-4
@@ -8,10 +8,12 @@ import (
8
core "github.com/jbenet/go-ipfs/core"
9
"github.com/jbenet/go-ipfs/core/commands"
10
u "github.com/jbenet/go-ipfs/util"
11
+
12
+ ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
13
)
14
13
-//DaemonListener listens to an initialized IPFS node and can send it commands instead of
14
-//starting up a new set of connections
15
+// DaemonListener listens to an initialized IPFS node and can send it commands instead of
16
+// starting up a new set of connections
17
type DaemonListener struct {
18
node *core.IpfsNode
19
list net.Listener
@@ -25,8 +27,13 @@ type Command struct {
27
Opts map[string]interface{}
28
}
29
28
-func NewDaemonListener(ipfsnode *core.IpfsNode, addr string) (*DaemonListener, error) {
29
- list, err := net.Listen("tcp", addr)
30
+func NewDaemonListener(ipfsnode *core.IpfsNode, addr *ma.Multiaddr) (*DaemonListener, error) {
31
+ network, host, err := addr.DialArgs()
32
+ if err != nil {
33
+ return nil, err
34
+ }
35
+
36
+ list, err := net.Listen(network, host)
37
if err != nil {
38
return nil, err
39
}