tcpreuse

package
v0.38.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 18, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EnvReuseportVal = true

EnvReuseportVal stores the value of envReuseport. defaults to true.

View Source
var ErrListenerExists = errors.New("listener already exists for this conn type on this address")

Functions

func IsHTTP

func IsHTTP(s Prefix) bool

func IsMultistreamSelect

func IsMultistreamSelect(s Prefix) bool

func IsTLS

func IsTLS(s Prefix) bool

func ReuseportIsAvailable

func ReuseportIsAvailable() bool

ReuseportIsAvailable returns whether reuseport is available to be used. This is here because we want to be able to turn reuseport on and off selectively. For now we use an ENV variable, as this handles our pressing need:

LIBP2P_TCP_REUSEPORT=false ipfs daemon

If this becomes a sought after feature, we could add this to the config. In the end, reuseport is a stop-gap.

Types

type ConnMgr

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

ConnMgr enables you to share the same listen address between TCP and WebSocket transports.

func NewConnMgr

func NewConnMgr(enableReuseport bool, gater connmgr.ConnectionGater, rcmgr network.ResourceManager) *ConnMgr

func (*ConnMgr) DemultiplexedListen

func (t *ConnMgr) DemultiplexedListen(laddr ma.Multiaddr, connType DemultiplexedConnType) (manet.Listener, error)

DemultiplexedListen returns a listener for laddr listening for `connType` connections. The connections accepted from returned listeners need to be upgraded with a `transport.Upgrader`. NOTE: All listeners for port 0 share the same underlying socket, so they have the same specific port.

func (*ConnMgr) DialContext

func (t *ConnMgr) DialContext(ctx context.Context, raddr ma.Multiaddr) (manet.Conn, error)

DialContext is like Dial but takes a context.

type DemultiplexedConnType

type DemultiplexedConnType int
const (
	DemultiplexedConnType_Unknown DemultiplexedConnType = iota
	DemultiplexedConnType_MultistreamSelect
	DemultiplexedConnType_HTTP
	DemultiplexedConnType_TLS
)

func (DemultiplexedConnType) IsKnown

func (t DemultiplexedConnType) IsKnown() bool

func (DemultiplexedConnType) String

func (t DemultiplexedConnType) String() string

type Prefix

type Prefix = [3]byte

Matchers are implemented here instead of in the transports so we can easily fuzz them together.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL