From a3b2c9099f7b4600c9a2c3a78160b5f46e06a7b4 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Thu, 25 Feb 2016 12:36:51 +0100 Subject: [PATCH] Fixed issue #27 --- lib/functions.php | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/lib/functions.php b/lib/functions.php index 6f06537..73724bb 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -14,7 +14,8 @@ use LibDNS\Messages\MessageTypes; 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: * @@ -59,24 +60,15 @@ function resolve($name, array $options = []) { /** * 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 array $options + * @param array $options @see resolve documentation * @return \Amp\Promise - * @TODO document options */ function query($name, $type, array $options = []) { - if (!$inAddr = @\inet_pton($name)) { - if (__isValidHostName($name)) { - $handler = __NAMESPACE__ . "\\" . (empty($options["recurse"]) ? "__doResolve" : "__doRecurse"); - $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")); - } + $handler = __NAMESPACE__ . "\\" . (empty($options["recurse"]) ? "__doResolve" : "__doRecurse"); + $types = (array) $type; + return __pipeResult(\Amp\resolve($handler($name, $types, $options)), $types); } function __isValidHostName($name) {