luci-mod-network: follow-up fix for 7235072315

add a null-check before parsing networks
loop through available networks on all interfaces except loopback

Closes #7047

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
This commit is contained in:
Paul Donald 2024-04-07 03:30:56 +02:00
parent 4ca87f6576
commit 7fa789a13a

View File

@ -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;