diff --git a/p2p/transport/quic/conn.go b/p2p/transport/quic/conn.go index ed837835c..bf173458a 100644 --- a/p2p/transport/quic/conn.go +++ b/p2p/transport/quic/conn.go @@ -1,10 +1,11 @@ package libp2pquic import ( - ic "github.com/libp2p/go-libp2p-crypto" - peer "github.com/libp2p/go-libp2p-peer" - tpt "github.com/libp2p/go-libp2p-transport" - smux "github.com/libp2p/go-stream-muxer" + ic "github.com/libp2p/go-libp2p-core/crypto" + "github.com/libp2p/go-libp2p-core/mux" + "github.com/libp2p/go-libp2p-core/peer" + tpt "github.com/libp2p/go-libp2p-core/transport" + quic "github.com/lucas-clemente/quic-go" ma "github.com/multiformats/go-multiaddr" ) @@ -22,7 +23,7 @@ type conn struct { remoteMultiaddr ma.Multiaddr } -var _ tpt.Conn = &conn{} +var _ tpt.CapableConn = &conn{} func (c *conn) Close() error { return c.sess.Close() @@ -34,13 +35,13 @@ func (c *conn) IsClosed() bool { } // OpenStream creates a new stream. -func (c *conn) OpenStream() (smux.Stream, error) { +func (c *conn) OpenStream() (mux.MuxedStream, error) { qstr, err := c.sess.OpenStreamSync() return &stream{Stream: qstr}, err } // AcceptStream accepts a stream opened by the other side. -func (c *conn) AcceptStream() (smux.Stream, error) { +func (c *conn) AcceptStream() (mux.MuxedStream, error) { qstr, err := c.sess.AcceptStream() return &stream{Stream: qstr}, err } diff --git a/p2p/transport/quic/conn_test.go b/p2p/transport/quic/conn_test.go index 1e0863e77..8b86af207 100644 --- a/p2p/transport/quic/conn_test.go +++ b/p2p/transport/quic/conn_test.go @@ -10,9 +10,9 @@ import ( "io/ioutil" "time" - ic "github.com/libp2p/go-libp2p-crypto" - peer "github.com/libp2p/go-libp2p-peer" - tpt "github.com/libp2p/go-libp2p-transport" + ic "github.com/libp2p/go-libp2p-core/crypto" + "github.com/libp2p/go-libp2p-core/peer" + tpt "github.com/libp2p/go-libp2p-core/transport" ma "github.com/multiformats/go-multiaddr" . "github.com/onsi/ginkgo" @@ -35,9 +35,9 @@ var _ = Describe("Connection", func() { return id, priv } - runServer := func(tr tpt.Transport, multiaddr string) (ma.Multiaddr, <-chan tpt.Conn) { + runServer := func(tr tpt.Transport, multiaddr string) (ma.Multiaddr, <-chan tpt.CapableConn) { addrChan := make(chan ma.Multiaddr) - connChan := make(chan tpt.Conn) + connChan := make(chan tpt.CapableConn) go func() { defer GinkgoRecover() addr, err := ma.NewMultiaddr(multiaddr) @@ -204,8 +204,8 @@ var _ = Describe("Connection", func() { // wait for both servers to accept a connection // then send some data go func() { - for _, c := range []tpt.Conn{<-serverConnChan, <-serverConnChan2} { - go func(conn tpt.Conn) { + for _, c := range []tpt.CapableConn{<-serverConnChan, <-serverConnChan2} { + go func(conn tpt.CapableConn) { defer GinkgoRecover() str, err := conn.OpenStream() Expect(err).ToNot(HaveOccurred()) @@ -225,8 +225,8 @@ var _ = Describe("Connection", func() { done := make(chan struct{}, 2) // receive the data on both connections at the same time - for _, c := range []tpt.Conn{c1, c2} { - go func(conn tpt.Conn) { + for _, c := range []tpt.CapableConn{c1, c2} { + go func(conn tpt.CapableConn) { defer GinkgoRecover() str, err := conn.AcceptStream() Expect(err).ToNot(HaveOccurred()) diff --git a/p2p/transport/quic/crypto.go b/p2p/transport/quic/crypto.go index 1ce18bcb9..68a30a629 100644 --- a/p2p/transport/quic/crypto.go +++ b/p2p/transport/quic/crypto.go @@ -11,8 +11,8 @@ import ( "time" "github.com/gogo/protobuf/proto" - ic "github.com/libp2p/go-libp2p-crypto" - pb "github.com/libp2p/go-libp2p-crypto/pb" + ic "github.com/libp2p/go-libp2p-core/crypto" + pb "github.com/libp2p/go-libp2p-core/crypto/pb" ) // mint certificate selection is broken. diff --git a/p2p/transport/quic/listener.go b/p2p/transport/quic/listener.go index ef8b01904..327af2f4c 100644 --- a/p2p/transport/quic/listener.go +++ b/p2p/transport/quic/listener.go @@ -4,9 +4,10 @@ import ( "crypto/tls" "net" - ic "github.com/libp2p/go-libp2p-crypto" - peer "github.com/libp2p/go-libp2p-peer" - tpt "github.com/libp2p/go-libp2p-transport" + ic "github.com/libp2p/go-libp2p-core/crypto" + "github.com/libp2p/go-libp2p-core/peer" + tpt "github.com/libp2p/go-libp2p-core/transport" + quic "github.com/lucas-clemente/quic-go" ma "github.com/multiformats/go-multiaddr" manet "github.com/multiformats/go-multiaddr-net" @@ -57,7 +58,7 @@ func newListener(addr ma.Multiaddr, transport tpt.Transport, localPeer peer.ID, } // Accept accepts new connections. -func (l *listener) Accept() (tpt.Conn, error) { +func (l *listener) Accept() (tpt.CapableConn, error) { for { sess, err := l.quicListener.Accept() if err != nil { @@ -72,7 +73,7 @@ func (l *listener) Accept() (tpt.Conn, error) { } } -func (l *listener) setupConn(sess quic.Session) (tpt.Conn, error) { +func (l *listener) setupConn(sess quic.Session) (tpt.CapableConn, error) { remotePubKey, err := getRemotePubKey(sess.ConnectionState().PeerCertificates) if err != nil { return nil, err diff --git a/p2p/transport/quic/listener_test.go b/p2p/transport/quic/listener_test.go index dd7974cf4..bf0435f1a 100644 --- a/p2p/transport/quic/listener_test.go +++ b/p2p/transport/quic/listener_test.go @@ -7,8 +7,9 @@ import ( "fmt" "net" - ic "github.com/libp2p/go-libp2p-crypto" - tpt "github.com/libp2p/go-libp2p-transport" + ic "github.com/libp2p/go-libp2p-core/crypto" + tpt "github.com/libp2p/go-libp2p-core/transport" + ma "github.com/multiformats/go-multiaddr" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" diff --git a/p2p/transport/quic/stream.go b/p2p/transport/quic/stream.go index 108536560..e757de20d 100644 --- a/p2p/transport/quic/stream.go +++ b/p2p/transport/quic/stream.go @@ -1,7 +1,8 @@ package libp2pquic import ( - smux "github.com/libp2p/go-stream-muxer" + "github.com/libp2p/go-libp2p-core/mux" + quic "github.com/lucas-clemente/quic-go" ) @@ -9,7 +10,7 @@ type stream struct { quic.Stream } -var _ smux.Stream = &stream{} +var _ mux.MuxedStream = &stream{} func (s *stream) Reset() error { s.Stream.CancelRead(0) diff --git a/p2p/transport/quic/transport.go b/p2p/transport/quic/transport.go index d9f2c8f09..c33b24176 100644 --- a/p2p/transport/quic/transport.go +++ b/p2p/transport/quic/transport.go @@ -9,9 +9,10 @@ import ( "net" "sync" - ic "github.com/libp2p/go-libp2p-crypto" - peer "github.com/libp2p/go-libp2p-peer" - tpt "github.com/libp2p/go-libp2p-transport" + ic "github.com/libp2p/go-libp2p-core/crypto" + "github.com/libp2p/go-libp2p-core/peer" + tpt "github.com/libp2p/go-libp2p-core/transport" + quic "github.com/lucas-clemente/quic-go" ma "github.com/multiformats/go-multiaddr" manet "github.com/multiformats/go-multiaddr-net" @@ -99,7 +100,7 @@ func NewTransport(key ic.PrivKey) (tpt.Transport, error) { } // Dial dials a new QUIC connection -func (t *transport) Dial(ctx context.Context, raddr ma.Multiaddr, p peer.ID) (tpt.Conn, error) { +func (t *transport) Dial(ctx context.Context, raddr ma.Multiaddr, p peer.ID) (tpt.CapableConn, error) { network, host, err := manet.DialArgs(raddr) if err != nil { return nil, err diff --git a/p2p/transport/quic/transport_test.go b/p2p/transport/quic/transport_test.go index 0decd920a..8dfece43b 100644 --- a/p2p/transport/quic/transport_test.go +++ b/p2p/transport/quic/transport_test.go @@ -1,7 +1,7 @@ package libp2pquic import ( - tpt "github.com/libp2p/go-libp2p-transport" + tpt "github.com/libp2p/go-libp2p-core/transport" ma "github.com/multiformats/go-multiaddr" . "github.com/onsi/ginkgo"