Documentation
¶
Index ¶
- Variables
- func GetExternalIP(ctx context.Context, stunServers []string, localAddr net.Addr, ...) (string, error)
- func GetExternalIPv4(ctx context.Context, stunServers []string, localAddr net.Addr, ...) (string, error)
- func GetLocalIPAddresses(includeLoopback bool, includeV6 bool, ifFilter func(string) bool, ...) ([]string, error)
- func IPFilterFromConf(ips IPsConfig) (func(ip net.IP) bool, error)
- func InterfaceFilterFromConf(ifs InterfacesConfig) func(string) bool
- func SetNAT1To1AddressRewriteRules(s *webrtc.SettingEngine, ips []string, includeInternal bool) error
- type BatchIOConfig
- type ExternalIPOption
- type IPsConfig
- type InterfacesConfig
- type NodeIP
- type PortRange
- type RTCConfig
- type WebRTCConfig
Constants ¶
This section is empty.
Variables ¶
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, opts ...ExternalIPOption) (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, opts ...ExternalIPOption) (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 InterfaceFilterFromConf ¶
func InterfaceFilterFromConf(ifs InterfacesConfig) func(string) bool
func SetNAT1To1AddressRewriteRules ¶
func SetNAT1To1AddressRewriteRules(s *webrtc.SettingEngine, ips []string, includeInternal bool) error
Types ¶
type BatchIOConfig ¶
type ExternalIPOption ¶
type ExternalIPOption func(*externalIPOptions)
ExternalIPOption overrides a default used by GetExternalIP and GetExternalIPv4.
func WithStunPingTimeout ¶
func WithStunPingTimeout(d time.Duration) ExternalIPOption
WithStunPingTimeout sets how long one STUN binding request waits for a reply. A value of zero or less keeps the default.
func WithValidationTimeout ¶
func WithValidationTimeout(d time.Duration) ExternalIPOption
WithValidationTimeout sets how long external-IP validation waits for the probe packet to return. It has no effect when validation is skipped. A value of zero or less keeps the default.
type InterfacesConfig ¶
type NodeIP ¶
func (NodeIP) MarshalYAML ¶
func (*NodeIP) ToStringSlice ¶
func (*NodeIP) UnmarshalString ¶
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"`
// External-IP (STUN) discovery tuning. Zero keeps the defaults: 3 tries, a
// 500ms wait between tries, 5s per STUN lookup, 5s per validation. Widen these
// when a node may boot before it has network egress to the STUN servers.
ExternalIPRetries int `yaml:"external_ip_retries,omitempty"`
ExternalIPRetryInterval time.Duration `yaml:"external_ip_retry_interval,omitempty"`
ExternalIPStunTimeout time.Duration `yaml:"external_ip_stun_timeout,omitempty"`
ExternalIPValidationTimeout time.Duration `yaml:"external_ip_validation_timeout,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 ¶
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.
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)