Skip to content

Commit

Permalink
Merge pull request #6579 from systemcrash/fix_dnsmasq_instance_fields
Browse files Browse the repository at this point in the history
luci-mod-network: Fix 'instances' fields for dnsmasq dhcp config entries
(cherry picked from commit d353bc5)
  • Loading branch information
systemcrash committed Jan 28, 2024
1 parent 1a14bf6 commit 5b9bf40
Showing 1 changed file with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
return uci.load('dhcp').then(function() {
let sections = uci.sections('dhcp', 'dhcp'),
Expand Down Expand Up @@ -701,7 +716,7 @@ return view.extend({
so.optional = true;

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,
Expand Down Expand Up @@ -947,6 +962,14 @@ return view.extend({

so = ss.option(form.Value, 'hostid', _('IPv6 suffix (hex)'));

so = ss.option(form.Value, 'instance',
_('Instance'));
so.optional = true;

Object.values(L.uci.sections('dhcp', 'dnsmasq')).forEach(function(val, index) {
so.value(generateDnsmasqInstanceEntry(val));
});

o = s.taboption('leases', CBILeaseStatus, '__status__');

if (has_dhcpv6)
Expand Down

0 comments on commit 5b9bf40

Please sign in to comment.