feat: add default TURN servers for same-network call connectivity

Add OpenRelay (metered.ca) free TURN servers to IceServerConfig
as defaults alongside STUN. This fixes calls between devices on
the same WiFi network where hairpin NAT isn't supported — the
~20% case where STUN-only fails.

TURN servers on ports 80, 443, and 443/TCP to bypass corporate
firewalls. Uses openrelayproject public credentials (20GB/month
free tier).

https://claude.ai/code/session_017hZm7yu7CzmcQgZGSaqSXS
This commit is contained in:
Claude
2026-04-02 03:08:17 +00:00
parent 0bd26bcacd
commit 6e92e8153d
@@ -30,8 +30,27 @@ object IceServerConfig {
PeerConnection.IceServer.builder("stun:stun.cloudflare.com:3478").createIceServer(),
)
val defaultTurnServers =
listOf(
PeerConnection.IceServer
.builder("turn:openrelay.metered.ca:80")
.setUsername("openrelayproject")
.setPassword("openrelayproject")
.createIceServer(),
PeerConnection.IceServer
.builder("turn:openrelay.metered.ca:443")
.setUsername("openrelayproject")
.setPassword("openrelayproject")
.createIceServer(),
PeerConnection.IceServer
.builder("turn:openrelay.metered.ca:443?transport=tcp")
.setUsername("openrelayproject")
.setPassword("openrelayproject")
.createIceServer(),
)
fun buildIceServers(userTurnServers: List<TurnServerConfig> = emptyList()): List<PeerConnection.IceServer> {
val servers = defaultStunServers.toMutableList()
val servers = (defaultStunServers + defaultTurnServers).toMutableList()
userTurnServers.forEach { turn ->
servers.add(
PeerConnection.IceServer