cvs: pear /Net_DNS DNS.php /Net_DNS/DNS Header.php Packet.php Question.php RR.php Resolver.php /Net_DNS/DNS/RR A.php CNAME.php MX.php NS.php PTR.php
SOA.php
| From: | Eric Kilfoil | Date: | Thu, 15 Aug 2002 14:03:31 +0000 |
| Subject: | cvs: pear /Net_DNS DNS.php /Net_DNS/DNS Header.php Packet.php Question.php RR.php Resolver.php /Net_DNS/DNS/RR A.php CNAME.php MX.php NS.php PTR.php SOA.php |
||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-5759@lists.php.net to get a copy of this message | ||
ekilfoil Thu Aug 15 10:03:31 2002 EDT
Modified files:
/pear/Net_DNS DNS.php
/pear/Net_DNS/DNS Header.php Packet.php Question.php RR.php
Resolver.php
/pear/Net_DNS/DNS/RR A.php CNAME.php MX.php NS.php PTR.php SOA.php
Log:
Tons and tons of bug fixes. This release is semi-stable, although I need
to go through and check all of the parameter passing of the objects. I need
a decent pass by reference mechanism, and i'm not sure i'm grasping how PHP
is dealing with PBR at the moment. Some data seems to get lost after passing
an object to a function.
Index: pear/Net_DNS/DNS.php diff -u pear/Net_DNS/DNS.php:1.2 pear/Net_DNS/DNS.php:1.3 --- pear/Net_DNS/DNS.php:1.2 Wed Jul 31 08:13:12 2002 +++ pear/Net_DNS/DNS.php Thu Aug 15 10:03:28 2002 @@ -43,12 +43,12 @@ /* Include information {{{ */ - $phpdns_basedir = "Net"; - require_once("$phpdns_basedir/DNS/Header.php"); - require_once("$phpdns_basedir/DNS/Question.php"); - require_once("$phpdns_basedir/DNS/Packet.php"); - require_once("$phpdns_basedir/DNS/Resolver.php"); - require_once("$phpdns_basedir/DNS/RR.php"); + $phpdns_basedir = "Net"; + require_once("$phpdns_basedir/DNS/Header.php"); + require_once("$phpdns_basedir/DNS/Question.php"); + require_once("$phpdns_basedir/DNS/Packet.php"); + require_once("$phpdns_basedir/DNS/Resolver.php"); + require_once("$phpdns_basedir/DNS/RR.php"); /* }}} */ /* GLOBAL VARIABLE definitions {{{ */ @@ -332,11 +332,11 @@ "SRV" => 33, "ATMA" => 34, "NAPTR" => 35, - "TSIG" => 36, "UINFO" => 100, "UID" => 101, "GID" => 102, "UNSPEC" => 103, + "TSIG" => 250, "IXFR" => 251, "AXFR" => 252, "MAILB" => 253, @@ -398,11 +398,11 @@ 33 => "SRV", 34 => "ATMA", 35 => "NAPTR", - 36 => "TSIG", 100 => "UINFO", 101 => "UID", 102 => "GID", 103 => "UNSPEC", + 250 => "TSIG", 251 => "IXFR", 252 => "AXFR", 253 => "MAILB", @@ -497,7 +497,7 @@ * soft-stop-width: 4 * c indent on * End: - * vim600: sw=4 ts=4 sts=4 cindent fdm=marker + * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et * vim<600: sw=4 ts=4 * }}} */ ?> Index: pear/Net_DNS/DNS/Header.php diff -u pear/Net_DNS/DNS/Header.php:1.2 pear/Net_DNS/DNS/Header.php:1.3 --- pear/Net_DNS/DNS/Header.php:1.2 Wed Jul 31 08:13:12 2002 +++ pear/Net_DNS/DNS/Header.php Thu Aug 15 10:03:30 2002 @@ -282,8 +282,9 @@ * c-basic-offset: 4 * soft-stop-width: 4 * c indent on + * expandtab on * End: - * vim600: sw=4 ts=4 sts=4 cindent fdm=marker + * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et * vim<600: sw=4 ts=4 * }}} */ ?> Index: pear/Net_DNS/DNS/Packet.php diff -u pear/Net_DNS/DNS/Packet.php:1.2 pear/Net_DNS/DNS/Packet.php:1.3 --- pear/Net_DNS/DNS/Packet.php:1.2 Wed Jul 31 08:13:12 2002 +++ pear/Net_DNS/DNS/Packet.php Thu Aug 15 10:03:30 2002 @@ -182,7 +182,7 @@ $offset = 12; $this->question = array(); - for ($ctr = 0; $ctr < count($this->header->qdcount); $ctr++) { + for ($ctr = 0; $ctr < $this->header->qdcount; $ctr++) { list($qobj, $offset) = $this->parse_question($data, $offset); if (is_null($qobj)) { return(NULL); @@ -286,33 +286,20 @@ { $data = $this->header->data(); - if ($this->header->qdcount > 0) { - foreach ($this->question as $question) - { - $data .= $question->data($this, strlen($data)); - } + for ($ctr = 0; $ctr < $this->header->qdcount; $ctr++) { + $data .= $this->question[$ctr]->data(&$this, strlen($data)); } - if ($this->header->ancount > 0) { - foreach ($this->answer as $answer) - { - $data .= $answer->data($this, strlen($data)); - } + for ($ctr = 0; $ctr < $this->header->ancount; $ctr++) { + $data .= $this->answer[$ctr]->data(&$this, strlen($data)); } - if ($this->header->nscount > 0) { - foreach ($this->authority as $authority) - { - $data .= $authority->data($this, strlen($data)); - } + for ($ctr = 0; $ctr < $this->header->nscount; $ctr++) { + $data .= $this->authority[$ctr]->data(&$this, strlen($data)); } - - if ($this->header->arcount > 0) { - foreach ($this->additional as $additional) - { - $data .= $additional->data($this, strlen($data)); - } + for ($ctr = 0; $ctr < $this->header->arcount; $ctr++) { + $data .= $this->additional[$ctr]->data(&$this, strlen($data)); } return($data); @@ -341,8 +328,7 @@ while (count($names)) { $dname = join(".", $names); if ($this->compnames[$dname] != "") { - $pointer = $this->compnames[$dname]; - $compname .= pack("n", 0xc000 | $pointer); + $compname .= pack("n", 0xc000 | $this->compnames[$dname]); break; } @@ -554,6 +540,37 @@ $retval .= ";; " . $qr->string() . "\n"; } + $section = ($this->header->opcode == "UPDATE") ? "PREREQUISITE" : "ANSWER"; + $retval .= "\n;; $section SECTION (" . $this->header->ancount . + " record" . ($this->header->ancount == 1 ? "" : "s") . + ")\n"; + + if (is_array($this->answer)) { + foreach ($this->answer as $ans) { + $retval .= ";; " . $ans->string() . "\n"; + } + } + + $section = ($this->header->opcode == "UPDATE") ? "UPDATE" : "AUTHORITY"; + $retval .= "\n;; $section SECTION (" . $this->header->nscount . + " record" . ($this->header->nscount == 1 ? "" : "s") . + ")\n"; + + if (is_array($this->authority)) { + foreach ($this->authority as $auth) { + $retval .= ";; " . $auth->string() . "\n"; + } + } + + $retval .= "\n;; ADDITIONAL SECTION (" . $this->header->arcount . + " record" . ($this->header->arcount == 1 ? "" : "s") . + ")\n"; + + if (is_array($this->additional)) { + foreach ($this->additional as $addl) { + $retval .= ";; " . $addl->string() . "\n"; + } + } $retval .= "\n\n"; return($retval); @@ -569,7 +586,7 @@ * soft-stop-width: 4 * c indent on * End: - * vim600: sw=4 ts=4 sts=4 cindent fdm=marker + * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et * vim<600: sw=4 ts=4 * }}} */ ?> Index: pear/Net_DNS/DNS/Question.php diff -u pear/Net_DNS/DNS/Question.php:1.2 pear/Net_DNS/DNS/Question.php:1.3 --- pear/Net_DNS/DNS/Question.php:1.2 Wed Jul 31 08:13:12 2002 +++ pear/Net_DNS/DNS/Question.php Thu Aug 15 10:03:30 2002 @@ -81,7 +81,6 @@ /*}}}*/ } /* }}} */ - /* VIM settings{{{ * Local variables: * tab-width: 4 @@ -89,7 +88,7 @@ * soft-stop-width: 4 * c indent on * End: - * vim600: sw=4 ts=4 sts=4 cindent fdm=marker + * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et * vim<600: sw=4 ts=4 * }}} */ ?> Index: pear/Net_DNS/DNS/RR.php diff -u pear/Net_DNS/DNS/RR.php:1.2 pear/Net_DNS/DNS/RR.php:1.3 --- pear/Net_DNS/DNS/RR.php:1.2 Wed Jul 31 08:13:12 2002 +++ pear/Net_DNS/DNS/RR.php Thu Aug 15 10:03:30 2002 @@ -27,6 +27,7 @@ require_once("$phpdns_basedir/DNS/RR/PTR.php"); require_once("$phpdns_basedir/DNS/RR/SOA.php"); require_once("$phpdns_basedir/DNS/RR/MX.php"); +require_once("$phpdns_basedir/DNS/RR/TSIG.php"); /* }}} */ /* Net_DNS_RR object definition {{{ */ /** @@ -166,7 +167,7 @@ if (class_exists("Net_DNS_RR_" . $rrtype)) { $scn = "Net_DNS_RR_" . $rrtype; - $rc = $scn($rro, $rdata); + $rc = new $scn($this, $rdata); return($rc); } else { return($this); @@ -241,7 +242,7 @@ function rdata($packetORrdata, $offset = "") { if ($offset) { - return($this->rr_data($packetORrdata, $offset)); + return($this->rr_rdata($packetORrdata, $offset)); } else if (strlen($this->rdata)) { return($this->rdata); } else { @@ -266,7 +267,7 @@ $offset += strlen($data) + 2; // The 2 extra bytes are for rdlength - $rdata = $this->rdata($packet, $offset); + $rdata = $this->rdata(&$packet, $offset); $data .= pack("n", strlen($rdata)); $data .= $rdata; @@ -282,7 +283,7 @@ * soft-stop-width: 4 * c indent on * End: - * vim600: sw=4 ts=4 sts=4 cindent fdm=marker + * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et * vim<600: sw=4 ts=4 * }}} */ ?> Index: pear/Net_DNS/DNS/Resolver.php diff -u pear/Net_DNS/DNS/Resolver.php:1.3 pear/Net_DNS/DNS/Resolver.php:1.4 --- pear/Net_DNS/DNS/Resolver.php:1.3 Wed Jul 31 08:13:12 2002 +++ pear/Net_DNS/DNS/Resolver.php Thu Aug 15 10:03:30 2002 @@ -312,21 +312,21 @@ $value = $regs[2]; switch ($option) { - case "domain": + case 'domain': $this->domain = $regs[2]; break; - case "search": + case 'search': $this->searchlist[count($this->searchlist)] = $regs[2]; break; - case "nameserver": + case 'nameserver': foreach (split(" ", $regs[2]) as $ns) - $this->nameservers[count($this->nameservers)] = $ns; + $this->nameservers[count($this->nameservers)] = $ns; break; } } fclose($f); } - + /* }}} */ /* Net_DNS_Resolver::read_env() {{{ */ /** @@ -596,6 +596,10 @@ { $packet = $this->make_query_packet($packetORname, $qtype, $qclass); $packet_data = $packet->data(); + if ($this->debug) { + $packet->display(); + $this->printhex($packet_data); + } if ($this->usevc != 0 || strlen($packet_data > 512)) { $ans = $this->send_tcp($packet, $packet_data); @@ -611,7 +615,36 @@ } return($ans); } - + + /* }}} */ + /* Net_DNS_Resolver::printhex($packet_data) {{{ */ + /** + * Sends a packet via TCP to the list of name servers. + */ + function printhex($data) + { + $data = " " . $data; + $start = 0; + while ($start < strlen($data)) { + printf(";; %03d: ", $start); + for ($ctr = $start; $ctr < $start+16; $ctr++) { + if ($ctr < strlen($data)) + printf("%02x ", ord($data[$ctr])); + else + echo " "; + } + echo " "; + for ($ctr = $start; $ctr < $start+16; $ctr++) { + if (ord($data[$ctr]) < 32 || ord($data[$ctr]) > 127) { + echo "."; + } else { + echo $data[$ctr]; + } + } + echo "\n"; + $start += 16; + } + } /* }}} */ /* Net_DNS_Resolver::send_tcp($packet, $packet_data) {{{ */ /** @@ -1057,8 +1090,9 @@ * c-basic-offset: 4 * soft-stop-width: 4 * c indent on + * expandtab on * End: - * vim600: sw=4 ts=4 sts=4 cindent fdm=marker + * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et * vim<600: sw=4 ts=4 * }}} */ ?> Index: pear/Net_DNS/DNS/RR/A.php diff -u pear/Net_DNS/DNS/RR/A.php:1.2 pear/Net_DNS/DNS/RR/A.php:1.3 --- pear/Net_DNS/DNS/RR/A.php:1.2 Wed Jul 31 08:13:12 2002 +++ pear/Net_DNS/DNS/RR/A.php Thu Aug 15 10:03:30 2002 @@ -87,7 +87,7 @@ { $aparts = split("\.", $this->address); if (count($aparts) == 4) { - return(pack("n4", $aparts[0], $aparts[1], $aparts[2], $aparts[3])); + return(pack("c4", $aparts[0], $aparts[1], $aparts[2], $aparts[3])); } return(NULL); } @@ -103,7 +103,7 @@ * soft-stop-width: 4 * c indent on * End: - * vim600: sw=4 ts=4 sts=4 cindent fdm=marker + * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et * vim<600: sw=4 ts=4 * }}} */ ?> Index: pear/Net_DNS/DNS/RR/CNAME.php diff -u pear/Net_DNS/DNS/RR/CNAME.php:1.2 pear/Net_DNS/DNS/RR/CNAME.php:1.3 --- pear/Net_DNS/DNS/RR/CNAME.php:1.2 Wed Jul 31 08:13:12 2002 +++ pear/Net_DNS/DNS/RR/CNAME.php Thu Aug 15 10:03:30 2002 @@ -54,7 +54,7 @@ $this->cname = $cname; } } else { - $this->cname = ereg_replace("[ \t]+(.+)[ \t]*$", "\\1", $string); + $this->cname = ereg_replace("[ \t]+(.+)[\. \t]*$", "\\1", $data); } } @@ -88,7 +88,7 @@ * soft-stop-width: 4 * c indent on * End: - * vim600: sw=4 ts=4 sts=4 cindent fdm=marker + * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et * vim<600: sw=4 ts=4 * }}} */ ?> Index: pear/Net_DNS/DNS/RR/MX.php diff -u pear/Net_DNS/DNS/RR/MX.php:1.2 pear/Net_DNS/DNS/RR/MX.php:1.3 --- pear/Net_DNS/DNS/RR/MX.php:1.2 Wed Jul 31 08:13:12 2002 +++ pear/Net_DNS/DNS/RR/MX.php Thu Aug 15 10:03:30 2002 @@ -96,7 +96,7 @@ * soft-stop-width: 4 * c indent on * End: - * vim600: sw=4 ts=4 sts=4 cindent fdm=marker + * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et * vim<600: sw=4 ts=4 * }}} */ ?> Index: pear/Net_DNS/DNS/RR/NS.php diff -u pear/Net_DNS/DNS/RR/NS.php:1.2 pear/Net_DNS/DNS/RR/NS.php:1.3 --- pear/Net_DNS/DNS/RR/NS.php:1.2 Wed Jul 31 08:13:12 2002 +++ pear/Net_DNS/DNS/RR/NS.php Thu Aug 15 10:03:30 2002 @@ -83,13 +83,13 @@ } /* }}} */ /* VIM settings {{{ -* Local variables: -* tab-width: 4 -* c-basic-offset: 4 -* soft-stop-width: 4 -* c indent on -* End: -* vim600: sw=4 ts=4 sts=4 cindent fdm=marker -* vim<600: sw=4 ts=4 -* }}} */ + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * soft-stop-width: 4 + * c indent on + * End: + * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et + * vim<600: sw=4 ts=4 + * }}} */ ?> Index: pear/Net_DNS/DNS/RR/PTR.php diff -u pear/Net_DNS/DNS/RR/PTR.php:1.2 pear/Net_DNS/DNS/RR/PTR.php:1.3 --- pear/Net_DNS/DNS/RR/PTR.php:1.2 Wed Jul 31 08:13:12 2002 +++ pear/Net_DNS/DNS/RR/PTR.php Thu Aug 15 10:03:30 2002 @@ -55,7 +55,7 @@ $this->ptrdname = $ptrdname; } } else { - $this->ptrdname = ereg_replace("[ \t]+(.+)[ \t]*$", "\\1", $string); + $this->ptrdname = ereg_replace("[ \t]+(.+)[ \t]*$", "\\1", $data); } } @@ -89,7 +89,7 @@ * soft-stop-width: 4 * c indent on * End: - * vim600: sw=4 ts=4 sts=4 cindent fdm=marker + * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et * vim<600: sw=4 ts=4 * }}} */ ?> Index: pear/Net_DNS/DNS/RR/SOA.php diff -u pear/Net_DNS/DNS/RR/SOA.php:1.2 pear/Net_DNS/DNS/RR/SOA.php:1.3 --- pear/Net_DNS/DNS/RR/SOA.php:1.2 Wed Jul 31 08:13:12 2002 +++ pear/Net_DNS/DNS/RR/SOA.php Thu Aug 15 10:03:30 2002 @@ -131,7 +131,7 @@ * soft-stop-width: 4 * c indent on * End: - * vim600: sw=4 ts=4 sts=4 cindent fdm=marker + * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et * vim<600: sw=4 ts=4 * }}} */ ?>
Index: pear/Net_DNS/DNS.php diff -u pear/Net_DNS/DNS.php:1.2 pear/Net_DNS/DNS.php:1.3 --- pear/Net_DNS/DNS.php:1.2 Wed Jul 31 08:13:12 2002 +++ pear/Net_DNS/DNS.php Thu Aug 15 10:03:28 2002 @@ -43,12 +43,12 @@ /* Include information {{{ */ - $phpdns_basedir = "Net"; - require_once("$phpdns_basedir/DNS/Header.php"); - require_once("$phpdns_basedir/DNS/Question.php"); - require_once("$phpdns_basedir/DNS/Packet.php"); - require_once("$phpdns_basedir/DNS/Resolver.php"); - require_once("$phpdns_basedir/DNS/RR.php"); + $phpdns_basedir = "Net"; + require_once("$phpdns_basedir/DNS/Header.php"); + require_once("$phpdns_basedir/DNS/Question.php"); + require_once("$phpdns_basedir/DNS/Packet.php"); + require_once("$phpdns_basedir/DNS/Resolver.php"); + require_once("$phpdns_basedir/DNS/RR.php"); /* }}} */ /* GLOBAL VARIABLE definitions {{{ */ @@ -332,11 +332,11 @@ "SRV" => 33, "ATMA" => 34, "NAPTR" => 35, - "TSIG" => 36, "UINFO" => 100, "UID" => 101, "GID" => 102, "UNSPEC" => 103, + "TSIG" => 250, "IXFR" => 251, "AXFR" => 252, "MAILB" => 253, @@ -398,11 +398,11 @@ 33 => "SRV", 34 => "ATMA", 35 => "NAPTR", - 36 => "TSIG", 100 => "UINFO", 101 => "UID", 102 => "GID", 103 => "UNSPEC", + 250 => "TSIG", 251 => "IXFR", 252 => "AXFR", 253 => "MAILB", @@ -497,7 +497,7 @@ * soft-stop-width: 4 * c indent on * End: - * vim600: sw=4 ts=4 sts=4 cindent fdm=marker + * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et * vim<600: sw=4 ts=4 * }}} */ ?> Index: pear/Net_DNS/DNS/Header.php diff -u pear/Net_DNS/DNS/Header.php:1.2 pear/Net_DNS/DNS/Header.php:1.3 --- pear/Net_DNS/DNS/Header.php:1.2 Wed Jul 31 08:13:12 2002 +++ pear/Net_DNS/DNS/Header.php Thu Aug 15 10:03:30 2002 @@ -282,8 +282,9 @@ * c-basic-offset: 4 * soft-stop-width: 4 * c indent on + * expandtab on * End: - * vim600: sw=4 ts=4 sts=4 cindent fdm=marker + * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et * vim<600: sw=4 ts=4 * }}} */ ?> Index: pear/Net_DNS/DNS/Packet.php diff -u pear/Net_DNS/DNS/Packet.php:1.2 pear/Net_DNS/DNS/Packet.php:1.3 --- pear/Net_DNS/DNS/Packet.php:1.2 Wed Jul 31 08:13:12 2002 +++ pear/Net_DNS/DNS/Packet.php Thu Aug 15 10:03:30 2002 @@ -182,7 +182,7 @@ $offset = 12; $this->question = array(); - for ($ctr = 0; $ctr < count($this->header->qdcount); $ctr++) { + for ($ctr = 0; $ctr < $this->header->qdcount; $ctr++) { list($qobj, $offset) = $this->parse_question($data, $offset); if (is_null($qobj)) { return(NULL); @@ -286,33 +286,20 @@ { $data = $this->header->data(); - if ($this->header->qdcount > 0) { - foreach ($this->question as $question) - { - $data .= $question->data($this, strlen($data)); - } + for ($ctr = 0; $ctr < $this->header->qdcount; $ctr++) { + $data .= $this->question[$ctr]->data(&$this, strlen($data)); } - if ($this->header->ancount > 0) { - foreach ($this->answer as $answer) - { - $data .= $answer->data($this, strlen($data)); - } + for ($ctr = 0; $ctr < $this->header->ancount; $ctr++) { + $data .= $this->answer[$ctr]->data(&$this, strlen($data)); } - if ($this->header->nscount > 0) { - foreach ($this->authority as $authority) - { - $data .= $authority->data($this, strlen($data)); - } + for ($ctr = 0; $ctr < $this->header->nscount; $ctr++) { + $data .= $this->authority[$ctr]->data(&$this, strlen($data)); } - - if ($this->header->arcount > 0) { - foreach ($this->additional as $additional) - { - $data .= $additional->data($this, strlen($data)); - } + for ($ctr = 0; $ctr < $this->header->arcount; $ctr++) { + $data .= $this->additional[$ctr]->data(&$this, strlen($data)); } return($data); @@ -341,8 +328,7 @@ while (count($names)) { $dname = join(".", $names); if ($this->compnames[$dname] != "") { - $pointer = $this->compnames[$dname]; - $compname .= pack("n", 0xc000 | $pointer); + $compname .= pack("n", 0xc000 | $this->compnames[$dname]); break; } @@ -554,6 +540,37 @@ $retval .= ";; " . $qr->string() . "\n"; } + $section = ($this->header->opcode == "UPDATE") ? "PREREQUISITE" : "ANSWER"; + $retval .= "\n;; $section SECTION (" . $this->header->ancount . + " record" . ($this->header->ancount == 1 ? "" : "s") . + ")\n"; + + if (is_array($this->answer)) { + foreach ($this->answer as $ans) { + $retval .= ";; " . $ans->string() . "\n"; + } + } + + $section = ($this->header->opcode == "UPDATE") ? "UPDATE" : "AUTHORITY"; + $retval .= "\n;; $section SECTION (" . $this->header->nscount . + " record" . ($this->header->nscount == 1 ? "" : "s") . + ")\n"; + + if (is_array($this->authority)) { + foreach ($this->authority as $auth) { + $retval .= ";; " . $auth->string() . "\n"; + } + } + + $retval .= "\n;; ADDITIONAL SECTION (" . $this->header->arcount . + " record" . ($this->header->arcount == 1 ? "" : "s") . + ")\n"; + + if (is_array($this->additional)) { + foreach ($this->additional as $addl) { + $retval .= ";; " . $addl->string() . "\n"; + } + } $retval .= "\n\n"; return($retval); @@ -569,7 +586,7 @@ * soft-stop-width: 4 * c indent on * End: - * vim600: sw=4 ts=4 sts=4 cindent fdm=marker + * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et * vim<600: sw=4 ts=4 * }}} */ ?> Index: pear/Net_DNS/DNS/Question.php diff -u pear/Net_DNS/DNS/Question.php:1.2 pear/Net_DNS/DNS/Question.php:1.3 --- pear/Net_DNS/DNS/Question.php:1.2 Wed Jul 31 08:13:12 2002 +++ pear/Net_DNS/DNS/Question.php Thu Aug 15 10:03:30 2002 @@ -81,7 +81,6 @@ /*}}}*/ } /* }}} */ - /* VIM settings{{{ * Local variables: * tab-width: 4 @@ -89,7 +88,7 @@ * soft-stop-width: 4 * c indent on * End: - * vim600: sw=4 ts=4 sts=4 cindent fdm=marker + * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et * vim<600: sw=4 ts=4 * }}} */ ?> Index: pear/Net_DNS/DNS/RR.php diff -u pear/Net_DNS/DNS/RR.php:1.2 pear/Net_DNS/DNS/RR.php:1.3 --- pear/Net_DNS/DNS/RR.php:1.2 Wed Jul 31 08:13:12 2002 +++ pear/Net_DNS/DNS/RR.php Thu Aug 15 10:03:30 2002 @@ -27,6 +27,7 @@ require_once("$phpdns_basedir/DNS/RR/PTR.php"); require_once("$phpdns_basedir/DNS/RR/SOA.php"); require_once("$phpdns_basedir/DNS/RR/MX.php"); +require_once("$phpdns_basedir/DNS/RR/TSIG.php"); /* }}} */ /* Net_DNS_RR object definition {{{ */ /** @@ -166,7 +167,7 @@ if (class_exists("Net_DNS_RR_" . $rrtype)) { $scn = "Net_DNS_RR_" . $rrtype; - $rc = $scn($rro, $rdata); + $rc = new $scn($this, $rdata); return($rc); } else { return($this); @@ -241,7 +242,7 @@ function rdata($packetORrdata, $offset = "") { if ($offset) { - return($this->rr_data($packetORrdata, $offset)); + return($this->rr_rdata($packetORrdata, $offset)); } else if (strlen($this->rdata)) { return($this->rdata); } else { @@ -266,7 +267,7 @@ $offset += strlen($data) + 2; // The 2 extra bytes are for rdlength - $rdata = $this->rdata($packet, $offset); + $rdata = $this->rdata(&$packet, $offset); $data .= pack("n", strlen($rdata)); $data .= $rdata; @@ -282,7 +283,7 @@ * soft-stop-width: 4 * c indent on * End: - * vim600: sw=4 ts=4 sts=4 cindent fdm=marker + * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et * vim<600: sw=4 ts=4 * }}} */ ?> Index: pear/Net_DNS/DNS/Resolver.php diff -u pear/Net_DNS/DNS/Resolver.php:1.3 pear/Net_DNS/DNS/Resolver.php:1.4 --- pear/Net_DNS/DNS/Resolver.php:1.3 Wed Jul 31 08:13:12 2002 +++ pear/Net_DNS/DNS/Resolver.php Thu Aug 15 10:03:30 2002 @@ -312,21 +312,21 @@ $value = $regs[2]; switch ($option) { - case "domain": + case 'domain': $this->domain = $regs[2]; break; - case "search": + case 'search': $this->searchlist[count($this->searchlist)] = $regs[2]; break; - case "nameserver": + case 'nameserver': foreach (split(" ", $regs[2]) as $ns) - $this->nameservers[count($this->nameservers)] = $ns; + $this->nameservers[count($this->nameservers)] = $ns; break; } } fclose($f); } - + /* }}} */ /* Net_DNS_Resolver::read_env() {{{ */ /** @@ -596,6 +596,10 @@ { $packet = $this->make_query_packet($packetORname, $qtype, $qclass); $packet_data = $packet->data(); + if ($this->debug) { + $packet->display(); + $this->printhex($packet_data); + } if ($this->usevc != 0 || strlen($packet_data > 512)) { $ans = $this->send_tcp($packet, $packet_data); @@ -611,7 +615,36 @@ } return($ans); } - + + /* }}} */ + /* Net_DNS_Resolver::printhex($packet_data) {{{ */ + /** + * Sends a packet via TCP to the list of name servers. + */ + function printhex($data) + { + $data = " " . $data; + $start = 0; + while ($start < strlen($data)) { + printf(";; %03d: ", $start); + for ($ctr = $start; $ctr < $start+16; $ctr++) { + if ($ctr < strlen($data)) + printf("%02x ", ord($data[$ctr])); + else + echo " "; + } + echo " "; + for ($ctr = $start; $ctr < $start+16; $ctr++) { + if (ord($data[$ctr]) < 32 || ord($data[$ctr]) > 127) { + echo "."; + } else { + echo $data[$ctr]; + } + } + echo "\n"; + $start += 16; + } + } /* }}} */ /* Net_DNS_Resolver::send_tcp($packet, $packet_data) {{{ */ /** @@ -1057,8 +1090,9 @@ * c-basic-offset: 4 * soft-stop-width: 4 * c indent on + * expandtab on * End: - * vim600: sw=4 ts=4 sts=4 cindent fdm=marker + * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et * vim<600: sw=4 ts=4 * }}} */ ?> Index: pear/Net_DNS/DNS/RR/A.php diff -u pear/Net_DNS/DNS/RR/A.php:1.2 pear/Net_DNS/DNS/RR/A.php:1.3 --- pear/Net_DNS/DNS/RR/A.php:1.2 Wed Jul 31 08:13:12 2002 +++ pear/Net_DNS/DNS/RR/A.php Thu Aug 15 10:03:30 2002 @@ -87,7 +87,7 @@ { $aparts = split("\.", $this->address); if (count($aparts) == 4) { - return(pack("n4", $aparts[0], $aparts[1], $aparts[2], $aparts[3])); + return(pack("c4", $aparts[0], $aparts[1], $aparts[2], $aparts[3])); } return(NULL); } @@ -103,7 +103,7 @@ * soft-stop-width: 4 * c indent on * End: - * vim600: sw=4 ts=4 sts=4 cindent fdm=marker + * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et * vim<600: sw=4 ts=4 * }}} */ ?> Index: pear/Net_DNS/DNS/RR/CNAME.php diff -u pear/Net_DNS/DNS/RR/CNAME.php:1.2 pear/Net_DNS/DNS/RR/CNAME.php:1.3 --- pear/Net_DNS/DNS/RR/CNAME.php:1.2 Wed Jul 31 08:13:12 2002 +++ pear/Net_DNS/DNS/RR/CNAME.php Thu Aug 15 10:03:30 2002 @@ -54,7 +54,7 @@ $this->cname = $cname; } } else { - $this->cname = ereg_replace("[ \t]+(.+)[ \t]*$", "\\1", $string); + $this->cname = ereg_replace("[ \t]+(.+)[\. \t]*$", "\\1", $data); } } @@ -88,7 +88,7 @@ * soft-stop-width: 4 * c indent on * End: - * vim600: sw=4 ts=4 sts=4 cindent fdm=marker + * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et * vim<600: sw=4 ts=4 * }}} */ ?> Index: pear/Net_DNS/DNS/RR/MX.php diff -u pear/Net_DNS/DNS/RR/MX.php:1.2 pear/Net_DNS/DNS/RR/MX.php:1.3 --- pear/Net_DNS/DNS/RR/MX.php:1.2 Wed Jul 31 08:13:12 2002 +++ pear/Net_DNS/DNS/RR/MX.php Thu Aug 15 10:03:30 2002 @@ -96,7 +96,7 @@ * soft-stop-width: 4 * c indent on * End: - * vim600: sw=4 ts=4 sts=4 cindent fdm=marker + * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et * vim<600: sw=4 ts=4 * }}} */ ?> Index: pear/Net_DNS/DNS/RR/NS.php diff -u pear/Net_DNS/DNS/RR/NS.php:1.2 pear/Net_DNS/DNS/RR/NS.php:1.3 --- pear/Net_DNS/DNS/RR/NS.php:1.2 Wed Jul 31 08:13:12 2002 +++ pear/Net_DNS/DNS/RR/NS.php Thu Aug 15 10:03:30 2002 @@ -83,13 +83,13 @@ } /* }}} */ /* VIM settings {{{ -* Local variables: -* tab-width: 4 -* c-basic-offset: 4 -* soft-stop-width: 4 -* c indent on -* End: -* vim600: sw=4 ts=4 sts=4 cindent fdm=marker -* vim<600: sw=4 ts=4 -* }}} */ + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * soft-stop-width: 4 + * c indent on + * End: + * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et + * vim<600: sw=4 ts=4 + * }}} */ ?> Index: pear/Net_DNS/DNS/RR/PTR.php diff -u pear/Net_DNS/DNS/RR/PTR.php:1.2 pear/Net_DNS/DNS/RR/PTR.php:1.3 --- pear/Net_DNS/DNS/RR/PTR.php:1.2 Wed Jul 31 08:13:12 2002 +++ pear/Net_DNS/DNS/RR/PTR.php Thu Aug 15 10:03:30 2002 @@ -55,7 +55,7 @@ $this->ptrdname = $ptrdname; } } else { - $this->ptrdname = ereg_replace("[ \t]+(.+)[ \t]*$", "\\1", $string); + $this->ptrdname = ereg_replace("[ \t]+(.+)[ \t]*$", "\\1", $data); } } @@ -89,7 +89,7 @@ * soft-stop-width: 4 * c indent on * End: - * vim600: sw=4 ts=4 sts=4 cindent fdm=marker + * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et * vim<600: sw=4 ts=4 * }}} */ ?> Index: pear/Net_DNS/DNS/RR/SOA.php diff -u pear/Net_DNS/DNS/RR/SOA.php:1.2 pear/Net_DNS/DNS/RR/SOA.php:1.3 --- pear/Net_DNS/DNS/RR/SOA.php:1.2 Wed Jul 31 08:13:12 2002 +++ pear/Net_DNS/DNS/RR/SOA.php Thu Aug 15 10:03:30 2002 @@ -131,7 +131,7 @@ * soft-stop-width: 4 * c indent on * End: - * vim600: sw=4 ts=4 sts=4 cindent fdm=marker + * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et * vim<600: sw=4 ts=4 * }}} */ ?>