Merge pull request #4709 from opastushkov/dnsmasq_crash_on_duplication_of_static_ip

luci-mod-network: issue with breakdown of dnsmasq after duplication o…
This commit is contained in:
Florian Eckert 2021-03-17 08:55:09 +01:00 committed by GitHub
commit 811225156a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -469,6 +469,25 @@ return view.extend({
so.value(mac, hint ? '%s (%s)'.format(mac, hint) : mac);
});
so.write = function(section, value) {
var ip = this.map.lookupOption('ip', section)[0].formvalue(section);
var hosts = uci.sections('dhcp', 'host');
var section_removed = false;
for (var i = 0; i < hosts.length; i++) {
if (ip == hosts[i].ip) {
uci.set('dhcp', hosts[i]['.name'], 'mac', [hosts[i].mac, value].join(' '));
uci.remove('dhcp', section);
section_removed = true;
break;
}
}
if (!section_removed) {
uci.set('dhcp', section, 'mac', value);
}
}
so = ss.option(form.Value, 'ip', _('<abbr title="Internet Protocol Version 4">IPv4</abbr>-Address'));
so.datatype = 'or(ip4addr,"ignore")';
so.validate = function(section, value) {