mirror of
https://github.com/danog/dns.git
synced 2024-11-30 04:29:06 +01:00
Fixed issue #27
This commit is contained in:
parent
35b147d6f0
commit
a3b2c9099f
@ -14,7 +14,8 @@ use LibDNS\Messages\MessageTypes;
|
|||||||
use LibDNS\Records\QuestionFactory;
|
use LibDNS\Records\QuestionFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolve a DNS name to an IP address
|
* Resolve a hostname name to an IP address
|
||||||
|
* [hostname as defined by RFC 3986]
|
||||||
*
|
*
|
||||||
* Upon success the returned promise resolves to an indexed array of the form:
|
* Upon success the returned promise resolves to an indexed array of the form:
|
||||||
*
|
*
|
||||||
@ -59,24 +60,15 @@ function resolve($name, array $options = []) {
|
|||||||
/**
|
/**
|
||||||
* Query specific DNS records.
|
* Query specific DNS records.
|
||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name Unlike resolve(), query() allows for requesting _any_ name (as DNS RFC allows for arbitrary strings)
|
||||||
* @param int|int[] $type Use constants of Amp\Dns\Record
|
* @param int|int[] $type Use constants of Amp\Dns\Record
|
||||||
* @param array $options
|
* @param array $options @see resolve documentation
|
||||||
* @return \Amp\Promise
|
* @return \Amp\Promise
|
||||||
* @TODO document options
|
|
||||||
*/
|
*/
|
||||||
function query($name, $type, array $options = []) {
|
function query($name, $type, array $options = []) {
|
||||||
if (!$inAddr = @\inet_pton($name)) {
|
$handler = __NAMESPACE__ . "\\" . (empty($options["recurse"]) ? "__doResolve" : "__doRecurse");
|
||||||
if (__isValidHostName($name)) {
|
$types = (array) $type;
|
||||||
$handler = __NAMESPACE__ . "\\" . (empty($options["recurse"]) ? "__doResolve" : "__doRecurse");
|
return __pipeResult(\Amp\resolve($handler($name, $types, $options)), $types);
|
||||||
$types = (array) $type;
|
|
||||||
return __pipeResult(\Amp\resolve($handler($name, $types, $options)), $types);
|
|
||||||
} else {
|
|
||||||
return new Failure(new ResolutionException("Query failed; invalid host name"));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return new Failure(new ResolutionException("Cannot query records from an IP address"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function __isValidHostName($name) {
|
function __isValidHostName($name) {
|
||||||
|
Loading…
Reference in New Issue
Block a user