isMACStatic: {},
isDUIDStatic: {},
+ isDUIDIAIDStatic: {},
load() {
return Promise.all([
const ip6arr = ip6addr ? validation.parseIPv6(ip6addr) : null;
// Combine DUID and IAID if both available
- let duid_iaid = lease.duid ? lease.duid.toUpperCase() : null;
- if (duid_iaid && lease.iaid)
- duid_iaid += `%${lease.iaid}`;
+ // (note that we know that lease.duid is set here)
+ let duid_iaid = lease.duid.toLowerCase();
+ if (lease.iaid)
+ duid_iaid += `%${lease.iaid}`.toLowerCase();
uci.set('dhcp', cfg, 'name', lease.hostname);
uci.set('dhcp', cfg, 'duid', [duid_iaid]);
if (leases.length == 0 && leases6.length == 0)
return E([]);
const machints = host_hints.getMACHints(false);
- const hosts = uci.sections('dhcp', 'host');
const isReadonlyView = !L.hasViewPermission();
for (const host of uci.sections('dhcp', 'host')) {
- if (host.mac) {
- for (const mac of L.toArray(host.mac).map(m => m.toUpperCase())) {
- this.isMACStatic[mac] = true;
- }
- }
- if (host.duid) {
- if (Array.isArray(host.duid)){
- host.duid.map(m => {
- this.isDUIDStatic[m.toUpperCase()] = true;
- })
- } else {
- this.isDUIDStatic[host.duid.toUpperCase()] = true;
- }
+ for (const mac of L.toArray(host.mac).map(m => m.toLowerCase()))
+ this.isMACStatic[mac] = true;
+
+ for (const duid_iaid of L.toArray(host.duid).map(m => m.toLowerCase())) {
+ const parts = duid_iaid.split('%').length;
+
+ if (parts == 1)
+ this.isDUIDStatic[duid_iaid] = true;
+ else if (parts == 2)
+ this.isDUIDIAIDStatic[duid_iaid] = true;
}
};
else if (hint)
host = hint[1];
+ const duid = lease.duid?.toLowerCase();
+ const iaid = lease.iaid?.toLowerCase();
+
+ // Note: "disabled: false" doesn't work
+ let disabled = null;
+ if (!duid)
+ disabled = true;
+ else if (duid && this.isDUIDStatic[duid])
+ disabled = true;
+ else if (duid && iaid && this.isDUIDIAIDStatic[`${duid}%${iaid}`])
+ disabled = true;
+
const columns = [
host || '-',
lease.ip6addrs ? lease.ip6addrs.join('<br />') : lease.ip6addr,
- lease?.duid,
- lease?.iaid,
+ duid || '-',
+ iaid || '-',
exp
];
'class': 'cbi-button cbi-button-apply',
'click': L.bind(this.handleCreateStaticLease6, this, lease),
'data-tooltip': _('Reserve a specific IP address for this device'),
- 'disabled': this.isDUIDStatic[lease?.duid?.toUpperCase()]
+ 'disabled': disabled
}, [ _('Reserve IP') ]));
}