From 1a5cb300cb80a7dbd8d6a895e8f976c2fa6b4ce2 Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Thu, 20 Nov 2014 04:35:25 -0800 Subject: [PATCH] config: swarm is list of addrs --- cmd/ipfs/init.go | 7 +++++-- config/config.go | 4 ++-- core/core.go | 12 ++++++------ core/core_test.go | 4 ++-- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/cmd/ipfs/init.go b/cmd/ipfs/init.go index 2b41befb1..92eac60ed 100644 --- a/cmd/ipfs/init.go +++ b/cmd/ipfs/init.go @@ -179,8 +179,11 @@ func initConfig(configFilename string, dspathOverride string, nBitsForKeypair in // setup the node addresses. Addresses: config.Addresses{ - Swarm: "/ip4/0.0.0.0/tcp/4001", - API: "/ip4/127.0.0.1/tcp/5001", + Swarm: []string{ + "/ip4/0.0.0.0/tcp/4001", + "/ip4/0.0.0.0/udp/4002/utp", + }, + API: "/ip4/127.0.0.1/tcp/5001", }, Bootstrap: []*config.BootstrapPeer{ diff --git a/config/config.go b/config/config.go index 73b2bc707..46fc8badd 100644 --- a/config/config.go +++ b/config/config.go @@ -36,8 +36,8 @@ type Datastore struct { // Addresses stores the (string) multiaddr addresses for the node. type Addresses struct { - Swarm string // address for the swarm network - API string // address for the local API (RPC) + Swarm []string // addresses for the swarm network + API string // address for the local API (RPC) } // Mounts stores the (string) mount points diff --git a/core/core.go b/core/core.go index 09014cd11..1fe9c9992 100644 --- a/core/core.go +++ b/core/core.go @@ -268,15 +268,15 @@ func initConnections(ctx context.Context, cfg *config.Config, pstore peer.Peerst } func listenAddresses(cfg *config.Config) ([]ma.Multiaddr, error) { - var listen []ma.Multiaddr - if len(cfg.Addresses.Swarm) > 0 { - maddr, err := ma.NewMultiaddr(cfg.Addresses.Swarm) + var err error + listen := make([]ma.Multiaddr, len(cfg.Addresses.Swarm)) + for i, addr := range cfg.Addresses.Swarm { + + listen[i], err = ma.NewMultiaddr(addr) if err != nil { - return nil, fmt.Errorf("Failure to parse config.Addresses.Swarm: %s", cfg.Addresses.Swarm) + return nil, fmt.Errorf("Failure to parse config.Addresses.Swarm[%d]: %s", i, cfg.Addresses.Swarm) } - - listen = append(listen, maddr) } return listen, nil diff --git a/core/core_test.go b/core/core_test.go index 8c01b350a..91c311050 100644 --- a/core/core_test.go +++ b/core/core_test.go @@ -17,7 +17,7 @@ func TestInitialization(t *testing.T) { Type: "memory", }, Addresses: config.Addresses{ - Swarm: "/ip4/0.0.0.0/tcp/4001", + Swarm: []string{"/ip4/0.0.0.0/tcp/4001"}, API: "/ip4/127.0.0.1/tcp/8000", }, }, @@ -29,7 +29,7 @@ func TestInitialization(t *testing.T) { Path: ".testdb", }, Addresses: config.Addresses{ - Swarm: "/ip4/0.0.0.0/tcp/4001", + Swarm: []string{"/ip4/0.0.0.0/tcp/4001"}, API: "/ip4/127.0.0.1/tcp/8000", }, },