@bulolo/hermes-link 0.2.7 → 0.2.8
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.
|
@@ -1462,29 +1462,20 @@ function normalizeLogLevel(level) {
|
|
|
1462
1462
|
return defaultLinkConfig.logLevel;
|
|
1463
1463
|
}
|
|
1464
1464
|
function normalizeLanHost(value) {
|
|
1465
|
-
if (value === null || value === void 0)
|
|
1466
|
-
|
|
1467
|
-
}
|
|
1468
|
-
if (typeof value !== "string") {
|
|
1469
|
-
return null;
|
|
1470
|
-
}
|
|
1465
|
+
if (value === null || value === void 0) return null;
|
|
1466
|
+
if (typeof value !== "string") return null;
|
|
1471
1467
|
const host = value.trim().replace(/^\[/u, "").replace(/\]$/u, "");
|
|
1472
|
-
if (!host)
|
|
1473
|
-
|
|
1474
|
-
}
|
|
1475
|
-
if (!isUsableLanIpv4(host)) {
|
|
1476
|
-
return null;
|
|
1477
|
-
}
|
|
1468
|
+
if (!host) return null;
|
|
1469
|
+
if (!isValidHostIpv4(host)) return null;
|
|
1478
1470
|
return host;
|
|
1479
1471
|
}
|
|
1480
|
-
function
|
|
1472
|
+
function isValidHostIpv4(value) {
|
|
1481
1473
|
const parts = value.split(".").map((part) => Number.parseInt(part, 10));
|
|
1482
1474
|
if (parts.length !== 4 || parts.some((part) => !Number.isInteger(part) || part < 0 || part > 255)) {
|
|
1483
1475
|
return false;
|
|
1484
1476
|
}
|
|
1485
|
-
const [
|
|
1486
|
-
|
|
1487
|
-
return privateRange && fourth !== 0 && fourth !== 255;
|
|
1477
|
+
const [, , , fourth] = parts;
|
|
1478
|
+
return fourth !== 0 && fourth !== 255;
|
|
1488
1479
|
}
|
|
1489
1480
|
|
|
1490
1481
|
// src/network/topology.ts
|
|
@@ -1517,7 +1508,7 @@ function discoverLanIpsFromInterfaces(interfaces) {
|
|
|
1517
1508
|
for (const [name, items] of Object.entries(interfaces)) {
|
|
1518
1509
|
if (shouldIgnoreInterface(name)) continue;
|
|
1519
1510
|
for (const item of items ?? []) {
|
|
1520
|
-
if (!item.internal && item.address && item.family === "IPv4" &&
|
|
1511
|
+
if (!item.internal && item.address && item.family === "IPv4" && isUsableLanIpv4(item.address, item.netmask)) {
|
|
1521
1512
|
candidates.push({ name, address: item.address });
|
|
1522
1513
|
}
|
|
1523
1514
|
}
|
|
@@ -1593,7 +1584,7 @@ function compareLanCandidate(left, right) {
|
|
|
1593
1584
|
function interfacePriority(name) {
|
|
1594
1585
|
return /^(en|eth|wlan|wi-fi|wifi)/iu.test(name) ? 0 : 1;
|
|
1595
1586
|
}
|
|
1596
|
-
function
|
|
1587
|
+
function isUsableLanIpv4(address, netmask) {
|
|
1597
1588
|
return isPrivateIpv4(address) && !isNetworkOrBroadcastIpv4Address(address, netmask);
|
|
1598
1589
|
}
|
|
1599
1590
|
function isUsablePublicIpv4(address) {
|
package/dist/cli/index.js
CHANGED
package/dist/http/app.js
CHANGED