1
0
mirror of https://github.com/danog/dns.git synced 2024-11-26 20:14:51 +01:00

Validate name format in private method

This commit is contained in:
Chris Wright 2014-06-16 17:47:51 +01:00
parent 6174dfdb25
commit 5a5610a0de

View File

@ -63,6 +63,26 @@ class Resolver
}
}
/**
* Verify the supplied domain name is in a valid format
*
* @param $name
* @param $callback
* @return bool
*/
private function validateName($name, $callback)
{
if (!$this->nameValidator->validate($name)) {
$this->reactor->immediately(function() use($callback) {
call_user_func($callback, null, ResolutionErrors::ERR_INVALID_NAME);
});
return false;
}
return true;
}
/**
* Check if a supplied name is an IP address and resolve immediately
*
@ -183,11 +203,8 @@ class Resolver
return;
}
if (!$this->nameValidator->validate($name)) {
$this->reactor->immediately(function() use($callback) {
call_user_func($callback, null, ResolutionErrors::ERR_INVALID_NAME);
});
$name = strtolower($name);
if (!$this->validateName($name, $callback)) {
return;
}