Skip to content

Commit

Permalink
luci-mod-network: follow-up fix for 7235072
Browse files Browse the repository at this point in the history
add a null-check before parsing networks
loop through available networks on all interfaces except loopback

Closes openwrt#7047

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
  • Loading branch information
systemcrash committed Apr 7, 2024
1 parent 4ca87f6 commit 7fa789a
Showing 1 changed file with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -996,15 +996,19 @@ return view.extend({
for(var x of uci.get('system', 'ntp', 'server') || '') {
so.value(x);
}
var lan_net = this.networks.filter(function(n) { return n.getName() == 'lan' })[0];
// If ntpd is set up, suggest our IP(v6) also
if(uci.get('system', 'ntp', 'enable_server')) {
lan_net.getIPAddrs().forEach(function(i4) {
so.value(i4.split('/')[0]);
});
lan_net.getIP6Addrs().forEach(function(i6) {
so.value(i6.split('/')[0]);
});
var local_nets = this.networks.filter(function(n) { return n.getName() != 'loopback' });
if(local_nets) {
// If ntpd is set up, suggest our IP(v6) also
if(uci.get('system', 'ntp', 'enable_server')) {
local_nets.forEach(function(n){
n.getIPAddrs().forEach(function(i4) {
so.value(i4.split('/')[0]);
});
n.getIP6Addrs().forEach(function(i6) {
so.value(i6.split('/')[0]);
});
});
}
}
so.optional = true;
so.rmempty = true;
Expand Down

0 comments on commit 7fa789a

Please sign in to comment.