luci-mod-network: follow-up fix for 723507231566b61750e32284b49acdae0d0162d3
[project/luci.git] / modules / luci-mod-network / htdocs / luci-static / resources / view / network / interfaces.js
index 3748f04b05fb5b9243741a6148d72a27ac526cc9..8825b5201cb06a0272837a7b9cda62b896039849 100644 (file)
@@ -245,6 +245,24 @@ function has_peerdns(proto) {
        return false;
 }
 
+function has_sourcefilter(proto) {
+       switch (proto) {
+       case '3g':
+       case 'dhcpv6':
+       case 'directip':
+       case 'mbim':
+       case 'ncm':
+       case 'ppp':
+       case 'pppoa':
+       case 'pppoe':
+       case 'pptp':
+       case 'qmi':
+               return true;
+       }
+
+       return false;
+}
+
 var cbiRichListValue = form.ListValue.extend({
        renderWidget: function(section_id, option_index, cfgvalue) {
                var choices = this.transformChoices();
@@ -484,7 +502,8 @@ return view.extend({
                s.load = function() {
                        return Promise.all([
                                network.getNetworks(),
-                               firewall.getZones()
+                               firewall.getZones(),
+                               uci.load('system')
                        ]).then(L.bind(function(data) {
                                this.networks = data[0];
                                this.zones = data[1];
@@ -537,6 +556,11 @@ return view.extend({
                                tdEl.lastChild.childNodes[3].disabled = true;
                        }
 
+                       if (dynamic) {
+                               //disable the 'Edit' button on dynamic interfaces
+                               tdEl.lastChild.childNodes[2].disabled = true;
+                       }
+
                        return tdEl;
                };
 
@@ -588,6 +612,10 @@ return view.extend({
                                o.nobridges = false;
                                o.optional = false;
                                o.network = ifc.getName();
+                               o.exclude = '@' + ifc.getName();
+
+                               o = s.taboption('general', form.Flag, 'disabled', _('Disable this interface'));
+                               o.modalonly = true;
 
                                o = s.taboption('general', form.Flag, 'auto', _('Bring up on boot'));
                                o.modalonly = true;
@@ -961,6 +989,31 @@ return view.extend({
                                        so.depends('dhcpv6', 'server');
                                        so.depends({ dhcpv6: 'hybrid', master: '0' });
 
+                                       //This is a DHCPv6 specific odhcpd setting
+                                       so = ss.taboption('ipv6', form.DynamicList, 'ntp', _('NTP Servers'),
+                                               _('DHCPv6 option 56. %s.', 'DHCPv6 option 56. RFC5908 link').format('<a href="%s" target="_blank">RFC5908</a>').format('https://www.rfc-editor.org/rfc/rfc5908#section-4'));
+                                       so.datatype = 'host(0)';
+                                       for(var x of uci.get('system', 'ntp', 'server') || '') {
+                                               so.value(x);
+                                       }
+                                       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;
+                                       so.depends('dhcpv6', 'server');
+                                       so.depends({ dhcpv6: 'hybrid', master: '0' });
 
                                        so = ss.taboption('ipv6', cbiRichListValue, 'ndp', _('<abbr title="Neighbour Discovery Protocol">NDP</abbr>-Proxy'),
                                                _('Configures the operation mode of the NDP proxy service on this interface.'));
@@ -1032,7 +1085,7 @@ return view.extend({
                                for (var i = 0; i < rtTables.length; i++)
                                        o.value(rtTables[i][1], '%s (%d)'.format(rtTables[i][1], rtTables[i][0]));
 
-                               if (protoval == 'dhcpv6') {
+                               if (has_sourcefilter(protoval)) {
                                        o = nettools.replaceOption(s, 'advanced', form.Flag, 'sourcefilter', _('IPv6 source routing'), _('Automatically handle multiple uplink interfaces using source-based policy routing.'));
                                        o.default = o.enabled;
                                }
@@ -1536,7 +1589,10 @@ return view.extend({
                s.addremove = false;
                s.anonymous = true;
 
-               o = s.option(form.Value, 'ula_prefix', _('IPv6 ULA-Prefix'), _('Unique Local Address - in the range <code>fc00::/7</code>.  Typically only within the &#8216;local&#8217; half <code>fd00::/8</code>. ULA for IPv6 is analogous to IPv4 private network addressing. This prefix is randomly generated at first install.'));
+               o = s.option(form.Value, 'ula_prefix', _('IPv6 ULA-Prefix'),
+                       _('Unique Local Address (%s) - prefix <code>fd00::/8</code> (the L bit is always 1).').format('<a href="%s" target="_blank">RFC4193</a>').format('https://datatracker.ietf.org/doc/html/rfc4193#section-3') + ' ' +
+                       _('ULA for IPv6 is analogous to IPv4 private network addressing.') + ' ' +
+                       _('This prefix is randomly generated at first install.'));
                o.datatype = 'cidr6';
 
                o = s.option(form.Flag, 'packet_steering', _('Packet Steering'), _('Enable packet steering across all CPUs. May help or hinder network speed.'));