Turn with external tls termination (#168)
* add TURN TCP port for plain tcp listener * use externalTLS turn config option * remove unused TCPPort config option
This commit is contained in:
@@ -109,6 +109,7 @@ type TURNConfig struct {
|
|||||||
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"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type WebHookConfig struct {
|
type WebHookConfig struct {
|
||||||
|
|||||||
+14
-1
@@ -55,6 +55,7 @@ func NewTurnServer(conf *config.Config, authHandler turn.AuthHandler) (*turn.Ser
|
|||||||
return nil, errors.New("TURN domain is not correct")
|
return nil, errors.New("TURN domain is not correct")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !turnConf.ExternalTLS {
|
||||||
cert, err := tls.LoadX509KeyPair(turnConf.CertFile, turnConf.KeyFile)
|
cert, err := tls.LoadX509KeyPair(turnConf.CertFile, turnConf.KeyFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "TURN tls cert required")
|
return nil, errors.Wrap(err, "TURN tls cert required")
|
||||||
@@ -74,7 +75,19 @@ func NewTurnServer(conf *config.Config, authHandler turn.AuthHandler) (*turn.Ser
|
|||||||
RelayAddressGenerator: relayAddrGen,
|
RelayAddressGenerator: relayAddrGen,
|
||||||
}
|
}
|
||||||
serverConfig.ListenerConfigs = append(serverConfig.ListenerConfigs, listenerConfig)
|
serverConfig.ListenerConfigs = append(serverConfig.ListenerConfigs, listenerConfig)
|
||||||
logValues = append(logValues, "turn.portTLS", turnConf.TLSPort)
|
} else {
|
||||||
|
tcpListener, err := net.Listen("tcp4", "0.0.0.0:"+strconv.Itoa(turnConf.TLSPort))
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "could not listen on TURN TCP port")
|
||||||
|
}
|
||||||
|
|
||||||
|
listenerConfig := turn.ListenerConfig{
|
||||||
|
Listener: tcpListener,
|
||||||
|
RelayAddressGenerator: relayAddrGen,
|
||||||
|
}
|
||||||
|
serverConfig.ListenerConfigs = append(serverConfig.ListenerConfigs, listenerConfig)
|
||||||
|
}
|
||||||
|
logValues = append(logValues, "turn.portTLS", turnConf.TLSPort, "turn.externalTLS", turnConf.ExternalTLS)
|
||||||
}
|
}
|
||||||
|
|
||||||
if turnConf.UDPPort > 0 {
|
if turnConf.UDPPort > 0 {
|
||||||
|
|||||||
Reference in New Issue
Block a user