diff --git a/node/src/Router.ts b/node/src/Router.ts index 9b836f67ad..28dad26213 100644 --- a/node/src/Router.ts +++ b/node/src/Router.ts @@ -7,7 +7,8 @@ import { Transport, TransportListenInfo, TransportListenIp, - TransportProtocol + TransportProtocol, + TransportSocketFlag } from './Transport'; import { WebRtcTransport, WebRtcTransportOptions, parseWebRtcTransportDumpResponse } from './WebRtcTransport'; import { PlainTransport, PlainTransportOptions, parsePlainTransportDumpResponse } from './PlainTransport'; @@ -570,6 +571,7 @@ export class Router listenInfo.ip, listenInfo.announcedIp, listenInfo.port, + socketFlagsToInteger(listenInfo.flags), listenInfo.sendBufferSize, listenInfo.recvBufferSize )); @@ -749,6 +751,7 @@ export class Router listenInfo!.ip, listenInfo!.announcedIp, listenInfo!.port, + socketFlagsToInteger(listenInfo!.flags), listenInfo!.sendBufferSize, listenInfo!.recvBufferSize ), @@ -759,6 +762,7 @@ export class Router rtcpListenInfo.ip, rtcpListenInfo.announcedIp, rtcpListenInfo.port, + socketFlagsToInteger(rtcpListenInfo.flags), rtcpListenInfo.sendBufferSize, rtcpListenInfo.recvBufferSize ) : undefined, @@ -897,6 +901,7 @@ export class Router listenInfo!.ip, listenInfo!.announcedIp, listenInfo!.port, + socketFlagsToInteger(listenInfo!.flags), listenInfo!.sendBufferSize, listenInfo!.recvBufferSize ), @@ -1619,3 +1624,15 @@ export function parseRouterDumpResponse( mapDataConsumerIdDataProducerId : parseStringStringVector(binary, 'mapDataConsumerIdDataProducerId') }; } + +function socketFlagsToInteger(flags: TransportSocketFlag[] = []): number +{ + let flagsInteger = 0; + + for (const flag of flags) + { + flagsInteger |= flag; + } + + return flagsInteger; +} diff --git a/node/src/Transport.ts b/node/src/Transport.ts index 7ae79d39df..869d76c2d1 100644 --- a/node/src/Transport.ts +++ b/node/src/Transport.ts @@ -73,6 +73,11 @@ export type TransportListenInfo = */ port?: number; + /** + * Socket flags. + */ + flags?: TransportSocketFlag[]; + /** * Send buffer size (bytes). */ @@ -107,6 +112,25 @@ export type TransportListenIp = */ export type TransportProtocol = 'udp' | 'tcp'; +/** + * UDP/TCP socket flag. + */ +// NOTE: ESLint absurdly complains about "'TransportSocketFlag' is already +// declared in the upper scope". +// eslint-disable-next-line no-shadow +export enum TransportSocketFlag +{ + /** + * Disable dual-stack support so only IPv6 is used (only if ip is IPv6). + */ + IPV6ONLY = FbsTransport.SocketFlag.IPV6ONLY, + /** + * Make different transports bind to the same ip and port (only for UDP). + * Useful for multicast scenarios with plain transport. Use with caution. + */ + UDP_REUSEPORT = FbsTransport.SocketFlag.UDP_REUSEPORT +} + export type TransportTuple = { localIp: string; diff --git a/node/src/tests/test-PlainTransport.ts b/node/src/tests/test-PlainTransport.ts index 3e75c50586..da0986e0f7 100644 --- a/node/src/tests/test-PlainTransport.ts +++ b/node/src/tests/test-PlainTransport.ts @@ -316,6 +316,43 @@ test('router.createPlainTransport() with non bindable IP rejects with Error', as .toThrow(Error); }, 2000); +test('two transports listening in same IP:port succeed if UDP_REUSEPORT flag is set', async () => +{ + let transport1: mediasoup.types.PlainTransport | undefined; + let transport2: mediasoup.types.PlainTransport | undefined; + + await expect(async () => + { + const multicastIp = '224.0.0.1'; + const port = await pickPort({ ip: multicastIp, reserveTimeout: 0 }); + + transport1 = await router.createPlainTransport( + { + listenInfo : + { + protocol : 'udp', + ip : multicastIp, + port : port, + flags : [ mediasoup.types.TransportSocketFlag.UDP_REUSEPORT ] + } + }); + + transport2 = await router.createPlainTransport( + { + listenInfo : + { + protocol : 'udp', + ip : multicastIp, + port : port, + flags : [ mediasoup.types.TransportSocketFlag.UDP_REUSEPORT ] + } + }); + }).not.toThrow(); + + transport1?.close(); + transport2?.close(); +}, 2000); + test('plainTransport.getStats() succeeds', async () => { const data = await transport.getStats(); diff --git a/npm-scripts.mjs b/npm-scripts.mjs index 6dab36a258..a734c35e33 100644 --- a/npm-scripts.mjs +++ b/npm-scripts.mjs @@ -1,7 +1,7 @@ -import process from 'node:process'; -import os from 'node:os'; -import fs from 'node:fs'; -import path from 'node:path'; +import * as process from 'node:process'; +import * as os from 'node:os'; +import * as fs from 'node:fs'; +import * as path from 'node:path'; import { execSync } from 'node:child_process'; import fetch from 'node-fetch'; import tar from 'tar'; diff --git a/worker/fbs/transport.fbs b/worker/fbs/transport.fbs index d2a77d4ae9..22415fb862 100644 --- a/worker/fbs/transport.fbs +++ b/worker/fbs/transport.fbs @@ -13,11 +13,17 @@ enum Protocol: uint8 { TCP } +enum SocketFlag: uint8 { + IPV6ONLY = 1, + UDP_REUSEPORT = 2 +} + table ListenInfo { - protocol: FBS.Transport.Protocol = UDP; + protocol: Protocol = UDP; ip: string (required); announced_ip: string; port: uint16 = 0; + flags: uint8 = 0; send_buffer_size: uint32 = 0; recv_buffer_size: uint32 = 0; } @@ -85,7 +91,7 @@ table Tuple { local_port: uint16; remote_ip: string; remote_port: uint16; - protocol: FBS.Transport.Protocol = UDP; + protocol: Protocol = UDP; } table RtpListener { diff --git a/worker/include/Logger.hpp b/worker/include/Logger.hpp index 53c16f32a4..e3c22bb71f 100644 --- a/worker/include/Logger.hpp +++ b/worker/include/Logger.hpp @@ -126,6 +126,19 @@ ((value & 0x02) ? '1' : '0'), \ ((value & 0x01) ? '1' : '0') +// Usage: +// MS_DEBUG_DEV("Leading text "MS_UINT8_TO_BINARY_PATTERN, MS_UINT8_TO_BINARY(value)); +#define MS_UINT8_TO_BINARY_PATTERN "%c%c%c%c%c%c%c%c" +#define MS_UINT8_TO_BINARY(value) \ + ((value & 0x80) ? '1' : '0'), \ + ((value & 0x40) ? '1' : '0'), \ + ((value & 0x20) ? '1' : '0'), \ + ((value & 0x10) ? '1' : '0'), \ + ((value & 0x08) ? '1' : '0'), \ + ((value & 0x04) ? '1' : '0'), \ + ((value & 0x02) ? '1' : '0'), \ + ((value & 0x01) ? '1' : '0') + class Logger { public: diff --git a/worker/include/RTC/PortManager.hpp b/worker/include/RTC/PortManager.hpp index 4300548385..775a7235d9 100644 --- a/worker/include/RTC/PortManager.hpp +++ b/worker/include/RTC/PortManager.hpp @@ -20,21 +20,21 @@ namespace RTC }; public: - static uv_udp_t* BindUdp(std::string& ip) + static uv_udp_t* BindUdp(std::string& ip, uint8_t flags) { - return reinterpret_cast(Bind(Transport::UDP, ip)); + return reinterpret_cast(Bind(Transport::UDP, ip, flags)); } - static uv_udp_t* BindUdp(std::string& ip, uint16_t port) + static uv_udp_t* BindUdp(std::string& ip, uint16_t port, uint8_t flags) { - return reinterpret_cast(Bind(Transport::UDP, ip, port)); + return reinterpret_cast(Bind(Transport::UDP, ip, port, flags)); } - static uv_tcp_t* BindTcp(std::string& ip) + static uv_tcp_t* BindTcp(std::string& ip, uint8_t flags) { - return reinterpret_cast(Bind(Transport::TCP, ip)); + return reinterpret_cast(Bind(Transport::TCP, ip, flags)); } - static uv_tcp_t* BindTcp(std::string& ip, uint16_t port) + static uv_tcp_t* BindTcp(std::string& ip, uint16_t port, uint8_t flags) { - return reinterpret_cast(Bind(Transport::TCP, ip, port)); + return reinterpret_cast(Bind(Transport::TCP, ip, port, flags)); } static void UnbindUdp(std::string& ip, uint16_t port) { @@ -46,10 +46,11 @@ namespace RTC } private: - static uv_handle_t* Bind(Transport transport, std::string& ip); - static uv_handle_t* Bind(Transport transport, std::string& ip, uint16_t port); + static uv_handle_t* Bind(Transport transport, std::string& ip, uint8_t flags); + static uv_handle_t* Bind(Transport transport, std::string& ip, uint16_t port, uint8_t flags); static void Unbind(Transport transport, std::string& ip, uint16_t port); static std::vector& GetPorts(Transport transport, const std::string& ip); + static uint8_t ConvertSocketFlags(uint8_t flags); private: thread_local static absl::flat_hash_map> mapUdpIpPorts; diff --git a/worker/include/RTC/TcpServer.hpp b/worker/include/RTC/TcpServer.hpp index 89e03ca6b8..102d85c2fc 100644 --- a/worker/include/RTC/TcpServer.hpp +++ b/worker/include/RTC/TcpServer.hpp @@ -23,9 +23,14 @@ namespace RTC }; public: - TcpServer(Listener* listener, RTC::TcpConnection::Listener* connListener, std::string& ip); TcpServer( - Listener* listener, RTC::TcpConnection::Listener* connListener, std::string& ip, uint16_t port); + Listener* listener, RTC::TcpConnection::Listener* connListener, std::string& ip, uint8_t flags); + TcpServer( + Listener* listener, + RTC::TcpConnection::Listener* connListener, + std::string& ip, + uint16_t port, + uint8_t flags); ~TcpServer() override; /* Pure virtual methods inherited from ::TcpServerHandle. */ diff --git a/worker/include/RTC/Transport.hpp b/worker/include/RTC/Transport.hpp index 61bdd3ec65..e5702f515d 100644 --- a/worker/include/RTC/Transport.hpp +++ b/worker/include/RTC/Transport.hpp @@ -126,6 +126,7 @@ namespace RTC uint16_t port{ 0u }; uint32_t sendBufferSize{ 0u }; uint32_t recvBufferSize{ 0u }; + uint8_t flags{ 0u }; }; private: diff --git a/worker/include/RTC/UdpSocket.hpp b/worker/include/RTC/UdpSocket.hpp index 46e90f3edd..aff4a5b8c3 100644 --- a/worker/include/RTC/UdpSocket.hpp +++ b/worker/include/RTC/UdpSocket.hpp @@ -21,8 +21,8 @@ namespace RTC }; public: - UdpSocket(Listener* listener, std::string& ip); - UdpSocket(Listener* listener, std::string& ip, uint16_t port); + UdpSocket(Listener* listener, std::string& ip, uint8_t flags); + UdpSocket(Listener* listener, std::string& ip, uint16_t port, uint8_t flags); ~UdpSocket() override; /* Pure virtual methods inherited from ::UdpSocketHandle. */ diff --git a/worker/src/RTC/PipeTransport.cpp b/worker/src/RTC/PipeTransport.cpp index 950697b111..ae0ea29231 100644 --- a/worker/src/RTC/PipeTransport.cpp +++ b/worker/src/RTC/PipeTransport.cpp @@ -50,19 +50,10 @@ namespace RTC this->listenInfo.announcedIp.assign(options->listenInfo()->announcedIp()->str()); } - this->listenInfo.port = options->listenInfo()->port(); - - if (flatbuffers::IsFieldPresent( - options->listenInfo(), FBS::Transport::ListenInfo::VT_SENDBUFFERSIZE)) - { - this->listenInfo.sendBufferSize = options->listenInfo()->sendBufferSize(); - } - - if (flatbuffers::IsFieldPresent( - options->listenInfo(), FBS::Transport::ListenInfo::VT_RECVBUFFERSIZE)) - { - this->listenInfo.recvBufferSize = options->listenInfo()->recvBufferSize(); - } + this->listenInfo.port = options->listenInfo()->port(); + this->listenInfo.sendBufferSize = options->listenInfo()->sendBufferSize(); + this->listenInfo.recvBufferSize = options->listenInfo()->recvBufferSize(); + this->listenInfo.flags = options->listenInfo()->flags(); this->rtx = options->enableRtx(); @@ -77,11 +68,12 @@ namespace RTC // This may throw. if (this->listenInfo.port != 0) { - this->udpSocket = new RTC::UdpSocket(this, this->listenInfo.ip, this->listenInfo.port); + this->udpSocket = new RTC::UdpSocket( + this, this->listenInfo.ip, this->listenInfo.port, this->listenInfo.flags); } else { - this->udpSocket = new RTC::UdpSocket(this, this->listenInfo.ip); + this->udpSocket = new RTC::UdpSocket(this, this->listenInfo.ip, this->listenInfo.flags); } if (this->listenInfo.sendBufferSize != 0) diff --git a/worker/src/RTC/PlainTransport.cpp b/worker/src/RTC/PlainTransport.cpp index 305e67516f..36d0fa53d8 100644 --- a/worker/src/RTC/PlainTransport.cpp +++ b/worker/src/RTC/PlainTransport.cpp @@ -52,19 +52,10 @@ namespace RTC this->listenInfo.announcedIp.assign(options->listenInfo()->announcedIp()->str()); } - this->listenInfo.port = options->listenInfo()->port(); - - if (flatbuffers::IsFieldPresent( - options->listenInfo(), FBS::Transport::ListenInfo::VT_SENDBUFFERSIZE)) - { - this->listenInfo.sendBufferSize = options->listenInfo()->sendBufferSize(); - } - - if (flatbuffers::IsFieldPresent( - options->listenInfo(), FBS::Transport::ListenInfo::VT_RECVBUFFERSIZE)) - { - this->listenInfo.recvBufferSize = options->listenInfo()->recvBufferSize(); - } + this->listenInfo.port = options->listenInfo()->port(); + this->listenInfo.sendBufferSize = options->listenInfo()->sendBufferSize(); + this->listenInfo.recvBufferSize = options->listenInfo()->recvBufferSize(); + this->listenInfo.flags = options->listenInfo()->flags(); this->rtcpMux = options->rtcpMux(); this->comedia = options->comedia(); @@ -90,19 +81,10 @@ namespace RTC this->rtcpListenInfo.announcedIp.assign(options->rtcpListenInfo()->announcedIp()->str()); } - this->rtcpListenInfo.port = options->rtcpListenInfo()->port(); - - if (flatbuffers::IsFieldPresent( - options->rtcpListenInfo(), FBS::Transport::ListenInfo::VT_SENDBUFFERSIZE)) - { - this->rtcpListenInfo.sendBufferSize = options->rtcpListenInfo()->sendBufferSize(); - } - - if (flatbuffers::IsFieldPresent( - options->rtcpListenInfo(), FBS::Transport::ListenInfo::VT_RECVBUFFERSIZE)) - { - this->rtcpListenInfo.recvBufferSize = options->rtcpListenInfo()->recvBufferSize(); - } + this->rtcpListenInfo.port = options->rtcpListenInfo()->port(); + this->rtcpListenInfo.sendBufferSize = options->rtcpListenInfo()->sendBufferSize(); + this->rtcpListenInfo.recvBufferSize = options->rtcpListenInfo()->recvBufferSize(); + this->rtcpListenInfo.flags = options->rtcpListenInfo()->flags(); } // If rtcpListenInfo is not given, just clone listenInfo. else @@ -160,11 +142,12 @@ namespace RTC // This may throw. if (this->listenInfo.port != 0) { - this->udpSocket = new RTC::UdpSocket(this, this->listenInfo.ip, this->listenInfo.port); + this->udpSocket = new RTC::UdpSocket( + this, this->listenInfo.ip, this->listenInfo.port, this->listenInfo.flags); } else { - this->udpSocket = new RTC::UdpSocket(this, this->listenInfo.ip); + this->udpSocket = new RTC::UdpSocket(this, this->listenInfo.ip, this->listenInfo.flags); } if (this->listenInfo.sendBufferSize != 0) @@ -184,12 +167,13 @@ namespace RTC // This may throw. if (this->rtcpListenInfo.port != 0) { - this->rtcpUdpSocket = - new RTC::UdpSocket(this, this->rtcpListenInfo.ip, this->rtcpListenInfo.port); + this->rtcpUdpSocket = new RTC::UdpSocket( + this, this->rtcpListenInfo.ip, this->rtcpListenInfo.port, this->rtcpListenInfo.flags); } else { - this->rtcpUdpSocket = new RTC::UdpSocket(this, this->rtcpListenInfo.ip); + this->rtcpUdpSocket = + new RTC::UdpSocket(this, this->rtcpListenInfo.ip, this->rtcpListenInfo.flags); } if (this->rtcpListenInfo.sendBufferSize != 0) diff --git a/worker/src/RTC/PortManager.cpp b/worker/src/RTC/PortManager.cpp index 0d19d686f3..82eaee0e4f 100644 --- a/worker/src/RTC/PortManager.cpp +++ b/worker/src/RTC/PortManager.cpp @@ -7,6 +7,7 @@ #include "MediaSoupErrors.hpp" #include "Settings.hpp" #include "Utils.hpp" +#include "FBS/transport.h" #include // std:make_tuple() #include // std::piecewise_construct @@ -38,18 +39,20 @@ namespace RTC /* Class methods. */ - uv_handle_t* PortManager::Bind(Transport transport, std::string& ip) + uv_handle_t* PortManager::Bind(Transport transport, std::string& ip, uint8_t flags) { MS_TRACE(); // First normalize the IP. This may throw if invalid IP. Utils::IP::NormalizeIp(ip); + // Covert given flags into libuv flags. + flags = ConvertSocketFlags(flags); + int err; const int family = Utils::IP::GetFamily(ip); struct sockaddr_storage bindAddr; // NOLINT(cppcoreguidelines-pro-type-member-init) size_t portIdx; - int flags{ 0 }; std::vector& ports = PortManager::GetPorts(transport, ip); size_t attempt{ 0u }; const size_t numAttempts = ports.size(); @@ -60,12 +63,18 @@ namespace RTC switch (transport) { case Transport::UDP: + { transportStr.assign("udp"); + break; + } case Transport::TCP: + { transportStr.assign("tcp"); + break; + } } switch (family) @@ -91,9 +100,6 @@ namespace RTC MS_THROW_ERROR("uv_ip6_addr() failed: %s", uv_strerror(err)); } - // Don't also bind into IPv4 when listening in IPv6. - flags |= UV_UDP_IPV6ONLY; - break; } @@ -160,12 +166,18 @@ namespace RTC switch (family) { case AF_INET: + { (reinterpret_cast(&bindAddr))->sin_port = htons(port); + break; + } case AF_INET6: + { (reinterpret_cast(&bindAddr))->sin6_port = htons(port); + break; + } } // Try to bind on it. @@ -356,29 +368,37 @@ namespace RTC return static_cast(uvHandle); } - uv_handle_t* PortManager::Bind(Transport transport, std::string& ip, uint16_t port) + uv_handle_t* PortManager::Bind(Transport transport, std::string& ip, uint16_t port, uint8_t flags) { MS_TRACE(); // First normalize the IP. This may throw if invalid IP. Utils::IP::NormalizeIp(ip); + // Covert given flags into libuv flags. + flags = ConvertSocketFlags(flags); + int err; const int family = Utils::IP::GetFamily(ip); struct sockaddr_storage bindAddr; // NOLINT(cppcoreguidelines-pro-type-member-init) - int flags{ 0 }; uv_handle_t* uvHandle{ nullptr }; std::string transportStr; switch (transport) { case Transport::UDP: + { transportStr.assign("udp"); + break; + } case Transport::TCP: + { transportStr.assign("tcp"); + break; + } } switch (family) @@ -404,9 +424,6 @@ namespace RTC MS_THROW_ERROR("uv_ip6_addr() failed: %s", uv_strerror(err)); } - // Don't also bind into IPv4 when listening in IPv6. - flags |= UV_UDP_IPV6ONLY; - break; } @@ -421,27 +438,39 @@ namespace RTC switch (family) { case AF_INET: + { (reinterpret_cast(&bindAddr))->sin_port = htons(port); + break; + } case AF_INET6: + { (reinterpret_cast(&bindAddr))->sin6_port = htons(port); + break; + } } // Try to bind on it. switch (transport) { case Transport::UDP: + { uvHandle = reinterpret_cast(new uv_udp_t()); err = uv_udp_init_ex( DepLibUV::GetLoop(), reinterpret_cast(uvHandle), UV_UDP_RECVMMSG); + break; + } case Transport::TCP: + { uvHandle = reinterpret_cast(new uv_tcp_t()); err = uv_tcp_init(DepLibUV::GetLoop(), reinterpret_cast(uvHandle)); + break; + } } if (err != 0) @@ -666,4 +695,24 @@ namespace RTC return emptyPorts; } + + uint8_t PortManager::ConvertSocketFlags(uint8_t flags) + { + MS_TRACE(); + + uint8_t newFlags{ 0u }; + + if (flags & static_cast(FBS::Transport::SocketFlag::IPV6ONLY)) + { + newFlags |= UV_UDP_IPV6ONLY; + newFlags |= UV_TCP_IPV6ONLY; // Same flag number but anyway. + } + + if (flags & static_cast(FBS::Transport::SocketFlag::UDP_REUSEPORT)) + { + newFlags |= UV_UDP_REUSEADDR; + } + + return newFlags; + } } // namespace RTC diff --git a/worker/src/RTC/TcpServer.cpp b/worker/src/RTC/TcpServer.cpp index ddd1d2da82..b007fad3c0 100644 --- a/worker/src/RTC/TcpServer.cpp +++ b/worker/src/RTC/TcpServer.cpp @@ -10,19 +10,24 @@ namespace RTC { /* Instance methods. */ - TcpServer::TcpServer(Listener* listener, RTC::TcpConnection::Listener* connListener, std::string& ip) + TcpServer::TcpServer( + Listener* listener, RTC::TcpConnection::Listener* connListener, std::string& ip, uint8_t flags) : // This may throw. - ::TcpServerHandle::TcpServerHandle(RTC::PortManager::BindTcp(ip)), listener(listener), + ::TcpServerHandle::TcpServerHandle(RTC::PortManager::BindTcp(ip, flags)), listener(listener), connListener(connListener) { MS_TRACE(); } TcpServer::TcpServer( - Listener* listener, RTC::TcpConnection::Listener* connListener, std::string& ip, uint16_t port) + Listener* listener, + RTC::TcpConnection::Listener* connListener, + std::string& ip, + uint16_t port, + uint8_t flags) : // This may throw. - ::TcpServerHandle::TcpServerHandle(RTC::PortManager::BindTcp(ip, port)), listener(listener), - connListener(connListener), fixedPort(true) + ::TcpServerHandle::TcpServerHandle(RTC::PortManager::BindTcp(ip, port, flags)), + listener(listener), connListener(connListener), fixedPort(true) { MS_TRACE(); } diff --git a/worker/src/RTC/UdpSocket.cpp b/worker/src/RTC/UdpSocket.cpp index 6c47ab4671..f340fd86f2 100644 --- a/worker/src/RTC/UdpSocket.cpp +++ b/worker/src/RTC/UdpSocket.cpp @@ -10,16 +10,16 @@ namespace RTC { /* Instance methods. */ - UdpSocket::UdpSocket(Listener* listener, std::string& ip) + UdpSocket::UdpSocket(Listener* listener, std::string& ip, uint8_t flags) : // This may throw. - ::UdpSocketHandle::UdpSocketHandle(PortManager::BindUdp(ip)), listener(listener) + ::UdpSocketHandle::UdpSocketHandle(PortManager::BindUdp(ip, flags)), listener(listener) { MS_TRACE(); } - UdpSocket::UdpSocket(Listener* listener, std::string& ip, uint16_t port) + UdpSocket::UdpSocket(Listener* listener, std::string& ip, uint16_t port, uint8_t flags) : // This may throw. - ::UdpSocketHandle::UdpSocketHandle(PortManager::BindUdp(ip, port)), listener(listener), + ::UdpSocketHandle::UdpSocketHandle(PortManager::BindUdp(ip, port, flags)), listener(listener), fixedPort(true) { MS_TRACE(); diff --git a/worker/src/RTC/WebRtcServer.cpp b/worker/src/RTC/WebRtcServer.cpp index 8fe9f760a3..c89a64ddfb 100644 --- a/worker/src/RTC/WebRtcServer.cpp +++ b/worker/src/RTC/WebRtcServer.cpp @@ -67,11 +67,11 @@ namespace RTC if (listenInfo->port() != 0) { - udpSocket = new RTC::UdpSocket(this, ip, listenInfo->port()); + udpSocket = new RTC::UdpSocket(this, ip, listenInfo->port(), listenInfo->flags()); } else { - udpSocket = new RTC::UdpSocket(this, ip); + udpSocket = new RTC::UdpSocket(this, ip, listenInfo->flags()); } this->udpSocketOrTcpServers.emplace_back(udpSocket, nullptr, announcedIp); @@ -99,11 +99,11 @@ namespace RTC if (listenInfo->port() != 0) { - tcpServer = new RTC::TcpServer(this, this, ip, listenInfo->port()); + tcpServer = new RTC::TcpServer(this, this, ip, listenInfo->port(), listenInfo->flags()); } else { - tcpServer = new RTC::TcpServer(this, this, ip); + tcpServer = new RTC::TcpServer(this, this, ip, listenInfo->flags()); } this->udpSocketOrTcpServers.emplace_back(nullptr, tcpServer, announcedIp); diff --git a/worker/src/RTC/WebRtcTransport.cpp b/worker/src/RTC/WebRtcTransport.cpp index 19e33d5f6d..9b897649b0 100644 --- a/worker/src/RTC/WebRtcTransport.cpp +++ b/worker/src/RTC/WebRtcTransport.cpp @@ -72,11 +72,11 @@ namespace RTC if (listenInfo->port() != 0) { - udpSocket = new RTC::UdpSocket(this, ip, listenInfo->port()); + udpSocket = new RTC::UdpSocket(this, ip, listenInfo->port(), listenInfo->flags()); } else { - udpSocket = new RTC::UdpSocket(this, ip); + udpSocket = new RTC::UdpSocket(this, ip, listenInfo->flags()); } this->udpSockets[udpSocket] = announcedIp; @@ -114,11 +114,11 @@ namespace RTC if (listenInfo->port() != 0) { - tcpServer = new RTC::TcpServer(this, this, ip, listenInfo->port()); + tcpServer = new RTC::TcpServer(this, this, ip, listenInfo->port(), listenInfo->flags()); } else { - tcpServer = new RTC::TcpServer(this, this, ip); + tcpServer = new RTC::TcpServer(this, this, ip, listenInfo->flags()); } this->tcpServers[tcpServer] = announcedIp;