webrtc

package
v0.31.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 44 Imported by: 0

Documentation

Index

Constants

View Source
const ConfigID = ControllerID

ConfigID is the string used to identify this config object.

View Source
const ControllerID = "bifrost/webrtc"

ControllerID is the WebRTC controller ID.

View Source
const TransportType = "webrtc"

TransportType is the transport type identifier for this transport.

View Source
const WebRTCSignalHandlerControllerID = ControllerID + "/signal-handler"

WebRTCSignalHandlerControllerID is the controller ID for WebRTCSignalHandler

Variables

View Source
var (
	IceTransportPolicy_name = map[int32]string{
		0: "IceTransportPolicy_ALL",
		1: "IceTransportPolicy_RELAY",
	}
	IceTransportPolicy_value = map[string]int32{
		"IceTransportPolicy_ALL":   0,
		"IceTransportPolicy_RELAY": 1,
	}
)

Enum value maps for IceTransportPolicy.

View Source
var SignalingCryptContext = "github.com/aperturerobotics/bifrost 2024-01-15 17:58:55 webrtc signaling"

SignalingCryptContext is the encryption context to use for the signaling messages.

View Source
var SignalingProtocolID protocol.ID = signaling.ProtocolID

SignalingProtocolID is the default protocol id to use for the signaling client.

View Source
var Version = semver.MustParse("0.0.1")

Version is the version of the implementation.

Functions

func EncodeWebRtcSignal

func EncodeWebRtcSignal(s *WebRtcSignal, dstPeer crypto.PubKey) ([]byte, error)

EncodeWebRtcSignal marshals and encrypts the WebRtcSignal message.

func NewLinkUUID

func NewLinkUUID(transportType, localPeerID, remotePeerID peer.ID) uint64

NewLinkUUID builds the UUID for a link

func NewTransportUUID

func NewTransportUUID(transportType string, peerID peer.ID) uint64

NewTransportUUID builds the UUID for a transport with a local address and peer id

Types

type Config

type Config struct {

	// SignalingId is the signaling channel identifier.
	// Cannot be empty.
	SignalingId string `protobuf:"bytes,1,opt,name=signaling_id,json=signalingId,proto3" json:"signalingId,omitempty"`
	// TransportPeerId sets the peer ID to attach the transport to.
	// If unset, attaches to any running peer with a private key.
	// Must match the transport peer ID of the signaling transport.
	TransportPeerId string `protobuf:"bytes,2,opt,name=transport_peer_id,json=transportPeerId,proto3" json:"transportPeerId,omitempty"`
	// TransportType overrides the transport type id for dial addresses.
	// Defaults to "webrtc"
	// Configures the scheme for addr matching to this transport.
	// E.x.: webrtc://
	TransportType string `protobuf:"bytes,3,opt,name=transport_type,json=transportType,proto3" json:"transportType,omitempty"`
	// Quic contains the quic protocol options.
	//
	// The WebRTC transport always disables FEC and several other UDP-centric
	// features which are unnecessary due to the "reliable" nature of WebRTC.
	Quic *quic.Opts `protobuf:"bytes,4,opt,name=quic,proto3" json:"quic,omitempty"`
	// WebRtc contains the WebRTC protocol options.
	WebRtc *WebRtcConfig `protobuf:"bytes,5,opt,name=web_rtc,json=webRtc,proto3" json:"webRtc,omitempty"`
	// Backoff is the backoff config for connecting to a PeerConnection.
	// If unset, defaults to reasonable defaults.
	Backoff *backoff.Backoff `protobuf:"bytes,6,opt,name=backoff,proto3" json:"backoff,omitempty"`
	// Dialers maps peer IDs to dialers.
	// This allows mapping which peer ID should be dialed via this transport.
	Dialers map[string]*dialer.DialerOpts `` /* 155-byte string literal not displayed */
	// AllPeers tells the transport to attempt to negotiate a WebRTC session with
	// any peer, even those not listed in the Dialers map.
	AllPeers bool `protobuf:"varint,8,opt,name=all_peers,json=allPeers,proto3" json:"allPeers,omitempty"`
	// DisableListen disables listening for incoming Links.
	// If set, we will only dial out, not accept incoming links.
	DisableListen bool `protobuf:"varint,9,opt,name=disable_listen,json=disableListen,proto3" json:"disableListen,omitempty"`
	// BlockPeers is a list of peer ids that will not be contacted via this transport.
	BlockPeers []string `protobuf:"bytes,10,rep,name=block_peers,json=blockPeers,proto3" json:"blockPeers,omitempty"`
	// Verbose enables very verbose logging.
	Verbose bool `protobuf:"varint,11,opt,name=verbose,proto3" json:"verbose,omitempty"`
	// contains filtered or unexported fields
}

Config is the configuration for the WebRTC Signal RPC transport.

func (*Config) CloneMessageVT

func (m *Config) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*Config) CloneVT

func (m *Config) CloneVT() *Config

func (*Config) EqualMessageVT

func (this *Config) EqualMessageVT(thatMsg any) bool

func (*Config) EqualVT

func (this *Config) EqualVT(that *Config) bool

func (*Config) EqualsConfig

func (c *Config) EqualsConfig(other config.Config) bool

EqualsConfig checks if the other config is equal.

func (*Config) GetAllPeers

func (x *Config) GetAllPeers() bool

func (*Config) GetBackoff

