mirror of
https://github.com/libp2p/go-libp2p.git
synced 2025-09-26 20:21:26 +08:00

Allows the same socket to be shared amongst TCP,WS,WSS transports. --------- Co-authored-by: sukun <sukunrt@gmail.com> Co-authored-by: Marco Munizaga <git@marcopolo.io>
17 lines
399 B
Go
17 lines
399 B
Go
package tcpreuse
|
|
|
|
import (
|
|
"context"
|
|
ma "github.com/multiformats/go-multiaddr"
|
|
manet "github.com/multiformats/go-multiaddr/net"
|
|
)
|
|
|
|
// DialContext is like Dial but takes a context.
|
|
func (t *ConnMgr) DialContext(ctx context.Context, raddr ma.Multiaddr) (manet.Conn, error) {
|
|
if t.useReuseport() {
|
|
return t.reuse.DialContext(ctx, raddr)
|
|
}
|
|
var d manet.Dialer
|
|
return d.DialContext(ctx, raddr)
|
|
}
|