diff --git a/src/lib/util/eventedhttp.ts b/src/lib/util/eventedhttp.ts index 7a96488d3..585a0cad7 100644 --- a/src/lib/util/eventedhttp.ts +++ b/src/lib/util/eventedhttp.ts @@ -713,7 +713,8 @@ export class HAPConnection extends EventEmitter { if (ipVersion === "ipv4") { for (const info of infos) { - if (info.family === "IPv4") { + // @ts-expect-error Nodejs 18+ uses the number 4 the string "IPv4" + if (info.family === "IPv4" || info.family === 4) { return info.address; } } @@ -723,7 +724,8 @@ export class HAPConnection extends EventEmitter { let localUniqueAddress: string | undefined = undefined; for (const info of infos) { - if (info.family === "IPv6") { + // @ts-expect-error Nodejs 18+ uses the number 6 instead of the string "IPv6" + if (info.family === "IPv6" || info.family === 6) { if (!info.scopeid) { return info.address; } else if (!localUniqueAddress) { diff --git a/src/lib/util/net-utils.ts b/src/lib/util/net-utils.ts index 63e10703d..0acc6a0a4 100644 --- a/src/lib/util/net-utils.ts +++ b/src/lib/util/net-utils.ts @@ -13,11 +13,13 @@ export function findLoopbackAddress(): string { } internal = true; - if (info.family === "IPv4") { + // @ts-expect-error Nodejs 18+ uses the number 4 the string "IPv4" + if (info.family === "IPv4" || info.family === 4) { if (!ipv4) { ipv4 = info.address; } - } else if (info.family === "IPv6") { + // @ts-expect-error Nodejs 18+ uses the number 6 the string "IPv6" + } else if (info.family === "IPv6" || info.family === 6) { if (info.scopeid) { if (!ipv6LinkLocal) { ipv6LinkLocal = info.address + "%" + name; // ipv6 link local addresses are only valid with a scope