luci-mod-network: restrict peerdns option to protocols that implemenent it
authorJo-Philipp Wich <[email protected]>
Tue, 15 Nov 2022 00:44:28 +0000 (01:44 +0100)
committerJo-Philipp Wich <[email protected]>
Mon, 3 Apr 2023 11:45:03 +0000 (13:45 +0200)
Only some supported protocol extensions honour the `peerdns` options.

Fixes: #6093
Signed-off-by: Jo-Philipp Wich <[email protected]>
(cherry picked from commit 2be01cbfcb34746d9713173a60c3f8a69c554a68)

modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js

index d5f9060114958d05b53846e4c27628ecad505b5c..d44b0cf6d0d5d0e130565e64229610341e39651e 100644 (file)
@@ -228,6 +228,22 @@ function get_netmask(s, use_cfgvalue) {
        return subnetmask;
 }
 
+function has_peerdns(proto) {
+       switch (proto) {
+       case 'dhcp':
+       case 'qmi':
+       case 'ppp':
+       case 'pppoe':
+       case 'pppoa':
+       case 'pptp':
+       case 'openvpn':
+       case 'sstp':
+               return true;
+       }
+
+       return false;
+}
+
 var cbiRichListValue = form.ListValue.extend({
        renderWidget: function(section_id, option_index, cfgvalue) {
                var choices = this.transformChoices();
@@ -936,13 +952,13 @@ return view.extend({
                                o = nettools.replaceOption(s, 'advanced', form.Flag, 'defaultroute', _('Use default gateway'), _('If unchecked, no default route is configured'));
                                o.default = o.enabled;
 
-                               if (protoval != 'static') {
+                               if (has_peerdns(protoval)) {
                                        o = nettools.replaceOption(s, 'advanced', form.Flag, 'peerdns', _('Use DNS servers advertised by peer'), _('If unchecked, the advertised DNS server addresses are ignored'));
                                        o.default = o.enabled;
                                }
 
                                o = nettools.replaceOption(s, 'advanced', form.DynamicList, 'dns', _('Use custom DNS servers'));
-                               if (protoval != 'static')
+                               if (has_peerdns(protoval))
                                        o.depends('peerdns', '0');
                                o.datatype = 'ipaddr';