luci-mod-network: follow-up fix for 723507231566b61750e32284b49acdae0d0162d3
authorPaul Donald <newtwen+github@gmail.com>
Sun, 7 Apr 2024 01:30:56 +0000 (03:30 +0200)
committerPaul Donald <newtwen+github@gmail.com>
Sun, 7 Apr 2024 01:52:07 +0000 (03:52 +0200)
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>
modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js

index b826ccb09473698afa7f9590c468a21b38b3a58a..8825b5201cb06a0272837a7b9cda62b896039849 100644 (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;