[mirotalksfu] - refactoring config
هذا الالتزام موجود في:
@@ -202,6 +202,11 @@ const presenters = {}; // collect presenters grp by roomId
|
||||
|
||||
const webRtcServerActive = config.mediasoup.webRtcServerActive;
|
||||
|
||||
// ip (server local IPv4)
|
||||
const IPv4 = webRtcServerActive
|
||||
? config.mediasoup.webRtcServerOptions.listenInfos[0].ip
|
||||
: config.mediasoup.webRtcTransport.listenInfos[0].ip;
|
||||
|
||||
// announcedAddress (server public IPv4)
|
||||
let announcedAddress = webRtcServerActive
|
||||
? config.mediasoup.webRtcServerOptions.listenInfos[0].announcedAddress
|
||||
@@ -212,7 +217,7 @@ const workers = [];
|
||||
let nextMediasoupWorkerIdx = 0;
|
||||
|
||||
// Autodetect announcedAddress (https://www.ipify.org)
|
||||
if (!announcedAddress) {
|
||||
if (!announcedAddress && IPv4 === '0.0.0.0') {
|
||||
http.get(
|
||||
{
|
||||
host: 'api.ipify.org',
|
||||
|
||||
@@ -1,28 +1,24 @@
|
||||
'use strict';
|
||||
|
||||
const os = require('os');
|
||||
const ifaces = os.networkInterfaces();
|
||||
|
||||
const getLocalIp = () => {
|
||||
let localIp = '127.0.0.1';
|
||||
let checkIp = true;
|
||||
Object.keys(ifaces).forEach((ifname) => {
|
||||
for (const iface of ifaces[ifname]) {
|
||||
// Ignore IPv6 and 127.0.0.1
|
||||
if (iface.family !== 'IPv4' || iface.internal !== false || checkIp === false) {
|
||||
continue;
|
||||
}
|
||||
// Set the local ip to the first IPv4 address found and exit the loop
|
||||
localIp = iface.address;
|
||||
checkIp = false;
|
||||
return;
|
||||
}
|
||||
});
|
||||
return localIp;
|
||||
};
|
||||
|
||||
// https://api.ipify.org
|
||||
|
||||
function getIPv4() {
|
||||
const ifaces = os.networkInterfaces();
|
||||
for (const interfaceName in ifaces) {
|
||||
const iface = ifaces[interfaceName];
|
||||
for (const { address, family, internal } of iface) {
|
||||
if (family === 'IPv4' && !internal) {
|
||||
return address;
|
||||
}
|
||||
}
|
||||
}
|
||||
return '0.0.0.0'; // Default to 0.0.0.0 if no external IPv4 address found
|
||||
}
|
||||
|
||||
const IPv4 = getIPv4();
|
||||
|
||||
module.exports = {
|
||||
server: {
|
||||
listen: {
|
||||
@@ -402,15 +398,15 @@ module.exports = {
|
||||
webRtcServerActive: false,
|
||||
webRtcServerOptions: {
|
||||
listenInfos: [
|
||||
{ protocol: 'udp', ip: '0.0.0.0', announcedAddress: getLocalIp(), port: 44444 },
|
||||
{ protocol: 'tcp', ip: '0.0.0.0', announcedAddress: getLocalIp(), port: 44444 },
|
||||
{ protocol: 'udp', ip: '0.0.0.0', announcedAddress: IPv4, port: 44444 },
|
||||
{ protocol: 'tcp', ip: '0.0.0.0', announcedAddress: IPv4, port: 44444 },
|
||||
],
|
||||
},
|
||||
// WebRtcTransportOptions
|
||||
webRtcTransport: {
|
||||
listenInfos: [
|
||||
{ protocol: 'udp', ip: '0.0.0.0', announcedAddress: getLocalIp() },
|
||||
{ protocol: 'tcp', ip: '0.0.0.0', announcedAddress: getLocalIp() },
|
||||
{ protocol: 'udp', ip: '0.0.0.0', announcedAddress: IPv4 },
|
||||
{ protocol: 'tcp', ip: '0.0.0.0', announcedAddress: IPv4 },
|
||||
],
|
||||
initialAvailableOutgoingBitrate: 1000000,
|
||||
minimumAvailableOutgoingBitrate: 600000,
|
||||
|
||||
المرجع في مشكلة جديدة
حظر مستخدم