Skip to content

Commit

Permalink
[mirotalk] - make Stun editable
Browse files Browse the repository at this point in the history
  • Loading branch information
miroslavpejic85 committed Jul 23, 2022
1 parent a0bad8e commit 7a0bbfb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
5 changes: 5 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ PORT=3000
NGROK_ENABLED=true|false
NGROK_AUTH_TOKEN=YourNgrokAuthToken

# Stun
# Check: https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/

STUN=stun:stun.l.google.com:19302

# Turn
# 1. Goto http://numb.viagenie.ca/
# 2. Create an account
Expand Down
36 changes: 16 additions & 20 deletions app/src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ const ngrok = require('ngrok');
const ngrokEnabled = process.env.NGROK_ENABLED || false;
const ngrokAuthToken = process.env.NGROK_AUTH_TOKEN;

// Stun config
const stun = process.env.STUN || 'stun:stun.l.google.com:19302';

// Turn config
const turnEnabled = process.env.TURN_ENABLED || false;
const turnUrls = process.env.TURN_URLS;
Expand Down Expand Up @@ -323,29 +326,22 @@ app.get('*', function (req, res) {
*/
const iceServers = [];

// Stun is always needed
iceServers.push({ urls: stun });

if (turnEnabled == 'true') {
iceServers.push(
{
urls: 'stun:stun.l.google.com:19302',
},
{
urls: turnUrls,
username: turnUsername,
credential: turnCredential,
},
);
iceServers.push({
urls: turnUrls,
username: turnUsername,
credential: turnCredential,
});
} else {
// My own As backup if not configured, please configure your in the .env file
iceServers.push(
{
urls: 'stun:stun.l.google.com:19302',
},
{
urls: 'turn:numb.viagenie.ca',
username: 'miroslav.pejic.85@gmail.com',
credential: 'mirotalkp2p',
},
);
iceServers.push({
urls: 'turn:numb.viagenie.ca',
username: 'miroslav.pejic.85@gmail.com',
credential: 'mirotalkp2p',
});
}

/**
Expand Down

0 comments on commit 7a0bbfb

Please sign in to comment.