Documentation
¶
Index ¶
- Variables
- func NewPeer(addr string, cfg *config.Config, mgr *Manager) *peerImpl
- type Manager
- func (m *Manager) AnnounceLocalRoutes()
- func (m *Manager) ClearRoutesForPeer(p *peerImpl)
- func (m *Manager) Done() <-chan struct{}
- func (m *Manager) ForwardUDP(routeKey string, dstPort int, pc net.PacketConn, clientAddr *net.UDPAddr, ...) error
- func (m *Manager) GetBandwidthScheduler() *bandwidth.Scheduler
- func (m *Manager) GetPeerForHostname(hostname string) (iface.Peer, bool)
- func (m *Manager) HandleInboundPeer(conn *websocket.Conn)
- func (m *Manager) HandleOutboundUDPClose(flowID uuid.UUID) bool
- func (m *Manager) HandleOutboundUDPData(flowID uuid.UUID, payload []byte) bool
- func (m *Manager) HandleTunnelClose(clientID uuid.UUID)
- func (m *Manager) HandleTunnelData(clientID uuid.UUID, payload []byte)
- func (m *Manager) HandleTunnelRequest(p iface.Peer, hostname string, clientID uuid.UUID, clientIP string, ...)
- func (m *Manager) Run(ctx context.Context)
- func (m *Manager) Stop()
- func (m *Manager) UpdatePeerRoutes(p *peerImpl, version uint64, hostnames []string)
- type TunneledConn
- func (c *TunneledConn) Close() error
- func (c *TunneledConn) IsPaused() bool
- func (c *TunneledConn) LocalAddr() net.Addr
- func (c *TunneledConn) Pause()
- func (c *TunneledConn) Read(b []byte) (n int, err error)
- func (c *TunneledConn) RemoteAddr() net.Addr
- func (c *TunneledConn) Resume()
- func (c *TunneledConn) SetDeadline(t time.Time) error
- func (c *TunneledConn) SetReadDeadline(t time.Time) error
- func (c *TunneledConn) SetWriteDeadline(t time.Time) error
- func (c *TunneledConn) Write(b []byte) (n int, err error)
- func (c *TunneledConn) WriteToPipe(b []byte) (n int, err error)
Constants ¶
This section is empty.
Variables ¶
var ErrPeerSendFailed = errors.New("peer send queue full")
ErrPeerSendFailed is returned when the peer send queue is full.
Functions ¶
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is responsible for establishing and maintaining connections to all peer Nexus nodes and managing the global routing table.
func NewManager ¶
NewManager creates a new peer manager.
func (*Manager) AnnounceLocalRoutes ¶
func (m *Manager) AnnounceLocalRoutes()
AnnounceLocalRoutes calculates the current local routes, increments the state version, and broadcasts the new state to all connected peers.
func (*Manager) ClearRoutesForPeer ¶
func (m *Manager) ClearRoutesForPeer(p *peerImpl)
ClearRoutesForPeer is called when a peer disconnects, to purge its routes.
func (*Manager) Done ¶
func (m *Manager) Done() <-chan struct{}
Done returns a channel that is closed when the manager is shutting down. Used by peers for graceful shutdown during bandwidth waits.
func (*Manager) ForwardUDP ¶
func (*Manager) GetBandwidthScheduler ¶
GetBandwidthScheduler returns the bandwidth scheduler from the hub. Used by peers for bandwidth limiting during tunneling.
func (*Manager) GetPeerForHostname ¶
GetPeerForHostname checks the routing table for a peer that can service a given hostname.
func (*Manager) HandleInboundPeer ¶
HandleInboundPeer manages a new connection initiated by another peer.
func (*Manager) HandleOutboundUDPClose ¶
func (*Manager) HandleOutboundUDPData ¶
func (*Manager) HandleTunnelClose ¶
HandleTunnelClose cleans up a tunnel when a peer signals it has closed.
func (*Manager) HandleTunnelData ¶
HandleTunnelData forwards data received from a peer to the correct tunneled connection.
func (*Manager) HandleTunnelRequest ¶
func (m *Manager) HandleTunnelRequest(p iface.Peer, hostname string, clientID uuid.UUID, clientIP string, connPort int, isTLS bool)
HandleTunnelRequest is called by a peer's read pump when it receives a request to establish a tunnel for a client. It selects a local backend and starts the proxying.
func (*Manager) Run ¶
Run starts the manager, which will attempt to connect to all configured peers.
func (*Manager) UpdatePeerRoutes ¶
UpdatePeerRoutes is called by a Peer when it receives an announcement.
type TunneledConn ¶
type TunneledConn struct {
// contains filtered or unexported fields
}
TunneledConn implements the net.Conn interface for a client connection that is being tunneled from another peer.
func NewTunneledConn ¶
func NewTunneledConn(clientID uuid.UUID, peer iface.Peer, clientIp string, connPort int) *TunneledConn
NewTunneledConn creates a new virtual connection for a tunneled client. clientIp is parsed eagerly into a *net.TCPAddr using numeric-only parsing (no DNS resolution). If parsing fails, a warning is logged and a zero-value fallback is stored.
func (*TunneledConn) Close ¶
func (c *TunneledConn) Close() error
Close signals to the peer that this end of the tunnel is closed. Safe to call multiple times - only sends close message once.
func (*TunneledConn) IsPaused ¶
func (c *TunneledConn) IsPaused() bool
IsPaused returns the current pause state.
func (*TunneledConn) LocalAddr ¶
func (c *TunneledConn) LocalAddr() net.Addr
LocalAddr, RemoteAddr, SetDeadline, etc., are part of the net.Conn interface.
func (*TunneledConn) Pause ¶
func (c *TunneledConn) Pause()
Pause propagates pause to the origin peer where actual backpressure occurs. The local paused flag tracks state but does NOT block Read() locally. Local state is only updated if the peer message is successfully queued.
func (*TunneledConn) Read ¶
func (c *TunneledConn) Read(b []byte) (n int, err error)
Read reads from the pipe. This method does NOT block when paused because: 1. io.Pipe is unbuffered - blocking here would deadlock the shared readPump 2. The actual backpressure happens at the origin peer's PausableConn 3. Any in-flight data when pause is requested will still be delivered
func (*TunneledConn) RemoteAddr ¶
func (c *TunneledConn) RemoteAddr() net.Addr
func (*TunneledConn) Resume ¶
func (c *TunneledConn) Resume()
Resume propagates resume to the origin peer to restore data flow. Local state is only updated if the peer message is successfully queued.
func (*TunneledConn) SetDeadline ¶
func (c *TunneledConn) SetDeadline(t time.Time) error
func (*TunneledConn) SetReadDeadline ¶
func (c *TunneledConn) SetReadDeadline(t time.Time) error
func (*TunneledConn) SetWriteDeadline ¶
func (c *TunneledConn) SetWriteDeadline(t time.Time) error
func (*TunneledConn) Write ¶
func (c *TunneledConn) Write(b []byte) (n int, err error)
Write writes data back to the originating peer. Returns ErrPeerSendFailed if the peer send queue is full.
func (*TunneledConn) WriteToPipe ¶
func (c *TunneledConn) WriteToPipe(b []byte) (n int, err error)
WriteToPipe writes data received from a peer into the tunnel's read pipe. Called by the peer's readPump - must never block indefinitely.