Skip to content

Commit

Permalink
fix: local addresses should be ignored on interface (#32)
Browse files Browse the repository at this point in the history
Co-authored-by: Jonathan Kelley <jkelley@cloudflare.com>
  • Loading branch information
jkelleyrtp and Jonathan Kelley authored Sep 13, 2022
1 parent 823b70c commit c316a04
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/address.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,13 @@ address.interface = function (family, name) {
}

if (noName) {
// filter 127.0.0.1, get the first ip
// filter all loopback or local addresses
for (var k in interfaces) {
var items = interfaces[k];
for (var i = 0; i < items.length; i++) {
var item = items[i];
if (matchName(item.family, family) && item.address !== '127.0.0.1') {
// all 127 addresses are local and should be ignored
if (matchName(item.family, family) && !item.address.startsWith('127.')) {
return item;
}
}
Expand Down

0 comments on commit c316a04

Please sign in to comment.