func (x *Config) GetBackoff() *backoff.Backoff

func (*Config) GetBlockPeers

func (x *Config) GetBlockPeers() []string

func (*Config) GetConfigID

func (c *Config) GetConfigID() string

GetConfigID returns the unique string for this configuration type. This string is stored with the encoded config.

func (*Config) GetDebugVals

func (c *Config) GetDebugVals() config.DebugValues

GetDebugVals returns the directive arguments as key/value pairs. This should be something like param1="test", param2="test". This is not necessarily unique, and is primarily intended for display.

func (*Config) GetDialers

func (x *Config) GetDialers() map[string]*dialer.DialerOpts

func (*Config) GetDisableListen

func (x *Config) GetDisableListen() bool

func (*Config) GetQuic

func (x *Config) GetQuic() *quic.Opts

func (*Config) GetSignalingId

func (x *Config) GetSignalingId() string

func (*Config) GetTransportPeerId

func (x *Config) GetTransportPeerId() string

func (*Config) GetTransportType

func (x *Config) GetTransportType() string

func (*Config) GetVerbose

func (x *Config) GetVerbose() bool

func (*Config) GetWebRtc

func (x *Config) GetWebRtc() *WebRtcConfig

func (*Config) MarshalJSON added in v0.29.0

func (x *Config) MarshalJSON() ([]byte, error)

MarshalJSON marshals the Config to JSON.

func (*Config) MarshalProtoJSON added in v0.29.0

func (x *Config) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the Config message to JSON.

func (*Config) MarshalProtoText added in v0.29.2

func (x *Config) MarshalProtoText() string

func (*Config) MarshalToSizedBufferVT

func (m *Config) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*Config) MarshalToVT

func (m *Config) MarshalToVT(dAtA []byte) (int, error)

func (*Config) MarshalVT

func (m *Config) MarshalVT() (dAtA []byte, err error)

func (*Config) ParseBlockPeerIDs

func (c *Config) ParseBlockPeerIDs() ([]peer.ID, error)

ParseBlockPeerIDs parses the remote peer IDs to not allow.

func (*Config) ParseTransportPeerID

func (c *Config) ParseTransportPeerID() (peer.ID, error)

ParseTransportPeerID parses the node peer ID if it is not empty.

func (*Config) ProtoMessage

func (*Config) ProtoMessage()

func (*Config) Reset

func (x *Config) Reset()

func (*Config) SetTransportPeerId

func (c *Config) SetTransportPeerId(peerID string)

SetTransportPeerId sets the node peer ID field.

func (*Config) SizeVT

func (m *Config) SizeVT() (n int)

func (*Config) String

func (x *Config) String() string

func (*Config) UnmarshalJSON added in v0.29.0

func (x *Config) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the Config from JSON.

func (*Config) UnmarshalProtoJSON added in v0.29.0

func (x *Config) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the Config message from JSON.

func (*Config) UnmarshalVT

func (m *Config) UnmarshalVT(dAtA []byte) error

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the configuration. This is a cursory validation to see if the values "look correct."

type Config_DialersEntry added in v0.29.0

type Config_DialersEntry struct {
	Key   string             `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
	Value *dialer.DialerOpts `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
	// contains filtered or unexported fields
}

func (*Config_DialersEntry) GetKey added in v0.29.0

func (x *Config_DialersEntry) GetKey() string

func (*Config_DialersEntry) GetValue added in v0.29.0

func (x *Config_DialersEntry) GetValue() *dialer.DialerOpts

func (*Config_DialersEntry) MarshalJSON added in v0.29.0

func (x *Config_DialersEntry) MarshalJSON() ([]byte, error)

MarshalJSON marshals the Config_DialersEntry to JSON.

func (*Config_DialersEntry) MarshalProtoJSON added in v0.29.0

func (x *Config_DialersEntry) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the Config_DialersEntry message to JSON.

func (*Config_DialersEntry) MarshalProtoText added in v0.29.2

func (x *Config_DialersEntry) MarshalProtoText() string

func (*Config_DialersEntry) ProtoMessage added in v0.29.0

func (*Config_DialersEntry) ProtoMessage()

func (*Config_DialersEntry) Reset added in v0.29.0

func (x *Config_DialersEntry) Reset()

func (*Config_DialersEntry) String added in v0.29.2

func (x *Config_DialersEntry) String() string

func (*Config_DialersEntry) UnmarshalJSON added in v0.29.0

func (x *Config_DialersEntry) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the Config_DialersEntry from JSON.

func (*Config_DialersEntry) UnmarshalProtoJSON added in v0.29.0

func (x *Config_DialersEntry) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the Config_DialersEntry message from JSON.

type Factory

type Factory struct {
	// contains filtered or unexported fields
}

Factory constructs the transport.

func NewFactory

func NewFactory(bus bus.Bus) *Factory

NewFactory builds a transport factory.

func (*Factory) Construct

func (t *Factory) Construct(
	ctx context.Context,
	conf config.Config,
	opts controller.ConstructOpts,
) (controller.Controller, error)

Construct constructs the associated controller given configuration. The transport's identity (private key) comes from a GetNode lookup.

func (*Factory) ConstructConfig

func (t *Factory) ConstructConfig() config.Config

ConstructConfig constructs an instance of the controller configuration.

func (*Factory) GetConfigID

func (t *Factory) GetConfigID() string

