Documentation
¶
Index ¶
- Constants
- type ConnectionClosedEvent
- type ConnectionManager
- func (c *ConnectionManager) AddConnection(conn *ouroboros.Connection, isInbound bool, peerAddr string)
- func (c *ConnectionManager) CreateOutboundConn(ctx context.Context, address string) (*ouroboros.Connection, error)
- func (c *ConnectionManager) GetConnectionById(connId ouroboros.ConnectionId) *ouroboros.Connection
- func (c *ConnectionManager) HandleConnectionRecycleRequestedEvent(evt event.Event)
- func (c *ConnectionManager) HasInboundFromHost(peerAddr string) bool
- func (c *ConnectionManager) IPConnCount(ipKey string) int
- func (c *ConnectionManager) InboundCount() int
- func (c *ConnectionManager) RemoveConnection(connId ouroboros.ConnectionId)
- func (c *ConnectionManager) Start(ctx context.Context) error
- func (c *ConnectionManager) Stop(ctx context.Context) error
- type ConnectionManagerConfig
- type ConnectionManagerConnClosedFunc
- type ConnectionRecycleRequestedEvent
- type InboundConnectionEvent
- type ListenerConfig
- type UnixConn
- type UnixConnAddr
Constants ¶
const ( InboundConnectionEventType = "connmanager.inbound_conn" ConnectionClosedEventType = "connmanager.conn_closed" ConnectionRecycleRequestedEventType = "connmanager.connection_recycle_requested" )
const DefaultMaxConnectionsPerIP = 5
DefaultMaxConnectionsPerIP is the default maximum number of concurrent connections allowed from a single IP address (or /64 prefix for IPv6).
const ( // DefaultMaxInboundConnections is the default maximum number of // simultaneous inbound connections accepted by the connection manager. // This prevents resource exhaustion from malicious or accidental // connection floods. DefaultMaxInboundConnections = 100 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConnectionClosedEvent ¶ added in v0.2.0
type ConnectionClosedEvent struct {
ConnectionId ouroboros.ConnectionId
Error error
}
type ConnectionManager ¶
type ConnectionManager struct {
// contains filtered or unexported fields
}
func NewConnectionManager ¶
func NewConnectionManager(cfg ConnectionManagerConfig) *ConnectionManager
func (*ConnectionManager) AddConnection ¶
func (c *ConnectionManager) AddConnection( conn *ouroboros.Connection, isInbound bool, peerAddr string, )
func (*ConnectionManager) CreateOutboundConn ¶ added in v0.2.0
func (c *ConnectionManager) CreateOutboundConn( ctx context.Context, address string, ) (*ouroboros.Connection, error)
func (*ConnectionManager) GetConnectionById ¶
func (c *ConnectionManager) GetConnectionById( connId ouroboros.ConnectionId, ) *ouroboros.Connection
func (*ConnectionManager) HandleConnectionRecycleRequestedEvent ¶ added in v0.22.0
func (c *ConnectionManager) HandleConnectionRecycleRequestedEvent( evt event.Event, )
HandleConnectionRecycleRequestedEvent closes a connection when a recycle request event is received.
func (*ConnectionManager) HasInboundFromHost ¶ added in v0.22.0
func (c *ConnectionManager) HasInboundFromHost( peerAddr string, ) bool
HasInboundFromHost returns true if there is already an inbound connection from the same host (IP) as peerAddr, regardless of port or DiffusionMode. When OutboundSourcePort is set (listen port reuse), an outbound connection to the same host would create an identical TCP 4-tuple and fail with EADDRINUSE. The existing inbound connection serves as the bidirectional link between the two nodes.
func (*ConnectionManager) IPConnCount ¶ added in v0.22.0
func (c *ConnectionManager) IPConnCount(ipKey string) int
ipConnCount returns the current connection count for an IP key. Exported for testing only.
func (*ConnectionManager) InboundCount ¶ added in v0.22.0
func (c *ConnectionManager) InboundCount() int
InboundCount returns the current number of inbound connections.
func (*ConnectionManager) RemoveConnection ¶
func (c *ConnectionManager) RemoveConnection(connId ouroboros.ConnectionId)
type ConnectionManagerConfig ¶
type ConnectionManagerConfig struct {
PromRegistry prometheus.Registerer
Logger *slog.Logger
EventBus *event.EventBus
ConnClosedFunc ConnectionManagerConnClosedFunc
Listeners []ListenerConfig
OutboundConnOpts []ouroboros.ConnectionOptionFunc
OutboundSourcePort uint
MaxInboundConns int // 0 means use DefaultMaxInboundConnections
// MaxConnectionsPerIP limits the number of concurrent inbound
// connections from the same IP address. IPv6 addresses are grouped
// by /64 prefix. A value of 0 means use DefaultMaxConnectionsPerIP.
MaxConnectionsPerIP int
}
type ConnectionManagerConnClosedFunc ¶
type ConnectionManagerConnClosedFunc func(ouroboros.ConnectionId, error)
ConnectionManagerConnClosedFunc is a function that takes a connection ID and an optional error
type ConnectionRecycleRequestedEvent ¶ added in v0.22.0
type ConnectionRecycleRequestedEvent struct {
ConnectionId ouroboros.ConnectionId
ConnKey string
Reason string
}
ConnectionRecycleRequestedEvent requests that a specific connection be recycled.
type InboundConnectionEvent ¶ added in v0.1.7
type ListenerConfig ¶ added in v0.1.7
type UnixConn ¶ added in v0.4.0
UnixConn is a wrapper around net.UnixConn that provides a unique remote address
func (UnixConn) RemoteAddr ¶ added in v0.4.0
type UnixConnAddr ¶ added in v0.4.0
type UnixConnAddr struct {
// contains filtered or unexported fields
}
func (UnixConnAddr) Network ¶ added in v0.4.0
func (UnixConnAddr) Network() string
func (UnixConnAddr) String ¶ added in v0.4.0
func (u UnixConnAddr) String() string