rtcconfig

package
v0.0.0-...-77f742a Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: Apache-2.0 Imports: 21 Imported by: 17

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultStunServers = []string{
	"global.stun.twilio.com:3478",
	"stun.l.google.com:19302",
	"stun1.l.google.com:19302",
}

Functions

func GetExternalIP

func GetExternalIP(ctx context.Context, stunServers []string, localAddr net.Addr) (string, error)

GetExternalIP return external IP for localAddr from stun server. If localAddr is nil, a local address is chosen automatically, else the address will be used to validate the external IP is accessible from the outside.

func GetLocalIPAddresses

func GetLocalIPAddresses(includeLoopback bool, includeV6 bool, ifFilter func(string) bool, ipFilter func(net.IP) bool) ([]string, error)

func IPFilterFromConf

func IPFilterFromConf(ips IPsConfig) (func(ip net.IP) bool, error)

func InterfaceFilterFromConf

func InterfaceFilterFromConf(ifs InterfacesConfig) func(string) bool

func SetNAT1To1AddressRewriteRules

func SetNAT1To1AddressRewriteRules(s *webrtc.SettingEngine, ips []string, candidateType webrtc.ICECandidateType) error

Types

type BatchIOConfig

type BatchIOConfig struct {
	BatchSize        int           `yaml:"batch_size,omitempty"`
	MaxFlushInterval time.Duration `yaml:"max_flush_interval,omitempty"`
}

type IPsConfig

type IPsConfig struct {
	Includes []string `yaml:"includes,omitempty"`
	Excludes []string `yaml:"excludes,omitempty"`
}

type InterfacesConfig

type InterfacesConfig struct {
	Includes []string `yaml:"includes,omitempty"`
	Excludes []string `yaml:"excludes,omitempty"`
}

type NodeIP

type NodeIP struct {
	V4 string `yaml:"ipv4,omitempty"`
	V6 string `yaml:"ipv6,omitempty"`
}

func (*NodeIP) IsEmpty

func (n *NodeIP) IsEmpty() bool

func (NodeIP) MarshalYAML

func (n NodeIP) MarshalYAML() (interface{}, error)

func (*NodeIP) PrimaryIP

func (n *NodeIP) PrimaryIP() string

func (*NodeIP) ToStringSlice

func (n *NodeIP) ToStringSlice() []string

func (*NodeIP) UnmarshalString

func (n *NodeIP) UnmarshalString(str string) error

func (*NodeIP) UnmarshalYAML

func (n *NodeIP) UnmarshalYAML(value *yaml.Node) error

type PortRange

type PortRange struct {
	Start int `yaml:"start,omitempty"`
	End   int `yaml:"end,omitempty"`
}

func (PortRange) MarshalYAML

func (r PortRange) MarshalYAML() (any, error)

func (*PortRange) ToSlice

func (r *PortRange) ToSlice() []int

func (*PortRange) UnmarshalString

func (r *PortRange) UnmarshalString(str string) error

func (*PortRange) UnmarshalYAML

func (r *PortRange) UnmarshalYAML(value *yaml.Node) error

func (*PortRange) Valid

func (r *PortRange) Valid() bool

type RTCConfig

type RTCConfig struct {
	UDPPort                 PortRange        `yaml:"udp_port,omitempty"`
	TCPPort                 uint32           `yaml:"tcp_port,omitempty"`
	ICEPortRangeStart       uint32           `yaml:"port_range_start,omitempty"`
	ICEPortRangeEnd         uint32           `yaml:"port_range_end,omitempty"`
	UseStunPortAsICE        bool             `yaml:"use_stun_port_as_ice,omitempty"`
	NodeIP                  NodeIP           `yaml:"node_ip,omitempty"`
	NodeIPAutoGenerated     bool             `yaml:"-"`
	STUNServers             []string         `yaml:"stun_servers,omitempty"`
	UseExternalIP           bool             `yaml:"use_external_ip"`
	UseICELite              bool             `yaml:"use_ice_lite,omitempty"`
	Interfaces              InterfacesConfig `yaml:"interfaces,omitempty"`
	IPs                     IPsConfig        `yaml:"ips,omitempty"`
	EnableLoopbackCandidate bool             `yaml:"enable_loopback_candidate"`
	UseMDNS                 bool             `yaml:"use_mdns,omitempty"`
	// when UseExternalIP is true, only advertise the external IP to client
	ExternalIPOnly bool          `yaml:"external_ip_only,omitempty"`
	BatchIO        BatchIOConfig `yaml:"batch_io,omitempty"`

	// SCTP congestion control
	SCTPMinCwnd    int `yaml:"sctp_min_cwnd,omitempty"`
	SCTPFastRtxWnd int `yaml:"sctp_fast_rtx_wnd,omitempty"`
	SCTPCwndCAStep int `yaml:"sctp_cwnd_ca_step,omitempty"`

	// for testing, disable UDP
	ForceTCP bool `yaml:"force_tcp,omitempty"`
}

func (*RTCConfig) Validate

func (conf *RTCConfig) Validate(development bool) error

type WebRTCConfig

type WebRTCConfig struct {
	Configuration  webrtc.Configuration
	SettingEngine  webrtc.SettingEngine
	UDPMux         ice.UDPMux
	TCPMuxListener *net.TCPListener
	NAT1To1IPs     []string
	UseMDNS        bool
}

func NewWebRTCConfig

func NewWebRTCConfig(rtcConf *RTCConfig, development bool) (*WebRTCConfig, error)

Jump to

Keyboard shortcuts

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