GetConfigID returns the configuration ID for the controller.

func (*Factory) GetControllerID

func (t *Factory) GetControllerID() string

GetControllerID returns the unique ID for the controller.

func (*Factory) GetVersion

func (t *Factory) GetVersion() semver.Version

GetVersion returns the version of this controller.

type IceServerConfig

type IceServerConfig struct {

	// Urls is the list of URLs for the ICE server.
	//
	// Format: stun:{url} or turn:{url} or turns:{url}?transport=tcp
	// Examples:
	// - stun:stun.l.google.com:19302
	// - stun:stun.stunprotocol.org:3478
	// - turns:google.de?transport=tcp
	Urls []string `protobuf:"bytes,1,rep,name=urls,proto3" json:"urls,omitempty"`
	// Username is the username for the ICE server.
	Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"`
	// Credential contains the ice server credential, if any.
	//
	// Types that are assignable to Credential:
	//
	//	*IceServerConfig_Password
	//	*IceServerConfig_Oauth
	Credential isIceServerConfig_Credential `protobuf_oneof:"credential"`
	// contains filtered or unexported fields
}

IceServer is a WebRTC ICE server config.

func (*IceServerConfig) CloneMessageVT

func (m *IceServerConfig) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*IceServerConfig) CloneVT

func (m *IceServerConfig) CloneVT() *IceServerConfig

func (*IceServerConfig) EqualMessageVT

func (this *IceServerConfig) EqualMessageVT(thatMsg any) bool

func (*IceServerConfig) EqualVT

func (this *IceServerConfig) EqualVT(that *IceServerConfig) bool

func (*IceServerConfig) GetCredential

func (m *IceServerConfig) GetCredential() isIceServerConfig_Credential

func (*IceServerConfig) GetOauth

func (*IceServerConfig) GetPassword

func (x *IceServerConfig) GetPassword() string

func (*IceServerConfig) GetUrls

func (x *IceServerConfig) GetUrls() []string

func (*IceServerConfig) GetUsername

func (x *IceServerConfig) GetUsername() string

func (*IceServerConfig) MarshalJSON added in v0.29.0

func (x *IceServerConfig) MarshalJSON() ([]byte, error)

MarshalJSON marshals the IceServerConfig to JSON.

func (*IceServerConfig) MarshalProtoJSON added in v0.29.0

func (x *IceServerConfig) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the IceServerConfig message to JSON.

func (*IceServerConfig) MarshalProtoText added in v0.29.2

func (x *IceServerConfig) MarshalProtoText() string

func (*IceServerConfig) MarshalToSizedBufferVT

func (m *IceServerConfig) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*IceServerConfig) MarshalToVT

func (m *IceServerConfig) MarshalToVT(dAtA []byte) (int, error)

func (*IceServerConfig) MarshalVT

func (m *IceServerConfig) MarshalVT() (dAtA []byte, err error)

func (*IceServerConfig) ProtoMessage

func (*IceServerConfig) ProtoMessage()

func (*IceServerConfig) Reset

func (x *IceServerConfig) Reset()

func (*IceServerConfig) SizeVT

func (m *IceServerConfig) SizeVT() (n int)

func (*IceServerConfig) String

func (x *IceServerConfig) String() string

func (*IceServerConfig) ToICEServer

func (c *IceServerConfig) ToICEServer() webrtc.ICEServer

ToICEServer converts the IceServerConfig to a webrtc.ICEServer.

func (*IceServerConfig) UnmarshalJSON added in v0.29.0

func (x *IceServerConfig) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the IceServerConfig from JSON.

func (*IceServerConfig) UnmarshalProtoJSON added in v0.29.0

func (x *IceServerConfig) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the IceServerConfig message from JSON.

func (*IceServerConfig) UnmarshalVT

func (m *IceServerConfig) UnmarshalVT(dAtA []byte) error

type IceServerConfig_Oauth

type IceServerConfig_Oauth struct {
	// Oauth contains an OAuth credential.
	Oauth *IceServerConfig_OauthCredential `protobuf:"bytes,4,opt,name=oauth,proto3,oneof"`
}

func (*IceServerConfig_Oauth) CloneVT

func (*IceServerConfig_Oauth) EqualVT

func (this *IceServerConfig_Oauth) EqualVT(thatIface isIceServerConfig_Credential) bool

func (*IceServerConfig_Oauth) MarshalToSizedBufferVT

func (m *IceServerConfig_Oauth) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*IceServerConfig_Oauth) MarshalToVT

func (m *IceServerConfig_Oauth) MarshalToVT(dAtA []byte) (int, error)

func (*IceServerConfig_Oauth) SizeVT

func (m *IceServerConfig_Oauth) SizeVT() (n int)

type IceServerConfig_OauthCredential

type IceServerConfig_OauthCredential struct {

	// MacKey is a base64-url format.
	MacKey string `protobuf:"bytes,1,opt,name=mac_key,json=macKey,proto3" json:"macKey,omitempty"`
	// AccessToken is the access token in base64-encoded format.
	AccessToken string `protobuf:"bytes,2,opt,name=access_token,json=accessToken,proto3" json:"accessToken,omitempty"`
	// contains filtered or unexported fields
}

OauthCredential is an OAuth credential information for the ICE server.

func (*IceServerConfig_OauthCredential) CloneMessageVT

