Skip to content

Commit 93e5471

Browse files
committed
Fixed network discovery when multiple ipv6 addresses have to be skipped
1 parent 095972f commit 93e5471

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

Serverland/controller/Controller.js

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,23 +66,18 @@ module.exports = class Controller {
6666
var alias = 0;
6767

6868
ifaces[ifname].forEach(function (iface) {
69-
if ('IPv4' !== iface.family || iface.internal !== false) {
69+
if ('IPv4' !== iface.family || iface.internal !== false) {
7070
// skip over internal (i.e. 127.0.0.1) and non-ipv4 addresses
71+
alias++;
7172
return;
7273
}
7374

74-
if (alias >= 1) {
75-
// this single interface has multiple ipv4 addresses
76-
//console.log(ifname + ':' + alias, iface.address);
77-
} else {
78-
// this interface has only one ipv4 adress
79-
//console.log(ifname, iface.address, iface.netmask);
80-
if(searchIf == ""){
81-
searchIf = ifname;
82-
searchalias = alias+1;
83-
}
75+
// use first external ipv4 address found in interface
76+
// this may cause the wrong address to be selected if there are multiple ipv4 addresses in the interface
77+
if(searchIf == ""){
78+
searchIf = ifname;
79+
searchalias = alias;
8480
}
85-
++alias;
8681
});
8782
});
8883

0 commit comments

Comments
 (0)