Skip to content

Commit c316a04

Browse files
jkelleyrtpJonathan Kelley
andauthored
fix: local addresses should be ignored on interface (#32)
Co-authored-by: Jonathan Kelley <jkelley@cloudflare.com>
1 parent 823b70c commit c316a04

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/address.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,13 @@ address.interface = function (family, name) {
8686
}
8787

8888
if (noName) {
89-
// filter 127.0.0.1, get the first ip
89+
// filter all loopback or local addresses
9090
for (var k in interfaces) {
9191
var items = interfaces[k];
9292
for (var i = 0; i < items.length; i++) {
9393
var item = items[i];
94-
if (matchName(item.family, family) && item.address !== '127.0.0.1') {
94+
// all 127 addresses are local and should be ignored
95+
if (matchName(item.family, family) && !item.address.startsWith('127.')) {
9596
return item;
9697
}
9798
}

0 commit comments

Comments
 (0)