func (*IceServerConfig_OauthCredential) CloneVT

func (*IceServerConfig_OauthCredential) EqualMessageVT

func (this *IceServerConfig_OauthCredential) EqualMessageVT(thatMsg any) bool

func (*IceServerConfig_OauthCredential) EqualVT

func (*IceServerConfig_OauthCredential) GetAccessToken

func (x *IceServerConfig_OauthCredential) GetAccessToken() string

func (*IceServerConfig_OauthCredential) GetMacKey

func (x *IceServerConfig_OauthCredential) GetMacKey() string

func (*IceServerConfig_OauthCredential) MarshalJSON added in v0.29.0

func (x *IceServerConfig_OauthCredential) MarshalJSON() ([]byte, error)

MarshalJSON marshals the IceServerConfig_OauthCredential to JSON.

func (*IceServerConfig_OauthCredential) MarshalProtoJSON added in v0.29.0

func (x *IceServerConfig_OauthCredential) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the IceServerConfig_OauthCredential message to JSON.

func (*IceServerConfig_OauthCredential) MarshalProtoText added in v0.29.2

func (x *IceServerConfig_OauthCredential) MarshalProtoText() string

func (*IceServerConfig_OauthCredential) MarshalToSizedBufferVT

func (m *IceServerConfig_OauthCredential) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*IceServerConfig_OauthCredential) MarshalToVT

func (m *IceServerConfig_OauthCredential) MarshalToVT(dAtA []byte) (int, error)

func (*IceServerConfig_OauthCredential) MarshalVT

func (m *IceServerConfig_OauthCredential) MarshalVT() (dAtA []byte, err error)

func (*IceServerConfig_OauthCredential) ProtoMessage

func (*IceServerConfig_OauthCredential) ProtoMessage()

func (*IceServerConfig_OauthCredential) Reset

func (*IceServerConfig_OauthCredential) SizeVT

func (m *IceServerConfig_OauthCredential) SizeVT() (n int)

func (*IceServerConfig_OauthCredential) String

func (*IceServerConfig_OauthCredential) ToOauthCredential

func (o *IceServerConfig_OauthCredential) ToOauthCredential() webrtc.OAuthCredential

ToOauthCredential converts to a webrtc credential.

func (*IceServerConfig_OauthCredential) UnmarshalJSON added in v0.29.0

func (x *IceServerConfig_OauthCredential) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the IceServerConfig_OauthCredential from JSON.

func (*IceServerConfig_OauthCredential) UnmarshalProtoJSON added in v0.29.0

func (x *IceServerConfig_OauthCredential) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the IceServerConfig_OauthCredential message from JSON.

func (*IceServerConfig_OauthCredential) UnmarshalVT

func (m *IceServerConfig_OauthCredential) UnmarshalVT(dAtA []byte) error

type IceServerConfig_Password

type IceServerConfig_Password struct {
	// Password contains the ICE server password.
	Password string `protobuf:"bytes,3,opt,name=password,proto3,oneof"`
}

func (*IceServerConfig_Password) CloneVT

func (*IceServerConfig_Password) EqualVT

func (this *IceServerConfig_Password) EqualVT(thatIface isIceServerConfig_Credential) bool

func (*IceServerConfig_Password) MarshalToSizedBufferVT

func (m *IceServerConfig_Password) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*IceServerConfig_Password) MarshalToVT

func (m *IceServerConfig_Password) MarshalToVT(dAtA []byte) (int, error)

func (*IceServerConfig_Password) SizeVT

func (m *IceServerConfig_Password) SizeVT() (n int)

type IceTransportPolicy

type IceTransportPolicy int32

IceTransportPolicy contains the set of allowed ICE transport policies.

const (
	// IceTransportPolicy_ALL allows any kind of ICE candidate.
	IceTransportPolicy_IceTransportPolicy_ALL IceTransportPolicy = 0
	// IceTransportPolicy_RELAY allows only media relay candidates (TURN).
	IceTransportPolicy_IceTransportPolicy_RELAY IceTransportPolicy = 1
)

func (IceTransportPolicy) Enum

func (IceTransportPolicy) MarshalJSON added in v0.29.0

func (x IceTransportPolicy) MarshalJSON() ([]byte, error)

MarshalJSON marshals the IceTransportPolicy to JSON.

func (IceTransportPolicy) MarshalProtoJSON added in v0.29.0

func (x IceTransportPolicy) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the IceTransportPolicy to JSON.

func (IceTransportPolicy) MarshalProtoText added in v0.29.2

func (x IceTransportPolicy) MarshalProtoText() string

func (IceTransportPolicy) MarshalText added in v0.29.0

func (x IceTransportPolicy) MarshalText() ([]byte, error)

MarshalText marshals the IceTransportPolicy to text.

func (IceTransportPolicy) String

func (x IceTransportPolicy) String() string

func (IceTransportPolicy) ToICETransportPolicy

func (c IceTransportPolicy) ToICETransportPolicy() webrtc.ICETransportPolicy

ToICETransportPolicy converts the IceTransportPolicy to a webrtc.ICETransportPolicy.

func (*IceTransportPolicy) UnmarshalJSON added in v0.29.0

func (x *IceTransportPolicy) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the IceTransportPolicy from JSON.

func (*IceTransportPolicy) UnmarshalProtoJSON added in v0.29.0

func (x *IceTransportPolicy) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the IceTransportPolicy from JSON.

func (*IceTransportPolicy) UnmarshalText added in v0.29.0

func (x *IceTransportPolicy) UnmarshalText(b []byte) error

UnmarshalText unmarshals the IceTransportPolicy from text.

type Link = conn.Link

Link represents a WebSocket-based connection/link.

type WebRTC

type WebRTC struct {
	// contains filtered or unexported fields
}

WebRTC implements a WebRTC transport.

func NewWebRTC

func NewWebRTC(
	ctx context.Context,
	le *logrus.Entry,
	b bus.Bus,
	conf *Config,
	pKey crypto.PrivKey,
	c transport.TransportHandler,
) (*WebRTC, error)

NewWebRTC builds a new WebRTC transport.

ServeHTTP is implemented and can be used with a standard HTTP mux. Optionally listens on an address.

func (*WebRTC) Close

func (w *WebRTC) Close() error

Close closes the transport, returning any errors closing.

func (*WebRTC) DialPeer

func (w *WebRTC) DialPeer(
	ctx context.Context,
	peerID peer.ID,
	addr string,
) (fatal bool, err error)

DialPeer dials a peer given an address. The yielded link should be emitted to the transport handler. DialPeer should return nil if the link was established. DialPeer will then not be called again for the same peer ID and address tuple until the yielded link is lost. Returns fatal and error.

func (*WebRTC) Execute

func (w *WebRTC) Execute(ctx context.Context) error

Execute executes the transport as configured, returning any fatal error.

func (*WebRTC) GetPeerDialer

func (w *WebRTC) GetPeerDialer(ctx context.Context, peerID peer.ID) (*dialer.DialerOpts, error)

GetPeerDialer returns the dialing information for a peer. Called when resolving EstablishLink. Return nil, nil to indicate not found or unavailable.

func (*WebRTC) GetPeerID

func (w *WebRTC) GetPeerID() peer.ID

GetPeerID returns the peer ID.

func (*WebRTC) GetUUID

func (w *WebRTC) GetUUID() uint64

GetUUID returns a host-unique ID for this transport.

func (*WebRTC) GetVerbose

func (w *WebRTC) GetVerbose() bool

GetVerbose gets if verbose logging is enabled.

func (*WebRTC) MatchTransportType

func (w *WebRTC) MatchTransportType(transportType string) bool

MatchTransportType checks if the given transport type ID matches this transport. If returns true, the transport controller will call DialPeer with that tptaddr. E.x.: "udp-quic" or "ws"

type WebRTCSignalHandler

type WebRTCSignalHandler struct {
	// contains filtered or unexported fields
}

WebRTCSignalHandler handles incoming signaling messages from other peers.

This controller is usually started & managed by the WebRTC transport.

func NewWebRTCSignalHandler

func NewWebRTCSignalHandler(t *WebRTC) *WebRTCSignalHandler

NewWebRTCSignalHandler constructs the WebRTCSignalHandler controller.

Listens for HandleSignalPeer directives and calls the transport.

func (*WebRTCSignalHandler) Close

func (c *WebRTCSignalHandler) Close() error

Close releases any resources used by the controller. Error indicates any issue encountered releasing.

func (*WebRTCSignalHandler) Execute

func (c *WebRTCSignalHandler) Execute(ctx context.Context) error

Execute executes the controller goroutine. Returning nil ends execution. Returning an error triggers a retry with backoff.

func (*WebRTCSignalHandler) GetControllerInfo

func (c *WebRTCSignalHandler) GetControllerInfo() *controller.Info

GetControllerInfo returns information about the controller.

func (*WebRTCSignalHandler) HandleDirective

func (c *WebRTCSignalHandler) HandleDirective(ctx context.Context, di directive.Instance) ([]directive.Resolver, error)

HandleDirective asks if the handler can resolve the directive. If it can, it returns resolver(s). If not, returns nil. It is safe to add a reference to the directive during this call. The passed context is canceled when the directive instance expires. NOTE: the passed context is not canceled when the handler is removed.

type WebRtcConfig

type WebRtcConfig struct {

	// IceServers contains the list of ICE servers to use.
	IceServers []*IceServerConfig `protobuf:"bytes,1,rep,name=ice_servers,json=iceServers,proto3" json:"iceServers,omitempty"`
	// IceTransportPolicy defines the policy for permitted ICE candidates.
	// Optional.
	IceTransportPolicy IceTransportPolicy `protobuf:"varint,2,opt,name=ice_transport_policy,json=iceTransportPolicy,proto3" json:"iceTransportPolicy,omitempty"`
	// IceCandidatePoolSize defines the size of the prefetched ICE pool.
	// Optional.
	IceCandidatePoolSize uint32 `protobuf:"varint,3,opt,name=ice_candidate_pool_size,json=iceCandidatePoolSize,proto3" json:"iceCandidatePoolSize,omitempty"`
	// contains filtered or unexported fields
}

WebRtcConfig configures the WebRTC PeerConnection.

func (*WebRtcConfig) CloneMessageVT

func (m *WebRtcConfig) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*WebRtcConfig) CloneVT

func (m *WebRtcConfig) CloneVT() *WebRtcConfig

func (*WebRtcConfig) EqualMessageVT

func (this *WebRtcConfig) EqualMessageVT(thatMsg any) bool

func (*WebRtcConfig) EqualVT

