node-rtc-connection 1.0.8 → 1.0.10
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/dist/index.cjs
CHANGED
|
@@ -1497,12 +1497,19 @@ function requireICEGatherer () {
|
|
|
1497
1497
|
|
|
1498
1498
|
for (const [name, addrs] of Object.entries(interfaces)) {
|
|
1499
1499
|
for (const addr of addrs) {
|
|
1500
|
-
// Skip internal
|
|
1501
|
-
if (addr.internal
|
|
1500
|
+
// Skip internal/loopback addresses
|
|
1501
|
+
if (addr.internal) {
|
|
1502
1502
|
continue;
|
|
1503
1503
|
}
|
|
1504
1504
|
|
|
1505
|
-
|
|
1505
|
+
// Support both IPv4 and IPv6
|
|
1506
|
+
if (addr.family !== 'IPv4' && addr.family !== 'IPv6') {
|
|
1507
|
+
continue;
|
|
1508
|
+
}
|
|
1509
|
+
|
|
1510
|
+
// Calculate priority (IPv4 slightly higher than IPv6)
|
|
1511
|
+
const typePreference = addr.family === 'IPv4' ? 65535 : 65534;
|
|
1512
|
+
const priority = this._calculatePriority('host', typePreference, foundation);
|
|
1506
1513
|
|
|
1507
1514
|
candidates.push({
|
|
1508
1515
|
candidate: `candidate:${foundation} 1 udp ${priority} ${addr.address} ${port} typ host`,
|
|
@@ -1600,7 +1607,7 @@ function requireICEGatherer () {
|
|
|
1600
1607
|
_getLocalIPForRemote() {
|
|
1601
1608
|
const interfaces = os.networkInterfaces();
|
|
1602
1609
|
|
|
1603
|
-
// Prefer non-internal IPv4 addresses
|
|
1610
|
+
// Prefer non-internal IPv4 addresses first
|
|
1604
1611
|
for (const [name, addrs] of Object.entries(interfaces)) {
|
|
1605
1612
|
for (const addr of addrs) {
|
|
1606
1613
|
if (!addr.internal && addr.family === 'IPv4') {
|
|
@@ -1609,6 +1616,15 @@ function requireICEGatherer () {
|
|
|
1609
1616
|
}
|
|
1610
1617
|
}
|
|
1611
1618
|
|
|
1619
|
+
// Fall back to IPv6 if no IPv4 available
|
|
1620
|
+
for (const [name, addrs] of Object.entries(interfaces)) {
|
|
1621
|
+
for (const addr of addrs) {
|
|
1622
|
+
if (!addr.internal && addr.family === 'IPv6') {
|
|
1623
|
+
return addr.address;
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
|
|
1612
1628
|
return '0.0.0.0';
|
|
1613
1629
|
}
|
|
1614
1630
|
|
|
@@ -3102,7 +3118,7 @@ a=max-message-size:262144
|
|
|
3102
3118
|
_getLocalIPAddress() {
|
|
3103
3119
|
const interfaces = os.networkInterfaces();
|
|
3104
3120
|
|
|
3105
|
-
// Try to find a non-internal IPv4 address
|
|
3121
|
+
// Try to find a non-internal IPv4 address first
|
|
3106
3122
|
for (const name of Object.keys(interfaces)) {
|
|
3107
3123
|
for (const iface of interfaces[name]) {
|
|
3108
3124
|
if (iface.family === 'IPv4' && !iface.internal) {
|
|
@@ -3111,6 +3127,15 @@ a=max-message-size:262144
|
|
|
3111
3127
|
}
|
|
3112
3128
|
}
|
|
3113
3129
|
|
|
3130
|
+
// Fall back to IPv6 if no IPv4 available
|
|
3131
|
+
for (const name of Object.keys(interfaces)) {
|
|
3132
|
+
for (const iface of interfaces[name]) {
|
|
3133
|
+
if (iface.family === 'IPv6' && !iface.internal) {
|
|
3134
|
+
return iface.address;
|
|
3135
|
+
}
|
|
3136
|
+
}
|
|
3137
|
+
}
|
|
3138
|
+
|
|
3114
3139
|
// Fallback to localhost
|
|
3115
3140
|
return '127.0.0.1';
|
|
3116
3141
|
}
|