From bf8a925ce902705cc859056eee9f89ec27ba3590 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Mon, 4 Feb 2019 08:35:19 +1100 Subject: [PATCH 1/5] Use the DHT bootstrap peer list --- bootstrap.go | 31 +++++-------------------------- p2pd/main.go | 10 ++++++++-- 2 files changed, 13 insertions(+), 28 deletions(-) diff --git a/bootstrap.go b/bootstrap.go index 82332d8..f726128 100644 --- a/bootstrap.go +++ b/bootstrap.go @@ -6,45 +6,24 @@ import ( "math/rand" "time" + dht "github.com/libp2p/go-libp2p-kad-dht" inet "github.com/libp2p/go-libp2p-net" pstore "github.com/libp2p/go-libp2p-peerstore" - ma "github.com/multiformats/go-multiaddr" ) -var BootstrapPeers = []string{ - "/dnsaddr/bootstrap.libp2p.io/ipfs/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN", - "/dnsaddr/bootstrap.libp2p.io/ipfs/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa", - "/dnsaddr/bootstrap.libp2p.io/ipfs/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb", - "/dnsaddr/bootstrap.libp2p.io/ipfs/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt", - "/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ", // mars.i.ipfs.io - "/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM", // pluto.i.ipfs.io - "/ip4/128.199.219.111/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu", // saturn.i.ipfs.io - "/ip4/104.236.76.40/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64", // venus.i.ipfs.io - "/ip4/178.62.158.247/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd", // earth.i.ipfs.io - "/ip6/2604:a880:1:20::203:d001/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM", // pluto.i.ipfs.io - "/ip6/2400:6180:0:d0::151:6001/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu", // saturn.i.ipfs.io - "/ip6/2604:a880:800:10::4a:5001/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64", // venus.i.ipfs.io - "/ip6/2a03:b0c0:0:1010::23:1001/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd", // earth.i.ipfs.io -} +var BootstrapPeers = dht.DefaultBootstrapPeers const BootstrapConnections = 4 func bootstrapPeerInfo() ([]*pstore.PeerInfo, error) { - pis := make([]*pstore.PeerInfo, len(BootstrapPeers)) - for x, p := range BootstrapPeers { - a, err := ma.NewMultiaddr(p) - if err != nil { - return nil, err - } - + var pis []*pstore.PeerInfo + for _, a := range BootstrapPeers { pi, err := pstore.InfoFromP2pAddr(a) if err != nil { return nil, err } - - pis[x] = pi + pis = append(pis, pi) } - return pis, nil } diff --git a/p2pd/main.go b/p2pd/main.go index d3edb88..e8fa620 100644 --- a/p2pd/main.go +++ b/p2pd/main.go @@ -13,7 +13,7 @@ import ( p2pd "github.com/libp2p/go-libp2p-daemon" ps "github.com/libp2p/go-libp2p-pubsub" quic "github.com/libp2p/go-libp2p-quic-transport" - identify "github.com/libp2p/go-libp2p/p2p/protocol/identify" + "github.com/libp2p/go-libp2p/p2p/protocol/identify" multiaddr "github.com/multiformats/go-multiaddr" ) @@ -128,7 +128,13 @@ func main() { } if *bootstrapPeers != "" { - p2pd.BootstrapPeers = strings.Split(*bootstrapPeers, ",") + for _, s := range strings.Split(*bootstrapPeers, ",") { + ma, err := multiaddr.NewMultiaddr(s) + if err != nil { + log.Fatalf("error parsing bootstrap peer %q: %v", s, err) + } + p2pd.BootstrapPeers = append(p2pd.BootstrapPeers, ma) + } } if *bootstrap { From c9723fe3ad793739a0a515492919e616313dba09 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Tue, 5 Feb 2019 09:16:01 +1100 Subject: [PATCH 2/5] Address PR feedback --- bootstrap.go | 2 +- p2pd/main.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bootstrap.go b/bootstrap.go index f726128..bc4180e 100644 --- a/bootstrap.go +++ b/bootstrap.go @@ -16,7 +16,7 @@ var BootstrapPeers = dht.DefaultBootstrapPeers const BootstrapConnections = 4 func bootstrapPeerInfo() ([]*pstore.PeerInfo, error) { - var pis []*pstore.PeerInfo + pis := make([]*pstore.PeerInfo, 0, len(BootstrapPeers)) for _, a := range BootstrapPeers { pi, err := pstore.InfoFromP2pAddr(a) if err != nil { diff --git a/p2pd/main.go b/p2pd/main.go index e8fa620..e2fea02 100644 --- a/p2pd/main.go +++ b/p2pd/main.go @@ -13,7 +13,7 @@ import ( p2pd "github.com/libp2p/go-libp2p-daemon" ps "github.com/libp2p/go-libp2p-pubsub" quic "github.com/libp2p/go-libp2p-quic-transport" - "github.com/libp2p/go-libp2p/p2p/protocol/identify" + identify "github.com/libp2p/go-libp2p/p2p/protocol/identify" multiaddr "github.com/multiformats/go-multiaddr" ) From 79eb54d705fe54b9aa4dab8440f2b7f0b99cd8f3 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Tue, 5 Feb 2019 09:51:41 +1100 Subject: [PATCH 3/5] Use Go 1.11.x --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5a95995..2172ef2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ sudo: false language: go go: -- 1.9.x +- 1.11.x install: - make deps From a5dde20dda07ef4f05a78d9de341155208d87c1b Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Tue, 5 Feb 2019 10:31:47 +1100 Subject: [PATCH 4/5] go fmt Seems the CI wants this --- daemon.go | 2 +- p2pclient/p2pclient.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/daemon.go b/daemon.go index 15c4488..37cc035 100644 --- a/daemon.go +++ b/daemon.go @@ -35,7 +35,7 @@ type Daemon struct { func NewDaemon(ctx context.Context, maddr ma.Multiaddr, dhtEnabled bool, dhtClient bool, opts ...libp2p.Option) (*Daemon, error) { d := &Daemon{ - ctx: ctx, + ctx: ctx, handlers: make(map[proto.ID]ma.Multiaddr), } diff --git a/p2pclient/p2pclient.go b/p2pclient/p2pclient.go index f6c8af9..06d25cf 100644 --- a/p2pclient/p2pclient.go +++ b/p2pclient/p2pclient.go @@ -21,7 +21,7 @@ const MessageSizeMax = 1 << 22 // 4 MB type Client struct { controlMaddr multiaddr.Multiaddr listenMaddr multiaddr.Multiaddr - listener manet.Listener + listener manet.Listener mhandlers sync.Mutex handlers map[string]StreamHandlerFunc From 7e892d68cced63e6ad1343a6cd7ecf1bfc7ddf2c Mon Sep 17 00:00:00 2001 From: vyzo Date: Tue, 5 Feb 2019 11:21:21 +0200 Subject: [PATCH 5/5] gx bump dht dep --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 5846944..90686e9 100644 --- a/package.json +++ b/package.json @@ -12,9 +12,9 @@ "version": "6.0.30" }, { - "hash": "QmNoNExMdWrYSPZDiJJTVmxSh6uKLN26xYVzbLzBLedRcv", + "hash": "QmbSCZ2CWbbrT7NY7vdntnF39hnrvGpVbbP1XaP5fwTmvo", "name": "go-libp2p-kad-dht", - "version": "4.4.19" + "version": "4.4.20" }, { "author": "whyrusleeping",