[mirotalksfu] - #87 auto-detect announcedIP if not set
هذا الالتزام موجود في:
@@ -46,6 +46,7 @@ const compression = require('compression');
|
|||||||
const https = require('httpolyglot');
|
const https = require('httpolyglot');
|
||||||
const mediasoup = require('mediasoup');
|
const mediasoup = require('mediasoup');
|
||||||
const mediasoupClient = require('mediasoup-client');
|
const mediasoupClient = require('mediasoup-client');
|
||||||
|
const http = require('http');
|
||||||
const config = require('./config');
|
const config = require('./config');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const ngrok = require('ngrok');
|
const ngrok = require('ngrok');
|
||||||
@@ -82,7 +83,6 @@ const io = require('socket.io')(httpsServer, {
|
|||||||
transports: ['websocket'],
|
transports: ['websocket'],
|
||||||
});
|
});
|
||||||
const host = 'https://' + 'localhost' + ':' + config.listenPort; // config.listenIp
|
const host = 'https://' + 'localhost' + ':' + config.listenPort; // config.listenIp
|
||||||
const announcedIP = config.mediasoup.webRtcTransport.listenIps[0].announcedIp;
|
|
||||||
|
|
||||||
const hostCfg = {
|
const hostCfg = {
|
||||||
protected: config.hostProtected,
|
protected: config.hostProtected,
|
||||||
@@ -118,16 +118,6 @@ if (sentryEnabled) {
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
// Authenticated IP by Login
|
|
||||||
let authHost;
|
|
||||||
|
|
||||||
// all mediasoup workers
|
|
||||||
let workers = [];
|
|
||||||
let nextMediasoupWorkerIdx = 0;
|
|
||||||
|
|
||||||
// all Room lists
|
|
||||||
let roomList = new Map();
|
|
||||||
|
|
||||||
// directory
|
// directory
|
||||||
const dir = {
|
const dir = {
|
||||||
public: path.join(__dirname, '../../', 'public'),
|
public: path.join(__dirname, '../../', 'public'),
|
||||||
@@ -145,6 +135,38 @@ const views = {
|
|||||||
room: path.join(__dirname, '../../', 'public/views/Room.html'),
|
room: path.join(__dirname, '../../', 'public/views/Room.html'),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let announcedIP = config.mediasoup.webRtcTransport.listenIps[0].announcedIp; // AnnouncedIP (server public IPv4)
|
||||||
|
|
||||||
|
let authHost; // Authenticated IP by Login
|
||||||
|
|
||||||
|
let roomList = new Map();
|
||||||
|
|
||||||
|
// All mediasoup workers
|
||||||
|
let workers = [];
|
||||||
|
let nextMediasoupWorkerIdx = 0;
|
||||||
|
|
||||||
|
// Autodetect announcedIP (https://www.ipify.org)
|
||||||
|
if (!announcedIP) {
|
||||||
|
http.get(
|
||||||
|
{
|
||||||
|
host: 'api.ipify.org',
|
||||||
|
port: 80,
|
||||||
|
path: '/',
|
||||||
|
},
|
||||||
|
(resp) => {
|
||||||
|
resp.on('data', (ip) => {
|
||||||
|
announcedIP = ip.toString();
|
||||||
|
config.mediasoup.webRtcTransport.listenIps[0].announcedIp = announcedIP;
|
||||||
|
startServer();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
startServer();
|
||||||
|
}
|
||||||
|
|
||||||
|
function startServer() {
|
||||||
|
// Start the app
|
||||||
app.use(cors());
|
app.use(cors());
|
||||||
app.use(compression());
|
app.use(compression());
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
@@ -923,3 +945,4 @@ function removeIP(socket) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ module.exports = {
|
|||||||
listenIps: [
|
listenIps: [
|
||||||
{
|
{
|
||||||
ip: '0.0.0.0',
|
ip: '0.0.0.0',
|
||||||
announcedIp: getLocalIp(), // replace by public static IP address https://api.ipify.org
|
announcedIp: getLocalIp(), // replace by public static IP address https://api.ipify.org or put '' and will be auto-detected on server start
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
initialAvailableOutgoingBitrate: 1000000,
|
initialAvailableOutgoingBitrate: 1000000,
|
||||||
|
|||||||
المرجع في مشكلة جديدة
حظر مستخدم