From 4d52c9f5d2af0f008cc626daeaef7ecbda41e4f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Gierwia=C5=82o?= Date: Sat, 15 Nov 2025 19:00:24 +0100 Subject: [PATCH] feat: add TURN servers for symmetric NAT traversal - Add openrelay.metered.ca TURN servers for testing - Support connections through symmetric NAT (mobile networks) - Add TCP transport fallback for strict firewalls - Enables P2P file transfer across different networks --- frontend/src/hooks/useWebRTC.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/frontend/src/hooks/useWebRTC.js b/frontend/src/hooks/useWebRTC.js index 618679b..5c25a75 100644 --- a/frontend/src/hooks/useWebRTC.js +++ b/frontend/src/hooks/useWebRTC.js @@ -1,12 +1,30 @@ import { useState, useEffect, useRef, useCallback } from 'react'; import { getSocket } from '../services/socket'; -// WebRTC configuration with STUN servers for NAT traversal +// WebRTC configuration with STUN and TURN servers for NAT traversal const rtcConfig = { iceServers: [ + // STUN servers for basic NAT traversal { urls: 'stun:stun.l.google.com:19302' }, { urls: 'stun:stun1.l.google.com:19302' }, { urls: 'stun:stun2.l.google.com:19302' }, + + // TURN servers for symmetric NAT and strict firewalls (public relay for testing) + { + urls: 'turn:openrelay.metered.ca:80', + username: 'openrelayproject', + credential: 'openrelayproject', + }, + { + urls: 'turn:openrelay.metered.ca:443', + username: 'openrelayproject', + credential: 'openrelayproject', + }, + { + urls: 'turn:openrelay.metered.ca:443?transport=tcp', + username: 'openrelayproject', + credential: 'openrelayproject', + }, ], };