aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Enderlin <ivan.enderlin@hoa-project.net>2012-11-28 18:41:44 +0100
committerIvan Enderlin <ivan.enderlin@hoa-project.net>2012-11-28 18:41:44 +0100
commit7e1c3ff966223a51f02a2b2b441b2bebd3ec0b7b (patch)
tree6dc932e146346d4c7967e15e06b9872fc6daf106
parent3b5341b9654b68a0ff563f5f4e6d2509d9b4ed82 (diff)
downloadDns-7e1c3ff966223a51f02a2b2b441b2bebd3ec0b7b.zip
Dns-7e1c3ff966223a51f02a2b2b441b2bebd3ec0b7b.tar.gz
Dns-7e1c3ff966223a51f02a2b2b441b2bebd3ec0b7b.tar.bz2
Implement NXDOMAIN.
If the listener returns false, then it is interpreted as NXDOMAIN.
-rw-r--r--Dns.php35
1 files changed, 35 insertions, 0 deletions
diff --git a/Dns.php b/Dns.php
index aa8267d..b5ddf84 100644
--- a/Dns.php
+++ b/Dns.php
@@ -255,6 +255,41 @@ class Dns implements \Hoa\Core\Event\Listenable {
)));
$ip = null;
+ if(false === $ips[0]) {
+
+ $this->_server->writeAll(
+ // Header.
+
+ // ID.
+ $buffer[0] .
+ $buffer[1] .
+ pack(
+ 'C',
+ 1 << 7 // QR, 1 = response.
+ // OpCode, 0 = QUERY.
+ // AA, 0
+ // TC, 0
+ | 1 // RD
+ ) .
+ pack(
+ 'C',
+ 0 // RA, Z, AD, CD.
+ | 3 // NXDOMAIN.
+ ) .
+ // QDCOUNT.
+ $buffer[4] .
+ $buffer[5] .
+ // ANCOUNT.
+ pack('n', 1) .
+ // NSCOUNT.
+ pack('n', 0) .
+ // ARCOUNT.
+ pack('n', 0)
+ );
+
+ continue;
+ }
+
foreach(explode('.', $ips[0]) as $foo)
$ip .= pack('C', $foo);