package tcp

import "github.com/libp2p/go-libp2p/p2p/transport/tcp"

Index

Variables

var ReuseportIsAvailable = tcpreuse.ReuseportIsAvailable

Deprecated: Use tcpreuse.ReuseportIsAvailable

Types

type ContextDialer

type ContextDialer interface {
	DialContext(ctx context.Context, network, address string) (net.Conn, error)
}

type DialerForAddr

type DialerForAddr func(raddr ma.Multiaddr) (ContextDialer, error)

DialerForAddr is a function that returns a dialer for a given address. Implementations must return either a ContextDialer or an error. It is invalid to return nil, nil.

type Option

type Option func(*TcpTransport) error

func DisableReuseport

func DisableReuseport() Option

func WithConnectionTimeout

func WithConnectionTimeout(d time.Duration) Option

func WithDialerForAddr

func WithDialerForAddr(d DialerForAddr) Option

WithDialerForAddr sets a custom dialer for the given address. If set, it will be the *ONLY* dialer used.

func WithMetrics

func WithMetrics() Option

type TcpTransport

type TcpTransport struct {
	// contains filtered or unexported fields
}

TcpTransport is the TCP transport.

func NewTCPTransport

func NewTCPTransport(upgrader transport.Upgrader, rcmgr network.ResourceManager, sharedTCP *tcpreuse.ConnMgr, opts ...Option) (*TcpTransport, error)

NewTCPTransport creates a tcp transport object that tracks dialers and listeners created.

func (*TcpTransport) CanDial

func (t *TcpTransport) CanDial(addr ma.Multiaddr) bool

CanDial returns true if this transport believes it can dial the given multiaddr.

func (*TcpTransport) Dial

Dial dials the peer at the remote address.

func (*TcpTransport) DialWithUpdates

func (t *TcpTransport) DialWithUpdates(ctx context.Context, raddr ma.Multiaddr, p peer.ID, updateChan chan<- transport.DialUpdate) (transport.CapableConn, error)

func (*TcpTransport) Listen

func (t *TcpTransport) Listen(laddr ma.Multiaddr) (transport.Listener, error)

Listen listens on the given multiaddr.

func (*TcpTransport) Protocols

func (t *TcpTransport) Protocols() []int

Protocols returns the list of terminal protocols this transport can dial.

func (*TcpTransport) Proxy

func (t *TcpTransport) Proxy() bool

Proxy always returns false for the TCP transport.

func (*TcpTransport) String

func (t *TcpTransport) String() string

func (*TcpTransport) UseReuseport

func (t *TcpTransport) UseReuseport() bool

UseReuseport returns true if reuseport is enabled and available.

Source Files

metrics.go metrics_linux.go tcp.go

Version
v0.42.0 (latest)
Published
Jun 18, 2025
Platform
linux/amd64
Imports
22 packages
Last checked
4 weeks ago

Tools for package owners.