Documentation
¶
Index ¶
- Constants
- func RecoveredPanicCount() uint64
- type Server
- func (s *Server) Addr() net.Addr
- func (s *Server) Close() error
- func (s *Server) CloseCompatWSS() error
- func (s *Server) EnableCompatWSS(bindAddr string, pubKeyLookup bwss.PubKeyLookupFn) error
- func (s *Server) ListenAndServe(addr string) error
- func (s *Server) LocalNodeCount() int
- func (s *Server) NotifyNode(nodeID uint32) error
- func (s *Server) PeerNodeCount() int
- func (s *Server) Ready() <-chan struct{}
- func (s *Server) RelayDropped() uint64
- func (s *Server) RelayForwarded() uint64
- func (s *Server) RelayNotFound() uint64
- func (s *Server) SendPunchCommand(nodeID uint32, targetIP net.IP, targetPort uint16) error
- func (s *Server) ServeHealth(addr string) error
- func (s *Server) SetAdvertiseAddr(addr string)
- func (s *Server) SetAuthoritativeKeyLookup(fn authKeyLookupFn)
- func (s *Server) SetBreakerAllow(fn func(name string) (bool, string))
- func (s *Server) SetHealthy(ok bool)
- func (s *Server) SetPunchWhitelist(ips []string)
- func (s *Server) SetRegistry(addr string)
- func (s *Server) SetRegistryAdminToken(token string)
- func (s *Server) SetRequirePunchToken(v bool)
- func (s *Server) SetStrictGossip(v bool)
- func (s *Server) StrictGossip() bool
- func (s *Server) WSSAddr() string
- func (s *Server) WSSIsConnected(nodeID uint32) bool
- func (s *Server) WSSMetrics() bwss.Metrics
Constants ¶
const MaxReusePortShards = 0
MaxReusePortShards is unlimited on Linux — the kernel flow-hashes across all open SO_REUSEPORT sockets. 0 means "use the configured 2× NumCPU default in ListenAndServe."
const MsgNotify byte = 0x0A
MsgNotify is a beacon → node message, [0x0A][kind(1)], telling the node that the registry is holding something for it. It carries no node ID, address or payload, so it discloses nothing to the node or to anyone watching the path; the node reacts by polling the registry over its own authenticated connection. Daemons that predate it drop it as an unknown beacon message. (The other beacon message types live in common/protocol; this one should move there. Must match the daemon's beaconMsgNotify.)
const NotifyKindHandshake byte = 0x01
NotifyKindHandshake is the MsgNotify kind for a relayed trust-handshake request or answer waiting at the registry.
Variables ¶
This section is empty.
Functions ¶
func RecoveredPanicCount ¶ added in v0.2.7
func RecoveredPanicCount() uint64
RecoveredPanicCount returns the total number of panics swallowed by recoverHandler since process start.
Types ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewWithPeers ¶
NewWithPeers creates a beacon server with gossip peer support. beaconID uniquely identifies this beacon instance (0 = standalone). peers is a list of peer beacon addresses for gossip exchange.
func (*Server) Close ¶
Close shuts down the server's UDP sockets and signals goroutines to exit. Safe to call multiple times: the teardown runs exactly once, and any subsequent call returns the first-error observed during that single teardown without re-closing already-closed sockets.
func (*Server) CloseCompatWSS ¶
CloseCompatWSS shuts down the WSS bridge. Idempotent. Used by graceful shutdown paths and tests.
func (*Server) EnableCompatWSS ¶
func (s *Server) EnableCompatWSS(bindAddr string, pubKeyLookup bwss.PubKeyLookupFn) error
EnableCompatWSS attaches a WSS-bridge listener for compat-mode daemons. After Start, the beacon's relay worker checks the WSS peer map BEFORE the UDP tier-1/2 lookups: relay packets destined for a WSS-connected daemon are written over WSS instead of UDP. Inbound WSS frames feed into handlePacket the same way UDP datagrams do, so the existing dispatch logic (BeaconMsgRelay, BeaconMsgDiscover, etc.) handles them without changes.
pubKeyLookup must return the Ed25519 pubkey registered for nodeID. In the rendezvous binary this is plumbed to the in-process registry's pubkey index.
Call this BEFORE ListenAndServe so the wssServer is in place when the first UDP datagram arrives.
func (*Server) ListenAndServe ¶
func (*Server) LocalNodeCount ¶
LocalNodeCount returns the number of locally registered nodes.
func (*Server) NotifyNode ¶ added in v0.2.12
NotifyNode tells a node that the registry holds a relayed handshake for it. Best effort: the node may not be registered with this beacon, may be on the compat (WSS) transport, or may predate MsgNotify — it then finds the handshake on its next poll, as before. A notify within notifyMinInterval of the previous one to the same node is skipped (nil).
func (*Server) PeerNodeCount ¶
PeerNodeCount returns the number of nodes known via gossip from peer beacons.
func (*Server) Ready ¶
func (s *Server) Ready() <-chan struct{}
Ready returns a channel that is closed when the server has bound its port.
func (*Server) RelayDropped ¶
RelayDropped returns the count of relay packets dropped (capacity / errors).
func (*Server) RelayForwarded ¶
RelayForwarded returns the count of relay packets the beacon has forwarded since startup. Used by /api/stats to surface observable evidence that the relay path is live.
func (*Server) RelayNotFound ¶
RelayNotFound returns the count of relay packets dropped because the destination node was not registered with the beacon.
func (*Server) SendPunchCommand ¶
SendPunchCommand tells a node to send UDP to a target endpoint.
func (*Server) ServeHealth ¶
ServeHealth starts a simple HTTP server with a /healthz endpoint for load balancer health checks.
func (*Server) SetAdvertiseAddr ¶
SetAdvertiseAddr sets the address this beacon registers with the registry. When empty (default), the beacon auto-detects from its TCP local addr to the registry — which on a GCP MIG deployment yields the INTERNAL VPC address (10.128.0.x), unreachable from external daemons. MIG-deployed beacons must set this to the public DNAT entrypoint (e.g. the rendezvous reserved IP on UDP 9001) so external clients receive a routable address from beacon_list.
func (*Server) SetAuthoritativeKeyLookup ¶ added in v0.2.7
func (s *Server) SetAuthoritativeKeyLookup(fn authKeyLookupFn)
func (*Server) SetBreakerAllow ¶ added in v0.2.6
SetPunchWhitelist replaces the source-IP whitelist for punch-request rate limits (PILOT-342). Entries are matched against remote.IP.String() so callers should pass canonical text-form IPs (IPv4: "10.0.0.1", IPv6: "2001:db8::1" without zone/port). Empty slice clears the whitelist. Safe to call concurrently with handlePunchRequest — the underlying field is an atomic.Pointer. SetBreakerAllow installs the parent process's breaker-query callback. When set, the beacon consults it before serving each punch / relay / discover request; Open drops the message silently (the sender's regular retry takes over). Pass nil to disable. Safe to call after Serve has started.
func (*Server) SetHealthy ¶
SetHealthy sets the health status (for graceful drain on scale-down).
func (*Server) SetPunchWhitelist ¶ added in v0.2.5
func (*Server) SetRegistry ¶
SetRegistry sets the registry address for dynamic peer discovery. Safe to call at any time — protected by mu so the discovery loop does not race against a post-startup SetRegistry call.
func (*Server) SetRegistryAdminToken ¶
SetRegistryAdminToken sets the admin token sent with beacon_register. Required when the registry enforces SEC-002 beacon registration auth.
func (*Server) SetRequirePunchToken ¶ added in v0.2.7
func (*Server) SetStrictGossip ¶ added in v0.2.8
SetStrictGossip controls whether inbound gossip sync messages must come from an address in the peer set — the beacons configured at construction plus those learned from the registry in registryDiscover. With it off (the default) any source may publish node-id → beacon routes into the peer mesh, so it should be enabled wherever every mesh member's observed source address matches the address it registers. Off by default because a beacon behind DNAT egresses from an address other than the one it advertises, and enabling the check there would stop the mesh from converging.
func (*Server) StrictGossip ¶ added in v0.2.8
StrictGossip reports whether the handleSync peer-set check is active.
func (*Server) WSSAddr ¶
WSSAddr returns the actual listen address of the compat WSS bridge. Empty string if EnableCompatWSS was never called. Used by tests that bind to :0 and need to discover the real port.
func (*Server) WSSIsConnected ¶
WSSIsConnected reports whether a compat-mode daemon is currently connected via the WSS bridge for the given nodeID. False if the bridge isn't enabled. Used by tests that need to wait for the post-handshake registration to land.
func (*Server) WSSMetrics ¶
WSSMetrics returns the live WSS-bridge metrics, or zero values if EnableCompatWSS was never called. Used by the dashboard / Prom scrape to expose compat-mode visibility.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
beacon
command
|
|
|
Package wss is the beacon-side WSS listener for compat-mode daemons.
|
Package wss is the beacon-side WSS listener for compat-mode daemons. |
|
internal/daemonwss
Package wss implements pkg/daemon/transport.Transport over a WebSocket Secure connection to a Pilot beacon.
|
Package wss implements pkg/daemon/transport.Transport over a WebSocket Secure connection to a Pilot beacon. |