diff options
author | Vladislav Grigoryev <vg.aetera@gmail.com> | 2021-09-04 00:24:48 +0300 |
---|---|---|
committer | Vladislav Grigoryev <vg.aetera@gmail.com> | 2021-09-04 15:51:11 +0300 |
commit | 0be0f069077fb01038b34446afea510d26b8782e (patch) | |
tree | 3f04152ccaaa48c7c4c2af4d26c17468678c71a1 /modules/luci-mod-network/htdocs | |
parent | 4f7db0e2ec3016e01b9308fe68c4680c04250adb (diff) |
luci-mod-network: fix route and rule options
Allow adding routes with unspecified interface.
This is required for prohibit, blackhole and unreachable routes.
Allow adding routes with loopback interface.
This can work as a blackhole route.
Fix netmask to prefix conversion for the routes.
Identify the IP family by the UCI section type.
Avoid setting the routing table textvalue for the rules.
The rules should target none table unless specified otherwise.
Signed-off-by: Vladislav Grigoryev <vg.aetera@gmail.com>
Diffstat (limited to 'modules/luci-mod-network/htdocs')
-rw-r--r-- | modules/luci-mod-network/htdocs/luci-static/resources/view/network/routes.js | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/routes.js b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/routes.js index f19a5b41cf..701f16c75f 100644 --- a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/routes.js +++ b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/routes.js @@ -39,7 +39,7 @@ return view.extend({ s.tab('advanced', _('Advanced Settings')); o = s.taboption('general', widgets.NetworkSelect, 'interface', _('Interface')); - o.rmempty = false; + o.loopback = true; o.nocreate = true; o = s.taboption('general', form.ListValue, 'type', _('Route type')); @@ -58,12 +58,13 @@ return view.extend({ o.datatype = (family == 6) ? 'cidr6' : 'cidr4'; o.placeholder = (family == 6) ? '::/0' : '0.0.0.0/0'; o.cfgvalue = function(section_id) { - var t = uci.get('network', section_id, 'target'), - m = uci.get('network', section_id, 'netmask'), - s = (family == 6) ? 128 : 32, - p = m ? network.maskToPrefix(m, (family == 6) ? true : false) : s; - if (t) { - return t.split('/')[1] ? t : t + '/' + p; + var section_type = uci.get('network', section_id, '.type'), + target = uci.get('network', section_id, 'target'), + mask = uci.get('network', section_id, 'netmask'), + v6 = (section_type == 'route6') ? true : false, + bits = mask ? network.maskToPrefix(mask, v6) : (v6 ? 128 : 32); + if (target) { + return target.split('/')[1] ? target : target + '/' + bits; } } o.write = function(section_id, formvalue) { @@ -166,9 +167,6 @@ return view.extend({ o.datatype = 'or(uinteger, string)'; for (var i = 0; i < rtTables.length; i++) o.value(rtTables[i][1], '%s (%d)'.format(rtTables[i][1], rtTables[i][0])); - o.textvalue = function(section_id) { - return this.cfgvalue(section_id) || 'main'; - }; o = s.taboption('advanced', form.Value, 'goto', _('Jump to rule')); o.modalonly = true; |