mirror of
https://github.com/livekit/livekit.git
synced 2026-08-28 05:04:10 +00:00
add interface filter config (#502)
* add interface filter config * Update config-sample.yaml Co-authored-by: David Zhao <david@davidzhao.com> * better description Co-authored-by: David Zhao <david@davidzhao.com>
This commit is contained in:
co-authored by
David Zhao
parent
cd2a7c2447
commit
e4c321de02
@@ -61,6 +61,15 @@ rtc:
|
||||
# low_quality: 500ms
|
||||
# mid_quality: 1s
|
||||
# high_quality: 1s
|
||||
# # network interface filter. If the machine has more than one network interface and you'd like it to use or skip specific interfaces
|
||||
# # both inclusion and exclusion filters can be used together. If neither is defined (default), all interfaces on the machine will be used.
|
||||
# # If both of them are set, then only interfaces that satisfy both filters will be used.
|
||||
# # If an interface is present in both lists, include takes precedence.
|
||||
# interfaces:
|
||||
# includes:
|
||||
# - en0
|
||||
# excludes:
|
||||
# - docker0
|
||||
|
||||
# when enabled, LiveKit will expose prometheus metrics on :6789/metrics
|
||||
# prometheus_port: 6789
|
||||
|
||||
+15
-9
@@ -46,15 +46,16 @@ type Config struct {
|
||||
}
|
||||
|
||||
type RTCConfig struct {
|
||||
UDPPort uint32 `yaml:"udp_port,omitempty"`
|
||||
TCPPort uint32 `yaml:"tcp_port,omitempty"`
|
||||
ICEPortRangeStart uint32 `yaml:"port_range_start,omitempty"`
|
||||
ICEPortRangeEnd uint32 `yaml:"port_range_end,omitempty"`
|
||||
NodeIP string `yaml:"node_ip,omitempty"`
|
||||
STUNServers []string `yaml:"stun_servers,omitempty"`
|
||||
TURNServers []TURNServer `yaml:"turn_servers,omitempty"`
|
||||
UseExternalIP bool `yaml:"use_external_ip"`
|
||||
UseICELite bool `yaml:"use_ice_lite,omitempty"`
|
||||
UDPPort uint32 `yaml:"udp_port,omitempty"`
|
||||
TCPPort uint32 `yaml:"tcp_port,omitempty"`
|
||||
ICEPortRangeStart uint32 `yaml:"port_range_start,omitempty"`
|
||||
ICEPortRangeEnd uint32 `yaml:"port_range_end,omitempty"`
|
||||
NodeIP string `yaml:"node_ip,omitempty"`
|
||||
STUNServers []string `yaml:"stun_servers,omitempty"`
|
||||
TURNServers []TURNServer `yaml:"turn_servers,omitempty"`
|
||||
UseExternalIP bool `yaml:"use_external_ip"`
|
||||
UseICELite bool `yaml:"use_ice_lite,omitempty"`
|
||||
Interfaces InterfacesConfig `yaml:"interfaces"`
|
||||
|
||||
// Number of packets to buffer for NACK
|
||||
PacketBufferSize int `yaml:"packet_buffer_size,omitempty"`
|
||||
@@ -92,6 +93,11 @@ type CongestionControlConfig struct {
|
||||
ProbeMode CongestionControlProbeMode `yaml:"padding_mode,omitempty"`
|
||||
}
|
||||
|
||||
type InterfacesConfig struct {
|
||||
Includes []string `yaml:"includes"`
|
||||
Excludes []string `yaml:"excludes"`
|
||||
}
|
||||
|
||||
type AudioConfig struct {
|
||||
// minimum level to be considered active, 0-127, where 0 is loudest
|
||||
ActiveLevel uint8 `yaml:"active_level"`
|
||||
|
||||
+27
-1
@@ -64,7 +64,7 @@ func NewWebRTCConfig(conf *config.Config, externalIP string) (*WebRTCConfig, err
|
||||
LoggerFactory: logging.NewLoggerFactory(logger.GetLogger()),
|
||||
}
|
||||
|
||||
if externalIP != "" {
|
||||
if conf.RTC.UseExternalIP && externalIP != "" {
|
||||
s.SetNAT1To1IPs([]string{externalIP}, webrtc.ICECandidateTypeHost)
|
||||
}
|
||||
|
||||
@@ -180,6 +180,32 @@ func NewWebRTCConfig(conf *config.Config, externalIP string) (*WebRTCConfig, err
|
||||
s.SetLite(true)
|
||||
}
|
||||
|
||||
if len(rtcConf.Interfaces.Includes) != 0 || len(rtcConf.Interfaces.Excludes) != 0 {
|
||||
includes := rtcConf.Interfaces.Includes
|
||||
excludes := rtcConf.Interfaces.Excludes
|
||||
s.SetInterfaceFilter(func(s string) bool {
|
||||
//filter by include interfaces
|
||||
if len(includes) > 0 {
|
||||
for _, iface := range includes {
|
||||
if iface == s {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// filter by exclude interfaces
|
||||
if len(excludes) > 0 {
|
||||
for _, iface := range excludes {
|
||||
if iface == s {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
||||
return &WebRTCConfig{
|
||||
Configuration: c,
|
||||
SettingEngine: s,
|
||||
|
||||
Reference in New Issue
Block a user