From 6c7918033d2adbabbfcdad1186e22ea146d388f4 Mon Sep 17 00:00:00 2001 From: raviks789 Date: Tue, 6 Aug 2024 13:46:14 +0200 Subject: [PATCH] PropertyModifierGetHostByName: Fix `inet_pton` unrecognized address error --- .../PropertyModifier/PropertyModifierGetHostByName.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/library/Director/PropertyModifier/PropertyModifierGetHostByName.php b/library/Director/PropertyModifier/PropertyModifierGetHostByName.php index d7921dea..f178697d 100644 --- a/library/Director/PropertyModifier/PropertyModifierGetHostByName.php +++ b/library/Director/PropertyModifier/PropertyModifierGetHostByName.php @@ -34,7 +34,14 @@ class PropertyModifierGetHostByName extends PropertyModifierHook } $host = gethostbyname($value); - $inAddr = inet_pton($host); + + // Workaround for "inet_pton: unrecognized address" error in PHP 7.2 + if ($host !== $value) { + $inAddr = inet_pton($host); + } else { + $inAddr = false; + } + if (! $inAddr || strlen($inAddr) !== 4) { switch ($this->getSetting('on_failure')) { case 'null':