package tcpreuse
import "github.com/libp2p/go-libp2p/p2p/transport/tcpreuse"
Index ¶
- Variables
- func IsHTTP(s Prefix) bool
- func IsMultistreamSelect(s Prefix) bool
- func IsTLS(s Prefix) bool
- func ReuseportIsAvailable() bool
- type ConnMgr
- func NewConnMgr(enableReuseport bool, gater connmgr.ConnectionGater, rcmgr network.ResourceManager) *ConnMgr
- func (t *ConnMgr) DemultiplexedListen(laddr ma.Multiaddr, connType DemultiplexedConnType) (manet.Listener, error)
- func (t *ConnMgr) DialContext(ctx context.Context, raddr ma.Multiaddr) (manet.Conn, error)
- type DemultiplexedConnType
- type Prefix
Variables ¶
var EnvReuseportVal = true
EnvReuseportVal stores the value of envReuseport. defaults to true.
Functions ¶
func IsHTTP ¶
func IsMultistreamSelect ¶
func IsTLS ¶
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 ¶
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.
Source Files ¶
connwithscope.go demultiplex.go dialer.go listener.go reuseport.go
Directories ¶
Path | Synopsis |
---|---|
p2p/transport/tcpreuse/internal |
- Version
- v0.41.1 (latest)
- Published
- Mar 24, 2025
- Platform
- linux/amd64
- Imports
- 17 packages
- Last checked
- 3 weeks ago –
Tools for package owners.