luci-mod-network: Fix 'instances' fields for dnsmasq dhcp config entries
Fixed error wherein luci erroneously saved the iterator integer of the current dnsmasq config object to a host (and boot/PXE) config entry 'instance' field, instead of correctly referring to its name. Now we use the correct ".name" field of the dnsmasq config entry. Anonymous entries have e.g. "cfg01411c". The ".name" field corresponds to 'myName' in /etc/config/dhcp entries of: config dnsmasq 'myName' ... In this way, host and other entry types are bound correctly to specific dnsmasq instances. For anonymous entries, display "dnsmasq[x]" as name. Signed-off-by: Paul Donald <newtwen@gmail.com>
This commit is contained in:
parent
8a01448bde
commit
0fb8b1f9ad
1 changed files with 17 additions and 2 deletions
|
@ -89,6 +89,21 @@ function calculateNetwork(addr, mask) {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function generateDnsmasqInstanceEntry(data) {
|
||||||
|
const nameValueMap = new Map(Object.entries(data));
|
||||||
|
let formatString = nameValueMap.get('.index') + ' (' + _('Name') + (nameValueMap.get('.anonymous') ? ': dnsmasq[' + nameValueMap.get('.index') + ']': ': ' + nameValueMap.get('.name'));
|
||||||
|
|
||||||
|
if (data.domain) {
|
||||||
|
formatString += ', ' + _('Domain') + ': ' + data.domain;
|
||||||
|
}
|
||||||
|
if (data.local) {
|
||||||
|
formatString += ', ' + _('Local') + ': ' + data.local;
|
||||||
|
}
|
||||||
|
formatString += ')';
|
||||||
|
|
||||||
|
return nameValueMap.get('.name'), formatString;
|
||||||
|
}
|
||||||
|
|
||||||
function getDHCPPools() {
|
function getDHCPPools() {
|
||||||
return uci.load('dhcp').then(function() {
|
return uci.load('dhcp').then(function() {
|
||||||
let sections = uci.sections('dhcp', 'dhcp'),
|
let sections = uci.sections('dhcp', 'dhcp'),
|
||||||
|
@ -630,7 +645,7 @@ return view.extend({
|
||||||
so.optional = true;
|
so.optional = true;
|
||||||
|
|
||||||
Object.values(L.uci.sections('dhcp', 'dnsmasq')).forEach(function(val, index) {
|
Object.values(L.uci.sections('dhcp', 'dnsmasq')).forEach(function(val, index) {
|
||||||
so.value(index, '%s (Domain: %s, Local: %s)'.format(index, val.domain || '?', val.local || '?'));
|
so.value(generateDnsmasqInstanceEntry(val));
|
||||||
});
|
});
|
||||||
|
|
||||||
o = s.taboption('srvhosts', form.SectionValue, '__srvhosts__', form.TableSection, 'srvhost', null,
|
o = s.taboption('srvhosts', form.SectionValue, '__srvhosts__', form.TableSection, 'srvhost', null,
|
||||||
|
@ -932,7 +947,7 @@ return view.extend({
|
||||||
so.optional = true;
|
so.optional = true;
|
||||||
|
|
||||||
Object.values(L.uci.sections('dhcp', 'dnsmasq')).forEach(function(val, index) {
|
Object.values(L.uci.sections('dhcp', 'dnsmasq')).forEach(function(val, index) {
|
||||||
so.value(index, '%s (Domain: %s, Local: %s)'.format(index, val.domain || '?', val.local || '?'));
|
so.value(generateDnsmasqInstanceEntry(val));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue