From 4eed546e067f04e6278fe580a47dd4328426ec84 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Thu, 16 Feb 2017 15:19:48 +0100 Subject: [PATCH 1/3] deps: update dependencies for PNet License: MIT Signed-off-by: Jakub Sztandera --- core/commands/dht.go | 2 +- core/commands/id.go | 2 +- core/commands/pubsub.go | 2 +- core/commands/swarm.go | 2 +- core/core.go | 16 +-- core/corehttp/gateway.go | 2 +- core/corehttp/gateway_test.go | 2 +- core/corehttp/metrics_test.go | 4 +- core/mock/mock.go | 2 +- exchange/bitswap/bitswap_test.go | 2 +- exchange/bitswap/testnet/peernet.go | 2 +- exchange/bitswap/testutils.go | 2 +- namesys/republisher/repub_test.go | 2 +- package.json | 12 +- routing/mock/dht.go | 4 +- routing/supernode/client.go | 2 +- routing/supernode/proxy/loopback.go | 2 +- routing/supernode/proxy/standard.go | 2 +- routing/supernode/server.go | 2 +- routing/supernode/server_test.go | 2 +- test/integration/addcat_test.go | 2 +- test/integration/bench_cat_test.go | 2 +- test/integration/bitswap_wo_routing_test.go | 2 +- test/integration/grandcentral_test.go | 2 +- test/integration/three_legged_cat_test.go | 2 +- test/sharness/t0181-private-network.sh | 135 ++++++++++++++++++++ 26 files changed, 174 insertions(+), 39 deletions(-) create mode 100755 test/sharness/t0181-private-network.sh diff --git a/core/commands/dht.go b/core/commands/dht.go index d6b6b81cb61..6cfafef71f5 100644 --- a/core/commands/dht.go +++ b/core/commands/dht.go @@ -14,12 +14,12 @@ import ( pstore "gx/ipfs/QmQMQ2RUjnaEEX8ybmrhuFFGhAwPjyL1Eo6ZoJGD7aAccM/go-libp2p-peerstore" b58 "gx/ipfs/QmT8rehPR3F6bmwL6zjUN8XpiDBFFpMP2myPdC6ApsWfJf/go-base58" + ipdht "gx/ipfs/QmUpZqxzrUoyDsgWXDri9yYgi5r5EK7J5Tan1MbgnawYLx/go-libp2p-kad-dht" cid "gx/ipfs/QmV5gPoRsjN1Gid3LMdNZTyfCtP2DsvqEbMAmz82RmmiGk/go-cid" peer "gx/ipfs/QmZcUPvPhD1Xvk6mwijYF8AfR3mG31S1YsEfHG4khrFPRr/go-libp2p-peer" routing "gx/ipfs/QmZghcVHwXQC3Zvnvn24LgTmSPkEn2o3PDyKb6nrtPRzRh/go-libp2p-routing" notif "gx/ipfs/QmZghcVHwXQC3Zvnvn24LgTmSPkEn2o3PDyKb6nrtPRzRh/go-libp2p-routing/notifications" u "gx/ipfs/QmZuY8aV7zbNXVy6DyN9SmnuH3o9nG852F4aTiSBpts8d1/go-ipfs-util" - ipdht "gx/ipfs/QmdFu71pRmWMNWht96ZTJ3wRx4D7BPJ2JfHH24z59Gidsc/go-libp2p-kad-dht" ) var ErrNotDHT = errors.New("routing service is not a DHT") diff --git a/core/commands/id.go b/core/commands/id.go index 98c9b8acb14..3041208669f 100644 --- a/core/commands/id.go +++ b/core/commands/id.go @@ -16,7 +16,7 @@ import ( ic "gx/ipfs/QmNiCwBNA8MWDADTFVq1BonUEJbS2SvjAoNkZZrhEwcuUi/go-libp2p-crypto" pstore "gx/ipfs/QmQMQ2RUjnaEEX8ybmrhuFFGhAwPjyL1Eo6ZoJGD7aAccM/go-libp2p-peerstore" - identify "gx/ipfs/QmSNJRX4uphb3Eyp69uYbpRVvgqjPxfjnJmjcdMWkDH5Pn/go-libp2p/p2p/protocol/identify" + identify "gx/ipfs/QmU3g3psEDiC4tQh1Qu2NYg5aYVQqxC3m74ZavLwPfJEtu/go-libp2p/p2p/protocol/identify" "gx/ipfs/QmZcUPvPhD1Xvk6mwijYF8AfR3mG31S1YsEfHG4khrFPRr/go-libp2p-peer" u "gx/ipfs/QmZuY8aV7zbNXVy6DyN9SmnuH3o9nG852F4aTiSBpts8d1/go-ipfs-util" ) diff --git a/core/commands/pubsub.go b/core/commands/pubsub.go index 194ac9844ab..096d95f4d1a 100644 --- a/core/commands/pubsub.go +++ b/core/commands/pubsub.go @@ -14,10 +14,10 @@ import ( cmds "github.com/ipfs/go-ipfs/commands" core "github.com/ipfs/go-ipfs/core" + floodsub "gx/ipfs/QmQDb7jmfC33qzGUGpWrfgRootQnmQvN7DMktfuekShsiF/floodsub" pstore "gx/ipfs/QmQMQ2RUjnaEEX8ybmrhuFFGhAwPjyL1Eo6ZoJGD7aAccM/go-libp2p-peerstore" cid "gx/ipfs/QmV5gPoRsjN1Gid3LMdNZTyfCtP2DsvqEbMAmz82RmmiGk/go-cid" u "gx/ipfs/QmZuY8aV7zbNXVy6DyN9SmnuH3o9nG852F4aTiSBpts8d1/go-ipfs-util" - floodsub "gx/ipfs/Qmf2UPccWR8aZWT8UvEEKP9PhJQNidSegwEMrzZKHsCX4u/floodsub" ) var PubsubCmd = &cmds.Command{ diff --git a/core/commands/swarm.go b/core/commands/swarm.go index 0cdc7031802..8875f5db394 100644 --- a/core/commands/swarm.go +++ b/core/commands/swarm.go @@ -13,8 +13,8 @@ import ( config "github.com/ipfs/go-ipfs/repo/config" "github.com/ipfs/go-ipfs/repo/fsrepo" iaddr "github.com/ipfs/go-ipfs/thirdparty/ipfsaddr" + swarm "gx/ipfs/QmNT1JbT5S89ew7kozkHoX5KUG1rfPZvTU3oMDRyJua7rU/go-libp2p-swarm" pstore "gx/ipfs/QmQMQ2RUjnaEEX8ybmrhuFFGhAwPjyL1Eo6ZoJGD7aAccM/go-libp2p-peerstore" - swarm "gx/ipfs/QmY8hduizbuACvYmL4aZQbpFeKhEQJ1Nom2jY6kv6rL8Gf/go-libp2p-swarm" mafilter "gx/ipfs/QmSMZwvs3n4GBikZ7hKzT17c3bk65FmyZo2JqtJ16swqCv/multiaddr-filter" ma "gx/ipfs/QmSWLfmj5frN9xVLMMN846dMDriy5wN5jeghUm7aTW3DAG/go-multiaddr" diff --git a/core/core.go b/core/core.go index c01c636768a..aa660c0fed1 100644 --- a/core/core.go +++ b/core/core.go @@ -40,34 +40,34 @@ import ( offroute "github.com/ipfs/go-ipfs/routing/offline" ft "github.com/ipfs/go-ipfs/unixfs" + swarm "gx/ipfs/QmNT1JbT5S89ew7kozkHoX5KUG1rfPZvTU3oMDRyJua7rU/go-libp2p-swarm" ic "gx/ipfs/QmNiCwBNA8MWDADTFVq1BonUEJbS2SvjAoNkZZrhEwcuUi/go-libp2p-crypto" addrutil "gx/ipfs/QmPB5aAzt2wo5Xk8SoZi6y2oFN7shQMvYWgduMATojkdpj/go-addr-util" metrics "gx/ipfs/QmPj6rmE2sWJ65h6b8F4fcN5kySDhYqL2Ty8DWWF3WEUNS/go-libp2p-metrics" mplex "gx/ipfs/QmQ3UABWTgK78utKeiVXaH9BrjC7Ydn1pRuwqnWHT3p4zh/go-smux-multiplex" + floodsub "gx/ipfs/QmQDb7jmfC33qzGUGpWrfgRootQnmQvN7DMktfuekShsiF/floodsub" pstore "gx/ipfs/QmQMQ2RUjnaEEX8ybmrhuFFGhAwPjyL1Eo6ZoJGD7aAccM/go-libp2p-peerstore" mssmux "gx/ipfs/QmRVYfZ7tWNHPBzWiG6KWGzvT2hcGems8srihsQE29x1U5/go-smux-multistream" ds "gx/ipfs/QmRWDav6mzWseLWeYfVd5fvUKiVe9xNH29YfMF438fG364/go-datastore" goprocess "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess" mamask "gx/ipfs/QmSMZwvs3n4GBikZ7hKzT17c3bk65FmyZo2JqtJ16swqCv/multiaddr-filter" - discovery "gx/ipfs/QmSNJRX4uphb3Eyp69uYbpRVvgqjPxfjnJmjcdMWkDH5Pn/go-libp2p/p2p/discovery" - p2pbhost "gx/ipfs/QmSNJRX4uphb3Eyp69uYbpRVvgqjPxfjnJmjcdMWkDH5Pn/go-libp2p/p2p/host/basic" - rhost "gx/ipfs/QmSNJRX4uphb3Eyp69uYbpRVvgqjPxfjnJmjcdMWkDH5Pn/go-libp2p/p2p/host/routed" - identify "gx/ipfs/QmSNJRX4uphb3Eyp69uYbpRVvgqjPxfjnJmjcdMWkDH5Pn/go-libp2p/p2p/protocol/identify" - ping "gx/ipfs/QmSNJRX4uphb3Eyp69uYbpRVvgqjPxfjnJmjcdMWkDH5Pn/go-libp2p/p2p/protocol/ping" ma "gx/ipfs/QmSWLfmj5frN9xVLMMN846dMDriy5wN5jeghUm7aTW3DAG/go-multiaddr" logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log" b58 "gx/ipfs/QmT8rehPR3F6bmwL6zjUN8XpiDBFFpMP2myPdC6ApsWfJf/go-base58" + discovery "gx/ipfs/QmU3g3psEDiC4tQh1Qu2NYg5aYVQqxC3m74ZavLwPfJEtu/go-libp2p/p2p/discovery" + p2pbhost "gx/ipfs/QmU3g3psEDiC4tQh1Qu2NYg5aYVQqxC3m74ZavLwPfJEtu/go-libp2p/p2p/host/basic" + rhost "gx/ipfs/QmU3g3psEDiC4tQh1Qu2NYg5aYVQqxC3m74ZavLwPfJEtu/go-libp2p/p2p/host/routed" + identify "gx/ipfs/QmU3g3psEDiC4tQh1Qu2NYg5aYVQqxC3m74ZavLwPfJEtu/go-libp2p/p2p/protocol/identify" + ping "gx/ipfs/QmU3g3psEDiC4tQh1Qu2NYg5aYVQqxC3m74ZavLwPfJEtu/go-libp2p/p2p/protocol/ping" + dht "gx/ipfs/QmUpZqxzrUoyDsgWXDri9yYgi5r5EK7J5Tan1MbgnawYLx/go-libp2p-kad-dht" cid "gx/ipfs/QmV5gPoRsjN1Gid3LMdNZTyfCtP2DsvqEbMAmz82RmmiGk/go-cid" spdy "gx/ipfs/QmWUNsat6Jb19nC5CiJCDXepTkxjdxi3eZqeoB6mrmmaGu/go-smux-spdystream" - swarm "gx/ipfs/QmY8hduizbuACvYmL4aZQbpFeKhEQJ1Nom2jY6kv6rL8Gf/go-libp2p-swarm" peer "gx/ipfs/QmZcUPvPhD1Xvk6mwijYF8AfR3mG31S1YsEfHG4khrFPRr/go-libp2p-peer" routing "gx/ipfs/QmZghcVHwXQC3Zvnvn24LgTmSPkEn2o3PDyKb6nrtPRzRh/go-libp2p-routing" u "gx/ipfs/QmZuY8aV7zbNXVy6DyN9SmnuH3o9nG852F4aTiSBpts8d1/go-ipfs-util" yamux "gx/ipfs/Qmbn7RYyWzBVXiUp9jZ1dA4VADHy9DtS7iZLwfhEUQvm3U/go-smux-yamux" p2phost "gx/ipfs/QmbzbRyd22gcW92U1rA2yKagB3myMYhk45XBknJ49F9XWJ/go-libp2p-host" - dht "gx/ipfs/QmdFu71pRmWMNWht96ZTJ3wRx4D7BPJ2JfHH24z59Gidsc/go-libp2p-kad-dht" smux "gx/ipfs/QmeZBgYBHvxMukGK5ojg28BCNLB9SeXqT7XXg6o7r2GbJy/go-stream-muxer" - floodsub "gx/ipfs/Qmf2UPccWR8aZWT8UvEEKP9PhJQNidSegwEMrzZKHsCX4u/floodsub" ) const IpnsValidatorTag = "ipns" diff --git a/core/corehttp/gateway.go b/core/corehttp/gateway.go index 74b1cc3252e..169f4c78198 100644 --- a/core/corehttp/gateway.go +++ b/core/corehttp/gateway.go @@ -8,7 +8,7 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmSNJRX4uphb3Eyp69uYbpRVvgqjPxfjnJmjcdMWkDH5Pn/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmU3g3psEDiC4tQh1Qu2NYg5aYVQqxC3m74ZavLwPfJEtu/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/core/corehttp/gateway_test.go b/core/corehttp/gateway_test.go index a474ac25bd7..9e1abfd7888 100644 --- a/core/corehttp/gateway_test.go +++ b/core/corehttp/gateway_test.go @@ -20,7 +20,7 @@ import ( testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" ci "gx/ipfs/QmNiCwBNA8MWDADTFVq1BonUEJbS2SvjAoNkZZrhEwcuUi/go-libp2p-crypto" - id "gx/ipfs/QmSNJRX4uphb3Eyp69uYbpRVvgqjPxfjnJmjcdMWkDH5Pn/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmU3g3psEDiC4tQh1Qu2NYg5aYVQqxC3m74ZavLwPfJEtu/go-libp2p/p2p/protocol/identify" ) type mockNamesys map[string]path.Path diff --git a/core/corehttp/metrics_test.go b/core/corehttp/metrics_test.go index 748ee898ead..81b5dccb924 100644 --- a/core/corehttp/metrics_test.go +++ b/core/corehttp/metrics_test.go @@ -8,8 +8,8 @@ import ( core "github.com/ipfs/go-ipfs/core" inet "gx/ipfs/QmRuZnMorqodado1yeTQiv1i9rmtKj29CjPSsBKM7DFXV4/go-libp2p-net" - bhost "gx/ipfs/QmSNJRX4uphb3Eyp69uYbpRVvgqjPxfjnJmjcdMWkDH5Pn/go-libp2p/p2p/host/basic" - testutil "gx/ipfs/QmTcGn1vzu7YNxz6FEXvfUfMy6WmYeQ5VtU3MbWM8c92rB/go-libp2p-netutil" + bhost "gx/ipfs/QmU3g3psEDiC4tQh1Qu2NYg5aYVQqxC3m74ZavLwPfJEtu/go-libp2p/p2p/host/basic" + testutil "gx/ipfs/QmdGRzr9bPTt2ZrBFaq5R2zzD7JFXNRxXZGkzsVcW6pEzh/go-libp2p-netutil" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect diff --git a/core/mock/mock.go b/core/mock/mock.go index 0fa28c6a678..110ae3c478d 100644 --- a/core/mock/mock.go +++ b/core/mock/mock.go @@ -15,7 +15,7 @@ import ( pstore "gx/ipfs/QmQMQ2RUjnaEEX8ybmrhuFFGhAwPjyL1Eo6ZoJGD7aAccM/go-libp2p-peerstore" "gx/ipfs/QmRWDav6mzWseLWeYfVd5fvUKiVe9xNH29YfMF438fG364/go-datastore" syncds "gx/ipfs/QmRWDav6mzWseLWeYfVd5fvUKiVe9xNH29YfMF438fG364/go-datastore/sync" - mocknet "gx/ipfs/QmSNJRX4uphb3Eyp69uYbpRVvgqjPxfjnJmjcdMWkDH5Pn/go-libp2p/p2p/net/mock" + mocknet "gx/ipfs/QmU3g3psEDiC4tQh1Qu2NYg5aYVQqxC3m74ZavLwPfJEtu/go-libp2p/p2p/net/mock" peer "gx/ipfs/QmZcUPvPhD1Xvk6mwijYF8AfR3mG31S1YsEfHG4khrFPRr/go-libp2p-peer" host "gx/ipfs/QmbzbRyd22gcW92U1rA2yKagB3myMYhk45XBknJ49F9XWJ/go-libp2p-host" smux "gx/ipfs/QmeZBgYBHvxMukGK5ojg28BCNLB9SeXqT7XXg6o7r2GbJy/go-stream-muxer" diff --git a/exchange/bitswap/bitswap_test.go b/exchange/bitswap/bitswap_test.go index 6ebcdd35013..8cef2d3ad53 100644 --- a/exchange/bitswap/bitswap_test.go +++ b/exchange/bitswap/bitswap_test.go @@ -17,8 +17,8 @@ import ( detectrace "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-detect-race" - p2ptestutil "gx/ipfs/QmTcGn1vzu7YNxz6FEXvfUfMy6WmYeQ5VtU3MbWM8c92rB/go-libp2p-netutil" cid "gx/ipfs/QmV5gPoRsjN1Gid3LMdNZTyfCtP2DsvqEbMAmz82RmmiGk/go-cid" + p2ptestutil "gx/ipfs/QmdGRzr9bPTt2ZrBFaq5R2zzD7JFXNRxXZGkzsVcW6pEzh/go-libp2p-netutil" ) // FIXME the tests are really sensitive to the network delay. fix them to work diff --git a/exchange/bitswap/testnet/peernet.go b/exchange/bitswap/testnet/peernet.go index bfaa13aa265..38378736d18 100644 --- a/exchange/bitswap/testnet/peernet.go +++ b/exchange/bitswap/testnet/peernet.go @@ -6,7 +6,7 @@ import ( mockrouting "github.com/ipfs/go-ipfs/routing/mock" testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" ds "gx/ipfs/QmRWDav6mzWseLWeYfVd5fvUKiVe9xNH29YfMF438fG364/go-datastore" - mockpeernet "gx/ipfs/QmSNJRX4uphb3Eyp69uYbpRVvgqjPxfjnJmjcdMWkDH5Pn/go-libp2p/p2p/net/mock" + mockpeernet "gx/ipfs/QmU3g3psEDiC4tQh1Qu2NYg5aYVQqxC3m74ZavLwPfJEtu/go-libp2p/p2p/net/mock" peer "gx/ipfs/QmZcUPvPhD1Xvk6mwijYF8AfR3mG31S1YsEfHG4khrFPRr/go-libp2p-peer" ) diff --git a/exchange/bitswap/testutils.go b/exchange/bitswap/testutils.go index 526b6fa8862..65d122bf3f7 100644 --- a/exchange/bitswap/testutils.go +++ b/exchange/bitswap/testutils.go @@ -12,8 +12,8 @@ import ( ds "gx/ipfs/QmRWDav6mzWseLWeYfVd5fvUKiVe9xNH29YfMF438fG364/go-datastore" ds_sync "gx/ipfs/QmRWDav6mzWseLWeYfVd5fvUKiVe9xNH29YfMF438fG364/go-datastore/sync" - p2ptestutil "gx/ipfs/QmTcGn1vzu7YNxz6FEXvfUfMy6WmYeQ5VtU3MbWM8c92rB/go-libp2p-netutil" peer "gx/ipfs/QmZcUPvPhD1Xvk6mwijYF8AfR3mG31S1YsEfHG4khrFPRr/go-libp2p-peer" + p2ptestutil "gx/ipfs/QmdGRzr9bPTt2ZrBFaq5R2zzD7JFXNRxXZGkzsVcW6pEzh/go-libp2p-netutil" ) // WARNING: this uses RandTestBogusIdentity DO NOT USE for NON TESTS! diff --git a/namesys/republisher/repub_test.go b/namesys/republisher/repub_test.go index 30f4140f786..aeffa790b2d 100644 --- a/namesys/republisher/repub_test.go +++ b/namesys/republisher/repub_test.go @@ -14,7 +14,7 @@ import ( . "github.com/ipfs/go-ipfs/namesys/republisher" path "github.com/ipfs/go-ipfs/path" pstore "gx/ipfs/QmQMQ2RUjnaEEX8ybmrhuFFGhAwPjyL1Eo6ZoJGD7aAccM/go-libp2p-peerstore" - mocknet "gx/ipfs/QmSNJRX4uphb3Eyp69uYbpRVvgqjPxfjnJmjcdMWkDH5Pn/go-libp2p/p2p/net/mock" + mocknet "gx/ipfs/QmU3g3psEDiC4tQh1Qu2NYg5aYVQqxC3m74ZavLwPfJEtu/go-libp2p/p2p/net/mock" ) func TestRepublish(t *testing.T) { diff --git a/package.json b/package.json index 030a36ed98d..73ad3b6305f 100644 --- a/package.json +++ b/package.json @@ -196,9 +196,9 @@ }, { "author": "whyrusleeping", - "hash": "QmSNJRX4uphb3Eyp69uYbpRVvgqjPxfjnJmjcdMWkDH5Pn", + "hash": "QmU3g3psEDiC4tQh1Qu2NYg5aYVQqxC3m74ZavLwPfJEtu", "name": "go-libp2p", - "version": "4.3.9" + "version": "4.3.11" }, { "author": "whyrusleeping", @@ -243,9 +243,9 @@ "version": "0.1.2" }, { - "hash": "QmdFu71pRmWMNWht96ZTJ3wRx4D7BPJ2JfHH24z59Gidsc", + "hash": "QmUpZqxzrUoyDsgWXDri9yYgi5r5EK7J5Tan1MbgnawYLx", "name": "go-libp2p-kad-dht", - "version": "2.4.19" + "version": "2.4.21" }, { "author": "whyrusleeping", @@ -255,9 +255,9 @@ }, { "author": "whyrusleeping", - "hash": "Qmf2UPccWR8aZWT8UvEEKP9PhJQNidSegwEMrzZKHsCX4u", + "hash": "QmQDb7jmfC33qzGUGpWrfgRootQnmQvN7DMktfuekShsiF", "name": "floodsub", - "version": "0.8.11" + "version": "0.8.13" }, { "author": "whyrusleeping", diff --git a/routing/mock/dht.go b/routing/mock/dht.go index a227232f000..95a9931f961 100644 --- a/routing/mock/dht.go +++ b/routing/mock/dht.go @@ -5,8 +5,8 @@ import ( "github.com/ipfs/go-ipfs/thirdparty/testutil" ds "gx/ipfs/QmRWDav6mzWseLWeYfVd5fvUKiVe9xNH29YfMF438fG364/go-datastore" sync "gx/ipfs/QmRWDav6mzWseLWeYfVd5fvUKiVe9xNH29YfMF438fG364/go-datastore/sync" - mocknet "gx/ipfs/QmSNJRX4uphb3Eyp69uYbpRVvgqjPxfjnJmjcdMWkDH5Pn/go-libp2p/p2p/net/mock" - dht "gx/ipfs/QmdFu71pRmWMNWht96ZTJ3wRx4D7BPJ2JfHH24z59Gidsc/go-libp2p-kad-dht" + mocknet "gx/ipfs/QmU3g3psEDiC4tQh1Qu2NYg5aYVQqxC3m74ZavLwPfJEtu/go-libp2p/p2p/net/mock" + dht "gx/ipfs/QmUpZqxzrUoyDsgWXDri9yYgi5r5EK7J5Tan1MbgnawYLx/go-libp2p-kad-dht" ) type mocknetserver struct { diff --git a/routing/supernode/client.go b/routing/supernode/client.go index 63251ad86f5..fb4a8ddda4e 100644 --- a/routing/supernode/client.go +++ b/routing/supernode/client.go @@ -11,13 +11,13 @@ import ( pstore "gx/ipfs/QmQMQ2RUjnaEEX8ybmrhuFFGhAwPjyL1Eo6ZoJGD7aAccM/go-libp2p-peerstore" logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log" loggables "gx/ipfs/QmTcfnDHimxBJqx6utpnWqVHdvyquXgkwAvYt4zMaJMKS2/go-libp2p-loggables" + dhtpb "gx/ipfs/QmUpZqxzrUoyDsgWXDri9yYgi5r5EK7J5Tan1MbgnawYLx/go-libp2p-kad-dht/pb" cid "gx/ipfs/QmV5gPoRsjN1Gid3LMdNZTyfCtP2DsvqEbMAmz82RmmiGk/go-cid" proto "gx/ipfs/QmZ4Qi3GaRbjcx28Sme5eMH7RQjGkt8wHxt2a65oLaeFEV/gogo-protobuf/proto" peer "gx/ipfs/QmZcUPvPhD1Xvk6mwijYF8AfR3mG31S1YsEfHG4khrFPRr/go-libp2p-peer" routing "gx/ipfs/QmZghcVHwXQC3Zvnvn24LgTmSPkEn2o3PDyKb6nrtPRzRh/go-libp2p-routing" pb "gx/ipfs/QmZp9q8DbrGLztoxpkTC62mnRayRwHcAzGJJ8AvYRwjanR/go-libp2p-record/pb" "gx/ipfs/QmbzbRyd22gcW92U1rA2yKagB3myMYhk45XBknJ49F9XWJ/go-libp2p-host" - dhtpb "gx/ipfs/QmdFu71pRmWMNWht96ZTJ3wRx4D7BPJ2JfHH24z59Gidsc/go-libp2p-kad-dht/pb" ) var log = logging.Logger("supernode") diff --git a/routing/supernode/proxy/loopback.go b/routing/supernode/proxy/loopback.go index 3ae8bce8d5c..a7aaa2b7546 100644 --- a/routing/supernode/proxy/loopback.go +++ b/routing/supernode/proxy/loopback.go @@ -3,9 +3,9 @@ package proxy import ( context "context" inet "gx/ipfs/QmRuZnMorqodado1yeTQiv1i9rmtKj29CjPSsBKM7DFXV4/go-libp2p-net" + dhtpb "gx/ipfs/QmUpZqxzrUoyDsgWXDri9yYgi5r5EK7J5Tan1MbgnawYLx/go-libp2p-kad-dht/pb" ggio "gx/ipfs/QmZ4Qi3GaRbjcx28Sme5eMH7RQjGkt8wHxt2a65oLaeFEV/gogo-protobuf/io" peer "gx/ipfs/QmZcUPvPhD1Xvk6mwijYF8AfR3mG31S1YsEfHG4khrFPRr/go-libp2p-peer" - dhtpb "gx/ipfs/QmdFu71pRmWMNWht96ZTJ3wRx4D7BPJ2JfHH24z59Gidsc/go-libp2p-kad-dht/pb" ) // RequestHandler handles routing requests locally diff --git a/routing/supernode/proxy/standard.go b/routing/supernode/proxy/standard.go index 5933259aead..a5ae9061e9a 100644 --- a/routing/supernode/proxy/standard.go +++ b/routing/supernode/proxy/standard.go @@ -8,11 +8,11 @@ import ( inet "gx/ipfs/QmRuZnMorqodado1yeTQiv1i9rmtKj29CjPSsBKM7DFXV4/go-libp2p-net" logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log" loggables "gx/ipfs/QmTcfnDHimxBJqx6utpnWqVHdvyquXgkwAvYt4zMaJMKS2/go-libp2p-loggables" + dhtpb "gx/ipfs/QmUpZqxzrUoyDsgWXDri9yYgi5r5EK7J5Tan1MbgnawYLx/go-libp2p-kad-dht/pb" kbucket "gx/ipfs/QmUwZcbSVMsLZzovZssH96rCUM5FAkrjaqhHLhJnFYd5z3/go-libp2p-kbucket" ggio "gx/ipfs/QmZ4Qi3GaRbjcx28Sme5eMH7RQjGkt8wHxt2a65oLaeFEV/gogo-protobuf/io" peer "gx/ipfs/QmZcUPvPhD1Xvk6mwijYF8AfR3mG31S1YsEfHG4khrFPRr/go-libp2p-peer" host "gx/ipfs/QmbzbRyd22gcW92U1rA2yKagB3myMYhk45XBknJ49F9XWJ/go-libp2p-host" - dhtpb "gx/ipfs/QmdFu71pRmWMNWht96ZTJ3wRx4D7BPJ2JfHH24z59Gidsc/go-libp2p-kad-dht/pb" ) const ProtocolSNR = "/ipfs/supernoderouting" diff --git a/routing/supernode/server.go b/routing/supernode/server.go index 7cfe3ba17f1..25b20724ac1 100644 --- a/routing/supernode/server.go +++ b/routing/supernode/server.go @@ -10,11 +10,11 @@ import ( pstore "gx/ipfs/QmQMQ2RUjnaEEX8ybmrhuFFGhAwPjyL1Eo6ZoJGD7aAccM/go-libp2p-peerstore" datastore "gx/ipfs/QmRWDav6mzWseLWeYfVd5fvUKiVe9xNH29YfMF438fG364/go-datastore" + dhtpb "gx/ipfs/QmUpZqxzrUoyDsgWXDri9yYgi5r5EK7J5Tan1MbgnawYLx/go-libp2p-kad-dht/pb" proto "gx/ipfs/QmZ4Qi3GaRbjcx28Sme5eMH7RQjGkt8wHxt2a65oLaeFEV/gogo-protobuf/proto" peer "gx/ipfs/QmZcUPvPhD1Xvk6mwijYF8AfR3mG31S1YsEfHG4khrFPRr/go-libp2p-peer" record "gx/ipfs/QmZp9q8DbrGLztoxpkTC62mnRayRwHcAzGJJ8AvYRwjanR/go-libp2p-record" pb "gx/ipfs/QmZp9q8DbrGLztoxpkTC62mnRayRwHcAzGJJ8AvYRwjanR/go-libp2p-record/pb" - dhtpb "gx/ipfs/QmdFu71pRmWMNWht96ZTJ3wRx4D7BPJ2JfHH24z59Gidsc/go-libp2p-kad-dht/pb" ) // Server handles routing queries using a database backend diff --git a/routing/supernode/server_test.go b/routing/supernode/server_test.go index 5af0a8fd2d2..b4b49e05a45 100644 --- a/routing/supernode/server_test.go +++ b/routing/supernode/server_test.go @@ -4,7 +4,7 @@ import ( "testing" datastore "gx/ipfs/QmRWDav6mzWseLWeYfVd5fvUKiVe9xNH29YfMF438fG364/go-datastore" - dhtpb "gx/ipfs/QmdFu71pRmWMNWht96ZTJ3wRx4D7BPJ2JfHH24z59Gidsc/go-libp2p-kad-dht/pb" + dhtpb "gx/ipfs/QmUpZqxzrUoyDsgWXDri9yYgi5r5EK7J5Tan1MbgnawYLx/go-libp2p-kad-dht/pb" ) func TestPutProviderDoesntResultInDuplicates(t *testing.T) { diff --git a/test/integration/addcat_test.go b/test/integration/addcat_test.go index da8fe9e960e..765ab891bd9 100644 --- a/test/integration/addcat_test.go +++ b/test/integration/addcat_test.go @@ -19,8 +19,8 @@ import ( testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" "github.com/ipfs/go-ipfs/thirdparty/unit" pstore "gx/ipfs/QmQMQ2RUjnaEEX8ybmrhuFFGhAwPjyL1Eo6ZoJGD7aAccM/go-libp2p-peerstore" - mocknet "gx/ipfs/QmSNJRX4uphb3Eyp69uYbpRVvgqjPxfjnJmjcdMWkDH5Pn/go-libp2p/p2p/net/mock" logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log" + mocknet "gx/ipfs/QmU3g3psEDiC4tQh1Qu2NYg5aYVQqxC3m74ZavLwPfJEtu/go-libp2p/p2p/net/mock" ) var log = logging.Logger("epictest") diff --git a/test/integration/bench_cat_test.go b/test/integration/bench_cat_test.go index 779c93fedf1..e0b0216b01f 100644 --- a/test/integration/bench_cat_test.go +++ b/test/integration/bench_cat_test.go @@ -14,7 +14,7 @@ import ( testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" "github.com/ipfs/go-ipfs/thirdparty/unit" pstore "gx/ipfs/QmQMQ2RUjnaEEX8ybmrhuFFGhAwPjyL1Eo6ZoJGD7aAccM/go-libp2p-peerstore" - mocknet "gx/ipfs/QmSNJRX4uphb3Eyp69uYbpRVvgqjPxfjnJmjcdMWkDH5Pn/go-libp2p/p2p/net/mock" + mocknet "gx/ipfs/QmU3g3psEDiC4tQh1Qu2NYg5aYVQqxC3m74ZavLwPfJEtu/go-libp2p/p2p/net/mock" ) func BenchmarkCat1MB(b *testing.B) { benchmarkVarCat(b, unit.MB*1) } diff --git a/test/integration/bitswap_wo_routing_test.go b/test/integration/bitswap_wo_routing_test.go index 5d48b1c5b8e..8dbec4e8f3e 100644 --- a/test/integration/bitswap_wo_routing_test.go +++ b/test/integration/bitswap_wo_routing_test.go @@ -9,7 +9,7 @@ import ( "github.com/ipfs/go-ipfs/core/mock" context "context" - mocknet "gx/ipfs/QmSNJRX4uphb3Eyp69uYbpRVvgqjPxfjnJmjcdMWkDH5Pn/go-libp2p/p2p/net/mock" + mocknet "gx/ipfs/QmU3g3psEDiC4tQh1Qu2NYg5aYVQqxC3m74ZavLwPfJEtu/go-libp2p/p2p/net/mock" cid "gx/ipfs/QmV5gPoRsjN1Gid3LMdNZTyfCtP2DsvqEbMAmz82RmmiGk/go-cid" ) diff --git a/test/integration/grandcentral_test.go b/test/integration/grandcentral_test.go index 88034588493..e6603685f74 100644 --- a/test/integration/grandcentral_test.go +++ b/test/integration/grandcentral_test.go @@ -20,7 +20,7 @@ import ( testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" "github.com/ipfs/go-ipfs/thirdparty/unit" pstore "gx/ipfs/QmQMQ2RUjnaEEX8ybmrhuFFGhAwPjyL1Eo6ZoJGD7aAccM/go-libp2p-peerstore" - mocknet "gx/ipfs/QmSNJRX4uphb3Eyp69uYbpRVvgqjPxfjnJmjcdMWkDH5Pn/go-libp2p/p2p/net/mock" + mocknet "gx/ipfs/QmU3g3psEDiC4tQh1Qu2NYg5aYVQqxC3m74ZavLwPfJEtu/go-libp2p/p2p/net/mock" ) func TestSupernodeBootstrappedAddCat(t *testing.T) { diff --git a/test/integration/three_legged_cat_test.go b/test/integration/three_legged_cat_test.go index 0fbce25f875..ec547e610e0 100644 --- a/test/integration/three_legged_cat_test.go +++ b/test/integration/three_legged_cat_test.go @@ -16,7 +16,7 @@ import ( testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" "github.com/ipfs/go-ipfs/thirdparty/unit" pstore "gx/ipfs/QmQMQ2RUjnaEEX8ybmrhuFFGhAwPjyL1Eo6ZoJGD7aAccM/go-libp2p-peerstore" - mocknet "gx/ipfs/QmSNJRX4uphb3Eyp69uYbpRVvgqjPxfjnJmjcdMWkDH5Pn/go-libp2p/p2p/net/mock" + mocknet "gx/ipfs/QmU3g3psEDiC4tQh1Qu2NYg5aYVQqxC3m74ZavLwPfJEtu/go-libp2p/p2p/net/mock" ) func TestThreeLeggedCatTransfer(t *testing.T) { diff --git a/test/sharness/t0181-private-network.sh b/test/sharness/t0181-private-network.sh new file mode 100755 index 00000000000..f848a314637 --- /dev/null +++ b/test/sharness/t0181-private-network.sh @@ -0,0 +1,135 @@ +#!/bin/sh +# +# Copyright (c) 2015 Jeromy Johnson +# MIT Licensed; see the LICENSE file in this repository. +# + +test_description="Test private network feature" + +. lib/test-lib.sh + +test_init_ipfs + +export LIBP2P_FORCE_PNET=1 + +test_expect_success "daemon won't start with force pnet env but with no key" ' + test_must_fail go-timeout 5 ipfs daemon > stdout 2>&1 +' + +unset LIBP2P_FORCE_PNET + +test_expect_success "daemon output incudes info about the reason" ' + grep "private network was not configured but is enforced by the environment" stdout || + test_fsh cat stdout +' + +pnet_key() { + echo '/key/swarm/psk/1.0.0/' + echo '/bin/' + random 16 +} + +pnet_key > $IPFS_PATH/swarm.key + +LIBP2P_FORCE_PNET=1 test_launch_ipfs_daemon + +test_expect_success "set up iptb testbed" ' + iptb init -n 5 -p 0 -f --bootstrap=none && + iptb for-each ipfs config --json Addresses.Swarm '"'"'["/ip4/127.0.0.1/tcp/0"]'"'"' +' + +set_key() { + node="$1" + keyfile="$2" + + cp "$keyfile" "$IPTB_ROOT/$node/swarm.key" +} + +pnet_key > key1 +pnet_key > key2 + +set_key 1 key1 +set_key 2 key1 + +set_key 3 key2 +set_key 4 key2 + +unset LIBP2P_FORCE_PNET + +test_expect_success "start nodes" ' + iptb start [0-4] +' + +test_expect_success "try connecting node in public network with priv networks" ' + iptb connect [1-4] 0 +' + +test_expect_success "node 0 (public network) swarm is empty" ' + ipfsi 0 swarm peers && + [ $(ipfsi 0 swarm peers | wc -l) -eq 0 ] +' + +test_expect_success "try connecting nodes in different private networks" ' + iptb connect 2 3 +' + +test_expect_success "node 3 (pnet 2) swarm is empty" ' + ipfsi 3 swarm peers && + [ $(ipfsi 3 swarm peers | wc -l) -eq 0 ] +' + +test_expect_success "connect nodes in the same pnet" ' + iptb connect 1 2 && + iptb connect 3 4 +' + +test_expect_success "nodes 1 and 2 have connected" ' + ipfsi 2 swarm peers && + [ $(ipfsi 2 swarm peers | wc -l) -eq 1 ] +' + +test_expect_success "nodes 3 and 4 have connected" ' + ipfsi 4 swarm peers && + [ $(ipfsi 4 swarm peers | wc -l) -eq 1 ] +' + + +run_single_file_test() { + node1=$1 + node2=$2 + + test_expect_success "add a file on node$node1" ' + random 1000000 > filea && + FILEA_HASH=$(ipfsi $node1 add -q filea) + ' + + check_file_fetch $node1 $FILEA_HASH filea + check_file_fetch $node2 $FILEA_HASH filea +} + +check_file_fetch() { + node="$1" + fhash="$2" + fname="$3" + + test_expect_success "can fetch file" ' + ipfsi $node cat $fhash > fetch_out + ' + + test_expect_success "file looks good" ' + test_cmp $fname fetch_out + ' +} + +run_single_file_test 1 2 +run_single_file_test 2 1 + +run_single_file_test 3 4 +run_single_file_test 4 3 + + +test_expect_success "stop testbed" ' + iptb stop +' + +test_done From faca4518b36be06d8753969892e99914cd39aa71 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Fri, 17 Feb 2017 13:36:48 +0100 Subject: [PATCH 2/3] pnet: integrate PNet License: MIT Signed-off-by: Jakub Sztandera --- cmd/ipfs/daemon.go | 5 +++++ core/core.go | 33 ++++++++++++++++++++++++++------- core/mock/mock.go | 3 ++- package.json | 6 ++++++ repo/fsrepo/fsrepo.go | 22 ++++++++++++++++++++++ repo/mock.go | 4 ++++ repo/repo.go | 2 ++ 7 files changed, 67 insertions(+), 8 deletions(-) diff --git a/cmd/ipfs/daemon.go b/cmd/ipfs/daemon.go index 09a63d293cc..cf6c22c015f 100644 --- a/cmd/ipfs/daemon.go +++ b/cmd/ipfs/daemon.go @@ -347,6 +347,11 @@ func daemonFunc(req cmds.Request, res cmds.Response) { } node.SetLocal(false) + if node.PNetFingerpint != nil { + fmt.Println("Swarm is limited to private network of peers with the swarm key") + fmt.Printf("Swarm key fingerprint: %x\n", node.PNetFingerpint) + } + printSwarmAddrs(node) defer func() { diff --git a/core/core.go b/core/core.go index aa660c0fed1..9136c4f28c8 100644 --- a/core/core.go +++ b/core/core.go @@ -10,6 +10,7 @@ interfaces and how core/... fits into the bigger IPFS picture, see: package core import ( + "bytes" "context" "errors" "fmt" @@ -44,6 +45,7 @@ import ( ic "gx/ipfs/QmNiCwBNA8MWDADTFVq1BonUEJbS2SvjAoNkZZrhEwcuUi/go-libp2p-crypto" addrutil "gx/ipfs/QmPB5aAzt2wo5Xk8SoZi6y2oFN7shQMvYWgduMATojkdpj/go-addr-util" metrics "gx/ipfs/QmPj6rmE2sWJ65h6b8F4fcN5kySDhYqL2Ty8DWWF3WEUNS/go-libp2p-metrics" + pnet "gx/ipfs/QmQ2sk2irQYkeMMVKpLjq1bSiNPn9B5wZB53Nx8dd4dhnQ/go-libp2p-pnet" mplex "gx/ipfs/QmQ3UABWTgK78utKeiVXaH9BrjC7Ydn1pRuwqnWHT3p4zh/go-smux-multiplex" floodsub "gx/ipfs/QmQDb7jmfC33qzGUGpWrfgRootQnmQvN7DMktfuekShsiF/floodsub" pstore "gx/ipfs/QmQMQ2RUjnaEEX8ybmrhuFFGhAwPjyL1Eo6ZoJGD7aAccM/go-libp2p-peerstore" @@ -67,6 +69,7 @@ import ( u "gx/ipfs/QmZuY8aV7zbNXVy6DyN9SmnuH3o9nG852F4aTiSBpts8d1/go-ipfs-util" yamux "gx/ipfs/Qmbn7RYyWzBVXiUp9jZ1dA4VADHy9DtS7iZLwfhEUQvm3U/go-smux-yamux" p2phost "gx/ipfs/QmbzbRyd22gcW92U1rA2yKagB3myMYhk45XBknJ49F9XWJ/go-libp2p-host" + ipnet "gx/ipfs/QmcT6bMjz32yoMdyvZsMvqFnbbsDxhTYw6FG1yMqKV8Rbh/go-libp2p-interface-pnet" smux "gx/ipfs/QmeZBgYBHvxMukGK5ojg28BCNLB9SeXqT7XXg6o7r2GbJy/go-stream-muxer" ) @@ -100,9 +103,10 @@ type IpfsNode struct { Repo repo.Repo // Local node - Pinning pin.Pinner // the pinning manager - Mounts Mounts // current mount state, if any. - PrivateKey ic.PrivKey // the local node's private Key + Pinning pin.Pinner // the pinning manager + Mounts Mounts // current mount state, if any. + PrivateKey ic.PrivKey // the local node's private Key + PNetFingerpint []byte // fingerprint of private network // Services Peerstore pstore.Peerstore // storage for other Peer instances @@ -174,7 +178,22 @@ func (n *IpfsNode) startOnlineServices(ctx context.Context, routingOption Routin tpt := makeSmuxTransport(mplex) - peerhost, err := hostOption(ctx, n.Identity, n.Peerstore, n.Reporter, addrfilter, tpt) + swarmkey, err := n.Repo.SwarmKey() + if err != nil { + return err + } + + var protec ipnet.Protector + if swarmkey != nil { + protec, err = pnet.NewProtector(bytes.NewReader(swarmkey)) + if err != nil { + return err + } + n.PNetFingerpint = protec.Fingerprint() + } + + peerhost, err := hostOption(ctx, n.Identity, n.Peerstore, n.Reporter, + addrfilter, tpt, protec) if err != nil { return err } @@ -671,15 +690,15 @@ func listenAddresses(cfg *config.Config) ([]ma.Multiaddr, error) { return listen, nil } -type HostOption func(ctx context.Context, id peer.ID, ps pstore.Peerstore, bwr metrics.Reporter, fs []*net.IPNet, tpt smux.Transport) (p2phost.Host, error) +type HostOption func(ctx context.Context, id peer.ID, ps pstore.Peerstore, bwr metrics.Reporter, fs []*net.IPNet, tpt smux.Transport, protc ipnet.Protector) (p2phost.Host, error) var DefaultHostOption HostOption = constructPeerHost // isolates the complex initialization steps -func constructPeerHost(ctx context.Context, id peer.ID, ps pstore.Peerstore, bwr metrics.Reporter, fs []*net.IPNet, tpt smux.Transport) (p2phost.Host, error) { +func constructPeerHost(ctx context.Context, id peer.ID, ps pstore.Peerstore, bwr metrics.Reporter, fs []*net.IPNet, tpt smux.Transport, protec ipnet.Protector) (p2phost.Host, error) { // no addresses to begin with. we'll start later. - swrm, err := swarm.NewSwarmWithProtector(ctx, nil, id, ps, nil, tpt, bwr) + swrm, err := swarm.NewSwarmWithProtector(ctx, nil, id, ps, protec, tpt, bwr) if err != nil { return nil, err } diff --git a/core/mock/mock.go b/core/mock/mock.go index 110ae3c478d..a021b031d28 100644 --- a/core/mock/mock.go +++ b/core/mock/mock.go @@ -18,6 +18,7 @@ import ( mocknet "gx/ipfs/QmU3g3psEDiC4tQh1Qu2NYg5aYVQqxC3m74ZavLwPfJEtu/go-libp2p/p2p/net/mock" peer "gx/ipfs/QmZcUPvPhD1Xvk6mwijYF8AfR3mG31S1YsEfHG4khrFPRr/go-libp2p-peer" host "gx/ipfs/QmbzbRyd22gcW92U1rA2yKagB3myMYhk45XBknJ49F9XWJ/go-libp2p-host" + ipnet "gx/ipfs/QmcT6bMjz32yoMdyvZsMvqFnbbsDxhTYw6FG1yMqKV8Rbh/go-libp2p-interface-pnet" smux "gx/ipfs/QmeZBgYBHvxMukGK5ojg28BCNLB9SeXqT7XXg6o7r2GbJy/go-stream-muxer" ) @@ -33,7 +34,7 @@ func NewMockNode() (*core.IpfsNode, error) { } func MockHostOption(mn mocknet.Mocknet) core.HostOption { - return func(ctx context.Context, id peer.ID, ps pstore.Peerstore, bwr metrics.Reporter, fs []*net.IPNet, _ smux.Transport) (host.Host, error) { + return func(ctx context.Context, id peer.ID, ps pstore.Peerstore, bwr metrics.Reporter, fs []*net.IPNet, _ smux.Transport, _ ipnet.Protector) (host.Host, error) { return mn.AddPeerWithPeerstore(id, ps) } } diff --git a/package.json b/package.json index 73ad3b6305f..d90d27eca68 100644 --- a/package.json +++ b/package.json @@ -294,6 +294,12 @@ "hash": "QmU1N5xVAUXgo3XRTt6GhJ2SuJEbxj2zRgMS7FpjSR2U83", "name": "semver", "version": "3.3.0" + }, + { + "author": "libp2p", + "hash": "QmQ2sk2irQYkeMMVKpLjq1bSiNPn9B5wZB53Nx8dd4dhnQ", + "name": "go-libp2p-pnet", + "version": "2.2.1" } ], "gxVersion": "0.10.0", diff --git a/repo/fsrepo/fsrepo.go b/repo/fsrepo/fsrepo.go index 4ea8d31d2da..1abbe62a13f 100644 --- a/repo/fsrepo/fsrepo.go +++ b/repo/fsrepo/fsrepo.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "io" + "io/ioutil" "os" "path/filepath" "strconv" @@ -62,6 +63,7 @@ func (err NoRepoError) Error() string { } const apiFile = "api" +const swarmKeyFile = "swarm.key" var ( @@ -592,6 +594,26 @@ func (r *FSRepo) GetStorageUsage() (uint64, error) { return du, err } +func (r *FSRepo) SwarmKey() ([]byte, error) { + repoPath := filepath.Clean(r.path) + spath := filepath.Join(repoPath, swarmKeyFile) + + f, err := os.Open(spath) + if err != nil { + if os.IsNotExist(err) { + return nil, nil + } else { + return nil, err + } + } + defer f.Close() + if err != nil { + return nil, err + } + + return ioutil.ReadAll(f) +} + var _ io.Closer = &FSRepo{} var _ repo.Repo = &FSRepo{} diff --git a/repo/mock.go b/repo/mock.go index 3aae13bf730..07151fca983 100644 --- a/repo/mock.go +++ b/repo/mock.go @@ -44,3 +44,7 @@ func (m *Mock) Close() error { return errTODO } func (m *Mock) SetAPIAddr(addr ma.Multiaddr) error { return errTODO } func (m *Mock) Keystore() keystore.Keystore { return nil } + +func (m *Mock) SwarmKey() ([]byte, error) { + return nil, nil +} diff --git a/repo/repo.go b/repo/repo.go index 5e8824d80a3..493d06e084f 100644 --- a/repo/repo.go +++ b/repo/repo.go @@ -30,6 +30,8 @@ type Repo interface { // SetAPIAddr sets the API address in the repo. SetAPIAddr(addr ma.Multiaddr) error + SwarmKey() ([]byte, error) + io.Closer } From 4ce6358bd7ce88caa68981c8d7d776b608e80de7 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Fri, 17 Feb 2017 13:58:30 +0100 Subject: [PATCH 3/3] pnet: add warning when we are in PNet and have no peers License: MIT Signed-off-by: Jakub Sztandera --- core/core.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/core/core.go b/core/core.go index 9136c4f28c8..227831f97a7 100644 --- a/core/core.go +++ b/core/core.go @@ -190,6 +190,24 @@ func (n *IpfsNode) startOnlineServices(ctx context.Context, routingOption Routin return err } n.PNetFingerpint = protec.Fingerprint() + go func() { + t := time.NewTicker(30 * time.Second) + <-t.C // swallow one tick + for { + select { + case <-t.C: + if ph := n.PeerHost; ph != nil { + if len(ph.Network().Peers()) == 0 { + log.Warning("We are in private network and have no peers.") + log.Warning("This might be configuration mistake.") + } + } + case <-n.Process().Closing(): + t.Stop() + return + } + } + }() } peerhost, err := hostOption(ctx, n.Identity, n.Peerstore, n.Reporter,