From 29d710d38eaa46f507886f3f60e39004c4e78107 Mon Sep 17 00:00:00 2001 From: Ivan Matthew <76107136+Ivanmatthew@users.noreply.github.com> Date: Sun, 16 Apr 2023 20:31:48 +0000 Subject: [PATCH] Ignore virtual network switches (fixes issue #761) --- package.json | 2 +- source/utilities/http.ts | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 7ded4f52..2041a784 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "serve", - "version": "14.2.0", + "version": "14.2.1", "description": "Static file serving and directory listing", "keywords": [ "vercel", diff --git a/source/utilities/http.ts b/source/utilities/http.ts index 38bdb069..73e6f01d 100644 --- a/source/utilities/http.ts +++ b/source/utilities/http.ts @@ -31,13 +31,16 @@ export const registerCloseListener = (fn: () => void): void => { * @returns The address of the host. */ export const getNetworkAddress = (): string | undefined => { - for (const interfaceDetails of Object.values(networkInterfaces)) { + for (const name of Object.keys(networkInterfaces)) { + const interfaceDetails = networkInterfaces[name]; + if (!interfaceDetails) continue; for (const details of interfaceDetails) { const { address, family, internal } = details; - if (family === 'IPv4' && !internal) return address; + if (family === 'IPv4' && !internal && !name.startsWith('vEthernet')) + return address; } } };