luci-mod-network: repair DHCP relay validation logic
change && to || so as not to backtrace if only one was empty/null. Signed-off-by: Paul Donald <newtwen@gmail.com>
This commit is contained in:
parent
9889d3f735
commit
754b36d05a
1 changed files with 14 additions and 10 deletions
|
@ -484,23 +484,27 @@ return view.extend({
|
||||||
var m = this.section.formvalue(section, 'local_addr'),
|
var m = this.section.formvalue(section, 'local_addr'),
|
||||||
n = this.section.formvalue(section, 'server_addr'),
|
n = this.section.formvalue(section, 'server_addr'),
|
||||||
p;
|
p;
|
||||||
if (n != null && n != '')
|
|
||||||
p = n.split('#');
|
if (!m || !n) {
|
||||||
|
return _('Both "Relay from" and "Relay to address" must be specified.');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
p = n.split('#');
|
||||||
if (p.length > 1 && !/^[0-9]+$/.test(p[1]))
|
if (p.length > 1 && !/^[0-9]+$/.test(p[1]))
|
||||||
return _('Expected port number.');
|
return _('Expected port number.');
|
||||||
else
|
else
|
||||||
n = p[0];
|
n = p[0];
|
||||||
|
|
||||||
if ((m == null || m == '') && (n == null || n == ''))
|
if ((validation.parseIPv6(m) && validation.parseIPv6(n)) ||
|
||||||
return _('Both "Relay from" and "Relay to address" must be specified.');
|
validation.parseIPv4(m) && validation.parseIPv4(n))
|
||||||
|
return true;
|
||||||
if ((validation.parseIPv6(m) && validation.parseIPv6(n)) ||
|
else
|
||||||
validation.parseIPv4(m) && validation.parseIPv4(n))
|
return _('Address families of "Relay from" and "Relay to address" must match.')
|
||||||
return true;
|
}
|
||||||
else
|
return true;
|
||||||
return _('Address families of "Relay from" and "Relay to address" must match.')
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
so = ss.option(widgets.NetworkSelect, 'interface', _('Only accept replies via'));
|
so = ss.option(widgets.NetworkSelect, 'interface', _('Only accept replies via'));
|
||||||
so.optional = true;
|
so.optional = true;
|
||||||
so.rmempty = false;
|
so.rmempty = false;
|
||||||
|
|
Loading…
Reference in a new issue