mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-28 11:43:25 +02:00
dhcp.cgi: Call the unbound-dhcp-leases-client for all events
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
This commit is contained in:
@@ -1374,6 +1374,49 @@ sub buildconf {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Add event handlers
|
||||||
|
print FILE <<EOF;
|
||||||
|
on commit {
|
||||||
|
set ClientAddress = concat(
|
||||||
|
"ADDRESS=",
|
||||||
|
binary-to-ascii(10, 8, ".", leased-address)
|
||||||
|
);
|
||||||
|
set ClientName = concat(
|
||||||
|
"NAME=",
|
||||||
|
pick-first-value(option host-name, config-option-host-name, client-name, "")
|
||||||
|
);
|
||||||
|
|
||||||
|
if (ClientName != "") {
|
||||||
|
execute("/usr/sbin/unbound-dhcp-leases-client", "commit", ClientAddress, ClientName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
on release {
|
||||||
|
set ClientAddress = concat(
|
||||||
|
"ADDRESS=",
|
||||||
|
binary-to-ascii(10, 8, ".", leased-address)
|
||||||
|
);
|
||||||
|
set ClientName = concat(
|
||||||
|
"NAME=",
|
||||||
|
pick-first-value(option host-name, config-option-host-name, client-name, "")
|
||||||
|
);
|
||||||
|
|
||||||
|
if (ClientName != "") {
|
||||||
|
execute("/usr/sbin/unbound-dhcp-leases-client", "release", ClientAddress, ClientName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
on expiry {
|
||||||
|
set ClientAddress = concat(
|
||||||
|
"ADDRESS=",
|
||||||
|
binary-to-ascii(10, 8, ".", leased-address)
|
||||||
|
);
|
||||||
|
|
||||||
|
execute("/usr/sbin/unbound-dhcp-leases-client", "expiry", ClientAddress);
|
||||||
|
}
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
#write fixed leases if any. Does not handle duplicates to write them elsewhere than the global scope.
|
#write fixed leases if any. Does not handle duplicates to write them elsewhere than the global scope.
|
||||||
my $key = 0;
|
my $key = 0;
|
||||||
foreach my $line (@current2) {
|
foreach my $line (@current2) {
|
||||||
|
|||||||
Reference in New Issue
Block a user