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
|
var lc *turn.ListenerConfig
|
||||||
s := net.JoinHostPort(a.String(), strconv.Itoa(port))
|
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)
|
p, err := net.ListenPacket("udp4", s)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
pcc = &turn.PacketConnConfig{
|
pcc = &turn.PacketConnConfig{
|
||||||
PacketConn: p,
|
PacketConn: p,
|
||||||
RelayAddressGenerator: &turn.RelayAddressGeneratorStatic{
|
RelayAddressGenerator: g,
|
||||||
RelayAddress: relay,
|
|
||||||
Address: a.String(),
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.Printf("TURN: listenPacket(%v): %v", s, err)
|
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 {
|
if err == nil {
|
||||||
lc = &turn.ListenerConfig{
|
lc = &turn.ListenerConfig{
|
||||||
Listener: l,
|
Listener: l,
|
||||||
RelayAddressGenerator: &turn.RelayAddressGeneratorStatic{
|
RelayAddressGenerator: g,
|
||||||
RelayAddress: relay,
|
|
||||||
Address: a.String(),
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.Printf("TURN: listen(%v): %v", s, err)
|
log.Printf("TURN: listen(%v): %v", s, err)
|
||||||
|
@ -105,7 +111,7 @@ func Start() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("Starting built-in TURN server")
|
log.Printf("Starting built-in TURN server on %v", addr.String())
|
||||||
|
|
||||||
username = "galene"
|
username = "galene"
|
||||||
buf := make([]byte, 6)
|
buf := make([]byte, 6)
|
||||||
|
@ -152,7 +158,7 @@ func Start() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, a := range as {
|
for _, a := range as {
|
||||||
pcc, lc := listener(a, addr.Port, a)
|
pcc, lc := listener(a, addr.Port, nil)
|
||||||
if pcc != nil {
|
if pcc != nil {
|
||||||
pccs = append(pccs, *pcc)
|
pccs = append(pccs, *pcc)
|
||||||
addresses = append(addresses, &net.UDPAddr{
|
addresses = append(addresses, &net.UDPAddr{
|
||||||
|
|
Loading…
Reference in a new issue