Allow ping by hostname

Closing #477 and #480.

Co-Authored-By: Matthew <djmixman@users.noreply.github.com>
Co-Authored-By: Mircea Chirea <chirea.mircea@gmail.com>
This commit is contained in:
TimZ99 2018-05-24 14:49:18 +02:00
parent 41263a39b0
commit 3c55a353be
No known key found for this signature in database
GPG Key ID: 4D8268DC68E8339D
1 changed files with 3 additions and 10 deletions

View File

@ -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;
}