From 0ac5017e605b7ab06a703a9b28a5f582b3217b93 Mon Sep 17 00:00:00 2001 From: Hans Date: Tue, 4 Jun 2024 10:28:47 +0200 Subject: [PATCH] Do not include network aliases (identified by same MAC) (#370) * Do not include network aliases (identified by same MAC) * Update lib/server.ts Co-authored-by: Jan Romann * Update lib/server.ts Co-authored-by: Jan Romann * Update server.ts --------- Co-authored-by: Jan Romann --- lib/server.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/server.ts b/lib/server.ts index 7578c112..56d325b7 100644 --- a/lib/server.ts +++ b/lib/server.ts @@ -64,12 +64,15 @@ function allAddresses (type): string[] { family = 'IPv6' } const addresses: string[] = [] + const macs: string[] = [] const interfaces = os.networkInterfaces() for (const ifname in interfaces) { if (ifname in interfaces) { interfaces[ifname]?.forEach((a) => { - if (a.family === family) { + // Checking for repeating MAC address to avoid trying to listen on same interface twice + if (a.family === family && !macs.includes(a.mac)) { addresses.push(a.address) + macs.push(a.mac) } }) }