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
+14 -5
View File
@@ -513,11 +513,20 @@ func (r *RoomManager) iceServersForRoom(ri *livekit.Room) []*livekit.ICEServer {
})
}
if r.config.TURN.Enabled {
iceServers = append(iceServers, &livekit.ICEServer{
Urls: []string{fmt.Sprintf("turns:%s:443?transport=tcp", r.config.TURN.Domain)},
Username: ri.Name,
Credential: ri.TurnPassword,
})
var urls []string
if r.config.TURN.UDPPort > 0 {
urls = append(urls, fmt.Sprintf("turn:%s:%d?transport=udp", r.config.RTC.NodeIP, r.config.TURN.UDPPort))
}
if r.config.TURN.TLSPort > 0 {
urls = append(urls, fmt.Sprintf("turns:%s:443?transport=tcp", r.config.TURN.Domain))
}
if len(urls) > 0 {
iceServers = append(iceServers, &livekit.ICEServer{
Urls: urls,
Username: ri.Name,
Credential: ri.TurnPassword,
})
}
}
return iceServers
}