Merge pull request #84 from libp2p/feat/update-multistream
update multistream deps and fix code to work with new changes
This commit is contained in:
commit
14aac9bb58
|
@ -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"
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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
|
||||
})
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
)
|
||||
|
|
|
@ -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"
|
||||
)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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"
|
||||
)
|
||||
|
||||
|
|
|
@ -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"
|
||||
)
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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"
|
||||
)
|
||||
|
|
|
@ -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"
|
||||
)
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
)
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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 :)
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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.:
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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})
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
)
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
)
|
||||
|
||||
|
|
|
@ -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"
|
||||
)
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
)
|
||||
|
||||
|
|
|
@ -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())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
)
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
)
|
||||
|
|
|
@ -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"
|
||||
)
|
||||
|
||||
|
|
|
@ -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"
|
||||
)
|
||||
|
||||
|
|
|
@ -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"
|
||||
)
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue