Skip to content

Commit

Permalink
fix: ice server empty urls
Browse files Browse the repository at this point in the history
  • Loading branch information
ido-pluto committed Nov 3, 2023
1 parent 74d27d5 commit dfcc01c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 19 deletions.
16 changes: 2 additions & 14 deletions src/config/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,12 @@ export const SERVER_SECURE = import.meta.env.VITE_SERVER_SECURE;
export const ICE_SERVERS: RTCIceServer[] =
import.meta.env.VITE_ICE_SERVERS && JSON.parse(import.meta.env.VITE_ICE_SERVERS) ||
[
{
urls: 'turn:numb.viagenie.ca',
credential: 'muazkh',
username: 'webrtc@live.com'
},
{
urls: 'turn:192.158.29.39:3478?transport=tcp',
credential: 'JZEOEt2V3Qb0y27GRntt2u2PAYA=',
username: '28224511:1379330808'
},
{
urls: 'turn:turn.anyfirewall.com:443?transport=tcp',
credential: 'webrtc',
username: 'webrtc'
},
{
urls: 'turn:192.158.29.39:3478?transport=tcp',
credential: 'JZEOEt2V3Qb0y27GRntt2u2PAYA=',
username: '28224511:1379330808',
},
urls: ['stun:stun.l.google.com:19302']
}
];
2 changes: 1 addition & 1 deletion src/core/peer-to-peer/peer-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default class PeerManager {
const peerId = uuid();
const peer = new SimplePeer({
initiator: true,
trickle: false,
trickle: true,
config: {
iceServers: ServerSettings.iceServers
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/share/remote-directory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default class RemoteDirectory {
// SimplePeer is not es6 module
this.peerEvents = new SimplePeer({
initiator: false,
trickle: false,
trickle: true,
config: {
iceServers: ServerSettings.iceServers
}
Expand Down
19 changes: 16 additions & 3 deletions src/layouts/website/Settings/ICEServer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,20 @@ export default function ICEServer() {
const [servers, setServers] = useArrayState<RTCIceServer>(settings.iceServers);

useAsyncEffect(async () => {
settings.iceServers = servers;
const newServers = [];
for (const server of servers) {
if (!server.urls)
continue;

if (!server.username)
delete server.username;

if (!server.credential)
delete server.credential;

newServers.push(server);
}
settings.iceServers = newServers;
}, [servers]);

const restoreDefault = () => {
Expand Down Expand Up @@ -40,8 +53,8 @@ export default function ICEServer() {
<Box display="flex" justifyContent="space-between" alignItems="center" key={i} gap={2} mt={3}>
<Box display="flex" gap={2}>
<Input value={server.urls} onChange={updateServer(i, 'urls')} placeholder="url"/>
<Input value={server.username} onChange={updateServer(i, 'username')} placeholder="username"/>
<Input value={server.credential} onChange={updateServer(i, 'credential')} placeholder="credential"/>
<Input value={server.username || ''} onChange={updateServer(i, 'username')} placeholder="username"/>
<Input value={server.credential || ''} onChange={updateServer(i, 'credential')} placeholder="credential"/>
</Box>
<Button onClick={() => setServers.remove(i)} colorScheme="red" fontSize={20}>
<BiTrash/>
Expand Down

0 comments on commit dfcc01c

Please sign in to comment.