mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-25 20:37:53 +08:00
config: swarm is list of addrs
This commit is contained in:
parent
fc6bab7b73
commit
1a5cb300cb
@ -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{
|
||||
|
||||
@ -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
|
||||
|
||||
12
core/core.go
12
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
|
||||
|
||||
@ -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",
|
||||
},
|
||||
},
|
||||
|
||||
Loading…
Reference in New Issue
Block a user