Commit 84856f53 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Use null address generator in TURN server when possible.

parent 8d569e9f
......@@ -55,14 +55,23 @@ func listener(a net.IP, port int, relay net.IP) (*turn.PacketConnConfig, *turn.L
var lc *turn.ListenerConfig
s := net.JoinHostPort(a.String(), strconv.Itoa(port))
var g turn.RelayAddressGenerator
if relay == nil || relay.IsUnspecified() {
g = &turn.RelayAddressGeneratorNone{
Address: a.String(),
}
} else {
g = &turn.RelayAddressGeneratorStatic{
RelayAddress: relay,
Address: a.String(),
}
}
p, err := net.ListenPacket("udp4", s)
if err == nil {
pcc = &turn.PacketConnConfig{
PacketConn: p,
RelayAddressGenerator: &turn.RelayAddressGeneratorStatic{
RelayAddress: relay,
Address: a.String(),
},
RelayAddressGenerator: g,
}
} else {
log.Printf("TURN: listenPacket(%v): %v", s, err)
......@@ -72,10 +81,7 @@ func listener(a net.IP, port int, relay net.IP) (*turn.PacketConnConfig, *turn.L
if err == nil {
lc = &turn.ListenerConfig{
Listener: l,
RelayAddressGenerator: &turn.RelayAddressGeneratorStatic{
RelayAddress: relay,
Address: a.String(),
},
RelayAddressGenerator: g,
}
} else {
log.Printf("TURN: listen(%v): %v", s, err)
......@@ -105,7 +111,7 @@ func Start() error {
return err
}
log.Printf("Starting built-in TURN server")
log.Printf("Starting built-in TURN server on %v", addr.String())
username = "galene"
buf := make([]byte, 6)
......@@ -152,7 +158,7 @@ func Start() error {
}
for _, a := range as {
pcc, lc := listener(a, addr.Port, a)
pcc, lc := listener(a, addr.Port, nil)
if pcc != nil {
pccs = append(pccs, *pcc)
addresses = append(addresses, &net.UDPAddr{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment