@riddix/hamh 2.1.0-alpha.714 → 2.1.0-alpha.716

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.
@@ -127638,6 +127638,10 @@ function isLinkLocal(family, address) {
127638
127638
  if (family === "IPv4") return address.startsWith("169.254.");
127639
127639
  return address.toLowerCase().startsWith("fe80");
127640
127640
  }
127641
+ function isLinkLocalOrUla(address) {
127642
+ const a = address.toLowerCase();
127643
+ return /^fe[89ab]/.test(a) || /^f[cd]/.test(a);
127644
+ }
127641
127645
  function selectMdnsInterface(raw) {
127642
127646
  const external = [];
127643
127647
  const dockerLike = [];
@@ -129322,26 +129326,51 @@ var BetterLogger = class _BetterLogger extends Logger {
129322
129326
 
129323
129327
  // src/core/app/mdns.ts
129324
129328
  init_esm();
129329
+ init_esm7();
129325
129330
  import * as os5 from "node:os";
129326
129331
 
129327
129332
  // ../../node_modules/.pnpm/@matter+main@0.17.0/node_modules/@matter/main/dist/esm/protocol.js
129328
129333
  init_nodejs();
129329
129334
  init_esm4();
129330
129335
 
129336
+ // src/core/app/filtered-network.ts
129337
+ init_esm6();
129338
+ function filterAdvertisedIpv6(ipV6) {
129339
+ const local = ipV6.filter(isLinkLocalOrUla);
129340
+ return local.length > 0 ? local : [...ipV6];
129341
+ }
129342
+ var FilteredNetwork = class extends NodeJsNetwork {
129343
+ getIpMac(netInterface) {
129344
+ const details = super.getIpMac(netInterface);
129345
+ if (!details) return details;
129346
+ return { ...details, ipV6: filterAdvertisedIpv6(details.ipV6) };
129347
+ }
129348
+ };
129349
+
129331
129350
  // src/core/app/mdns.ts
129332
129351
  var logger168 = Logger.get("Mdns");
129333
129352
  function mdns(env, options) {
129334
- if (!options.networkInterface) {
129335
- warnIfMisadvertising();
129353
+ if (options.stripGlobalIpv6) {
129354
+ env.set(Network, new FilteredNetwork());
129355
+ } else {
129356
+ warnAboutAdvertising(options);
129336
129357
  }
129337
129358
  new MdnsService(env, {
129338
129359
  ipv4: options.ipv4,
129339
129360
  networkInterface: options.networkInterface
129340
129361
  });
129341
129362
  }
129342
- function warnIfMisadvertising() {
129363
+ function warnAboutAdvertising(options) {
129343
129364
  const choice = selectMdnsInterface(os5.networkInterfaces());
129344
- if (!choice.suspicious) {
129365
+ const hasGlobalIpv6 = choice.external.some(
129366
+ (i) => i.ipv6.some((a) => !isLinkLocalOrUla(a))
129367
+ );
129368
+ if (hasGlobalIpv6) {
129369
+ logger168.warn(
129370
+ "Matter mDNS is advertising a global IPv6 address that controllers may not reach on the LAN, so devices can show No Response (#361). Set mdns-strip-global-ipv6 if devices stay unreachable."
129371
+ );
129372
+ }
129373
+ if (options.networkInterface || !choice.suspicious) {
129345
129374
  return;
129346
129375
  }
129347
129376
  const suggestion = choice.selected ? ` Likely LAN interface: ${choice.selected}.` : "";
@@ -129433,7 +129462,8 @@ var Options = class {
129433
129462
  get mdns() {
129434
129463
  return {
129435
129464
  ipv4: true,
129436
- networkInterface: notEmpty(this.startOptions.mdnsNetworkInterface)
129465
+ networkInterface: notEmpty(this.startOptions.mdnsNetworkInterface),
129466
+ stripGlobalIpv6: this.startOptions.mdnsStripGlobalIpv6 ?? false
129437
129467
  };
129438
129468
  }
129439
129469
  get logging() {
@@ -164003,6 +164033,10 @@ function startOptionsBuilder(yargs2) {
164003
164033
  }).option("mdns-network-interface", {
164004
164034
  type: "string",
164005
164035
  description: "Limit mDNS to this network interface"
164036
+ }).option("mdns-strip-global-ipv6", {
164037
+ type: "boolean",
164038
+ default: false,
164039
+ description: "Drop global IPv6 (GUA) from mDNS so controllers use a locally reachable address (#361)"
164006
164040
  }).option("home-assistant-url", {
164007
164041
  type: "string",
164008
164042
  description: "The HTTP-URL of your Home Assistant URL"