From 3c55a353be8d60bd708b21dc2077f79d5bd67531 Mon Sep 17 00:00:00 2001 From: TimZ99 Date: Thu, 24 May 2018 14:49:18 +0200 Subject: [PATCH] Allow ping by hostname Closing #477 and #480. Co-Authored-By: Matthew Co-Authored-By: Mircea Chirea --- src/psm/Util/Server/ServerValidator.php | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/psm/Util/Server/ServerValidator.php b/src/psm/Util/Server/ServerValidator.php index 819e3e63..088c493a 100644 --- a/src/psm/Util/Server/ServerValidator.php +++ b/src/psm/Util/Server/ServerValidator.php @@ -93,18 +93,11 @@ class ServerValidator { } break; case 'service': - if( - !filter_var($value, FILTER_VALIDATE_IP) + case 'ping': + if(!filter_var($value, FILTER_VALIDATE_IP) // domain regex as per http://stackoverflow.com/questions/106179/regular-expression-to-match-hostname-or-ip-address : && !preg_match("/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])/", $value) - ) { - throw new \InvalidArgumentException('server_ip_bad_service'); - } - break; - case 'ping': - if(!filter_var($value, FILTER_VALIDATE_IP)) { - throw new \InvalidArgumentException('server_ip_bad_service'); - } + ){throw new \InvalidArgumentException('server_ip_bad_service');} break; }