mediasoup 3.20.1 → 3.20.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/node/lib/DataConsumer.d.ts +2 -3
- package/node/lib/DataConsumer.d.ts.map +1 -1
- package/node/lib/DataConsumer.js +8 -6
- package/node/lib/DataConsumerTypes.d.ts +5 -4
- package/node/lib/DataConsumerTypes.d.ts.map +1 -1
- package/node/lib/fbs/data-consumer/send-response.d.ts +21 -0
- package/node/lib/fbs/data-consumer/send-response.d.ts.map +1 -0
- package/node/lib/fbs/data-consumer/send-response.js +91 -0
- package/node/lib/fbs/data-consumer.d.ts +1 -0
- package/node/lib/fbs/data-consumer.d.ts.map +1 -1
- package/node/lib/fbs/data-consumer.js +4 -1
- package/node/lib/fbs/response/body.d.ts +7 -5
- package/node/lib/fbs/response/body.d.ts.map +1 -1
- package/node/lib/fbs/response/body.js +7 -3
- package/node/lib/fbs/response/response.d.ts +3 -2
- package/node/lib/fbs/response/response.d.ts.map +1 -1
- package/node/lib/test/test-DataConsumer.js +6 -0
- package/node/lib/test/test-werift-sctp.js +7 -0
- package/package.json +4 -4
- package/worker/Makefile +5 -1
- package/worker/fbs/dataConsumer.fbs +4 -0
- package/worker/fbs/response.fbs +1 -0
- package/worker/include/RTC/PortManager.hpp +91 -11
- package/worker/include/RTC/TcpServer.hpp +3 -2
- package/worker/include/RTC/UdpSocket.hpp +3 -2
- package/worker/meson.build +1 -0
- package/worker/src/RTC/DataConsumer.cpp +12 -2
- package/worker/src/RTC/PipeTransport.cpp +5 -4
- package/worker/src/RTC/PlainTransport.cpp +9 -8
- package/worker/src/RTC/PortManager.cpp +174 -114
- package/worker/src/RTC/SCTP/association/Association.cpp +17 -14
- package/worker/src/RTC/TcpServer.cpp +4 -4
- package/worker/src/RTC/Transport.cpp +33 -10
- package/worker/src/RTC/UdpSocket.cpp +4 -4
- package/worker/src/RTC/WebRtcServer.cpp +8 -8
- package/worker/src/RTC/WebRtcTransport.cpp +9 -8
- package/worker/tasks.py +293 -196
- package/worker/test/src/RTC/TestNackGenerator.cpp +1 -1
- package/worker/test/src/RTC/TestPortManager.cpp +126 -0
- package/worker/test/src/RTC/TestTransportTuple.cpp +3 -2
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
#include "common.hpp"
|
|
2
|
+
#include "RTC/PortManager.hpp"
|
|
3
|
+
#include <catch2/catch_test_macros.hpp>
|
|
4
|
+
#include <cstring>
|
|
5
|
+
|
|
6
|
+
// Pre-fix issue #1805: The legacy `GeneratePortRangeHash()` mangled the IPv4
|
|
7
|
+
// address with `(address >> 2) << 2`, so any two IPv4 addresses in the same
|
|
8
|
+
// /30 block produced the same `uint64_t` hash. The downstream
|
|
9
|
+
// `mapPortRanges.find(hash)` then treated them as the same PortRange and
|
|
10
|
+
// merged unrelated bindings. This scenario locks down the post-fix
|
|
11
|
+
// behavior: distinct tuples produce distinct keys, equal tuples produce equal
|
|
12
|
+
// keys.
|
|
13
|
+
SCENARIO("PortManager", "[rtc][portmanager]")
|
|
14
|
+
{
|
|
15
|
+
// Helper: build an IPv4 `sockaddr_storage` from a dotted-quad string + port=0.
|
|
16
|
+
auto makeV4 = [](const char* dottedQuad)
|
|
17
|
+
{
|
|
18
|
+
sockaddr_storage ss{};
|
|
19
|
+
auto* in = reinterpret_cast<sockaddr_in*>(std::addressof(ss));
|
|
20
|
+
|
|
21
|
+
in->sin_family = AF_INET;
|
|
22
|
+
in->sin_port = 0;
|
|
23
|
+
|
|
24
|
+
REQUIRE(inet_pton(AF_INET, dottedQuad, &in->sin_addr) == 1);
|
|
25
|
+
|
|
26
|
+
return ss;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// Helper: build an IPv6 `sockaddr_storage` from a textual address + port=0.
|
|
30
|
+
auto makeV6 = [](const char* literal)
|
|
31
|
+
{
|
|
32
|
+
sockaddr_storage ss{};
|
|
33
|
+
auto* in6 = reinterpret_cast<sockaddr_in6*>(std::addressof(ss));
|
|
34
|
+
|
|
35
|
+
in6->sin6_family = AF_INET6;
|
|
36
|
+
in6->sin6_port = 0;
|
|
37
|
+
|
|
38
|
+
REQUIRE(inet_pton(AF_INET6, literal, &in6->sin6_addr) == 1);
|
|
39
|
+
|
|
40
|
+
return ss;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
SECTION("identical tuples compare equal and hash equal")
|
|
44
|
+
{
|
|
45
|
+
const auto addr = makeV4("192.168.1.10");
|
|
46
|
+
|
|
47
|
+
const RTC::PortManager::PortRangeKey ka(RTC::PortManager::Protocol::UDP, addr, 40000u, 40099u);
|
|
48
|
+
const RTC::PortManager::PortRangeKey kb(RTC::PortManager::Protocol::UDP, addr, 40000u, 40099u);
|
|
49
|
+
|
|
50
|
+
REQUIRE(ka == kb);
|
|
51
|
+
REQUIRE(RTC::PortManager::PortRangeKeyHash{}(ka) == RTC::PortManager::PortRangeKeyHash{}(kb));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
SECTION("IPv4 addresses in the same /30 are NOT collapsed")
|
|
55
|
+
{
|
|
56
|
+
// 192.168.1.0 / .1 / .2 / .3 all live in 192.168.1.0/30. The old
|
|
57
|
+
// GeneratePortRangeHash dropped the bottom two bits of the address,
|
|
58
|
+
// merging all four into one bucket.
|
|
59
|
+
const auto a0 = makeV4("192.168.1.0");
|
|
60
|
+
const auto a1 = makeV4("192.168.1.1");
|
|
61
|
+
const auto a2 = makeV4("192.168.1.2");
|
|
62
|
+
const auto a3 = makeV4("192.168.1.3");
|
|
63
|
+
|
|
64
|
+
const RTC::PortManager::PortRangeKey k0(RTC::PortManager::Protocol::UDP, a0, 40000u, 40099u);
|
|
65
|
+
const RTC::PortManager::PortRangeKey k1(RTC::PortManager::Protocol::UDP, a1, 40000u, 40099u);
|
|
66
|
+
const RTC::PortManager::PortRangeKey k2(RTC::PortManager::Protocol::UDP, a2, 40000u, 40099u);
|
|
67
|
+
const RTC::PortManager::PortRangeKey k3(RTC::PortManager::Protocol::UDP, a3, 40000u, 40099u);
|
|
68
|
+
|
|
69
|
+
REQUIRE(k0 != k1);
|
|
70
|
+
REQUIRE(k0 != k2);
|
|
71
|
+
REQUIRE(k0 != k3);
|
|
72
|
+
REQUIRE(k1 != k2);
|
|
73
|
+
REQUIRE(k1 != k3);
|
|
74
|
+
REQUIRE(k2 != k3);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// The old IPv6 hash folded `a[0] ^ a[1] ^ a[2] ^ a[3]` (4 x uint32_t) into
|
|
78
|
+
// 32 bits. Any two IPv6 addresses where the four 32-bit words XOR to the
|
|
79
|
+
// same value collided. Easiest collision constructor: swap two words.
|
|
80
|
+
// ::1 = 0000:0000:0000:0000:0000:0000:0000:0001 XOR-folds the same as
|
|
81
|
+
// ::1:0:0 (just word reorder).
|
|
82
|
+
SECTION("IPv6 addresses that XOR-fold to the same value are NOT collapsed")
|
|
83
|
+
{
|
|
84
|
+
const auto a = makeV6("::1");
|
|
85
|
+
const auto b = makeV6("1::1:0:0:0");
|
|
86
|
+
|
|
87
|
+
const RTC::PortManager::PortRangeKey ka(RTC::PortManager::Protocol::UDP, a, 40000u, 40099u);
|
|
88
|
+
const RTC::PortManager::PortRangeKey kb(RTC::PortManager::Protocol::UDP, b, 40000u, 40099u);
|
|
89
|
+
|
|
90
|
+
REQUIRE(ka != kb);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
SECTION("protocol differentiates the key (UDP/TCP on same address+range)")
|
|
94
|
+
{
|
|
95
|
+
const auto addr = makeV4("10.0.0.1");
|
|
96
|
+
|
|
97
|
+
const RTC::PortManager::PortRangeKey udp(RTC::PortManager::Protocol::UDP, addr, 40000u, 40099u);
|
|
98
|
+
const RTC::PortManager::PortRangeKey tcp(RTC::PortManager::Protocol::TCP, addr, 40000u, 40099u);
|
|
99
|
+
|
|
100
|
+
REQUIRE(udp != tcp);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
SECTION("port-range bounds differentiate the key")
|
|
104
|
+
{
|
|
105
|
+
const auto addr = makeV4("10.0.0.1");
|
|
106
|
+
|
|
107
|
+
const RTC::PortManager::PortRangeKey ka(RTC::PortManager::Protocol::UDP, addr, 40000u, 40099u);
|
|
108
|
+
const RTC::PortManager::PortRangeKey kb(RTC::PortManager::Protocol::UDP, addr, 40000u, 40100u);
|
|
109
|
+
const RTC::PortManager::PortRangeKey kc(RTC::PortManager::Protocol::UDP, addr, 40001u, 40099u);
|
|
110
|
+
|
|
111
|
+
REQUIRE(ka != kb);
|
|
112
|
+
REQUIRE(ka != kc);
|
|
113
|
+
REQUIRE(kb != kc);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
SECTION("family differentiates the key")
|
|
117
|
+
{
|
|
118
|
+
const auto v4 = makeV4("0.0.0.0");
|
|
119
|
+
const auto v6 = makeV6("::");
|
|
120
|
+
|
|
121
|
+
const RTC::PortManager::PortRangeKey k4(RTC::PortManager::Protocol::UDP, v4, 40000u, 40099u);
|
|
122
|
+
const RTC::PortManager::PortRangeKey k6(RTC::PortManager::Protocol::UDP, v6, 40000u, 40099u);
|
|
123
|
+
|
|
124
|
+
REQUIRE(k4 != k6);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#include "common.hpp"
|
|
2
|
+
#include "RTC/PortManager.hpp"
|
|
2
3
|
#include "RTC/Transport.hpp"
|
|
3
4
|
#include "RTC/TransportTuple.hpp"
|
|
4
5
|
#include "RTC/UdpSocket.hpp"
|
|
@@ -24,9 +25,9 @@ SCENARIO("TransportTuple", "[transport-tuple]")
|
|
|
24
25
|
{
|
|
25
26
|
UdpSocketListener listener;
|
|
26
27
|
auto flags = RTC::Transport::SocketFlags{ .ipv6Only = false, .udpReusePort = false };
|
|
27
|
-
|
|
28
|
+
RTC::PortManager::PortRangeKey portRangeKey{};
|
|
28
29
|
auto* udpSocket = new RTC::UdpSocket(
|
|
29
|
-
std::addressof(listener), const_cast<std::string&>(ip), minPort, maxPort, flags,
|
|
30
|
+
std::addressof(listener), const_cast<std::string&>(ip), minPort, maxPort, flags, portRangeKey);
|
|
30
31
|
|
|
31
32
|
return std::unique_ptr<RTC::UdpSocket>(udpSocket);
|
|
32
33
|
};
|