rtcconfig

package
v0.0.0-...-f234b53 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: Apache-2.0 Imports: 20 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 GetExternalIPv4

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

GetExternalIPv4 is like GetExternalIP but forces the STUN request over IPv4, so it returns an IPv4 reflexive address (or an error if no IPv4 route exists).

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, includeInternal bool) 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"`
	RequireIPv4              bool             `yaml:"require_ipv4,omitempty"` // require a routable IPv4: dial STUN over udp4 and skip local IPv6 fallback
	SkipExternalIPValidation bool             `yaml:"skip_external_ip_validation,omitempty"`
	AdvertiseInternalIP      bool             `yaml:"advertise_internal_ip,omitempty"`
	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"`

	// ICE candidate-pair acceptance min-waits; 0 keeps pion's default
	HostAcceptanceMinWait  time.Duration `yaml:"host_acceptance_min_wait,omitempty"`
	SrflxAcceptanceMinWait time.Duration `yaml:"srflx_acceptance_min_wait,omitempty"`
	PrflxAcceptanceMinWait time.Duration `yaml:"prflx_acceptance_min_wait,omitempty"`
	RelayAcceptanceMinWait time.Duration `yaml:"relay_acceptance_min_wait,omitempty"`

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

func (*RTCConfig) ReloadExternalIP

func (conf *RTCConfig) ReloadExternalIP() error

ReloadExternalIP discards the currently resolved NodeIP and re-runs discovery. It lets callers retry a boot-time resolution miss (e.g. the node's IPv4 not being attached yet) without mutating config fields and re-invoking Validate. Set RequireIPv4 first if the caller needs an IPv4.

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