mirror of
https://github.com/jech/galene.git
synced 2024-11-22 08:35:57 +01:00
Use null address generator in TURN server when possible.
This commit is contained in:
parent
8d569e9f30
commit
84856f537b
1 changed files with 18 additions and 12 deletions
|
@ -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{
|
||||
|
|
Loading…
Reference in a new issue