Add turn relay start and end port configuration (#733)
This commit is contained in:
@@ -161,6 +161,9 @@ keys:
|
|||||||
# udp_port: 3478
|
# udp_port: 3478
|
||||||
# # defaults to 5349 - if not using a load balancer, this must be set to 443
|
# # defaults to 5349 - if not using a load balancer, this must be set to 443
|
||||||
# tls_port: 5349
|
# tls_port: 5349
|
||||||
|
# # set UDP port range for TURN relay to connect to LiveKit SFU, by default it uses a any available port
|
||||||
|
# relay_range_start: 1024
|
||||||
|
# relay_range_end: 30000
|
||||||
# # set external_tl to true if using a L4 load balancer to terminate TLS. when enabled,
|
# # set external_tl to true if using a L4 load balancer to terminate TLS. when enabled,
|
||||||
# # LiveKit expects unencrypted traffic on tls_port, and still advertise tls_port as a TURN/TLS candidate.
|
# # LiveKit expects unencrypted traffic on tls_port, and still advertise tls_port as a TURN/TLS candidate.
|
||||||
# external_tls: true
|
# external_tls: true
|
||||||
|
|||||||
+21
-7
@@ -151,13 +151,15 @@ type LoggingConfig struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type TURNConfig struct {
|
type TURNConfig struct {
|
||||||
Enabled bool `yaml:"enabled"`
|
Enabled bool `yaml:"enabled"`
|
||||||
Domain string `yaml:"domain"`
|
Domain string `yaml:"domain"`
|
||||||
CertFile string `yaml:"cert_file"`
|
CertFile string `yaml:"cert_file"`
|
||||||
KeyFile string `yaml:"key_file"`
|
KeyFile string `yaml:"key_file"`
|
||||||
TLSPort int `yaml:"tls_port"`
|
TLSPort int `yaml:"tls_port"`
|
||||||
UDPPort int `yaml:"udp_port"`
|
UDPPort int `yaml:"udp_port"`
|
||||||
ExternalTLS bool `yaml:"external_tls"`
|
RelayPortRangeStart uint16 `yaml:"relay_range_start,omitempty"`
|
||||||
|
RelayPortRangeEnd uint16 `yaml:"relay_range_end,omitempty"`
|
||||||
|
ExternalTLS bool `yaml:"external_tls"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type WebHookConfig struct {
|
type WebHookConfig struct {
|
||||||
@@ -276,6 +278,18 @@ func NewConfig(confString string, c *cli.Context) (*Config, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set defaults for Turn relay if none are set
|
||||||
|
if conf.TURN.RelayPortRangeStart == 0 || conf.TURN.RelayPortRangeEnd == 0 {
|
||||||
|
// to make it easier to run in dev mode/docker, default to two ports
|
||||||
|
if conf.Development {
|
||||||
|
conf.TURN.RelayPortRangeStart = 30000
|
||||||
|
conf.TURN.RelayPortRangeEnd = 30002
|
||||||
|
} else {
|
||||||
|
conf.TURN.RelayPortRangeStart = 30000
|
||||||
|
conf.TURN.RelayPortRangeEnd = 40000
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if conf.RTC.NodeIP == "" {
|
if conf.RTC.NodeIP == "" {
|
||||||
conf.RTC.NodeIP, err = conf.determineIP()
|
conf.RTC.NodeIP, err = conf.determineIP()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
+5
-2
@@ -42,12 +42,15 @@ func NewTurnServer(conf *config.Config, authHandler turn.AuthHandler) (*turn.Ser
|
|||||||
relayAddrGen := &turn.RelayAddressGeneratorPortRange{
|
relayAddrGen := &turn.RelayAddressGeneratorPortRange{
|
||||||
RelayAddress: net.ParseIP(conf.RTC.NodeIP),
|
RelayAddress: net.ParseIP(conf.RTC.NodeIP),
|
||||||
Address: "0.0.0.0",
|
Address: "0.0.0.0",
|
||||||
MinPort: turnMinPort,
|
MinPort: turnConf.RelayPortRangeStart,
|
||||||
MaxPort: turnMaxPort,
|
MaxPort: turnConf.RelayPortRangeEnd,
|
||||||
MaxRetries: allocateRetries,
|
MaxRetries: allocateRetries,
|
||||||
}
|
}
|
||||||
var logValues []interface{}
|
var logValues []interface{}
|
||||||
|
|
||||||
|
logValues = append(logValues, "turn.relay_range_start", turnConf.RelayPortRangeStart)
|
||||||
|
logValues = append(logValues, "turn.relay_range_end", turnConf.RelayPortRangeEnd)
|
||||||
|
|
||||||
if turnConf.TLSPort > 0 {
|
if turnConf.TLSPort > 0 {
|
||||||
if turnConf.Domain == "" {
|
if turnConf.Domain == "" {
|
||||||
return nil, errors.New("TURN domain required")
|
return nil, errors.New("TURN domain required")
|
||||||
|
|||||||
Reference in New Issue
Block a user