From b6807d274bba41a140f7c3a2cc8fbc2f1e6b2b24 Mon Sep 17 00:00:00 2001 From: Sebastian Wiesendahl Date: Mon, 8 Feb 2021 20:46:26 +0100 Subject: [PATCH] Add STUN_SERVER env variable with fallback default: "stun:stun.l.google.com:19302" Make STUN_SERVER available for app config Change also the STUN_SERVER for ScreenSharingPeer --- front/src/Enum/EnvironmentVariable.ts | 2 ++ front/src/WebRtc/ScreenSharingPeer.ts | 4 ++-- front/src/WebRtc/VideoPeer.ts | 6 +++--- front/webpack.config.js | 14 +++++++++++++- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/front/src/Enum/EnvironmentVariable.ts b/front/src/Enum/EnvironmentVariable.ts index a71506eb..97d7fa52 100644 --- a/front/src/Enum/EnvironmentVariable.ts +++ b/front/src/Enum/EnvironmentVariable.ts @@ -3,6 +3,7 @@ const START_ROOM_URL : string = process.env.START_ROOM_URL || '/_/global/maps.wo const API_URL = (process.env.API_PROTOCOL || (typeof(window) !== 'undefined' ? window.location.protocol : 'http:')) + '//' + (process.env.API_URL || "pusher.workadventure.localhost"); const UPLOADER_URL = (process.env.API_PROTOCOL || (typeof(window) !== 'undefined' ? window.location.protocol : 'http:')) + '//' + (process.env.UPLOADER_URL || 'uploader.workadventure.localhost'); const ADMIN_URL = (process.env.API_PROTOCOL || (typeof(window) !== 'undefined' ? window.location.protocol : 'http:')) + '//' + (process.env.ADMIN_URL || "workadventure.localhost"); +const STUN_SERVER: string = process.env.STUN_SERVER || "stun:stun.l.google.com:19302"; const TURN_SERVER: string = process.env.TURN_SERVER || "turn:numb.viagenie.ca"; const TURN_USER: string = process.env.TURN_USER || 'g.parant@thecodingmachine.com'; const TURN_PASSWORD: string = process.env.TURN_PASSWORD || 'itcugcOHxle9Acqi$'; @@ -23,6 +24,7 @@ export { ZOOM_LEVEL, POSITION_DELAY, MAX_EXTRAPOLATION_TIME, + STUN_SERVER, TURN_SERVER, TURN_USER, TURN_PASSWORD, diff --git a/front/src/WebRtc/ScreenSharingPeer.ts b/front/src/WebRtc/ScreenSharingPeer.ts index a6cf679b..1b8680cf 100644 --- a/front/src/WebRtc/ScreenSharingPeer.ts +++ b/front/src/WebRtc/ScreenSharingPeer.ts @@ -1,6 +1,6 @@ import * as SimplePeerNamespace from "simple-peer"; import {mediaManager} from "./MediaManager"; -import {TURN_SERVER, TURN_USER, TURN_PASSWORD} from "../Enum/EnvironmentVariable"; +import {STUN_SERVER, TURN_SERVER, TURN_USER, TURN_PASSWORD} from "../Enum/EnvironmentVariable"; import {RoomConnection} from "../Connexion/RoomConnection"; import {MESSAGE_TYPE_CONSTRAINT} from "./VideoPeer"; @@ -24,7 +24,7 @@ export class ScreenSharingPeer extends Peer { config: { iceServers: [ { - urls: 'stun:stun.l.google.com:19302' + urls: STUN_SERVER.split(',') }, { urls: TURN_SERVER.split(','), diff --git a/front/src/WebRtc/VideoPeer.ts b/front/src/WebRtc/VideoPeer.ts index 877f4e64..cc5ac62e 100644 --- a/front/src/WebRtc/VideoPeer.ts +++ b/front/src/WebRtc/VideoPeer.ts @@ -1,6 +1,6 @@ import * as SimplePeerNamespace from "simple-peer"; import {mediaManager} from "./MediaManager"; -import {TURN_PASSWORD, TURN_SERVER, TURN_USER} from "../Enum/EnvironmentVariable"; +import {STUN_SERVER, TURN_PASSWORD, TURN_SERVER, TURN_USER} from "../Enum/EnvironmentVariable"; import {RoomConnection} from "../Connexion/RoomConnection"; const Peer: SimplePeerNamespace.SimplePeer = require('simple-peer'); @@ -21,7 +21,7 @@ export class VideoPeer extends Peer { config: { iceServers: [ { - urls: 'stun:stun.l.google.com:19302' + urls: STUN_SERVER.split(',') }, { urls: TURN_SERVER.split(','), @@ -38,7 +38,7 @@ export class VideoPeer extends Peer { config: { iceServers: [ { - urls: 'stun:stun.l.google.com:19302' + urls: STUN_SERVER.split(',') }, { urls: TURN_SERVER.split(','), diff --git a/front/webpack.config.js b/front/webpack.config.js index 3b97081c..69d507f2 100644 --- a/front/webpack.config.js +++ b/front/webpack.config.js @@ -45,7 +45,19 @@ module.exports = { new webpack.ProvidePlugin({ Phaser: 'phaser' }), - new webpack.EnvironmentPlugin(['API_URL', 'UPLOADER_URL', 'ADMIN_URL', 'DEBUG_MODE', 'TURN_SERVER', 'TURN_USER', 'TURN_PASSWORD', 'JITSI_URL', 'JITSI_PRIVATE_MODE', 'START_ROOM_URL']) + new webpack.EnvironmentPlugin([ + 'API_URL', + 'UPLOADER_URL', + 'ADMIN_URL', + 'DEBUG_MODE', + 'STUN_SERVER', + 'TURN_SERVER', + 'TURN_USER', + 'TURN_PASSWORD', + 'JITSI_URL', + 'JITSI_PRIVATE_MODE', + 'START_ROOM_URL' + ]) ], };