func (this *WebRtcConfig) EqualVT(that *WebRtcConfig) bool

func (*WebRtcConfig) GetIceCandidatePoolSize

func (x *WebRtcConfig) GetIceCandidatePoolSize() uint32

func (*WebRtcConfig) GetIceServers

func (x *WebRtcConfig) GetIceServers() []*IceServerConfig

func (*WebRtcConfig) GetIceTransportPolicy

func (x *WebRtcConfig) GetIceTransportPolicy() IceTransportPolicy

func (*WebRtcConfig) MarshalJSON added in v0.29.0

func (x *WebRtcConfig) MarshalJSON() ([]byte, error)

MarshalJSON marshals the WebRtcConfig to JSON.

func (*WebRtcConfig) MarshalProtoJSON added in v0.29.0

func (x *WebRtcConfig) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the WebRtcConfig message to JSON.

func (*WebRtcConfig) MarshalProtoText added in v0.29.2

func (x *WebRtcConfig) MarshalProtoText() string

func (*WebRtcConfig) MarshalToSizedBufferVT

func (m *WebRtcConfig) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*WebRtcConfig) MarshalToVT

func (m *WebRtcConfig) MarshalToVT(dAtA []byte) (int, error)

func (*WebRtcConfig) MarshalVT

func (m *WebRtcConfig) MarshalVT() (dAtA []byte, err error)

func (*WebRtcConfig) ProtoMessage

func (*WebRtcConfig) ProtoMessage()

func (*WebRtcConfig) Reset

func (x *WebRtcConfig) Reset()

func (*WebRtcConfig) SizeVT

func (m *WebRtcConfig) SizeVT() (n int)

func (*WebRtcConfig) String

func (x *WebRtcConfig) String() string

func (*WebRtcConfig) ToWebRtcConfiguration

func (c *WebRtcConfig) ToWebRtcConfiguration() *webrtc.Configuration

ToWebRtcConfiguration converts the WebRtcConfig into a webrtc.Configuration.

func (*WebRtcConfig) UnmarshalJSON added in v0.29.0

func (x *WebRtcConfig) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the WebRtcConfig from JSON.

func (*WebRtcConfig) UnmarshalProtoJSON added in v0.29.0

func (x *WebRtcConfig) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the WebRtcConfig message from JSON.

func (*WebRtcConfig) UnmarshalVT

func (m *WebRtcConfig) UnmarshalVT(dAtA []byte) error

type WebRtcIce

type WebRtcIce struct {

	// Candidate contains the JSON-encoded ICE candidate.
	Candidate string `protobuf:"bytes,1,opt,name=candidate,proto3" json:"candidate,omitempty"`
	// contains filtered or unexported fields
}

WebRtcIce contains an ICE candidate.

func NewWebRtcIce

func NewWebRtcIce(candidate *webrtc.ICECandidateInit) (*WebRtcIce, error)

NewWebRtcIce constructs a new WebRtcIce from a ICECandidateInit.

func (*WebRtcIce) CloneMessageVT

func (m *WebRtcIce) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*WebRtcIce) CloneVT

func (m *WebRtcIce) CloneVT() *WebRtcIce

func (*WebRtcIce) EqualMessageVT

func (this *WebRtcIce) EqualMessageVT(thatMsg any) bool

func (*WebRtcIce) EqualVT

func (this *WebRtcIce) EqualVT(that *WebRtcIce) bool

func (*WebRtcIce) GetCandidate

func (x *WebRtcIce) GetCandidate() string

func (*WebRtcIce) MarshalJSON added in v0.29.0

func (x *WebRtcIce) MarshalJSON() ([]byte, error)

MarshalJSON marshals the WebRtcIce to JSON.

func (*WebRtcIce) MarshalProtoJSON added in v0.29.0

func (x *WebRtcIce) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the WebRtcIce message to JSON.

func (*WebRtcIce) MarshalProtoText added in v0.29.2

func (x *WebRtcIce) MarshalProtoText() string

func (*WebRtcIce) MarshalToSizedBufferVT

func (m *WebRtcIce) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*WebRtcIce) MarshalToVT

func (m *WebRtcIce) MarshalToVT(dAtA []byte) (int, error)

func (*WebRtcIce) MarshalVT

func (m *WebRtcIce) MarshalVT() (dAtA []byte, err error)

func (*WebRtcIce) ParseICECandidateInit

func (s *WebRtcIce) ParseICECandidateInit() (*webrtc.ICECandidateInit, error)

ParseICECandidateInit parses the ICECandidate from the JSON encoded body.

func (*WebRtcIce) ProtoMessage

func (*WebRtcIce) ProtoMessage()

func (*WebRtcIce) Reset

func (x *WebRtcIce) Reset()

func (*WebRtcIce) SizeVT

func (m *WebRtcIce) SizeVT() (n int)

func (*WebRtcIce) String

func (x *WebRtcIce) String() string

func (*WebRtcIce) UnmarshalJSON added in v0.29.0

func (x *WebRtcIce) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the WebRtcIce from JSON.

func (*WebRtcIce) UnmarshalProtoJSON added in v0.29.0

func (x *WebRtcIce) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the WebRtcIce message from JSON.

func (*WebRtcIce) UnmarshalVT

func (m *WebRtcIce) UnmarshalVT(dAtA []byte) error

func (*WebRtcIce) Validate

func (s *WebRtcIce) Validate() error

