From bc85bcda7b77983e1e6520ac297453d812dfe488 Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Tue, 9 Jul 2019 20:35:15 -0700 Subject: [PATCH 1/2] Prevent static DHCP leases from having duplicate hostnames Fixes #979 Signed-off-by: Mcat12 --- scripts/pi-hole/php/savesettings.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/pi-hole/php/savesettings.php b/scripts/pi-hole/php/savesettings.php index b088af15..2b637863 100644 --- a/scripts/pi-hole/php/savesettings.php +++ b/scripts/pi-hole/php/savesettings.php @@ -565,7 +565,7 @@ function readAdlists() if(strlen($ip) == 0) $ip = "noip"; - // Test if this MAC address is already included + // Test if this lease is already included readStaticLeasesFile(); foreach($dhcp_static_leases as $lease) { if($lease["hwaddr"] === $mac) @@ -578,6 +578,10 @@ function readAdlists() $error .= "Static lease for IP address (".htmlspecialchars($ip).") already defined!
"; break; } + if($lease["host"] === $hostname) + { + $error .= "Static lease for hostname (".htmlspecialchars($hostname).") already defined!
"; + } } if(!strlen($error)) From c5b25f23e51a48e6e76b8599bb41a65dfd29285d Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Tue, 9 Jul 2019 20:37:05 -0700 Subject: [PATCH 2/2] Add missing break Signed-off-by: Mcat12 --- scripts/pi-hole/php/savesettings.php | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/pi-hole/php/savesettings.php b/scripts/pi-hole/php/savesettings.php index 2b637863..ea6ae878 100644 --- a/scripts/pi-hole/php/savesettings.php +++ b/scripts/pi-hole/php/savesettings.php @@ -581,6 +581,7 @@ function readAdlists() if($lease["host"] === $hostname) { $error .= "Static lease for hostname (".htmlspecialchars($hostname).") already defined!
"; + break; } }