diff options
Diffstat (limited to 'applications/luci-app-firewall/htdocs/luci-static')
5 files changed, 66 insertions, 26 deletions
diff --git a/applications/luci-app-firewall/htdocs/luci-static/resources/tools/firewall.js b/applications/luci-app-firewall/htdocs/luci-static/resources/tools/firewall.js index 32998c2ff8..ebdd345c98 100644 --- a/applications/luci-app-firewall/htdocs/luci-static/resources/tools/firewall.js +++ b/applications/luci-app-firewall/htdocs/luci-static/resources/tools/firewall.js @@ -425,11 +425,26 @@ return baseclass.extend({ opt.addChoices(choices[0], choices[1]); }, + CBIDynamicMultiValueList: form.DynamicList.extend({ + renderWidget: function(/* ... */) { + var dl = form.DynamicList.prototype.renderWidget.apply(this, arguments), + inst = dom.findClassInstance(dl); + + inst.addItem = function(dl, value, text, flash) { + var values = L.toArray(value); + for (var i = 0; i < values.length; i++) + ui.DynamicList.prototype.addItem.call(this, dl, values[i], null, true); + }; + + return dl; + } + }), + addIPOption: function(s, tab, name, label, description, family, hosts, multiple) { - var o = s.taboption(tab, multiple ? form.DynamicList : form.Value, name, label, description); + var o = s.taboption(tab, multiple ? this.CBIDynamicMultiValueList : form.Value, name, label, description); o.modalonly = true; - o.datatype = 'list(neg(ipmask))'; + o.datatype = 'list(neg(ipmask("true")))'; o.placeholder = multiple ? _('-- add IP --') : _('any'); if (family != null) { @@ -474,7 +489,7 @@ return baseclass.extend({ }, addMACOption: function(s, tab, name, label, description, hosts) { - var o = s.taboption(tab, form.DynamicList, name, label, description); + var o = s.taboption(tab, this.CBIDynamicMultiValueList, name, label, description); o.modalonly = true; o.datatype = 'list(macaddr)'; @@ -522,6 +537,9 @@ return baseclass.extend({ } }, this)); + if (cfgvalue == '*' || cfgvalue == 'any' || cfgvalue == 'all') + cfgvalue = 'all'; + return cfgvalue; }, diff --git a/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/forwards.js b/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/forwards.js index 82703c320e..1c8c806562 100644 --- a/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/forwards.js +++ b/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/forwards.js @@ -201,7 +201,7 @@ return view.extend({ o = fwtool.addIPOption(s, 'advanced', 'src_ip', _('Source IP address'), _('Only match incoming traffic from this IP or range.'), 'ipv4', hosts); o.rmempty = true; - o.datatype = 'neg(ipmask4)'; + o.datatype = 'neg(ipmask4("true"))'; o = s.taboption('advanced', form.Value, 'src_port', _('Source port'), _('Only match incoming traffic originating from the given source port or port range on the client host')); @@ -214,7 +214,7 @@ return view.extend({ o = fwtool.addLocalIPOption(s, 'advanced', 'src_dip', _('External IP address'), _('Only match incoming traffic directed at the given IP address.'), devs); - o.datatype = 'neg(ipmask4)'; + o.datatype = 'neg(ipmask4("true"))'; o.rmempty = true; o = s.taboption('general', form.Value, 'src_dport', _('External port'), diff --git a/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/rules.js b/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/rules.js index 8cb1a1242b..df49dcf80c 100644 --- a/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/rules.js +++ b/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/rules.js @@ -193,13 +193,8 @@ return view.extend({ s.handleAdd = function(ev) { var config_name = this.uciconfig || this.map.config, section_id = uci.add(config_name, this.sectiontype), - opt1, opt2; - - for (var i = 0; i < this.children.length; i++) - if (this.children[i].option == 'src') - opt1 = this.children[i]; - else if (this.children[i].option == 'dest') - opt2 = this.children[i]; + opt1 = this.getOption('src'), + opt2 = this.getOption('dest'); opt1.default = 'wan'; opt2.default = 'lan'; @@ -236,7 +231,19 @@ return view.extend({ o.modalonly = false; o.default = o.enabled; o.editable = true; + o.tooltip = function(section_id) { + var weekdays = uci.get('firewall', section_id, 'weekdays'); + var monthdays = uci.get('firewall', section_id, 'monthdays'); + var start_time = uci.get('firewall', section_id, 'start_time'); + var stop_time = uci.get('firewall', section_id, 'stop_time'); + var start_date = uci.get('firewall', section_id, 'start_date'); + var stop_date = uci.get('firewall', section_id, 'stop_date'); + + if (weekdays || monthdays || start_time || stop_time || start_date || stop_date ) + return _('Time restritions are enabled for this rule'); + return null; + }; o = s.taboption('advanced', form.ListValue, 'direction', _('Match device')); o.modalonly = true; @@ -308,6 +315,7 @@ return view.extend({ o.value('network-redirect'); o.value('network-unknown'); o.value('network-unreachable'); + o.value('packet-too-big'); o.value('parameter-problem'); o.value('port-unreachable'); o.value('precedence-cutoff'); diff --git a/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/snats.js b/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/snats.js index 859dba3e88..ce65fc7839 100644 --- a/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/snats.js +++ b/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/snats.js @@ -180,7 +180,7 @@ return view.extend({ o = fwtool.addIPOption(s, 'general', 'src_ip', _('Source address'), _('Match forwarded traffic from this IP or range.'), 'ipv4', hosts); o.rmempty = true; - o.datatype = 'neg(ipmask4)'; + o.datatype = 'neg(ipmask4("true"))'; o = s.taboption('general', form.Value, 'src_port', _('Source port'), _('Match forwarded traffic originating from the given source port or port range.')); @@ -194,7 +194,7 @@ return view.extend({ o = fwtool.addIPOption(s, 'general', 'dest_ip', _('Destination address'), _('Match forwarded traffic directed at the given IP address.'), 'ipv4', hosts); o.rmempty = true; - o.datatype = 'neg(ipmask4)'; + o.datatype = 'neg(ipmask4("true"))'; o = s.taboption('general', form.Value, 'dest_port', _('Destination port'), _('Match forwarded traffic directed at the given destination port or port range.')); @@ -217,9 +217,8 @@ return view.extend({ o.placeholder = null; o.depends('target', 'SNAT'); o.validate = function(section_id, value) { - var port = this.map.lookupOption('snat_port', section_id), - a = this.formvalue(section_id), - p = port ? port[0].formvalue(section_id) : null; + var a = this.formvalue(section_id), + p = this.section.formvalue(section_id, 'snat_port'); if ((a == null || a == '') && (p == null || p == '') && value == '') return _('A rewrite IP must be specified!'); diff --git a/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/zones.js b/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/zones.js index b24521e1ee..f9d84bfb67 100644 --- a/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/zones.js +++ b/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/zones.js @@ -158,6 +158,14 @@ return view.extend({ o = s.taboption('general', form.Flag, 'masq', _('Masquerading')); o.editable = true; + o.tooltip = function(section_id) { + var masq_src = uci.get('firewall', section_id, 'masq_src') + var masq_dest = uci.get('firewall', section_id, 'masq_dest') + if (masq_src || masq_dest) + return _('Limited masquerading enabled'); + + return null; + }; o = s.taboption('general', form.Flag, 'mtu_fix', _('MSS clamping')); o.modalonly = true; @@ -170,25 +178,32 @@ return view.extend({ }; o.write = function(section_id, formvalue) { var name = uci.get('firewall', section_id, 'name'), - cfgvalue = this.cfgvalue(section_id); + cfgvalue = this.cfgvalue(section_id), + oldNetworks = L.toArray(cfgvalue), + newNetworks = L.toArray(formvalue); - if (typeof(cfgvalue) == 'string' && Array.isArray(formvalue) && (cfgvalue == formvalue.join(' '))) + oldNetworks.sort(); + newNetworks.sort(); + + if (oldNetworks.join(' ') == newNetworks.join(' ')) return; var tasks = [ firewall.getZone(name) ]; if (Array.isArray(formvalue)) - for (var i = 0; i < formvalue.length; i++) { - var netname = formvalue[i]; - tasks.push(network.getNetwork(netname).then(function(net) { + for (var i = 0; i < newNetworks.length; i++) { + var netname = newNetworks[i]; + tasks.push(network.getNetwork(netname).then(L.bind(function(netname, net) { return net || network.addNetwork(netname, { 'proto': 'none' }); - })); + }, this, netname))); } return Promise.all(tasks).then(function(zone_networks) { - if (zone_networks[0]) + if (zone_networks[0]) { + zone_networks[0].clearNetworks(); for (var i = 1; i < zone_networks.length; i++) zone_networks[0].addNetwork(zone_networks[i].getName()); + } }); }; @@ -209,7 +224,7 @@ return view.extend({ o.multiple = true; o = s.taboption('advanced', form.DynamicList, 'subnet', _('Covered subnets'), _('Use this option to classify zone traffic by source or destination subnet instead of networks or devices.')); - o.datatype = 'neg(cidr)'; + o.datatype = 'neg(cidr("true"))'; o.modalonly = true; o.multiple = true; @@ -244,7 +259,7 @@ return view.extend({ o.depends('auto_helper', '0'); o.modalonly = true; for (var i = 0; i < ctHelpers.length; i++) - o.value(ctHelpers[i].name, '<span class="hide-close">%s (%s)</span><span class="hide-open">%s</span>'.format(ctHelpers[i].description, ctHelpers[i].name.toUpperCase(), ctHelpers[i].name.toUpperCase())); + o.value(ctHelpers[i].name, E('<span><span class="hide-close">%s (%s)</span><span class="hide-open">%s</span></span>'.format(ctHelpers[i].description, ctHelpers[i].name.toUpperCase(), ctHelpers[i].name.toUpperCase()))); o = s.taboption('advanced', form.Flag, 'log', _('Enable logging on this zone')); o.modalonly = true; |