Validate validates the WebRtcIce message.

type WebRtcSdp

type WebRtcSdp struct {

	// TxSeqno is the sequence number of the transmitting peer.
	// The receiver should update the local seqno to match.
	TxSeqno uint64 `protobuf:"varint,1,opt,name=tx_seqno,json=txSeqno,proto3" json:"txSeqno,omitempty"`
	// SdpType is the string encoded type of the sdp.
	// Examples: "offer" "answer"
	SdpType string `protobuf:"bytes,2,opt,name=sdp_type,json=sdpType,proto3" json:"sdpType,omitempty"`
	// Sdp contains the WebRTC session description.
	Sdp string `protobuf:"bytes,3,opt,name=sdp,proto3" json:"sdp,omitempty"`
	// contains filtered or unexported fields
}

WebRtcSdp contains the SDP offer or answer.

func NewWebRtcSdp

func NewWebRtcSdp(txSeqno uint64, desc *webrtc.SessionDescription) *WebRtcSdp

NewWebRtcSdp constructs a new WebRtcSdp from a SessionDescription.

func (*WebRtcSdp) CloneMessageVT

func (m *WebRtcSdp) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*WebRtcSdp) CloneVT

func (m *WebRtcSdp) CloneVT() *WebRtcSdp

func (*WebRtcSdp) EqualMessageVT

func (this *WebRtcSdp) EqualMessageVT(thatMsg any) bool

func (*WebRtcSdp) EqualVT

func (this *WebRtcSdp) EqualVT(that *WebRtcSdp) bool

func (*WebRtcSdp) GetSdp

func (x *WebRtcSdp) GetSdp() string

func (*WebRtcSdp) GetSdpType

func (x *WebRtcSdp) GetSdpType() string

func (*WebRtcSdp) GetTxSeqno

func (x *WebRtcSdp) GetTxSeqno() uint64

func (*WebRtcSdp) MarshalJSON added in v0.29.0

func (x *WebRtcSdp) MarshalJSON() ([]byte, error)

MarshalJSON marshals the WebRtcSdp to JSON.

func (*WebRtcSdp) MarshalProtoJSON added in v0.29.0

func (x *WebRtcSdp) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the WebRtcSdp message to JSON.

func (*WebRtcSdp) MarshalProtoText added in v0.29.2

func (x *WebRtcSdp) MarshalProtoText() string

func (*WebRtcSdp) MarshalToSizedBufferVT

func (m *WebRtcSdp) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*WebRtcSdp) MarshalToVT

func (m *WebRtcSdp) MarshalToVT(dAtA []byte) (int, error)

func (*WebRtcSdp) MarshalVT

func (m *WebRtcSdp) MarshalVT() (dAtA []byte, err error)

func (*WebRtcSdp) ParseSDP

func (s *WebRtcSdp) ParseSDP() (*sdp.SessionDescription, error)

ParseSDP parses the SDP from the type and sdp fields.

Returns nil, nil if the message is empty.

func (*WebRtcSdp) ParseSDPType

func (s *WebRtcSdp) ParseSDPType() webrtc.SDPType

ParseSDPType parses the SDP type field.

func (*WebRtcSdp) ProtoMessage

func (*WebRtcSdp) ProtoMessage()

func (*WebRtcSdp) Reset

func (x *WebRtcSdp) Reset()

func (*WebRtcSdp) SizeVT

func (m *WebRtcSdp) SizeVT() (n int)

func (*WebRtcSdp) String

func (x *WebRtcSdp) String() string

func (*WebRtcSdp) ToSessionDescription

func (s *WebRtcSdp) ToSessionDescription() *webrtc.SessionDescription

ToSessionDescription converts the sdp into a webrtc session description object.

Returns nil if the message is empty.

func (*WebRtcSdp) UnmarshalJSON added in v0.29.0

func (x *WebRtcSdp) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the WebRtcSdp from JSON.

func (*WebRtcSdp) UnmarshalProtoJSON added in v0.29.0

func (x *WebRtcSdp) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the WebRtcSdp message from JSON.

func (*WebRtcSdp) UnmarshalVT

func (m *WebRtcSdp) UnmarshalVT(dAtA []byte) error

func (*WebRtcSdp) Validate

func (s *WebRtcSdp) Validate() error

Validate validates the WebRtcSdp message.

type WebRtcSignal

type WebRtcSignal struct {

	// Body is the body of the message.
	//
	// Types that are assignable to Body:
	//
	//	*WebRtcSignal_RequestOffer
	//	*WebRtcSignal_Sdp
	//	*WebRtcSignal_Ice
	Body isWebRtcSignal_Body `protobuf_oneof:"body"`
	// contains filtered or unexported fields
}

WebRtcSignal is a WebRTC Signaling message sent via the Signaling channel.

func DecodeWebRtcSignal

func DecodeWebRtcSignal(msg []byte, privKey crypto.PrivKey) (*WebRtcSignal, error)

DecodeWebRtcSignal decrypts and unmarshals the WebRtcSignal message.

func (*WebRtcSignal) CloneMessageVT

func (m *WebRtcSignal) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*WebRtcSignal) CloneVT

func (m *WebRtcSignal) CloneVT() *WebRtcSignal

func (*WebRtcSignal) EqualMessageVT

func (this *WebRtcSignal) EqualMessageVT(thatMsg any) bool

