Documentation
¶
Index ¶
- func New(cfg *config.Config, tlsConfig *tls.Config, validator auth.Validator, ...) *hubImpl
- type AttestationMetadata
- type Backend
- func (b *Backend) AddClient(clientConn net.Conn, clientID uuid.UUID, hostname string, isTLS bool) error
- func (b *Backend) AddOutboundClient(conn net.Conn, clientID uuid.UUID) error
- func (b *Backend) AttachBandwidthScheduler(s *bandwidth.Scheduler)
- func (b *Backend) BandwidthGateStats() (events, millisTotal int64)
- func (b *Backend) Close()
- func (b *Backend) HasRecentActivity(clientID uuid.UUID, since time.Time) bool
- func (b *Backend) ID() string
- func (b *Backend) RemoveClient(clientID uuid.UUID)
- func (b *Backend) ReplenishStats() (success, retryAttempts int64)
- func (b *Backend) SendControlMessage(msg protocol.ControlMessage) error
- func (b *Backend) SendData(clientID uuid.UUID, data []byte) error
- func (b *Backend) StartPumps()
- type LoadBalancerPool
- type UDPRoutePolicy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AttestationMetadata ¶
type AttestationMetadata struct {
Hostnames []string
TCPPorts []int
UDPRoutes []UDPRoutePolicy
Weight int
ReauthInterval time.Duration
ReauthGrace time.Duration
MaintenanceCap time.Duration
HasMaintenanceCap bool
AuthorizerStatusURI string
PolicyVersion string
OutboundAllowed bool
AllowedOutboundPorts []int
}
AttestationMetadata captures the policy directives extracted from the attested token that Nexus must enforce for a backend connection.
type Backend ¶
type Backend struct {
// contains filtered or unexported fields
}
Backend represents a single, authenticated WebSocket connection from a backend service.
func NewBackend ¶
func NewBackend(conn *websocket.Conn, meta *AttestationMetadata, cfg *config.Config, validator auth.Validator, httpClient *http.Client) *Backend
NewBackend creates a new Backend instance.
func (*Backend) AddOutboundClient ¶ added in v0.3.1
AddOutboundClient stores a proxy-dialed outbound connection in the clients map. Unlike AddClient, it does not send EventConnect (the backend initiated the request and already knows about the connection).
func (*Backend) AttachBandwidthScheduler ¶ added in v0.3.10
AttachBandwidthScheduler wires a bandwidth scheduler to this backend. Must be called at most once, strictly before StartPumps or AddClient, from the construction goroutine. The Register() side effect and the field write happen together so the pair cannot be split by refactors.
Safeguards (panic on misuse):
- nil scheduler → no-op.
- Called twice → panics. A second Register() would silently reset deficit / lastActive on a live backend.
- Called after any client is registered → panics. Mixing gated and ungated clients on the same backend is a debugging hazard.
func (*Backend) BandwidthGateStats ¶ added in v0.3.10
BandwidthGateStats returns the lifetime bandwidth gate counters for observability. events counts frames whose delivery was blocked by the per-backend bandwidth gate at least once (Request returned false ≥ 1 time). millisTotal accumulates the wall-clock wait across those blocked frames.
Operator guidance:
- Derived metric millisTotal/events approximates average block time per blocked frame. Alert threshold: sustained > 500ms average indicates cap exhaustion at current load.
- events rate should be near-zero when totalBandwidthMbps is unset (scheduler nil → gate nil → no drain-side gate activity). A non-zero rate under a nil scheduler indicates a bug.
- Use backend-ID correlation from logs to identify noisy-neighbor clients; per-client histograms are future work.
func (*Backend) HasRecentActivity ¶ added in v0.3.8
func (*Backend) RemoveClient ¶
func (*Backend) ReplenishStats ¶ added in v0.3.9
ReplenishStats returns the lifetime credit replenishment counters for observability. success counts EventResumeStream messages successfully enqueued on the control lane; retryAttempts counts failed enqueue attempts (the same stuck batch can contribute multiple retries).
func (*Backend) SendControlMessage ¶
func (b *Backend) SendControlMessage(msg protocol.ControlMessage) error
func (*Backend) StartPumps ¶
func (b *Backend) StartPumps()
type LoadBalancerPool ¶
type LoadBalancerPool struct {
// contains filtered or unexported fields
}
LoadBalancerPool manages a collection of backend instances for a single hostname.
func NewLoadBalancerPool ¶
func NewLoadBalancerPool() *LoadBalancerPool
NewLoadBalancerPool creates a new, empty load balancer pool.
func (*LoadBalancerPool) AddBackend ¶
func (p *LoadBalancerPool) AddBackend(b *Backend)
func (*LoadBalancerPool) HasBackends ¶
func (p *LoadBalancerPool) HasBackends() bool
HasBackends returns true if there are one or more backends in the pool.
func (*LoadBalancerPool) RemoveBackend ¶
func (p *LoadBalancerPool) RemoveBackend(b *Backend)