Use REST eduTurn
parent
cc4053ebea
commit
71b90dfb6c
|
|
@ -5,15 +5,7 @@ var config =
|
||||||
developmentPort : 3443,
|
developmentPort : 3443,
|
||||||
productionPort : 443,
|
productionPort : 443,
|
||||||
multipartyServer : 'letsmeet.no',
|
multipartyServer : 'letsmeet.no',
|
||||||
turnServers : [
|
|
||||||
{
|
|
||||||
urls : [
|
|
||||||
'turn:turn.example.com:443?transport=tcp'
|
|
||||||
],
|
|
||||||
username : 'example',
|
|
||||||
credential : 'example'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
/**
|
/**
|
||||||
* If defaultResolution is set, it will override user settings when joining:
|
* If defaultResolution is set, it will override user settings when joining:
|
||||||
* low ~ 320x240
|
* low ~ 320x240
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,7 @@ let ScreenShare;
|
||||||
|
|
||||||
let Spotlights;
|
let Spotlights;
|
||||||
|
|
||||||
let turnServers,
|
let requestTimeout,
|
||||||
requestTimeout,
|
|
||||||
transportOptions,
|
transportOptions,
|
||||||
lastN,
|
lastN,
|
||||||
mobileLastN,
|
mobileLastN,
|
||||||
|
|
@ -36,7 +35,6 @@ let turnServers,
|
||||||
if (process.env.NODE_ENV !== 'test')
|
if (process.env.NODE_ENV !== 'test')
|
||||||
{
|
{
|
||||||
({
|
({
|
||||||
turnServers,
|
|
||||||
requestTimeout,
|
requestTimeout,
|
||||||
transportOptions,
|
transportOptions,
|
||||||
lastN,
|
lastN,
|
||||||
|
|
@ -50,8 +48,7 @@ const logger = new Logger('RoomClient');
|
||||||
const ROOM_OPTIONS =
|
const ROOM_OPTIONS =
|
||||||
{
|
{
|
||||||
requestTimeout : requestTimeout,
|
requestTimeout : requestTimeout,
|
||||||
transportOptions : transportOptions,
|
transportOptions : transportOptions
|
||||||
turnServers : turnServers
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const VIDEO_CONSTRAINS =
|
const VIDEO_CONSTRAINS =
|
||||||
|
|
@ -1393,27 +1390,6 @@ export default class RoomClient
|
||||||
|
|
||||||
this._signalingUrl = getSignalingUrl(this._peerId, roomId);
|
this._signalingUrl = getSignalingUrl(this._peerId, roomId);
|
||||||
|
|
||||||
this._torrentSupport = WebTorrent.WEBRTC_SUPPORT;
|
|
||||||
|
|
||||||
this._webTorrent = this._torrentSupport && new WebTorrent({
|
|
||||||
tracker : {
|
|
||||||
rtcConfig : {
|
|
||||||
iceServers : ROOM_OPTIONS.turnServers
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
this._webTorrent.on('error', (error) =>
|
|
||||||
{
|
|
||||||
logger.error('Filesharing [error:"%o"]', error);
|
|
||||||
|
|
||||||
store.dispatch(requestActions.notify(
|
|
||||||
{
|
|
||||||
type : 'error',
|
|
||||||
text : intl.formatMessage({ id: 'filesharing.error', defaultMessage: 'There was a filesharing error' })
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
|
|
||||||
this._screenSharing = ScreenShare.create(this._device);
|
this._screenSharing = ScreenShare.create(this._device);
|
||||||
|
|
||||||
this._signalingSocket = io(this._signalingUrl);
|
this._signalingSocket = io(this._signalingUrl);
|
||||||
|
|
@ -1645,6 +1621,10 @@ export default class RoomClient
|
||||||
|
|
||||||
case 'roomReady':
|
case 'roomReady':
|
||||||
{
|
{
|
||||||
|
const { turnServers } = notification.data;
|
||||||
|
|
||||||
|
this._turnServers = turnServers;
|
||||||
|
|
||||||
store.dispatch(roomActions.toggleJoined());
|
store.dispatch(roomActions.toggleJoined());
|
||||||
store.dispatch(roomActions.setInLobby(false));
|
store.dispatch(roomActions.setInLobby(false));
|
||||||
|
|
||||||
|
|
@ -2062,6 +2042,27 @@ export default class RoomClient
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
this._torrentSupport = WebTorrent.WEBRTC_SUPPORT;
|
||||||
|
|
||||||
|
this._webTorrent = this._torrentSupport && new WebTorrent({
|
||||||
|
tracker : {
|
||||||
|
rtcConfig : {
|
||||||
|
iceServers : this._turnServers
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this._webTorrent.on('error', (error) =>
|
||||||
|
{
|
||||||
|
logger.error('Filesharing [error:"%o"]', error);
|
||||||
|
|
||||||
|
store.dispatch(requestActions.notify(
|
||||||
|
{
|
||||||
|
type : 'error',
|
||||||
|
text : intl.formatMessage({ id: 'filesharing.error', defaultMessage: 'There was a filesharing error' })
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
|
||||||
this._mediasoupDevice = new mediasoupClient.Device();
|
this._mediasoupDevice = new mediasoupClient.Device();
|
||||||
|
|
||||||
const routerRtpCapabilities =
|
const routerRtpCapabilities =
|
||||||
|
|
@ -2092,7 +2093,7 @@ export default class RoomClient
|
||||||
iceParameters,
|
iceParameters,
|
||||||
iceCandidates,
|
iceCandidates,
|
||||||
dtlsParameters,
|
dtlsParameters,
|
||||||
iceServers : ROOM_OPTIONS.turnServers,
|
iceServers : this._turnServers,
|
||||||
proprietaryConstraints : PC_PROPRIETARY_CONSTRAINTS
|
proprietaryConstraints : PC_PROPRIETARY_CONSTRAINTS
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -2154,7 +2155,7 @@ export default class RoomClient
|
||||||
iceParameters,
|
iceParameters,
|
||||||
iceCandidates,
|
iceCandidates,
|
||||||
dtlsParameters,
|
dtlsParameters,
|
||||||
iceServers : ROOM_OPTIONS.turnServers
|
iceServers : this._turnServers
|
||||||
});
|
});
|
||||||
|
|
||||||
this._recvTransport.on(
|
this._recvTransport.on(
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,19 @@ module.exports =
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
*/
|
*/
|
||||||
|
// URI and key for requesting geoip-based TURN server closest to the client
|
||||||
|
turnAPIKey : 'examplekey',
|
||||||
|
turnAPIURI : 'https://example.com/api/turn',
|
||||||
|
// Backup turnservers if REST fails or is not configured
|
||||||
|
backupTurnServers : [
|
||||||
|
{
|
||||||
|
urls : [
|
||||||
|
'turn:turn.example.com:443?transport=tcp'
|
||||||
|
],
|
||||||
|
username : 'example',
|
||||||
|
credential : 'example'
|
||||||
|
}
|
||||||
|
],
|
||||||
redisOptions : {},
|
redisOptions : {},
|
||||||
// session cookie secret
|
// session cookie secret
|
||||||
cookieSecret : 'T0P-S3cR3t_cook!e',
|
cookieSecret : 'T0P-S3cR3t_cook!e',
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
const EventEmitter = require('events').EventEmitter;
|
const EventEmitter = require('events').EventEmitter;
|
||||||
|
const axios = require('axios');
|
||||||
const Logger = require('./Logger');
|
const Logger = require('./Logger');
|
||||||
const Lobby = require('./Lobby');
|
const Lobby = require('./Lobby');
|
||||||
const config = require('../config/config');
|
const config = require('../config/config');
|
||||||
|
|
@ -319,7 +320,7 @@ class Room extends EventEmitter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_peerJoining(peer)
|
async _peerJoining(peer)
|
||||||
{
|
{
|
||||||
peer.socket.join(this._roomId);
|
peer.socket.join(this._roomId);
|
||||||
|
|
||||||
|
|
@ -333,7 +334,46 @@ class Room extends EventEmitter
|
||||||
this._peers[peer.id] = peer;
|
this._peers[peer.id] = peer;
|
||||||
|
|
||||||
this._handlePeer(peer);
|
this._handlePeer(peer);
|
||||||
this._notification(peer.socket, 'roomReady');
|
|
||||||
|
let turnServers;
|
||||||
|
|
||||||
|
if ('turnAPIURI' in config)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
const { data } = await axios.get(
|
||||||
|
config.turnAPIURI,
|
||||||
|
{
|
||||||
|
params : {
|
||||||
|
'uri_schema' : 'turn',
|
||||||
|
'transport' : 'tcp',
|
||||||
|
'ip_ver' : 'ipv4',
|
||||||
|
'servercount' : '2',
|
||||||
|
'api_key' : config.turnAPIKey,
|
||||||
|
'ip' : peer.socket.request.connection.remoteAddress
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
turnServers = [ {
|
||||||
|
urls : data.uris,
|
||||||
|
username : data.username,
|
||||||
|
credential : data.password
|
||||||
|
} ];
|
||||||
|
}
|
||||||
|
catch (error)
|
||||||
|
{
|
||||||
|
if ('backupTurnServers' in config)
|
||||||
|
turnServers = config.backupTurnServers;
|
||||||
|
|
||||||
|
logger.error('_peerJoining() | error on REST turn [error:"%o"]', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ('backupTurnServers' in config)
|
||||||
|
{
|
||||||
|
turnServers = config.backupTurnServers;
|
||||||
|
}
|
||||||
|
|
||||||
|
this._notification(peer.socket, 'roomReady', { turnServers });
|
||||||
}
|
}
|
||||||
|
|
||||||
_handlePeer(peer)
|
_handlePeer(peer)
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"awaitqueue": "^1.0.0",
|
"awaitqueue": "^1.0.0",
|
||||||
|
"axios": "^0.19.2",
|
||||||
"base-64": "^0.1.0",
|
"base-64": "^0.1.0",
|
||||||
"body-parser": "^1.19.0",
|
"body-parser": "^1.19.0",
|
||||||
"colors": "^1.4.0",
|
"colors": "^1.4.0",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue