Documentation
¶
Overview ¶
Package signaling implements the Cotilla zero-knowledge 1:1 WebRTC signaling gateway hub.
In accordance with the pure WebRTC signaling isolation architecture:
- /ws strictly handles the 1:1 authenticated WebRTC negotiation (register -> offer -> answer -> ok) to establish a direct WebRTC DataChannel connection between the newcomer and the server.
- Once the WebRTC DataChannel is opened, /ws is immediately closed.
- All peer discovery (PortPeerRequest -> PortPeerResponse / PortRootIntro) and WebRTC overlay peering (PortWebRTCSignal) happen exclusively through the Cotilla Packet protocol over WebRTC DataChannels.
Index ¶
- Constants
- type Hub
- func (h *Hub) Anchors() []string
- func (h *Hub) Close()
- func (h *Hub) HandleHealth(w http.ResponseWriter, r *http.Request)
- func (h *Hub) HandlePeerClose(peerAddr string)
- func (h *Hub) HandlePeerOpen(peerAddr string)
- func (h *Hub) HandleWS(w http.ResponseWriter, r *http.Request)
- func (h *Hub) HasAnchor(addr string) bool
- func (h *Hub) IntroFanout() int
- func (h *Hub) LastRegisterTS(peerAddr string) int64
- func (h *Hub) Node() *cot.Node
- func (h *Hub) SeedAnchor(addr string)
- func (h *Hub) SelfAddr() string
- func (h *Hub) SetQueryCooldown(d time.Duration)
- func (h *Hub) SolicitAnchors()
- func (h *Hub) StartSupervisor(ctx context.Context, interval time.Duration)
- func (h *Hub) TargetPool() int
- func (h *Hub) Transport() *cotillartc.PionTransport
- type WSMessage
Constants ¶
const ( DefaultMinAnchors = 50 DefaultIntroFanout = 5 DefaultAnchorQueryPeriod = 2 * time.Second )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Hub ¶
type Hub struct {
// contains filtered or unexported fields
}
Hub is the zero-knowledge signaling rendezvous hub and overlay anchor pool manager.
func NewHub ¶
func NewHub() *Hub
NewHub creates a signaling Hub with production defaults (50 anchors, 5 intro fanout).
func NewHubWithConfig ¶
NewHubWithConfig creates a signaling Hub with custom pool target, intro fanout, and STUN URLs.
func NewHubWithOptions ¶
func NewHubWithOptions(targetPool, introFanout int, trOpts cotillartc.TransportOptions) (*Hub, error)
NewHubWithOptions creates a signaling Hub with full PionTransport options.
func NewHubWithTarget ¶
NewHubWithTarget creates a signaling Hub targeting targetPool active anchors.
func (*Hub) Close ¶
func (h *Hub) Close()
Close shuts down the hub, stops background goroutines, and waits boundedly for them to exit.
func (*Hub) HandleHealth ¶
func (h *Hub) HandleHealth(w http.ResponseWriter, r *http.Request)
HandleHealth serves the JSON health & anchor-pool status endpoint.
func (*Hub) HandlePeerClose ¶
HandlePeerClose removes a disconnected peer, promotes connected leaves if needed, and triggers anchor solicitation.
func (*Hub) HandlePeerOpen ¶
HandlePeerOpen registers a peer in the overlay and anchor pool and sends PortRootIntro.
func (*Hub) HandleWS ¶
func (h *Hub) HandleWS(w http.ResponseWriter, r *http.Request)
HandleWS handles the 1:1 authenticated WebRTC DataChannel handshake on /ws.
func (*Hub) IntroFanout ¶
func (*Hub) LastRegisterTS ¶
LastRegisterTS returns the last accepted register timestamp for peerAddr.
func (*Hub) SeedAnchor ¶
SeedAnchor inserts addr directly into the anchor pool (used in unit tests).
func (*Hub) SetQueryCooldown ¶
SetQueryCooldown overrides the minimum interval between anchor solicitations.
func (*Hub) SolicitAnchors ¶
func (h *Hub) SolicitAnchors()
SolicitAnchors broadcasts PortAnchorSolicit over DataChannels if anchorPool is below targetPool.
func (*Hub) StartSupervisor ¶
StartSupervisor runs the periodic replay-cache pruner and anchor replenishment loop.
func (*Hub) TargetPool ¶
func (*Hub) Transport ¶
func (h *Hub) Transport() *cotillartc.PionTransport
type WSMessage ¶
type WSMessage struct {
Type string `json:"type"` // "register" | "offer" | "answer" | "ok" | "error"
Peer string `json:"peer"` // sender Ed25519 public address
Target string `json:"target,omitempty"` // target Ed25519 address (for "offer" / "answer")
SDP string `json:"sdp,omitempty"` // bundled WebRTC SDP offer/answer description
Timestamp int64 `json:"timestamp,omitempty"` // unix ms for replay protection
Signature string `json:"signature,omitempty"` // Ed25519 hex signature over CanonicalSignalingMsg
Error string `json:"error,omitempty"` // error description
ICEServers *[]cotillartc.ICEServer `json:"ice_servers,omitempty"` // explicit STUN/TURN hints advertised on "offer" (including empty [] when disabled)
}
WSMessage is the JSON wire envelope exchanged strictly during the 1:1 /ws handshake.