Skip to content

Commit

Permalink
Do not include network aliases (identified by same MAC) (#370)
Browse files Browse the repository at this point in the history
* Do not include network aliases (identified by same MAC)

* Update lib/server.ts

Co-authored-by: Jan Romann <[email protected]>

* Update lib/server.ts

Co-authored-by: Jan Romann <[email protected]>

* Update server.ts

---------

Co-authored-by: Jan Romann <[email protected]>
  • Loading branch information
htool and JKRhb authored Jun 4, 2024
1 parent 2dbe4da commit 0ac5017
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
})
}
Expand Down

0 comments on commit 0ac5017

Please sign in to comment.