From bc85bcda7b77983e1e6520ac297453d812dfe488 Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Tue, 9 Jul 2019 20:35:15 -0700 Subject: [PATCH] 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))