From 1653304129f49d0da0f12359c3385a1a86ea7603 Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Sun, 21 Sep 2014 03:29:34 -0700 Subject: [PATCH] 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 --- cmd/ipfs/init.go | 2 +- cmd/ipfs/mount_unix.go | 9 ++++++++- config/config.go | 7 ++++--- daemon/daemon.go | 15 +++++++++++---- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/cmd/ipfs/init.go b/cmd/ipfs/init.go index 1ad1a4587..5ee868556 100644 --- a/cmd/ipfs/init.go +++ b/cmd/ipfs/init.go @@ -71,7 +71,7 @@ func initCmd(c *commander.Command, inp []string) error { cfg.Identity = new(config.Identity) // This needs thought - // cfg.Identity.Address = "" + cfg.Identity.Address = "/ip4/127.0.0.1/tcp/4001" nbits, ok := c.Flag.Lookup("b").Value.Get().(int) if !ok { diff --git a/cmd/ipfs/mount_unix.go b/cmd/ipfs/mount_unix.go index 92d445395..56a802b5e 100644 --- a/cmd/ipfs/mount_unix.go +++ b/cmd/ipfs/mount_unix.go @@ -7,6 +7,8 @@ import ( "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/gonuts/flag" "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/commander" + ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" + "github.com/jbenet/go-ipfs/daemon" rofs "github.com/jbenet/go-ipfs/fuse/readonly" u "github.com/jbenet/go-ipfs/util" @@ -42,7 +44,12 @@ func mountCmd(c *commander.Command, inp []string) error { return err } - dl, err := daemon.NewDaemonListener(n, "localhost:12345") + maddr, err := ma.NewMultiaddr(n.Config.RPCAddress) + if err != nil { + return err + } + + dl, err := daemon.NewDaemonListener(n, maddr) if err != nil { return err } diff --git a/config/config.go b/config/config.go index 54d461b19..00d00e97f 100644 --- a/config/config.go +++ b/config/config.go @@ -30,9 +30,10 @@ type SavedPeer struct { // Config is used to load IPFS config files. type Config struct { - Identity *Identity - Datastore Datastore - Peers []*SavedPeer + Identity *Identity // local node's peer identity + Datastore Datastore // local node's storage + RPCAddress string // local node's RPC address + Peers []*SavedPeer // local nodes's bootstrap peers } const DefaultPathRoot = "~/.go-ipfs" diff --git a/daemon/daemon.go b/daemon/daemon.go index f1983e502..60814ceb8 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -8,10 +8,12 @@ import ( core "github.com/jbenet/go-ipfs/core" "github.com/jbenet/go-ipfs/core/commands" u "github.com/jbenet/go-ipfs/util" + + ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" ) -//DaemonListener listens to an initialized IPFS node and can send it commands instead of -//starting up a new set of connections +// DaemonListener listens to an initialized IPFS node and can send it commands instead of +// starting up a new set of connections type DaemonListener struct { node *core.IpfsNode list net.Listener @@ -25,8 +27,13 @@ type Command struct { Opts map[string]interface{} } -func NewDaemonListener(ipfsnode *core.IpfsNode, addr string) (*DaemonListener, error) { - list, err := net.Listen("tcp", addr) +func NewDaemonListener(ipfsnode *core.IpfsNode, addr *ma.Multiaddr) (*DaemonListener, error) { + network, host, err := addr.DialArgs() + if err != nil { + return nil, err + } + + list, err := net.Listen(network, host) if err != nil { return nil, err }