func (*WebRtcSignal) EqualVT

func (this *WebRtcSignal) EqualVT(that *WebRtcSignal) bool

func (*WebRtcSignal) GetBody

func (m *WebRtcSignal) GetBody() isWebRtcSignal_Body

func (*WebRtcSignal) GetIce

func (x *WebRtcSignal) GetIce() *WebRtcIce

func (*WebRtcSignal) GetRequestOffer

func (x *WebRtcSignal) GetRequestOffer() uint64

func (*WebRtcSignal) GetSdp

func (x *WebRtcSignal) GetSdp() *WebRtcSdp

func (*WebRtcSignal) MarshalJSON added in v0.29.0

func (x *WebRtcSignal) MarshalJSON() ([]byte, error)

MarshalJSON marshals the WebRtcSignal to JSON.

func (*WebRtcSignal) MarshalProtoJSON added in v0.29.0

func (x *WebRtcSignal) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the WebRtcSignal message to JSON.

func (*WebRtcSignal) MarshalProtoText added in v0.29.2

func (x *WebRtcSignal) MarshalProtoText() string

func (*WebRtcSignal) MarshalToSizedBufferVT

func (m *WebRtcSignal) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*WebRtcSignal) MarshalToVT

func (m *WebRtcSignal) MarshalToVT(dAtA []byte) (int, error)

func (*WebRtcSignal) MarshalVT

func (m *WebRtcSignal) MarshalVT() (dAtA []byte, err error)

func (*WebRtcSignal) ProtoMessage

func (*WebRtcSignal) ProtoMessage()

func (*WebRtcSignal) Reset

func (x *WebRtcSignal) Reset()

func (*WebRtcSignal) SizeVT

func (m *WebRtcSignal) SizeVT() (n int)

func (*WebRtcSignal) String

func (x *WebRtcSignal) String() string

func (*WebRtcSignal) UnmarshalJSON added in v0.29.0

func (x *WebRtcSignal) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the WebRtcSignal from JSON.

func (*WebRtcSignal) UnmarshalProtoJSON added in v0.29.0

func (x *WebRtcSignal) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the WebRtcSignal message from JSON.

func (*WebRtcSignal) UnmarshalVT

func (m *WebRtcSignal) UnmarshalVT(dAtA []byte) error

func (*WebRtcSignal) Validate

func (m *WebRtcSignal) Validate() error

Validate validates the WebRtcSignal message.

type WebRtcSignal_Ice

type WebRtcSignal_Ice struct {
	// Ice contains an ICE candidate.
	Ice *WebRtcIce `protobuf:"bytes,3,opt,name=ice,proto3,oneof"`
}

func (*WebRtcSignal_Ice) CloneVT

func (m *WebRtcSignal_Ice) CloneVT() *WebRtcSignal_Ice

func (*WebRtcSignal_Ice) EqualVT

func (this *WebRtcSignal_Ice) EqualVT(thatIface isWebRtcSignal_Body) bool

func (*WebRtcSignal_Ice) MarshalToSizedBufferVT

func (m *WebRtcSignal_Ice) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*WebRtcSignal_Ice) MarshalToVT

func (m *WebRtcSignal_Ice) MarshalToVT(dAtA []byte) (int, error)

func (*WebRtcSignal_Ice) SizeVT

func (m *WebRtcSignal_Ice) SizeVT() (n int)

type WebRtcSignal_RequestOffer

type WebRtcSignal_RequestOffer struct {
	// RequestOffer requests a new offer from the offerer with the local session seqno.
	// Incremented when negotiation is needed (something changes about the session).
	RequestOffer uint64 `protobuf:"varint,1,opt,name=request_offer,json=requestOffer,proto3,oneof"`
}

func (*WebRtcSignal_RequestOffer) CloneVT

func (*WebRtcSignal_RequestOffer) EqualVT

func (this *WebRtcSignal_RequestOffer) EqualVT(thatIface isWebRtcSignal_Body) bool

func (*WebRtcSignal_RequestOffer) MarshalToSizedBufferVT

func (m *WebRtcSignal_RequestOffer) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*WebRtcSignal_RequestOffer) MarshalToVT

func (m *WebRtcSignal_RequestOffer) MarshalToVT(dAtA []byte) (int, error)

func (*WebRtcSignal_RequestOffer) SizeVT

func (m *WebRtcSignal_RequestOffer) SizeVT() (n int)

type WebRtcSignal_Sdp

type WebRtcSignal_Sdp struct {
	// Sdp contains the sdp offer or answer.
	Sdp *WebRtcSdp `protobuf:"bytes,2,opt,name=sdp,proto3,oneof"`
}

func (*WebRtcSignal_Sdp) CloneVT

func (m *WebRtcSignal_Sdp) CloneVT() *WebRtcSignal_Sdp

func (*WebRtcSignal_Sdp) EqualVT

func (this *WebRtcSignal_Sdp) EqualVT(thatIface isWebRtcSignal_Body) bool

func (*WebRtcSignal_Sdp) MarshalToSizedBufferVT

func (m *WebRtcSignal_Sdp) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*WebRtcSignal_Sdp) MarshalToVT

func (m *WebRtcSignal_Sdp) MarshalToVT(dAtA []byte) (int, error)

func (*WebRtcSignal_Sdp) SizeVT

func (m *WebRtcSignal_Sdp) SizeVT() (n int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL