diff --git a/go.mod b/go.mod index e4bee6c..a26f354 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/libp2p/go-openssl v0.0.7 github.com/minio/sha256-simd v0.1.1 github.com/mr-tron/base58 v1.2.0 - github.com/multiformats/go-multiaddr v0.2.2 + github.com/multiformats/go-multiaddr v0.4.1 github.com/multiformats/go-multihash v0.0.14 github.com/multiformats/go-varint v0.0.6 github.com/stretchr/testify v1.7.0 diff --git a/go.sum b/go.sum index 8913ef7..f7578b6 100644 --- a/go.sum +++ b/go.sum @@ -46,8 +46,8 @@ github.com/multiformats/go-base32 v0.0.3 h1:tw5+NhuwaOjJCC5Pp82QuXbrmLzWg7uxlMFp github.com/multiformats/go-base32 v0.0.3/go.mod h1:pLiuGC8y0QR3Ue4Zug5UzK9LjgbkL8NSQj0zQ5Nz/AA= github.com/multiformats/go-base36 v0.1.0 h1:JR6TyF7JjGd3m6FbLU2cOxhC0Li8z8dLNGQ89tUg4F4= github.com/multiformats/go-base36 v0.1.0/go.mod h1:kFGE83c6s80PklsHO9sRn2NCoffoRdUUOENyW/Vv6sM= -github.com/multiformats/go-multiaddr v0.2.2 h1:XZLDTszBIJe6m0zF6ITBrEcZR73OPUhCBBS9rYAuUzI= -github.com/multiformats/go-multiaddr v0.2.2/go.mod h1:NtfXiOtHvghW9KojvtySjH5y0u0xW5UouOmQQrn6a3Y= +github.com/multiformats/go-multiaddr v0.4.1 h1:Pq37uLx3hsyNlTDir7FZyU8+cFCTqd5y1KiM2IzOutI= +github.com/multiformats/go-multiaddr v0.4.1/go.mod h1:3afI9HfVW8csiF8UZqtpYRiDyew8pRX7qLIGHu9FLuM= github.com/multiformats/go-multibase v0.0.3 h1:l/B6bJDQjvQ5G52jw4QGSYeOTZoAwIO77RblWplfIqk= github.com/multiformats/go-multibase v0.0.3/go.mod h1:5+1R4eQrT3PkYZ24C3W2Ue2tPwIdYQD509ZjSb5y9Oc= github.com/multiformats/go-multihash v0.0.13/go.mod h1:VdAWLKTwram9oKAatUcLxBNUjdtcVwxObEQBtRfuyjc= diff --git a/transport/transport.go b/transport/transport.go index f413eb6..33e1741 100644 --- a/transport/transport.go +++ b/transport/transport.go @@ -11,6 +11,7 @@ import ( "github.com/libp2p/go-libp2p-core/peer" ma "github.com/multiformats/go-multiaddr" + manet "github.com/multiformats/go-multiaddr/net" ) // A CapableConn represents a connection that has offers the basic @@ -87,7 +88,7 @@ type Listener interface { Multiaddr() ma.Multiaddr } -// Network is an inet.Network with methods for managing transports. +// TransportNetwork is an inet.Network with methods for managing transports. type TransportNetwork interface { network.Network @@ -104,3 +105,12 @@ type TransportNetwork interface { // handle the last protocol in the multiaddr. AddTransport(t Transport) error } + +// Upgrader is a multistream upgrader that can upgrade an underlying connection +// to a full transport connection (secure and multiplexed). +type Upgrader interface { + // UpgradeListener upgrades the passed multiaddr-net listener into a full libp2p-transport listener. + UpgradeListener(Transport, manet.Listener) Listener + // Upgrade upgrades the multiaddr/net connection into a full libp2p-transport connection. + Upgrade(ctx context.Context, t Transport, maconn manet.Conn, dir network.Direction, p peer.ID) (CapableConn, error) +}