node-rtc-connection 1.0.8 → 1.0.11
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/dist/index.cjs +30 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +30 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/ICEGatherer.js +20 -4
- package/src/NativePeerConnectionFactory.js +10 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-rtc-connection",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.11",
|
|
4
4
|
"description": "WebRTC DataChannel implementation for Node.js with STUN, TURN, NAT traversal, and encryption. Pure Node.js, no native dependencies.",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
package/src/ICEGatherer.js
CHANGED
|
@@ -64,12 +64,19 @@ class ICEGatherer {
|
|
|
64
64
|
|
|
65
65
|
for (const [name, addrs] of Object.entries(interfaces)) {
|
|
66
66
|
for (const addr of addrs) {
|
|
67
|
-
// Skip internal
|
|
68
|
-
if (addr.internal
|
|
67
|
+
// Skip internal/loopback addresses
|
|
68
|
+
if (addr.internal) {
|
|
69
69
|
continue;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
// Support both IPv4 and IPv6
|
|
73
|
+
if (addr.family !== 'IPv4' && addr.family !== 'IPv6') {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Calculate priority (IPv4 slightly higher than IPv6)
|
|
78
|
+
const typePreference = addr.family === 'IPv4' ? 65535 : 65534;
|
|
79
|
+
const priority = this._calculatePriority('host', typePreference, foundation);
|
|
73
80
|
|
|
74
81
|
candidates.push({
|
|
75
82
|
candidate: `candidate:${foundation} 1 udp ${priority} ${addr.address} ${port} typ host`,
|
|
@@ -167,7 +174,7 @@ class ICEGatherer {
|
|
|
167
174
|
_getLocalIPForRemote() {
|
|
168
175
|
const interfaces = os.networkInterfaces();
|
|
169
176
|
|
|
170
|
-
// Prefer non-internal IPv4 addresses
|
|
177
|
+
// Prefer non-internal IPv4 addresses first
|
|
171
178
|
for (const [name, addrs] of Object.entries(interfaces)) {
|
|
172
179
|
for (const addr of addrs) {
|
|
173
180
|
if (!addr.internal && addr.family === 'IPv4') {
|
|
@@ -176,6 +183,15 @@ class ICEGatherer {
|
|
|
176
183
|
}
|
|
177
184
|
}
|
|
178
185
|
|
|
186
|
+
// Fall back to IPv6 if no IPv4 available
|
|
187
|
+
for (const [name, addrs] of Object.entries(interfaces)) {
|
|
188
|
+
for (const addr of addrs) {
|
|
189
|
+
if (!addr.internal && addr.family === 'IPv6') {
|
|
190
|
+
return addr.address;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
179
195
|
return '0.0.0.0';
|
|
180
196
|
}
|
|
181
197
|
|
|
@@ -792,7 +792,7 @@ a=max-message-size:262144
|
|
|
792
792
|
_getLocalIPAddress() {
|
|
793
793
|
const interfaces = os.networkInterfaces();
|
|
794
794
|
|
|
795
|
-
// Try to find a non-internal IPv4 address
|
|
795
|
+
// Try to find a non-internal IPv4 address first
|
|
796
796
|
for (const name of Object.keys(interfaces)) {
|
|
797
797
|
for (const iface of interfaces[name]) {
|
|
798
798
|
if (iface.family === 'IPv4' && !iface.internal) {
|
|
@@ -801,6 +801,15 @@ a=max-message-size:262144
|
|
|
801
801
|
}
|
|
802
802
|
}
|
|
803
803
|
|
|
804
|
+
// Fall back to IPv6 if no IPv4 available
|
|
805
|
+
for (const name of Object.keys(interfaces)) {
|
|
806
|
+
for (const iface of interfaces[name]) {
|
|
807
|
+
if (iface.family === 'IPv6' && !iface.internal) {
|
|
808
|
+
return iface.address;
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
|
|
804
813
|
// Fallback to localhost
|
|
805
814
|
return '127.0.0.1';
|
|
806
815
|
}
|