diff --git a/examples/hosts/main.go b/examples/hosts/main.go index f92be28b..256fdbff 100644 --- a/examples/hosts/main.go +++ b/examples/hosts/main.go @@ -5,16 +5,15 @@ import ( "fmt" "io/ioutil" "log" - "time" pstore "github.com/ipfs/go-libp2p-peerstore" - host "github.com/ipfs/go-libp2p/p2p/host" - bhost "github.com/ipfs/go-libp2p/p2p/host/basic" - metrics "github.com/ipfs/go-libp2p/p2p/metrics" - net "github.com/ipfs/go-libp2p/p2p/net" - conn "github.com/ipfs/go-libp2p/p2p/net/conn" - swarm "github.com/ipfs/go-libp2p/p2p/net/swarm" - testutil "github.com/ipfs/go-libp2p/testutil" + host "github.com/libp2p/go-libp2p/p2p/host" + bhost "github.com/libp2p/go-libp2p/p2p/host/basic" + metrics "github.com/libp2p/go-libp2p/p2p/metrics" + net "github.com/libp2p/go-libp2p/p2p/net" + conn "github.com/libp2p/go-libp2p/p2p/net/conn" + swarm "github.com/libp2p/go-libp2p/p2p/net/swarm" + testutil "github.com/libp2p/go-libp2p/testutil" ipfsaddr "github.com/ipfs/go-ipfs/thirdparty/ipfsaddr" ma "github.com/jbenet/go-multiaddr" diff --git a/p2p/discovery/mdns.go b/p2p/discovery/mdns.go index 71eb0a5d..bc9c1f66 100644 --- a/p2p/discovery/mdns.go +++ b/p2p/discovery/mdns.go @@ -12,10 +12,10 @@ import ( "github.com/cryptix/mdns" "github.com/ipfs/go-libp2p-peer" pstore "github.com/ipfs/go-libp2p-peerstore" - "github.com/ipfs/go-libp2p/p2p/host" logging "github.com/ipfs/go-log" ma "github.com/jbenet/go-multiaddr" manet "github.com/jbenet/go-multiaddr-net" + "github.com/libp2p/go-libp2p/p2p/host" ) var log = logging.Logger("mdns") diff --git a/p2p/host/basic/basic_host.go b/p2p/host/basic/basic_host.go index b7e94632..2a697556 100644 --- a/p2p/host/basic/basic_host.go +++ b/p2p/host/basic/basic_host.go @@ -5,21 +5,21 @@ import ( peer "github.com/ipfs/go-libp2p-peer" pstore "github.com/ipfs/go-libp2p-peerstore" - metrics "github.com/ipfs/go-libp2p/p2p/metrics" - mstream "github.com/ipfs/go-libp2p/p2p/metrics/stream" - inet "github.com/ipfs/go-libp2p/p2p/net" - protocol "github.com/ipfs/go-libp2p/p2p/protocol" - identify "github.com/ipfs/go-libp2p/p2p/protocol/identify" - relay "github.com/ipfs/go-libp2p/p2p/protocol/relay" logging "github.com/ipfs/go-log" ma "github.com/jbenet/go-multiaddr" goprocess "github.com/jbenet/goprocess" + metrics "github.com/libp2p/go-libp2p/p2p/metrics" + mstream "github.com/libp2p/go-libp2p/p2p/metrics/stream" + inet "github.com/libp2p/go-libp2p/p2p/net" + protocol "github.com/libp2p/go-libp2p/p2p/protocol" + identify "github.com/libp2p/go-libp2p/p2p/protocol/identify" + relay "github.com/libp2p/go-libp2p/p2p/protocol/relay" context "golang.org/x/net/context" msmux "github.com/whyrusleeping/go-multistream" ) -var log = logging.Logger("github.com/ipfs/go-libp2p/p2p/host/basic") +var log = logging.Logger("github.com/libp2p/go-libp2p/p2p/host/basic") // Option is a type used to pass in options to the host. type Option int @@ -114,7 +114,8 @@ func (h *BasicHost) newStreamHandler(s inet.Stream) { logStream := mstream.WrapStream(s, protocol.ID(protoID), h.bwc) - go handle(logStream) + s.SetProtocol(protoID) + go handle(protoID, logStream) } // ID returns the (local) peer.ID associated with this Host @@ -147,8 +148,10 @@ func (h *BasicHost) IDService() *identify.IDService { // host.Mux().SetHandler(proto, handler) // (Threadsafe) func (h *BasicHost) SetStreamHandler(pid protocol.ID, handler inet.StreamHandler) { - h.Mux().AddHandler(string(pid), func(rwc io.ReadWriteCloser) error { - handler(rwc.(inet.Stream)) + h.Mux().AddHandler(string(pid), func(p string, rwc io.ReadWriteCloser) error { + is := rwc.(inet.Stream) + is.SetProtocol(p) + handler(is) return nil }) } diff --git a/p2p/host/basic/basic_host_test.go b/p2p/host/basic/basic_host_test.go index 3de87797..f1f2e248 100644 --- a/p2p/host/basic/basic_host_test.go +++ b/p2p/host/basic/basic_host_test.go @@ -5,9 +5,9 @@ import ( "io" "testing" - inet "github.com/ipfs/go-libp2p/p2p/net" - protocol "github.com/ipfs/go-libp2p/p2p/protocol" - testutil "github.com/ipfs/go-libp2p/p2p/test/util" + inet "github.com/libp2p/go-libp2p/p2p/net" + protocol "github.com/libp2p/go-libp2p/p2p/protocol" + testutil "github.com/libp2p/go-libp2p/p2p/test/util" context "golang.org/x/net/context" ) diff --git a/p2p/host/basic/natmgr.go b/p2p/host/basic/natmgr.go index 7581a2e2..03513470 100644 --- a/p2p/host/basic/natmgr.go +++ b/p2p/host/basic/natmgr.go @@ -4,10 +4,10 @@ import ( "sync" lgbl "github.com/ipfs/go-libp2p-loggables" - inat "github.com/ipfs/go-libp2p/p2p/nat" - inet "github.com/ipfs/go-libp2p/p2p/net" ma "github.com/jbenet/go-multiaddr" goprocess "github.com/jbenet/goprocess" + inat "github.com/libp2p/go-libp2p/p2p/nat" + inet "github.com/libp2p/go-libp2p/p2p/net" context "golang.org/x/net/context" ) diff --git a/p2p/host/host.go b/p2p/host/host.go index 1db42a8f..40bb6881 100644 --- a/p2p/host/host.go +++ b/p2p/host/host.go @@ -3,16 +3,16 @@ package host import ( peer "github.com/ipfs/go-libp2p-peer" pstore "github.com/ipfs/go-libp2p-peerstore" - metrics "github.com/ipfs/go-libp2p/p2p/metrics" - inet "github.com/ipfs/go-libp2p/p2p/net" - protocol "github.com/ipfs/go-libp2p/p2p/protocol" logging "github.com/ipfs/go-log" ma "github.com/jbenet/go-multiaddr" + metrics "github.com/libp2p/go-libp2p/p2p/metrics" + inet "github.com/libp2p/go-libp2p/p2p/net" + protocol "github.com/libp2p/go-libp2p/p2p/protocol" msmux "github.com/whyrusleeping/go-multistream" context "golang.org/x/net/context" ) -var log = logging.Logger("github.com/ipfs/go-libp2p/p2p/host") +var log = logging.Logger("github.com/libp2p/go-libp2p/p2p/host") // Host is an object participating in a p2p network, which // implements protocols or provides services. It handles diff --git a/p2p/host/routed/routed.go b/p2p/host/routed/routed.go index 532910c6..3f04a072 100644 --- a/p2p/host/routed/routed.go +++ b/p2p/host/routed/routed.go @@ -7,18 +7,18 @@ import ( lgbl "github.com/ipfs/go-libp2p-loggables" peer "github.com/ipfs/go-libp2p-peer" pstore "github.com/ipfs/go-libp2p-peerstore" - host "github.com/ipfs/go-libp2p/p2p/host" - metrics "github.com/ipfs/go-libp2p/p2p/metrics" - inet "github.com/ipfs/go-libp2p/p2p/net" - protocol "github.com/ipfs/go-libp2p/p2p/protocol" logging "github.com/ipfs/go-log" ma "github.com/jbenet/go-multiaddr" + host "github.com/libp2p/go-libp2p/p2p/host" + metrics "github.com/libp2p/go-libp2p/p2p/metrics" + inet "github.com/libp2p/go-libp2p/p2p/net" + protocol "github.com/libp2p/go-libp2p/p2p/protocol" context "golang.org/x/net/context" msmux "github.com/whyrusleeping/go-multistream" ) -var log = logging.Logger("github.com/ipfs/go-libp2p/p2p/host/routed") +var log = logging.Logger("github.com/libp2p/go-libp2p/p2p/host/routed") // AddressTTL is the expiry time for our addresses. // We expire them quickly. diff --git a/p2p/metrics/bw_stats.go b/p2p/metrics/bw_stats.go index 0f222b76..3b5fedd5 100644 --- a/p2p/metrics/bw_stats.go +++ b/p2p/metrics/bw_stats.go @@ -5,7 +5,7 @@ import ( "sync" peer "github.com/ipfs/go-libp2p-peer" - protocol "github.com/ipfs/go-libp2p/p2p/protocol" + protocol "github.com/libp2p/go-libp2p/p2p/protocol" ) type Stats struct { diff --git a/p2p/metrics/conn/conn.go b/p2p/metrics/conn/conn.go index 8cc0f62a..077ba8fa 100644 --- a/p2p/metrics/conn/conn.go +++ b/p2p/metrics/conn/conn.go @@ -2,7 +2,7 @@ package meterconn import ( transport "github.com/ipfs/go-libp2p-transport" - metrics "github.com/ipfs/go-libp2p/p2p/metrics" + metrics "github.com/libp2p/go-libp2p/p2p/metrics" ) type MeteredConn struct { diff --git a/p2p/metrics/interface.go b/p2p/metrics/interface.go index 876523c5..1ceb1e95 100644 --- a/p2p/metrics/interface.go +++ b/p2p/metrics/interface.go @@ -2,7 +2,7 @@ package metrics import ( peer "github.com/ipfs/go-libp2p-peer" - protocol "github.com/ipfs/go-libp2p/p2p/protocol" + protocol "github.com/libp2p/go-libp2p/p2p/protocol" ) type StreamMeterCallback func(int64, protocol.ID, peer.ID) diff --git a/p2p/metrics/stream/metered.go b/p2p/metrics/stream/metered.go index 2531dfbe..2c7a4c6b 100644 --- a/p2p/metrics/stream/metered.go +++ b/p2p/metrics/stream/metered.go @@ -2,9 +2,9 @@ package meterstream import ( peer "github.com/ipfs/go-libp2p-peer" - metrics "github.com/ipfs/go-libp2p/p2p/metrics" - inet "github.com/ipfs/go-libp2p/p2p/net" - protocol "github.com/ipfs/go-libp2p/p2p/protocol" + metrics "github.com/libp2p/go-libp2p/p2p/metrics" + inet "github.com/libp2p/go-libp2p/p2p/net" + protocol "github.com/libp2p/go-libp2p/p2p/protocol" ) type meteredStream struct { diff --git a/p2p/metrics/stream/metered_test.go b/p2p/metrics/stream/metered_test.go index 97d4374f..5af586ee 100644 --- a/p2p/metrics/stream/metered_test.go +++ b/p2p/metrics/stream/metered_test.go @@ -7,8 +7,8 @@ import ( randbo "github.com/dustin/randbo" peer "github.com/ipfs/go-libp2p-peer" - inet "github.com/ipfs/go-libp2p/p2p/net" - protocol "github.com/ipfs/go-libp2p/p2p/protocol" + inet "github.com/libp2p/go-libp2p/p2p/net" + protocol "github.com/libp2p/go-libp2p/p2p/protocol" ) type FakeStream struct { diff --git a/p2p/net/conn/conn_test.go b/p2p/net/conn/conn_test.go index 461a1314..fb1d9afb 100644 --- a/p2p/net/conn/conn_test.go +++ b/p2p/net/conn/conn_test.go @@ -8,8 +8,8 @@ import ( "testing" "time" - travis "github.com/ipfs/go-libp2p/testutil/ci/travis" msgio "github.com/jbenet/go-msgio" + travis "github.com/libp2p/go-libp2p/testutil/ci/travis" context "golang.org/x/net/context" ) diff --git a/p2p/net/conn/dial.go b/p2p/net/conn/dial.go index 9d0e6a7c..6b29492b 100644 --- a/p2p/net/conn/dial.go +++ b/p2p/net/conn/dial.go @@ -10,9 +10,9 @@ import ( lgbl "github.com/ipfs/go-libp2p-loggables" peer "github.com/ipfs/go-libp2p-peer" transport "github.com/ipfs/go-libp2p-transport" - addrutil "github.com/ipfs/go-libp2p/p2p/net/swarm/addr" ma "github.com/jbenet/go-multiaddr" manet "github.com/jbenet/go-multiaddr-net" + addrutil "github.com/libp2p/go-libp2p/p2p/net/swarm/addr" msmux "github.com/whyrusleeping/go-multistream" context "golang.org/x/net/context" ) diff --git a/p2p/net/conn/dial_test.go b/p2p/net/conn/dial_test.go index f26f76f3..762113e8 100644 --- a/p2p/net/conn/dial_test.go +++ b/p2p/net/conn/dial_test.go @@ -14,7 +14,7 @@ import ( ic "github.com/ipfs/go-libp2p-crypto" peer "github.com/ipfs/go-libp2p-peer" transport "github.com/ipfs/go-libp2p-transport" - tu "github.com/ipfs/go-libp2p/testutil" + tu "github.com/libp2p/go-libp2p/testutil" ma "github.com/jbenet/go-multiaddr" msmux "github.com/whyrusleeping/go-multistream" @@ -23,7 +23,7 @@ import ( ) func goroFilter(r *grc.Goroutine) bool { - return strings.Contains(r.Function, "go-log.") + return strings.Contains(r.Function, "go-log.") || strings.Contains(r.Stack[0], "testing.(*T).Run") } func echoListen(ctx context.Context, listener Listener) { diff --git a/p2p/net/conn/interface.go b/p2p/net/conn/interface.go index 816284f3..e5d2b192 100644 --- a/p2p/net/conn/interface.go +++ b/p2p/net/conn/interface.go @@ -8,8 +8,8 @@ import ( ic "github.com/ipfs/go-libp2p-crypto" peer "github.com/ipfs/go-libp2p-peer" transport "github.com/ipfs/go-libp2p-transport" - filter "github.com/ipfs/go-libp2p/p2p/net/filter" ma "github.com/jbenet/go-multiaddr" + filter "github.com/libp2p/go-libp2p/p2p/net/filter" ) type PeerConn interface { diff --git a/p2p/net/conn/listen.go b/p2p/net/conn/listen.go index ee6443cc..1a7805b6 100644 --- a/p2p/net/conn/listen.go +++ b/p2p/net/conn/listen.go @@ -10,11 +10,11 @@ import ( ic "github.com/ipfs/go-libp2p-crypto" peer "github.com/ipfs/go-libp2p-peer" transport "github.com/ipfs/go-libp2p-transport" - filter "github.com/ipfs/go-libp2p/p2p/net/filter" ma "github.com/jbenet/go-multiaddr" tec "github.com/jbenet/go-temp-err-catcher" "github.com/jbenet/goprocess" goprocessctx "github.com/jbenet/goprocess/context" + filter "github.com/libp2p/go-libp2p/p2p/net/filter" msmux "github.com/whyrusleeping/go-multistream" context "golang.org/x/net/context" ) diff --git a/p2p/net/conn/secure_conn_test.go b/p2p/net/conn/secure_conn_test.go index 834f727d..0b74bc54 100644 --- a/p2p/net/conn/secure_conn_test.go +++ b/p2p/net/conn/secure_conn_test.go @@ -8,7 +8,7 @@ import ( "time" ic "github.com/ipfs/go-libp2p-crypto" - travis "github.com/ipfs/go-libp2p/testutil/ci/travis" + travis "github.com/libp2p/go-libp2p/testutil/ci/travis" context "golang.org/x/net/context" ) diff --git a/p2p/net/interface.go b/p2p/net/interface.go index 81d292ea..12826ed8 100644 --- a/p2p/net/interface.go +++ b/p2p/net/interface.go @@ -5,9 +5,9 @@ import ( peer "github.com/ipfs/go-libp2p-peer" pstore "github.com/ipfs/go-libp2p-peerstore" - conn "github.com/ipfs/go-libp2p/p2p/net/conn" ma "github.com/jbenet/go-multiaddr" "github.com/jbenet/goprocess" + conn "github.com/libp2p/go-libp2p/p2p/net/conn" context "golang.org/x/net/context" ) @@ -26,6 +26,9 @@ type Stream interface { io.Writer io.Closer + Protocol() string + SetProtocol(string) + // Conn returns the connection this stream is part of. Conn() Conn } diff --git a/p2p/net/mock/interface.go b/p2p/net/mock/interface.go index 0c83affe..d6384c4e 100644 --- a/p2p/net/mock/interface.go +++ b/p2p/net/mock/interface.go @@ -10,8 +10,8 @@ import ( "io" "time" - host "github.com/ipfs/go-libp2p/p2p/host" - inet "github.com/ipfs/go-libp2p/p2p/net" + host "github.com/libp2p/go-libp2p/p2p/host" + inet "github.com/libp2p/go-libp2p/p2p/net" ic "github.com/ipfs/go-libp2p-crypto" peer "github.com/ipfs/go-libp2p-peer" diff --git a/p2p/net/mock/mock_conn.go b/p2p/net/mock/mock_conn.go index f0fe6c1c..e9b72319 100644 --- a/p2p/net/mock/mock_conn.go +++ b/p2p/net/mock/mock_conn.go @@ -6,9 +6,9 @@ import ( ic "github.com/ipfs/go-libp2p-crypto" peer "github.com/ipfs/go-libp2p-peer" - inet "github.com/ipfs/go-libp2p/p2p/net" ma "github.com/jbenet/go-multiaddr" process "github.com/jbenet/goprocess" + inet "github.com/libp2p/go-libp2p/p2p/net" ) // conn represents one side's perspective of a diff --git a/p2p/net/mock/mock_link.go b/p2p/net/mock/mock_link.go index eb25dd41..30379dac 100644 --- a/p2p/net/mock/mock_link.go +++ b/p2p/net/mock/mock_link.go @@ -7,7 +7,7 @@ import ( "time" peer "github.com/ipfs/go-libp2p-peer" - inet "github.com/ipfs/go-libp2p/p2p/net" + inet "github.com/libp2p/go-libp2p/p2p/net" ) // link implements mocknet.Link diff --git a/p2p/net/mock/mock_net.go b/p2p/net/mock/mock_net.go index 832e0fa4..c8acdf82 100644 --- a/p2p/net/mock/mock_net.go +++ b/p2p/net/mock/mock_net.go @@ -5,11 +5,11 @@ import ( "sort" "sync" - host "github.com/ipfs/go-libp2p/p2p/host" - bhost "github.com/ipfs/go-libp2p/p2p/host/basic" - inet "github.com/ipfs/go-libp2p/p2p/net" - p2putil "github.com/ipfs/go-libp2p/p2p/test/util" - testutil "github.com/ipfs/go-libp2p/testutil" + host "github.com/libp2p/go-libp2p/p2p/host" + bhost "github.com/libp2p/go-libp2p/p2p/host/basic" + inet "github.com/libp2p/go-libp2p/p2p/net" + p2putil "github.com/libp2p/go-libp2p/p2p/test/util" + testutil "github.com/libp2p/go-libp2p/testutil" ic "github.com/ipfs/go-libp2p-crypto" peer "github.com/ipfs/go-libp2p-peer" diff --git a/p2p/net/mock/mock_notif_test.go b/p2p/net/mock/mock_notif_test.go index bf871da3..4c88ef9a 100644 --- a/p2p/net/mock/mock_notif_test.go +++ b/p2p/net/mock/mock_notif_test.go @@ -5,8 +5,8 @@ import ( "time" peer "github.com/ipfs/go-libp2p-peer" - inet "github.com/ipfs/go-libp2p/p2p/net" ma "github.com/jbenet/go-multiaddr" + inet "github.com/libp2p/go-libp2p/p2p/net" context "golang.org/x/net/context" ) diff --git a/p2p/net/mock/mock_peernet.go b/p2p/net/mock/mock_peernet.go index f4db87cb..048985b9 100644 --- a/p2p/net/mock/mock_peernet.go +++ b/p2p/net/mock/mock_peernet.go @@ -5,7 +5,7 @@ import ( "math/rand" "sync" - inet "github.com/ipfs/go-libp2p/p2p/net" + inet "github.com/libp2p/go-libp2p/p2p/net" peer "github.com/ipfs/go-libp2p-peer" pstore "github.com/ipfs/go-libp2p-peerstore" diff --git a/p2p/net/mock/mock_printer.go b/p2p/net/mock/mock_printer.go index 7afb1213..97732838 100644 --- a/p2p/net/mock/mock_printer.go +++ b/p2p/net/mock/mock_printer.go @@ -5,7 +5,7 @@ import ( "io" peer "github.com/ipfs/go-libp2p-peer" - inet "github.com/ipfs/go-libp2p/p2p/net" + inet "github.com/libp2p/go-libp2p/p2p/net" ) // separate object so our interfaces are separate :) diff --git a/p2p/net/mock/mock_stream.go b/p2p/net/mock/mock_stream.go index 78b4d750..2de6df2f 100644 --- a/p2p/net/mock/mock_stream.go +++ b/p2p/net/mock/mock_stream.go @@ -5,8 +5,8 @@ import ( "io" "time" - inet "github.com/ipfs/go-libp2p/p2p/net" process "github.com/jbenet/goprocess" + inet "github.com/libp2p/go-libp2p/p2p/net" ) // stream implements inet.Stream @@ -16,6 +16,8 @@ type stream struct { conn *conn toDeliver chan *transportObject proc process.Process + + protocol string } type transportObject struct { @@ -48,6 +50,14 @@ func (s *stream) Write(p []byte) (n int, err error) { return len(p), nil } +func (s *stream) Protocol() string { + return s.protocol +} + +func (s *stream) SetProtocol(proto string) { + s.protocol = proto +} + func (s *stream) Close() error { return s.proc.Close() } diff --git a/p2p/net/mock/mock_test.go b/p2p/net/mock/mock_test.go index a4964a6a..9c33b3bb 100644 --- a/p2p/net/mock/mock_test.go +++ b/p2p/net/mock/mock_test.go @@ -10,9 +10,9 @@ import ( "time" peer "github.com/ipfs/go-libp2p-peer" - inet "github.com/ipfs/go-libp2p/p2p/net" - protocol "github.com/ipfs/go-libp2p/p2p/protocol" - testutil "github.com/ipfs/go-libp2p/testutil" + inet "github.com/libp2p/go-libp2p/p2p/net" + protocol "github.com/libp2p/go-libp2p/p2p/protocol" + testutil "github.com/libp2p/go-libp2p/testutil" detectrace "github.com/jbenet/go-detect-race" context "golang.org/x/net/context" diff --git a/p2p/net/swarm/addr/addr.go b/p2p/net/swarm/addr/addr.go index d9ba8721..7759625f 100644 --- a/p2p/net/swarm/addr/addr.go +++ b/p2p/net/swarm/addr/addr.go @@ -9,7 +9,7 @@ import ( context "golang.org/x/net/context" ) -var log = logging.Logger("github.com/ipfs/go-libp2p/p2p/net/swarm/addr") +var log = logging.Logger("github.com/libp2p/go-libp2p/p2p/net/swarm/addr") // SupportedTransportStrings is the list of supported transports for the swarm. // These are strings of encapsulated multiaddr protocols. E.g.: diff --git a/p2p/net/swarm/dial_test.go b/p2p/net/swarm/dial_test.go index 031f3b3a..cfdb996c 100644 --- a/p2p/net/swarm/dial_test.go +++ b/p2p/net/swarm/dial_test.go @@ -6,9 +6,9 @@ import ( "testing" "time" - addrutil "github.com/ipfs/go-libp2p/p2p/net/swarm/addr" - testutil "github.com/ipfs/go-libp2p/testutil" - ci "github.com/ipfs/go-libp2p/testutil/ci" + addrutil "github.com/libp2p/go-libp2p/p2p/net/swarm/addr" + testutil "github.com/libp2p/go-libp2p/testutil" + ci "github.com/libp2p/go-libp2p/testutil/ci" peer "github.com/ipfs/go-libp2p-peer" pstore "github.com/ipfs/go-libp2p-peerstore" diff --git a/p2p/net/swarm/limiter.go b/p2p/net/swarm/limiter.go index 94ce05bb..19fc84c3 100644 --- a/p2p/net/swarm/limiter.go +++ b/p2p/net/swarm/limiter.go @@ -7,8 +7,8 @@ import ( ma "github.com/jbenet/go-multiaddr" context "golang.org/x/net/context" - conn "github.com/ipfs/go-libp2p/p2p/net/conn" - addrutil "github.com/ipfs/go-libp2p/p2p/net/swarm/addr" + conn "github.com/libp2p/go-libp2p/p2p/net/conn" + addrutil "github.com/libp2p/go-libp2p/p2p/net/swarm/addr" ) type dialResult struct { diff --git a/p2p/net/swarm/limiter_test.go b/p2p/net/swarm/limiter_test.go index 28733c5a..6ee6349a 100644 --- a/p2p/net/swarm/limiter_test.go +++ b/p2p/net/swarm/limiter_test.go @@ -12,7 +12,7 @@ import ( mafmt "github.com/whyrusleeping/mafmt" context "golang.org/x/net/context" - conn "github.com/ipfs/go-libp2p/p2p/net/conn" + conn "github.com/libp2p/go-libp2p/p2p/net/conn" ) func mustAddr(t *testing.T, s string) ma.Multiaddr { diff --git a/p2p/net/swarm/simul_test.go b/p2p/net/swarm/simul_test.go index e0165262..c6ee6cf9 100644 --- a/p2p/net/swarm/simul_test.go +++ b/p2p/net/swarm/simul_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - ci "github.com/ipfs/go-libp2p/testutil/ci" + ci "github.com/libp2p/go-libp2p/testutil/ci" peer "github.com/ipfs/go-libp2p-peer" pstore "github.com/ipfs/go-libp2p-peerstore" diff --git a/p2p/net/swarm/swarm.go b/p2p/net/swarm/swarm.go index 15e1ec5e..a86edb37 100644 --- a/p2p/net/swarm/swarm.go +++ b/p2p/net/swarm/swarm.go @@ -13,18 +13,18 @@ import ( peer "github.com/ipfs/go-libp2p-peer" pstore "github.com/ipfs/go-libp2p-peerstore" transport "github.com/ipfs/go-libp2p-transport" - metrics "github.com/ipfs/go-libp2p/p2p/metrics" - mconn "github.com/ipfs/go-libp2p/p2p/metrics/conn" - inet "github.com/ipfs/go-libp2p/p2p/net" - conn "github.com/ipfs/go-libp2p/p2p/net/conn" - filter "github.com/ipfs/go-libp2p/p2p/net/filter" - addrutil "github.com/ipfs/go-libp2p/p2p/net/swarm/addr" logging "github.com/ipfs/go-log" ma "github.com/jbenet/go-multiaddr" ps "github.com/jbenet/go-peerstream" pst "github.com/jbenet/go-stream-muxer" "github.com/jbenet/goprocess" goprocessctx "github.com/jbenet/goprocess/context" + metrics "github.com/libp2p/go-libp2p/p2p/metrics" + mconn "github.com/libp2p/go-libp2p/p2p/metrics/conn" + inet "github.com/libp2p/go-libp2p/p2p/net" + conn "github.com/libp2p/go-libp2p/p2p/net/conn" + filter "github.com/libp2p/go-libp2p/p2p/net/filter" + addrutil "github.com/libp2p/go-libp2p/p2p/net/swarm/addr" psmss "github.com/whyrusleeping/go-smux-multistream" spdy "github.com/whyrusleeping/go-smux-spdystream" yamux "github.com/whyrusleeping/go-smux-yamux" @@ -340,9 +340,9 @@ func (n *ps2netNotifee) Disconnected(c *ps.Conn) { } func (n *ps2netNotifee) OpenedStream(s *ps.Stream) { - n.not.OpenedStream(n.net, inet.Stream((*Stream)(s))) + n.not.OpenedStream(n.net, &Stream{stream: s}) } func (n *ps2netNotifee) ClosedStream(s *ps.Stream) { - n.not.ClosedStream(n.net, inet.Stream((*Stream)(s))) + n.not.ClosedStream(n.net, &Stream{stream: s}) } diff --git a/p2p/net/swarm/swarm_addr.go b/p2p/net/swarm/swarm_addr.go index 039683bf..85d4aafe 100644 --- a/p2p/net/swarm/swarm_addr.go +++ b/p2p/net/swarm/swarm_addr.go @@ -1,8 +1,8 @@ package swarm import ( - conn "github.com/ipfs/go-libp2p/p2p/net/conn" - addrutil "github.com/ipfs/go-libp2p/p2p/net/swarm/addr" + conn "github.com/libp2p/go-libp2p/p2p/net/conn" + addrutil "github.com/libp2p/go-libp2p/p2p/net/swarm/addr" ma "github.com/jbenet/go-multiaddr" ) diff --git a/p2p/net/swarm/swarm_addr_test.go b/p2p/net/swarm/swarm_addr_test.go index 0f9419bf..37eacbfd 100644 --- a/p2p/net/swarm/swarm_addr_test.go +++ b/p2p/net/swarm/swarm_addr_test.go @@ -3,9 +3,9 @@ package swarm import ( "testing" - metrics "github.com/ipfs/go-libp2p/p2p/metrics" - addrutil "github.com/ipfs/go-libp2p/p2p/net/swarm/addr" - testutil "github.com/ipfs/go-libp2p/testutil" + metrics "github.com/libp2p/go-libp2p/p2p/metrics" + addrutil "github.com/libp2p/go-libp2p/p2p/net/swarm/addr" + testutil "github.com/libp2p/go-libp2p/testutil" pstore "github.com/ipfs/go-libp2p-peerstore" ma "github.com/jbenet/go-multiaddr" diff --git a/p2p/net/swarm/swarm_conn.go b/p2p/net/swarm/swarm_conn.go index 96700ba8..36932784 100644 --- a/p2p/net/swarm/swarm_conn.go +++ b/p2p/net/swarm/swarm_conn.go @@ -3,8 +3,8 @@ package swarm import ( "fmt" - inet "github.com/ipfs/go-libp2p/p2p/net" - conn "github.com/ipfs/go-libp2p/p2p/net/conn" + inet "github.com/libp2p/go-libp2p/p2p/net" + conn "github.com/libp2p/go-libp2p/p2p/net/conn" ic "github.com/ipfs/go-libp2p-crypto" peer "github.com/ipfs/go-libp2p-peer" diff --git a/p2p/net/swarm/swarm_dial.go b/p2p/net/swarm/swarm_dial.go index 1100ca54..2f4d29fa 100644 --- a/p2p/net/swarm/swarm_dial.go +++ b/p2p/net/swarm/swarm_dial.go @@ -8,9 +8,9 @@ import ( lgbl "github.com/ipfs/go-libp2p-loggables" peer "github.com/ipfs/go-libp2p-peer" - conn "github.com/ipfs/go-libp2p/p2p/net/conn" - addrutil "github.com/ipfs/go-libp2p/p2p/net/swarm/addr" ma "github.com/jbenet/go-multiaddr" + conn "github.com/libp2p/go-libp2p/p2p/net/conn" + addrutil "github.com/libp2p/go-libp2p/p2p/net/swarm/addr" context "golang.org/x/net/context" ) diff --git a/p2p/net/swarm/swarm_listen.go b/p2p/net/swarm/swarm_listen.go index 38457f16..64fdb83b 100644 --- a/p2p/net/swarm/swarm_listen.go +++ b/p2p/net/swarm/swarm_listen.go @@ -5,11 +5,11 @@ import ( lgbl "github.com/ipfs/go-libp2p-loggables" transport "github.com/ipfs/go-libp2p-transport" - mconn "github.com/ipfs/go-libp2p/p2p/metrics/conn" - inet "github.com/ipfs/go-libp2p/p2p/net" - conn "github.com/ipfs/go-libp2p/p2p/net/conn" ma "github.com/jbenet/go-multiaddr" ps "github.com/jbenet/go-peerstream" + mconn "github.com/libp2p/go-libp2p/p2p/metrics/conn" + inet "github.com/libp2p/go-libp2p/p2p/net" + conn "github.com/libp2p/go-libp2p/p2p/net/conn" context "golang.org/x/net/context" ) diff --git a/p2p/net/swarm/swarm_net.go b/p2p/net/swarm/swarm_net.go index 92d2a801..8624dedb 100644 --- a/p2p/net/swarm/swarm_net.go +++ b/p2p/net/swarm/swarm_net.go @@ -5,8 +5,8 @@ import ( peer "github.com/ipfs/go-libp2p-peer" pstore "github.com/ipfs/go-libp2p-peerstore" - metrics "github.com/ipfs/go-libp2p/p2p/metrics" - inet "github.com/ipfs/go-libp2p/p2p/net" + metrics "github.com/libp2p/go-libp2p/p2p/metrics" + inet "github.com/libp2p/go-libp2p/p2p/net" ma "github.com/jbenet/go-multiaddr" "github.com/jbenet/goprocess" diff --git a/p2p/net/swarm/swarm_net_test.go b/p2p/net/swarm/swarm_net_test.go index 14c590b9..fddc8523 100644 --- a/p2p/net/swarm/swarm_net_test.go +++ b/p2p/net/swarm/swarm_net_test.go @@ -5,8 +5,8 @@ import ( "testing" "time" - inet "github.com/ipfs/go-libp2p/p2p/net" - testutil "github.com/ipfs/go-libp2p/p2p/test/util" + inet "github.com/libp2p/go-libp2p/p2p/net" + testutil "github.com/libp2p/go-libp2p/p2p/test/util" context "golang.org/x/net/context" ) diff --git a/p2p/net/swarm/swarm_notif_test.go b/p2p/net/swarm/swarm_notif_test.go index aa4fca24..06777469 100644 --- a/p2p/net/swarm/swarm_notif_test.go +++ b/p2p/net/swarm/swarm_notif_test.go @@ -5,11 +5,17 @@ import ( "time" peer "github.com/ipfs/go-libp2p-peer" - inet "github.com/ipfs/go-libp2p/p2p/net" ma "github.com/jbenet/go-multiaddr" + inet "github.com/libp2p/go-libp2p/p2p/net" context "golang.org/x/net/context" ) +func streamsSame(a, b inet.Stream) bool { + sa := a.(*Stream) + sb := b.(*Stream) + return sa.Stream() == sb.Stream() +} + func TestNotifications(t *testing.T) { ctx := context.Background() swarms := makeSwarms(ctx, t, 5) @@ -98,7 +104,7 @@ func TestNotifications(t *testing.T) { case <-time.After(timeout): t.Fatal("timeout") } - if s != s2 { + if !streamsSame(s, s2) { t.Fatal("got incorrect stream", s.Conn(), s2.Conn()) } @@ -108,7 +114,7 @@ func TestNotifications(t *testing.T) { case <-time.After(timeout): t.Fatal("timeout") } - if s != s2 { + if !streamsSame(s, s2) { t.Fatal("got incorrect stream", s.Conn(), s2.Conn()) } } diff --git a/p2p/net/swarm/swarm_stream.go b/p2p/net/swarm/swarm_stream.go index 7965d274..b305bf91 100644 --- a/p2p/net/swarm/swarm_stream.go +++ b/p2p/net/swarm/swarm_stream.go @@ -1,18 +1,21 @@ package swarm import ( - inet "github.com/ipfs/go-libp2p/p2p/net" + inet "github.com/libp2p/go-libp2p/p2p/net" ps "github.com/jbenet/go-peerstream" ) // a Stream is a wrapper around a ps.Stream that exposes a way to get // our Conn and Swarm (instead of just the ps.Conn and ps.Swarm) -type Stream ps.Stream +type Stream struct { + stream *ps.Stream + protocol string +} // Stream returns the underlying peerstream.Stream func (s *Stream) Stream() *ps.Stream { - return (*ps.Stream)(s) + return s.stream } // Conn returns the Conn associated with this Stream, as an inet.Conn @@ -22,27 +25,37 @@ func (s *Stream) Conn() inet.Conn { // SwarmConn returns the Conn associated with this Stream, as a *Conn func (s *Stream) SwarmConn() *Conn { - return (*Conn)(s.Stream().Conn()) + return (*Conn)(s.stream.Conn()) } // Read reads bytes from a stream. func (s *Stream) Read(p []byte) (n int, err error) { - return s.Stream().Read(p) + return s.stream.Read(p) } // Write writes bytes to a stream, flushing for each call. func (s *Stream) Write(p []byte) (n int, err error) { - return s.Stream().Write(p) + return s.stream.Write(p) } // Close closes the stream, indicating this side is finished // with the stream. func (s *Stream) Close() error { - return s.Stream().Close() + return s.stream.Close() +} + +func (s *Stream) Protocol() string { + return s.protocol +} + +func (s *Stream) SetProtocol(p string) { + s.protocol = p } func wrapStream(pss *ps.Stream) *Stream { - return (*Stream)(pss) + return &Stream{ + stream: pss, + } } func wrapStreams(st []*ps.Stream) []*Stream { diff --git a/p2p/net/swarm/swarm_test.go b/p2p/net/swarm/swarm_test.go index a19688d9..c11377ed 100644 --- a/p2p/net/swarm/swarm_test.go +++ b/p2p/net/swarm/swarm_test.go @@ -9,9 +9,9 @@ import ( "testing" "time" - metrics "github.com/ipfs/go-libp2p/p2p/metrics" - inet "github.com/ipfs/go-libp2p/p2p/net" - testutil "github.com/ipfs/go-libp2p/testutil" + metrics "github.com/libp2p/go-libp2p/p2p/metrics" + inet "github.com/libp2p/go-libp2p/p2p/net" + testutil "github.com/libp2p/go-libp2p/testutil" peer "github.com/ipfs/go-libp2p-peer" pstore "github.com/ipfs/go-libp2p-peerstore" diff --git a/p2p/protocol/identify/id.go b/p2p/protocol/identify/id.go index a8d59b48..3c44f24a 100644 --- a/p2p/protocol/identify/id.go +++ b/p2p/protocol/identify/id.go @@ -7,11 +7,11 @@ import ( semver "github.com/coreos/go-semver/semver" ggio "github.com/gogo/protobuf/io" pstore "github.com/ipfs/go-libp2p-peerstore" - host "github.com/ipfs/go-libp2p/p2p/host" - mstream "github.com/ipfs/go-libp2p/p2p/metrics/stream" - inet "github.com/ipfs/go-libp2p/p2p/net" - pb "github.com/ipfs/go-libp2p/p2p/protocol/identify/pb" ma "github.com/jbenet/go-multiaddr" + host "github.com/libp2p/go-libp2p/p2p/host" + mstream "github.com/libp2p/go-libp2p/p2p/metrics/stream" + inet "github.com/libp2p/go-libp2p/p2p/net" + pb "github.com/libp2p/go-libp2p/p2p/protocol/identify/pb" msmux "github.com/whyrusleeping/go-multistream" context "golang.org/x/net/context" diff --git a/p2p/protocol/identify/id_test.go b/p2p/protocol/identify/id_test.go index cd53a206..d0c147c4 100644 --- a/p2p/protocol/identify/id_test.go +++ b/p2p/protocol/identify/id_test.go @@ -5,9 +5,9 @@ import ( "time" peer "github.com/ipfs/go-libp2p-peer" - host "github.com/ipfs/go-libp2p/p2p/host" - identify "github.com/ipfs/go-libp2p/p2p/protocol/identify" - testutil "github.com/ipfs/go-libp2p/p2p/test/util" + host "github.com/libp2p/go-libp2p/p2p/host" + identify "github.com/libp2p/go-libp2p/p2p/protocol/identify" + testutil "github.com/libp2p/go-libp2p/p2p/test/util" ma "github.com/jbenet/go-multiaddr" context "golang.org/x/net/context" diff --git a/p2p/protocol/ping/ping.go b/p2p/protocol/ping/ping.go index f1d1758c..e16ff668 100644 --- a/p2p/protocol/ping/ping.go +++ b/p2p/protocol/ping/ping.go @@ -8,9 +8,9 @@ import ( u "github.com/ipfs/go-ipfs-util" peer "github.com/ipfs/go-libp2p-peer" - host "github.com/ipfs/go-libp2p/p2p/host" - inet "github.com/ipfs/go-libp2p/p2p/net" logging "github.com/ipfs/go-log" + host "github.com/libp2p/go-libp2p/p2p/host" + inet "github.com/libp2p/go-libp2p/p2p/net" context "golang.org/x/net/context" ) diff --git a/p2p/protocol/ping/ping_test.go b/p2p/protocol/ping/ping_test.go index eae81337..f0952d44 100644 --- a/p2p/protocol/ping/ping_test.go +++ b/p2p/protocol/ping/ping_test.go @@ -4,7 +4,7 @@ import ( "testing" "time" - netutil "github.com/ipfs/go-libp2p/p2p/test/util" + netutil "github.com/libp2p/go-libp2p/p2p/test/util" peer "github.com/ipfs/go-libp2p-peer" pstore "github.com/ipfs/go-libp2p-peerstore" diff --git a/p2p/protocol/relay/relay.go b/p2p/protocol/relay/relay.go index e2ad262b..6fa3c52a 100644 --- a/p2p/protocol/relay/relay.go +++ b/p2p/protocol/relay/relay.go @@ -6,15 +6,15 @@ import ( "time" peer "github.com/ipfs/go-libp2p-peer" - host "github.com/ipfs/go-libp2p/p2p/host" - inet "github.com/ipfs/go-libp2p/p2p/net" - protocol "github.com/ipfs/go-libp2p/p2p/protocol" logging "github.com/ipfs/go-log" mh "github.com/jbenet/go-multihash" + host "github.com/libp2p/go-libp2p/p2p/host" + inet "github.com/libp2p/go-libp2p/p2p/net" + protocol "github.com/libp2p/go-libp2p/p2p/protocol" context "golang.org/x/net/context" ) -var log = logging.Logger("github.com/ipfs/go-libp2p/p2p/protocol/relay") +var log = logging.Logger("github.com/libp2p/go-libp2p/p2p/protocol/relay") // ID is the protocol.ID of the Relay Service. const ID protocol.ID = "/ipfs/relay/line/0.1.0" diff --git a/p2p/protocol/relay/relay_test.go b/p2p/protocol/relay/relay_test.go index 57e69a66..858b5257 100644 --- a/p2p/protocol/relay/relay_test.go +++ b/p2p/protocol/relay/relay_test.go @@ -4,11 +4,11 @@ import ( "io" "testing" - inet "github.com/ipfs/go-libp2p/p2p/net" - protocol "github.com/ipfs/go-libp2p/p2p/protocol" - relay "github.com/ipfs/go-libp2p/p2p/protocol/relay" - testutil "github.com/ipfs/go-libp2p/p2p/test/util" logging "github.com/ipfs/go-log" + inet "github.com/libp2p/go-libp2p/p2p/net" + protocol "github.com/libp2p/go-libp2p/p2p/protocol" + relay "github.com/libp2p/go-libp2p/p2p/protocol/relay" + testutil "github.com/libp2p/go-libp2p/p2p/test/util" msmux "github.com/whyrusleeping/go-multistream" context "golang.org/x/net/context" ) diff --git a/p2p/test/backpressure/backpressure_test.go b/p2p/test/backpressure/backpressure_test.go index 1e32e30a..85969275 100644 --- a/p2p/test/backpressure/backpressure_test.go +++ b/p2p/test/backpressure/backpressure_test.go @@ -8,11 +8,11 @@ import ( u "github.com/ipfs/go-ipfs-util" peer "github.com/ipfs/go-libp2p-peer" - host "github.com/ipfs/go-libp2p/p2p/host" - inet "github.com/ipfs/go-libp2p/p2p/net" - protocol "github.com/ipfs/go-libp2p/p2p/protocol" - testutil "github.com/ipfs/go-libp2p/p2p/test/util" logging "github.com/ipfs/go-log" + host "github.com/libp2p/go-libp2p/p2p/host" + inet "github.com/libp2p/go-libp2p/p2p/net" + protocol "github.com/libp2p/go-libp2p/p2p/protocol" + testutil "github.com/libp2p/go-libp2p/p2p/test/util" context "golang.org/x/net/context" ) diff --git a/p2p/test/reconnects/reconnect_test.go b/p2p/test/reconnects/reconnect_test.go index 81c0d597..49125a39 100644 --- a/p2p/test/reconnects/reconnect_test.go +++ b/p2p/test/reconnects/reconnect_test.go @@ -8,13 +8,13 @@ import ( "time" u "github.com/ipfs/go-ipfs-util" - host "github.com/ipfs/go-libp2p/p2p/host" - inet "github.com/ipfs/go-libp2p/p2p/net" - swarm "github.com/ipfs/go-libp2p/p2p/net/swarm" - protocol "github.com/ipfs/go-libp2p/p2p/protocol" - testutil "github.com/ipfs/go-libp2p/p2p/test/util" logging "github.com/ipfs/go-log" ps "github.com/jbenet/go-peerstream" + host "github.com/libp2p/go-libp2p/p2p/host" + inet "github.com/libp2p/go-libp2p/p2p/net" + swarm "github.com/libp2p/go-libp2p/p2p/net/swarm" + protocol "github.com/libp2p/go-libp2p/p2p/protocol" + testutil "github.com/libp2p/go-libp2p/p2p/test/util" context "golang.org/x/net/context" ) diff --git a/p2p/test/util/key.go b/p2p/test/util/key.go index 2cbc436c..71054f23 100644 --- a/p2p/test/util/key.go +++ b/p2p/test/util/key.go @@ -8,8 +8,8 @@ import ( u "github.com/ipfs/go-ipfs-util" ic "github.com/ipfs/go-libp2p-crypto" peer "github.com/ipfs/go-libp2p-peer" - testutil "github.com/ipfs/go-libp2p/testutil" logging "github.com/ipfs/go-log" + testutil "github.com/libp2p/go-libp2p/testutil" ma "github.com/jbenet/go-multiaddr" ) diff --git a/p2p/test/util/util.go b/p2p/test/util/util.go index 52f028bd..d8f2aa74 100644 --- a/p2p/test/util/util.go +++ b/p2p/test/util/util.go @@ -4,11 +4,11 @@ import ( "testing" pstore "github.com/ipfs/go-libp2p-peerstore" - bhost "github.com/ipfs/go-libp2p/p2p/host/basic" - metrics "github.com/ipfs/go-libp2p/p2p/metrics" - inet "github.com/ipfs/go-libp2p/p2p/net" - swarm "github.com/ipfs/go-libp2p/p2p/net/swarm" - tu "github.com/ipfs/go-libp2p/testutil" + bhost "github.com/libp2p/go-libp2p/p2p/host/basic" + metrics "github.com/libp2p/go-libp2p/p2p/metrics" + inet "github.com/libp2p/go-libp2p/p2p/net" + swarm "github.com/libp2p/go-libp2p/p2p/net/swarm" + tu "github.com/libp2p/go-libp2p/testutil" ma "github.com/jbenet/go-multiaddr" context "golang.org/x/net/context" diff --git a/package.json b/package.json index e2ce569b..ecc6a23d 100644 --- a/package.json +++ b/package.json @@ -34,9 +34,9 @@ "version": "1.0.0" }, { - "hash": "Qmf91yhgRLo2dhhbc5zZ7TxjMaR1oxaWaoc9zRZdi1kU4a", + "hash": "QmXAWgboitGTKjCqHjVNKMAU13hV5LjYMui8n3UAGPBDLp", "name": "go-multistream", - "version": "0.0.0" + "version": "0.2.0" }, { "hash": "QmNLvkCDV6ZjUJsEwGNporYBuZdhWT6q7TBVYQwwRv12HT", @@ -171,9 +171,9 @@ }, { "author": "whyrusleeping", - "hash": "QmVcmcQE9eX4HQ8QwhVXpoHt3ennG7d299NDYFq9D1Uqa1", + "hash": "QmcK5em8AHkQf72b4JPyDdyuKkCc7xADTEN7w26CJh4uQN", "name": "go-smux-multistream", - "version": "1.0.0" + "version": "1.2.0" }, { "author": "whyrusleeping", diff --git a/testutil/ci/ci.go b/testutil/ci/ci.go index d3f69d0f..6539c030 100644 --- a/testutil/ci/ci.go +++ b/testutil/ci/ci.go @@ -6,8 +6,8 @@ package ci import ( "os" - jenkins "github.com/ipfs/go-libp2p/testutil/ci/jenkins" - travis "github.com/ipfs/go-libp2p/testutil/ci/travis" + jenkins "github.com/libp2p/go-libp2p/testutil/ci/jenkins" + travis "github.com/libp2p/go-libp2p/testutil/ci/travis" ) // EnvVar is a type to use travis-only env var names with