feat: support UDP in TURN (#61)

1. Add UDP option to TURN
2. GetLocalIPAddress default to IPv4
This commit is contained in:
hn8
2021-07-19 09:21:59 -07:00
committed by GitHub
parent c493022f0f
commit 06c44ca8f6
6 changed files with 83 additions and 42 deletions
+2
View File
@@ -91,6 +91,7 @@ type TURNConfig struct {
CertFile string `yaml:"cert_file"`
KeyFile string `yaml:"key_file"`
TLSPort int `yaml:"tls_port"`
UDPPort int `yaml:"udp_port"`
}
func NewConfig(confString string, c *cli.Context) (*Config, error) {
@@ -135,6 +136,7 @@ func NewConfig(confString string, c *cli.Context) (*Config, error) {
TURN: TURNConfig{
Enabled: false,
TLSPort: 3478,
UDPPort: 3478,
},
Keys: map[string]string{},
}
+5 -2
View File
@@ -41,12 +41,15 @@ func GetLocalIPAddress() (string, error) {
var ip net.IP
switch v := addr.(type) {
case *net.IPNet:
ip = v.IP
ip = v.IP.To4()
case *net.IPAddr:
ip = v.IP
ip = v.IP.To4()
default:
continue
}
if ip == nil {
continue
}
if ip.IsLoopback() {
loopBack = ip.String()
} else {