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
This commit is contained in:
Radosław Gierwiało
2025-11-15 19:00:24 +01:00
parent 6bfc9b04d2
commit 4d52c9f5d2

View File

@@ -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',
},
],
};