Documentation
¶
Index ¶
- func MarshalSDP(sdp string) []byte
- type DCHandler
- type PeerIdentity
- type PeerManager
- func (pm *PeerManager) Close()
- func (pm *PeerManager) GetDC(senderPub, sessionID string) *webrtc.DataChannel
- func (pm *PeerManager) GetPeerIdentity(senderPub string) (PeerIdentity, bool)
- func (pm *PeerManager) HandleOffer(senderPub, userID, email, orgRole string, passkeys []string, sdpOffer string) (string, error)
- func (pm *PeerManager) OnDC(handler DCHandler)
- type SDPPayload
- type SwappableWriter
- type WriteFn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalSDP ¶
MarshalSDP encodes an SDP payload to JSON bytes.
Types ¶
type DCHandler ¶
type DCHandler func(senderPub, sessionID string, dc *webrtc.DataChannel)
DCHandler is called when a new DataChannel opens on a peer connection.
type PeerIdentity ¶
PeerIdentity holds the relay-injected identity for a sender.
type PeerManager ¶
type PeerManager struct {
// contains filtered or unexported fields
}
PeerManager manages per-sender WebRTC peer connections.
func NewPeerManager ¶
func NewPeerManager(iceServers []webrtc.ICEServer) *PeerManager
NewPeerManager creates a PeerManager with the given ICE servers. Pass nil for host-only ICE (same-LAN only).
func (*PeerManager) GetDC ¶
func (pm *PeerManager) GetDC(senderPub, sessionID string) *webrtc.DataChannel
GetDC returns the DataChannel for a given sender and session. Returns nil if no matching DC exists.
func (*PeerManager) GetPeerIdentity ¶
func (pm *PeerManager) GetPeerIdentity(senderPub string) (PeerIdentity, bool)
GetPeerIdentity returns the cached identity for a sender.
func (*PeerManager) HandleOffer ¶
func (pm *PeerManager) HandleOffer(senderPub, userID, email, orgRole string, passkeys []string, sdpOffer string) (string, error)
HandleOffer processes a WebRTC offer from a browser, creating a PeerConnection and returning the answer SDP. Identity is cached from the relay-injected signaling.
func (*PeerManager) OnDC ¶
func (pm *PeerManager) OnDC(handler DCHandler)
OnDC registers a callback for new DataChannels.
type SDPPayload ¶
type SDPPayload struct {
SDP string `json:"sdp"`
}
SDPPayload is the JSON structure for webrtc.offer/answer tunnel payloads.
type SwappableWriter ¶
type SwappableWriter struct {
// contains filtered or unexported fields
}
SwappableWriter manages atomic switching between relay WS and DataChannel writes. It wraps a relay write function and can be migrated to/from a DataChannel.
func NewSwappableWriter ¶
func NewSwappableWriter(relayWrite WriteFn) *SwappableWriter
NewSwappableWriter creates a SwappableWriter backed by the relay write function.
func (*SwappableWriter) FallbackToRelay ¶
func (sw *SwappableWriter) FallbackToRelay(sessionID string) error
FallbackToRelay atomically switches output back to the relay WS. Sends a pty.fallback message via relay so the browser knows.
func (*SwappableWriter) MigrateToDC ¶
func (sw *SwappableWriter) MigrateToDC(sessionID string, dc *webrtc.DataChannel) error
MigrateToDC atomically switches output to a DataChannel. It sends a pty.migrated message via the relay (last WS message for this session) and swaps the write function.
func (*SwappableWriter) Mode ¶
func (sw *SwappableWriter) Mode() string
Mode returns the current transport mode ("relay" or "p2p").
func (*SwappableWriter) Write ¶
func (sw *SwappableWriter) Write(v any) error
Write sends a message via the current active transport. Lock is held through the write call to prevent migration mid-write.