Downgrade to previous version, keep file count low. See mailinglist
This commit is contained in:
@ -1,289 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* License Information:
|
||||
*
|
||||
* Net_DNS: A resolver library for PHP
|
||||
* Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/* Net_DNS_Header object definition {{{ */
|
||||
/**
|
||||
* Object representation of the HEADER section of a DNS packet
|
||||
*
|
||||
* The Net_DNS::Header class contains the values of a DNS packet. It parses
|
||||
* the header of a DNS packet or can generate the binary data
|
||||
* representation of the packet. The format of the header is described in
|
||||
* RFC1035.
|
||||
*
|
||||
* @package Net_DNS
|
||||
*/
|
||||
class Net_DNS_Header
|
||||
{
|
||||
/* class variable definitions {{{ */
|
||||
/**
|
||||
* The packet's request id
|
||||
*
|
||||
* The request id of the packet represented as a 16 bit integer.
|
||||
*/
|
||||
var $id;
|
||||
/**
|
||||
* The QR bit in a DNS packet header
|
||||
*
|
||||
* The QR bit as described in RFC1035. QR is set to 0 for queries, and
|
||||
* 1 for repsones.
|
||||
*/
|
||||
var $qr;
|
||||
/**
|
||||
* The OPCODE name of this packet.
|
||||
*
|
||||
* The string value (name) of the opcode for the DNS packet.
|
||||
*/
|
||||
var $opcode;
|
||||
/**
|
||||
* The AA (authoritative answer) bit in a DNS packet header
|
||||
*
|
||||
* The AA bit as described in RFC1035. AA is set to 1 if the answer
|
||||
* is authoritative. It has no meaning if QR is set to 0.
|
||||
*/
|
||||
var $aa;
|
||||
/**
|
||||
* The TC (truncated) bit in a DNS packet header
|
||||
*
|
||||
* This flag is set to 1 if the response was truncated. This flag has
|
||||
* no meaning in a query packet.
|
||||
*/
|
||||
var $tc;
|
||||
/**
|
||||
* The RD (recursion desired) bit in a DNS packet header
|
||||
*
|
||||
* This bit should be set to 1 in a query if recursion is desired by
|
||||
* the DNS server.
|
||||
*/
|
||||
var $rd;
|
||||
/**
|
||||
* The RA (recursion available) bit in a DNS packet header
|
||||
*
|
||||
* This bit is set to 1 by the DNS server if the server is willing to
|
||||
* perform recursion.
|
||||
*/
|
||||
var $ra;
|
||||
/**
|
||||
* The RCODE name for this packet.
|
||||
*
|
||||
* The string value (name) of the rcode for the DNS packet.
|
||||
*/
|
||||
var $rcode;
|
||||
/**
|
||||
* Number of questions contained within the packet
|
||||
*
|
||||
* 16bit integer representing the number of questions in the question
|
||||
* section of the DNS packet.
|
||||
*
|
||||
* @var integer $qdcount
|
||||
* @see Net_DNS_Question class
|
||||
*/
|
||||
var $qdcount;
|
||||
/**
|
||||
* Number of answer RRs contained within the packet
|
||||
*
|
||||
* 16bit integer representing the number of answer resource records
|
||||
* contained in the answer section of the DNS packet.
|
||||
*
|
||||
* @var integer $ancount
|
||||
* @see Net_DNS_RR class
|
||||
*/
|
||||
var $ancount;
|
||||
/**
|
||||
* Number of authority RRs within the packet
|
||||
*
|
||||
* 16bit integer representing the number of authority (NS) resource
|
||||
* records contained in the authority section of the DNS packet.
|
||||
*
|
||||
* @var integer $nscount
|
||||
* @see Net_DNS_RR class
|
||||
*/
|
||||
var $nscount;
|
||||
/**
|
||||
* Number of additional RRs within the packet
|
||||
*
|
||||
* 16bit integer representing the number of additional resource records
|
||||
* contained in the additional section of the DNS packet.
|
||||
*
|
||||
* @var integer $arcount
|
||||
* @see Net_DNS_RR class
|
||||
*/
|
||||
var $arcount;
|
||||
|
||||
/* }}} */
|
||||
/* class constructor - Net_DNS_Header($data = "") {{{ */
|
||||
/**
|
||||
* Initializes the default values for the Header object.
|
||||
*
|
||||
* Builds a header object from either default values, or from a DNS
|
||||
* packet passed into the constructor as $data
|
||||
*
|
||||
* @param string $data A DNS packet of which the header will be parsed.
|
||||
* @return object Net_DNS_Header
|
||||
* @access public
|
||||
*/
|
||||
function Net_DNS_Header($data = '')
|
||||
{
|
||||
if ($data != '') {
|
||||
/*
|
||||
* The header MUST be at least 12 bytes.
|
||||
* Passing the full datagram to this constructor
|
||||
* will examine only the header section of the DNS packet
|
||||
*/
|
||||
if (strlen($data) < 12)
|
||||
return false;
|
||||
|
||||
$a = unpack('nid/C2flags/n4counts', $data);
|
||||
$this->id = $a['id'];
|
||||
$this->qr = ($a['flags1'] >> 7) & 0x1;
|
||||
$this->opcode = ($a['flags1'] >> 3) & 0xf;
|
||||
$this->aa = ($a['flags1'] >> 2) & 0x1;
|
||||
$this->tc = ($a['flags1'] >> 1) & 0x1;
|
||||
$this->rd = $a['flags1'] & 0x1;
|
||||
$this->ra = ($a['flags2'] >> 7) & 0x1;
|
||||
$this->rcode = $a['flags2'] & 0xf;
|
||||
$this->qdcount = $a['counts1'];
|
||||
$this->ancount = $a['counts2'];
|
||||
$this->nscount = $a['counts3'];
|
||||
$this->arcount = $a['counts4'];
|
||||
}
|
||||
else {
|
||||
$this->id = Net_DNS_Resolver::nextid();
|
||||
$this->qr = 0;
|
||||
$this->opcode = 0;
|
||||
$this->aa = 0;
|
||||
$this->tc = 0;
|
||||
$this->rd = 1;
|
||||
$this->ra = 0;
|
||||
$this->rcode = 0;
|
||||
$this->qdcount = 1;
|
||||
$this->ancount = 0;
|
||||
$this->nscount = 0;
|
||||
$this->arcount = 0;
|
||||
}
|
||||
|
||||
if (Net_DNS::opcodesbyval($this->opcode)) {
|
||||
$this->opcode = Net_DNS::opcodesbyval($this->opcode);
|
||||
}
|
||||
if (Net_DNS::rcodesbyval($this->rcode)) {
|
||||
$this->rcode = Net_DNS::rcodesbyval($this->rcode);
|
||||
}
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* Net_DNS_Header::display() {{{ */
|
||||
/**
|
||||
* Displays the properties of the header.
|
||||
*
|
||||
* Displays the properties of the header.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function display()
|
||||
{
|
||||
echo $this->string();
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* Net_DNS_Header::string() {{{ */
|
||||
/**
|
||||
* Returns a formatted string containing the properties of the header.
|
||||
*
|
||||
* @return string a formatted string containing the properties of the header.
|
||||
* @access public
|
||||
*/
|
||||
function string()
|
||||
{
|
||||
$retval = ';; id = ' . $this->id . "\n";
|
||||
if ($this->opcode == 'UPDATE') {
|
||||
$retval .= ';; qr = ' . $this->qr . ' ' .
|
||||
'opcode = ' . $this->opcode . ' ' .
|
||||
'rcode = ' . $this->rcode . "\n";
|
||||
$retval .= ';; zocount = ' . $this->qdcount . ' ' .
|
||||
'prcount = ' . $this->ancount . ' ' .
|
||||
'upcount = ' . $this->nscount . ' ' .
|
||||
'adcount = ' . $this->arcount . "\n";
|
||||
} else {
|
||||
$retval .= ';; qr = ' . $this->qr . ' ' .
|
||||
'opcode = ' . $this->opcode . ' ' .
|
||||
'aa = ' . $this->aa . ' ' .
|
||||
'tc = ' . $this->tc . ' ' .
|
||||
'rd = ' . $this->rd . "\n";
|
||||
|
||||
$retval .= ';; ra = ' . $this->ra . ' ' .
|
||||
'rcode = ' . $this->rcode . "\n";
|
||||
|
||||
$retval .= ';; qdcount = ' . $this->qdcount . ' ' .
|
||||
'ancount = ' . $this->ancount . ' ' .
|
||||
'nscount = ' . $this->nscount . ' ' .
|
||||
'arcount = ' . $this->arcount . "\n";
|
||||
}
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* Net_DNS_Header::data() {{{ */
|
||||
/**
|
||||
* Returns the binary data containing the properties of the header
|
||||
*
|
||||
* Packs the properties of the Header object into a binary string
|
||||
* suitable for using as the Header section of a DNS packet.
|
||||
*
|
||||
* @return string binary representation of the header object
|
||||
* @access public
|
||||
*/
|
||||
function data()
|
||||
{
|
||||
$opcode = Net_DNS::opcodesbyname($this->opcode);
|
||||
$rcode = Net_DNS::rcodesbyname($this->rcode);
|
||||
|
||||
$byte2 = ($this->qr << 7)
|
||||
| ($opcode << 3)
|
||||
| ($this->aa << 2)
|
||||
| ($this->tc << 1)
|
||||
| ($this->rd);
|
||||
|
||||
$byte3 = ($this->ra << 7) | $rcode;
|
||||
|
||||
return pack('nC2n4', $this->id,
|
||||
$byte2,
|
||||
$byte3,
|
||||
$this->qdcount,
|
||||
$this->ancount,
|
||||
$this->nscount,
|
||||
$this->arcount);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
}
|
||||
/* }}} */
|
||||
/* VIM settings {{{
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* soft-stop-width: 4
|
||||
* c indent on
|
||||
* expandtab on
|
||||
* End:
|
||||
* vim600: sw=4 ts=4 sts=4 cindent fdm=marker et
|
||||
* vim<600: sw=4 ts=4
|
||||
* }}} */
|
||||
?>
|
@ -1,667 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* License Information:
|
||||
*
|
||||
* Net_DNS: A resolver library for PHP
|
||||
* Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/* Net_DNS_Packet object definition {{{ */
|
||||
/**
|
||||
* A object represation of a DNS packet (RFC1035)
|
||||
*
|
||||
* This object is used to manage a DNS packet. It contains methods for
|
||||
* DNS packet compression as defined in RFC1035, as well as parsing a DNS
|
||||
* packet response from a DNS server, or building a DNS packet from the
|
||||
* instance variables contained in the class.
|
||||
*
|
||||
* @package Net_DNS
|
||||
*/
|
||||
class Net_DNS_Packet
|
||||
{
|
||||
/* class variable definitions {{{ */
|
||||
/**
|
||||
* debugging flag
|
||||
*
|
||||
* If set to true (non-zero), debugging code will be displayed as the
|
||||
* packet is parsed.
|
||||
*
|
||||
* @var boolean $debug
|
||||
* @access public
|
||||
*/
|
||||
var $debug;
|
||||
/**
|
||||
* A packet Header object.
|
||||
*
|
||||
* An object of type Net_DNS_Header which contains the header
|
||||
* information of the packet.
|
||||
*
|
||||
* @var object Net_DNS_Header $header
|
||||
* @access public
|
||||
*/
|
||||
var $header;
|
||||
/**
|
||||
* A hash of compressed labels
|
||||
*
|
||||
* A list of all labels which have been compressed in the DNS packet
|
||||
* and the location offset of the label within the packet.
|
||||
*
|
||||
* @var array $compnames
|
||||
*/
|
||||
var $compnames;
|
||||
/**
|
||||
* The origin of the packet, if the packet is a server response.
|
||||
*
|
||||
* This contains a string containing the IP address of the name server
|
||||
* from which the answer was given.
|
||||
*
|
||||
* @var string $answerfrom
|
||||
* @access public
|
||||
*/
|
||||
var $answerfrom;
|
||||
/**
|
||||
* The size of the answer packet, if the packet is a server response.
|
||||
*
|
||||
* This contains a integer containing the size of the DNS packet the
|
||||
* server responded with if this packet was received by a DNS server
|
||||
* using the query() method.
|
||||
*
|
||||
* @var string $answersize
|
||||
* @access public
|
||||
*/
|
||||
var $answersize;
|
||||
/**
|
||||
* An array of Net_DNS_Question objects
|
||||
*
|
||||
* Contains all of the questions within the packet. Each question is
|
||||
* stored as an object of type Net_DNS_Question.
|
||||
*
|
||||
* @var array $question
|
||||
* @access public
|
||||
*/
|
||||
var $question;
|
||||
/**
|
||||
* An array of Net_DNS_RR ANSWER objects
|
||||
*
|
||||
* Contains all of the answer RRs within the packet. Each answer is
|
||||
* stored as an object of type Net_DNS_RR.
|
||||
*
|
||||
* @var array $answer
|
||||
* @access public
|
||||
*/
|
||||
var $answer;
|
||||
/**
|
||||
* An array of Net_DNS_RR AUTHORITY objects
|
||||
*
|
||||
* Contains all of the authority RRs within the packet. Each authority is
|
||||
* stored as an object of type Net_DNS_RR.
|
||||
*
|
||||
* @var array $authority
|
||||
* @access public
|
||||
*/
|
||||
var $authority;
|
||||
/**
|
||||
* An array of Net_DNS_RR ADDITIONAL objects
|
||||
*
|
||||
* Contains all of the additional RRs within the packet. Each additional is
|
||||
* stored as an object of type Net_DNS_RR.
|
||||
*
|
||||
* @var array $additional
|
||||
* @access public
|
||||
*/
|
||||
var $additional;
|
||||
|
||||
/* }}} */
|
||||
/* class constructor - Net_DNS_Packet($debug = false) {{{ */
|
||||
/*
|
||||
* unfortunately (or fortunately), we can't follow the same
|
||||
* silly method for determining if name is a hostname or a packet
|
||||
* stream in PHP, since there is no ref() function. So we're going
|
||||
* to define a new method called parse to deal with this
|
||||
* circumstance and another method called buildQuestion to build a question.
|
||||
* I like it better that way anyway.
|
||||
*/
|
||||
/**
|
||||
* Initalizes a Net_DNS_Packet object
|
||||
*
|
||||
* @param boolean $debug Turns debugging on or off
|
||||
*/
|
||||
function Net_DNS_Packet($debug = false)
|
||||
{
|
||||
$this->debug = $debug;
|
||||
$this->compnames = array();
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* Net_DNS_Packet::buildQuestion($name, $type = "A", $class = "IN") {{{ */
|
||||
/**
|
||||
* Adds a DNS question to the DNS packet
|
||||
*
|
||||
* @param string $name The name of the record to query
|
||||
* @param string $type The type of record to query
|
||||
* @param string $class The class of record to query
|
||||
* @see Net_DNS::typesbyname(), Net_DNS::classesbyname()
|
||||
*/
|
||||
function buildQuestion($name, $type = 'A', $class = 'IN')
|
||||
{
|
||||
$this->header = new Net_DNS_Header();
|
||||
$this->header->qdcount = 1;
|
||||
$this->question[0] = new Net_DNS_Question($name, $type, $class);
|
||||
$this->answer = null;
|
||||
$this->authority = null;
|
||||
$this->additional = null;
|
||||
/* Do not print question packet
|
||||
if ($this->debug) {
|
||||
$this->display();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* Net_DNS_Packet::parse($data) {{{ */
|
||||
/**
|
||||
* Parses a DNS packet returned by a DNS server
|
||||
*
|
||||
* Parses a complete DNS packet and builds an object hierarchy
|
||||
* containing all of the parts of the packet:
|
||||
* <ul>
|
||||
* <li>HEADER
|
||||
* <li>QUESTION
|
||||
* <li>ANSWER || PREREQUISITE
|
||||
* <li>ADDITIONAL || UPDATE
|
||||
* <li>AUTHORITY
|
||||
* </ul>
|
||||
*
|
||||
* @param string $data A binary string containing a DNS packet
|
||||
* @return boolean true on success, null on parser error
|
||||
*/
|
||||
function parse($data)
|
||||
{
|
||||
if ($this->debug) {
|
||||
echo ';; HEADER SECTION' . "\n";
|
||||
}
|
||||
|
||||
$this->header = new Net_DNS_Header($data);
|
||||
|
||||
if ($this->debug) {
|
||||
$this->header->display();
|
||||
}
|
||||
|
||||
/*
|
||||
* Print and parse the QUESTION section of the packet
|
||||
*/
|
||||
if ($this->debug) {
|
||||
echo "\n";
|
||||
$section = ($this->header->opcode == 'UPDATE') ? 'ZONE' : 'QUESTION';
|
||||
echo ";; $section SECTION (" . $this->header->qdcount . ' record' .
|
||||
($this->header->qdcount == 1 ? '' : 's') . ")\n";
|
||||
}
|
||||
|
||||
$offset = 12;
|
||||
|
||||
$this->question = array();
|
||||
for ($ctr = 0; $ctr < $this->header->qdcount; $ctr++) {
|
||||
list($qobj, $offset) = $this->parse_question($data, $offset);
|
||||
if (is_null($qobj)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->question[count($this->question)] = $qobj;
|
||||
if ($this->debug) {
|
||||
echo ";;\n;";
|
||||
$qobj->display();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Print and parse the PREREQUISITE or ANSWER section of the packet
|
||||
*/
|
||||
if ($this->debug) {
|
||||
echo "\n";
|
||||
$section = ($this->header->opcode == 'UPDATE') ? 'PREREQUISITE' :'ANSWER';
|
||||
echo ";; $section SECTION (" .
|
||||
$this->header->ancount . ' record' .
|
||||
(($this->header->ancount == 1) ? '' : 's') .
|
||||
")\n";
|
||||
}
|
||||
|
||||
$this->answer = array();
|
||||
for ($ctr = 0; $ctr < $this->header->ancount; $ctr++) {
|
||||
list($rrobj, $offset) = $this->parse_rr($data, $offset);
|
||||
|
||||
if (is_null($rrobj)) {
|
||||
return null;
|
||||
}
|
||||
array_push($this->answer, $rrobj);
|
||||
if ($this->debug) {
|
||||
$rrobj->display();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Print and parse the UPDATE or AUTHORITY section of the packet
|
||||
*/
|
||||
if ($this->debug) {
|
||||
echo "\n";
|
||||
$section = ($this->header->opcode == 'UPDATE') ? 'UPDATE' : 'AUTHORITY';
|
||||
echo ";; $section SECTION (" .
|
||||
$this->header->nscount . ' record' .
|
||||
(($this->header->nscount == 1) ? '' : 's') .
|
||||
")\n";
|
||||
}
|
||||
|
||||
$this->authority = array();
|
||||
for ($ctr = 0; $ctr < $this->header->nscount; $ctr++) {
|
||||
list($rrobj, $offset) = $this->parse_rr($data, $offset);
|
||||
|
||||
if (is_null($rrobj)) {
|
||||
return null;
|
||||
}
|
||||
array_push($this->authority, $rrobj);
|
||||
if ($this->debug) {
|
||||
$rrobj->display();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Print and parse the ADDITIONAL section of the packet
|
||||
*/
|
||||
if ($this->debug) {
|
||||
echo "\n";
|
||||
echo ';; ADDITIONAL SECTION (' .
|
||||
$this->header->arcount . ' record' .
|
||||
(($this->header->arcount == 1) ? '' : 's') .
|
||||
")\n";
|
||||
}
|
||||
|
||||
$this->additional = array();
|
||||
for ($ctr = 0; $ctr < $this->header->arcount; $ctr++) {
|
||||
list($rrobj, $offset) = $this->parse_rr($data, $offset);
|
||||
|
||||
if (is_null($rrobj)) {
|
||||
return null;
|
||||
}
|
||||
array_push($this->additional, $rrobj);
|
||||
if ($this->debug) {
|
||||
$rrobj->display();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* Net_DNS_Packet::data() {{{*/
|
||||
/**
|
||||
* Build a packet from a Packet object hierarchy
|
||||
*
|
||||
* Builds a valid DNS packet suitable for sending to a DNS server or
|
||||
* resolver client containing all of the data in the packet hierarchy.
|
||||
*
|
||||
* @return string A binary string containing a DNS Packet
|
||||
*/
|
||||
function data()
|
||||
{
|
||||
$data = $this->header->data();
|
||||
|
||||
for ($ctr = 0; $ctr < $this->header->qdcount; $ctr++) {
|
||||
$data .= $this->question[$ctr]->data($this, strlen($data));
|
||||
}
|
||||
|
||||
for ($ctr = 0; $ctr < $this->header->ancount; $ctr++) {
|
||||
$data .= $this->answer[$ctr]->data($this, strlen($data));
|
||||
}
|
||||
|
||||
for ($ctr = 0; $ctr < $this->header->nscount; $ctr++) {
|
||||
$data .= $this->authority[$ctr]->data($this, strlen($data));
|
||||
}
|
||||
|
||||
for ($ctr = 0; $ctr < $this->header->arcount; $ctr++) {
|
||||
$data .= $this->additional[$ctr]->data($this, strlen($data));
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/*}}}*/
|
||||
/* Net_DNS_Packet::dn_comp($name, $offset) {{{*/
|
||||
/**
|
||||
* DNS packet compression method
|
||||
*
|
||||
* Returns a domain name compressed for a particular packet object, to
|
||||
* be stored beginning at the given offset within the packet data. The
|
||||
* name will be added to a running list of compressed domain names for
|
||||
* future use.
|
||||
*
|
||||
* @param string $name The name of the label to compress
|
||||
* @param integer $offset The location offset in the packet to where
|
||||
* the label will be stored.
|
||||
* @return string $compname A binary string containing the compressed
|
||||
* label.
|
||||
* @see Net_DNS_Packet::dn_expand()
|
||||
*/
|
||||
function dn_comp($name, $offset)
|
||||
{
|
||||
$names = explode('.', $name);
|
||||
$compname = '';
|
||||
while (count($names)) {
|
||||
$dname = join('.', $names);
|
||||
if (isset($this->compnames[$dname])) {
|
||||
$compname .= pack('n', 0xc000 | $this->compnames[$dname]);
|
||||
break;
|
||||
}
|
||||
|
||||
$this->compnames[$dname] = $offset;
|
||||
$first = array_shift($names);
|
||||
$length = strlen($first);
|
||||
$compname .= pack('Ca*', $length, $first);
|
||||
$offset += $length + 1;
|
||||
}
|
||||
if (! count($names)) {
|
||||
$compname .= pack('C', 0);
|
||||
}
|
||||
return $compname;
|
||||
}
|
||||
|
||||
/*}}}*/
|
||||
/* Net_DNS_Packet::dn_expand($packet, $offset) {{{ */
|
||||
/**
|
||||
* DNS packet decompression method
|
||||
*
|
||||
* Expands the domain name stored at a particular location in a DNS
|
||||
* packet. The first argument is a variable containing the packet
|
||||
* data. The second argument is the offset within the packet where
|
||||
* the (possibly) compressed domain name is stored.
|
||||
*
|
||||
* @param string $packet The packet data
|
||||
* @param integer $offset The location offset in the packet of the
|
||||
* label to decompress.
|
||||
* @return array Returns a list of type array($name, $offset) where
|
||||
* $name is the name of the label which was decompressed
|
||||
* and $offset is the offset of the next field in the
|
||||
* packet. Returns array(null, null) on error
|
||||
*/
|
||||
function dn_expand($packet, $offset)
|
||||
{
|
||||
$packetlen = strlen($packet);
|
||||
$int16sz = 2;
|
||||
$name = '';
|
||||
while (1) {
|
||||
if ($packetlen < ($offset + 1)) {
|
||||
return array(null, null);
|
||||
}
|
||||
|
||||
$a = unpack("@$offset/Cchar", $packet);
|
||||
$len = $a['char'];
|
||||
|
||||
if ($len == 0) {
|
||||
$offset++;
|
||||
break;
|
||||
} else if (($len & 0xc0) == 0xc0) {
|
||||
if ($packetlen < ($offset + $int16sz)) {
|
||||
return array(null, null);
|
||||
}
|
||||
$ptr = unpack("@$offset/ni", $packet);
|
||||
$ptr = $ptr['i'];
|
||||
$ptr = $ptr & 0x3fff;
|
||||
$name2 = Net_DNS_Packet::dn_expand($packet, $ptr);
|
||||
|
||||
if (is_null($name2[0])) {
|
||||
return array(null, null);
|
||||
}
|
||||
$name .= $name2[0];
|
||||
$offset += $int16sz;
|
||||
break;
|
||||
} else {
|
||||
$offset++;
|
||||
|
||||
if ($packetlen < ($offset + $len)) {
|
||||
return array(null, null);
|
||||
}
|
||||
|
||||
$elem = substr($packet, $offset, $len);
|
||||
$name .= $elem . '.';
|
||||
$offset += $len;
|
||||
}
|
||||
}
|
||||
$name = ereg_replace('\.$', '', $name);
|
||||
return array($name, $offset);
|
||||
}
|
||||
|
||||
/*}}}*/
|
||||
/* Net_DNS_Packet::label_extract($packet, $offset) {{{ */
|
||||
/**
|
||||
* DNS packet decompression method
|
||||
*
|
||||
* Extracts the label stored at a particular location in a DNS
|
||||
* packet. The first argument is a variable containing the packet
|
||||
* data. The second argument is the offset within the packet where
|
||||
* the (possibly) compressed domain name is stored.
|
||||
*
|
||||
* @param string $packet The packet data
|
||||
* @param integer $offset The location offset in the packet of the
|
||||
* label to extract.
|
||||
* @return array Returns a list of type array($name, $offset) where
|
||||
* $name is the name of the label which was decompressed
|
||||
* and $offset is the offset of the next field in the
|
||||
* packet. Returns array(null, null) on error
|
||||
*/
|
||||
function label_extract($packet, $offset)
|
||||
{
|
||||
$packetlen = strlen($packet);
|
||||
$name = '';
|
||||
if ($packetlen < ($offset + 1)) {
|
||||
return array(null, null);
|
||||
}
|
||||
|
||||
$a = unpack("@$offset/Cchar", $packet);
|
||||
$len = $a['char'];
|
||||
$offset++;
|
||||
|
||||
if ($len + $offset > $packetlen) {
|
||||
$name = substr($packet, $offset);
|
||||
$offset = $packetlen;
|
||||
} else {
|
||||
$name = substr($packet, $offset, $len);
|
||||
$offset += $len;
|
||||
}
|
||||
return array($name, $offset);
|
||||
}
|
||||
|
||||
/*}}}*/
|
||||
/* Net_DNS_Packet::parse_question($data, $offset) {{{ */
|
||||
/**
|
||||
* Parses the question section of a packet
|
||||
*
|
||||
* Examines a DNS packet at the specified offset and parses the data
|
||||
* of the QUESTION section.
|
||||
*
|
||||
* @param string $data The packet data returned from the server
|
||||
* @param integer $offset The location offset of the start of the
|
||||
* question section.
|
||||
* @return array An array of type array($q, $offset) where $q
|
||||
* is a Net_DNS_Question object and $offset is the
|
||||
* location of the next section of the packet which
|
||||
* needs to be parsed.
|
||||
*/
|
||||
function parse_question($data, $offset)
|
||||
{
|
||||
list($qname, $offset) = $this->dn_expand($data, $offset);
|
||||
if (is_null($qname)) {
|
||||
return array(null, null);
|
||||
}
|
||||
|
||||
if (strlen($data) < ($offset + 2 * 2)) {
|
||||
return array(null, null);
|
||||
}
|
||||
|
||||
$q = unpack("@$offset/n2int", $data);
|
||||
$qtype = $q['int1'];
|
||||
$qclass = $q['int2'];
|
||||
$offset += 2 * 2;
|
||||
|
||||
$qtype = Net_DNS::typesbyval($qtype);
|
||||
$qclass = Net_DNS::classesbyval($qclass);
|
||||
|
||||
$q = new Net_DNS_Question($qname, $qtype, $qclass);
|
||||
return array($q, $offset);
|
||||
}
|
||||
|
||||
/*}}}*/
|
||||
/* Net_DNS_Packet::parse_rr($data, $offset) {{{ */
|
||||
/**
|
||||
* Parses a resource record section of a packet
|
||||
*
|
||||
* Examines a DNS packet at the specified offset and parses the data
|
||||
* of a section which contains RRs (ANSWER, AUTHORITY, ADDITIONAL).
|
||||
*
|
||||
* @param string $data The packet data returned from the server
|
||||
* @param integer $offset The location offset of the start of the resource
|
||||
* record section.
|
||||
* @return array An array of type array($rr, $offset) where $rr
|
||||
* is a Net_DNS_RR object and $offset is the
|
||||
* location of the next section of the packet which
|
||||
* needs to be parsed.
|
||||
*/
|
||||
function parse_rr($data, $offset)
|
||||
{
|
||||
list($name, $offset) = $this->dn_expand($data, $offset);
|
||||
if ($name === null) {
|
||||
return array(null, null);
|
||||
}
|
||||
|
||||
if (strlen($data) < ($offset + 10)) {
|
||||
return array(null, null);
|
||||
}
|
||||
|
||||
$a = unpack("@$offset/n2tc/Nttl/nrdlength", $data);
|
||||
$type = $a['tc1'];
|
||||
$class = $a['tc2'];
|
||||
$ttl = $a['ttl'];
|
||||
$rdlength = $a['rdlength'];
|
||||
|
||||
$type = Net_DNS::typesbyval($type);
|
||||
$class = Net_DNS::classesbyval($class);
|
||||
|
||||
$offset += 10;
|
||||
if (strlen($data) < ($offset + $rdlength)) {
|
||||
return array(null, null);
|
||||
}
|
||||
|
||||
$rrobj = &Net_DNS_RR::factory(array($name,
|
||||
$type,
|
||||
$class,
|
||||
$ttl,
|
||||
$rdlength,
|
||||
$data,
|
||||
$offset));
|
||||
|
||||
if (is_null($rrobj)) {
|
||||
return array(null, null);
|
||||
}
|
||||
|
||||
$offset += $rdlength;
|
||||
|
||||
return array($rrobj, $offset);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* Net_DNS_Packet::display() {{{ */
|
||||
/**
|
||||
* Prints out the packet in a human readable formatted string
|
||||
*/
|
||||
function display()
|
||||
{
|
||||
echo $this->string();
|
||||
}
|
||||
|
||||
/*}}}*/
|
||||
/* Net_DNS_Packet::string() {{{ */
|
||||
/**
|
||||
* Builds a human readable formatted string representing a packet
|
||||
*/
|
||||
function string()
|
||||
{
|
||||
$retval = '';
|
||||
if ($this->answerfrom) {
|
||||
$retval .= ';; Answer received from ' . $this->answerfrom . '(' .
|
||||
$this->answersize . " bytes)\n;;\n";
|
||||
}
|
||||
|
||||
$retval .= ";; HEADER SECTION\n";
|
||||
$retval .= $this->header->string();
|
||||
$retval .= "\n";
|
||||
|
||||
$section = ($this->header->opcode == 'UPDATE') ? 'ZONE' : 'QUESTION';
|
||||
$retval .= ";; $section SECTION (" . $this->header->qdcount .
|
||||
' record' . ($this->header->qdcount == 1 ? '' : 's') .
|
||||
")\n";
|
||||
|
||||
foreach ($this->question as $qr) {
|
||||
$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;
|
||||
}
|
||||
|
||||
/*}}}*/
|
||||
}
|
||||
/* }}} */
|
||||
/* 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 et
|
||||
* vim<600: sw=4 ts=4
|
||||
* }}} */
|
||||
?>
|
@ -1,96 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* License Information:
|
||||
*
|
||||
* Net_DNS: A resolver library for PHP
|
||||
* Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/* Net_DNS_Question object definition {{{ */
|
||||
/**
|
||||
* Builds or parses the QUESTION section of a DNS packet
|
||||
*
|
||||
* Builds or parses the QUESTION section of a DNS packet
|
||||
*
|
||||
* @package Net_DNS
|
||||
*/
|
||||
class Net_DNS_Question
|
||||
{
|
||||
/* class variable definitions {{{ */
|
||||
var $qname = null;
|
||||
var $qtype = null;
|
||||
var $qclass = null;
|
||||
|
||||
/* }}} */
|
||||
/* class constructor Net_DNS_Question($qname, $qtype, $qclass) {{{ */
|
||||
function Net_DNS_Question($qname, $qtype, $qclass)
|
||||
{
|
||||
$qtype = !is_null($qtype) ? strtoupper($qtype) : 'ANY';
|
||||
$qclass = !is_null($qclass) ? strtoupper($qclass) : 'ANY';
|
||||
|
||||
// Check if the caller has the type and class reversed.
|
||||
// We are not that kind for unknown types.... :-)
|
||||
if ( ( is_null(Net_DNS::typesbyname($qtype)) ||
|
||||
is_null(Net_DNS::classesbyname($qtype)) )
|
||||
&& !is_null(Net_DNS::classesbyname($qclass))
|
||||
&& !is_null(Net_DNS::typesbyname($qclass)))
|
||||
{
|
||||
list($qtype, $qclass) = array($qclass, $qtype);
|
||||
}
|
||||
$qname = preg_replace(array('/^\.+/', '/\.+$/'), '', $qname);
|
||||
$this->qname = $qname;
|
||||
$this->qtype = $qtype;
|
||||
$this->qclass = $qclass;
|
||||
}
|
||||
/* }}} */
|
||||
/* Net_DNS_Question::display() {{{*/
|
||||
function display()
|
||||
{
|
||||
echo $this->string() . "\n";
|
||||
}
|
||||
|
||||
/*}}}*/
|
||||
/* Net_DNS_Question::string() {{{*/
|
||||
function string()
|
||||
{
|
||||
return $this->qname . ".\t" . $this->qclass . "\t" . $this->qtype;
|
||||
}
|
||||
|
||||
/*}}}*/
|
||||
/* Net_DNS_Question::data(&$packet, $offset) {{{*/
|
||||
function data($packet, $offset)
|
||||
{
|
||||
$data = $packet->dn_comp($this->qname, $offset);
|
||||
$data .= pack('n', Net_DNS::typesbyname(strtoupper($this->qtype)));
|
||||
$data .= pack('n', Net_DNS::classesbyname(strtoupper($this->qclass)));
|
||||
return $data;
|
||||
}
|
||||
|
||||
/*}}}*/
|
||||
}
|
||||
/* }}} */
|
||||
/* 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 et
|
||||
* vim<600: sw=4 ts=4
|
||||
* }}} */
|
||||
?>
|
@ -1,312 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* License Information:
|
||||
*
|
||||
* Net_DNS: A resolver library for PHP
|
||||
* Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/* Include files {{{ */
|
||||
require_once("Net/DNS/RR/A.php");
|
||||
require_once("Net/DNS/RR/AAAA.php");
|
||||
require_once("Net/DNS/RR/NS.php");
|
||||
require_once("Net/DNS/RR/CNAME.php");
|
||||
require_once("Net/DNS/RR/PTR.php");
|
||||
require_once("Net/DNS/RR/SOA.php");
|
||||
require_once("Net/DNS/RR/MX.php");
|
||||
require_once("Net/DNS/RR/TSIG.php");
|
||||
require_once("Net/DNS/RR/TXT.php");
|
||||
require_once("Net/DNS/RR/HINFO.php");
|
||||
require_once("Net/DNS/RR/SRV.php");
|
||||
require_once("Net/DNS/RR/NAPTR.php");
|
||||
/* }}} */
|
||||
/* Net_DNS_RR object definition {{{ */
|
||||
/**
|
||||
* Resource Record object definition
|
||||
*
|
||||
* Builds or parses resource record sections of the DNS packet including
|
||||
* the answer, authority, and additional sections of the packet.
|
||||
*
|
||||
* @package Net_DNS
|
||||
*/
|
||||
class Net_DNS_RR
|
||||
{
|
||||
/* class variable definitions {{{ */
|
||||
var $name;
|
||||
var $type;
|
||||
var $class;
|
||||
var $ttl;
|
||||
var $rdlength;
|
||||
var $rdata;
|
||||
/* }}} */
|
||||
|
||||
/*
|
||||
* Use Net_DNS_RR::factory() instead
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
/* class constructor - Net_DNS_RR($rrdata) {{{ */
|
||||
function Net_DNS_RR($rrdata)
|
||||
{
|
||||
if ($rrdata != 'getRR') { //BC check/warning remove later
|
||||
trigger_error("Please use Net_DNS_RR::factory() instead");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns an RR object, use this instead of constructor
|
||||
*
|
||||
* @param mixed $rr_rdata Options as string, array or data
|
||||
* @return object Net_DNS_RR or Net_DNS_RR_<type>
|
||||
* @access public
|
||||
* @see Net_DNS_RR::new_from_array Net_DNS_RR::new_from_data Net_DNS_RR::new_from_string
|
||||
*/
|
||||
function &factory($rrdata, $update_type = '')
|
||||
{
|
||||
if (is_string($rrdata)) {
|
||||
$rr = &Net_DNS_RR::new_from_string($rrdata, $update_type);
|
||||
} elseif (count($rrdata) == 7) {
|
||||
list($name, $rrtype, $rrclass, $ttl, $rdlength, $data, $offset) = $rrdata;
|
||||
$rr = &Net_DNS_RR::new_from_data($name, $rrtype, $rrclass, $ttl, $rdlength, $data, $offset);
|
||||
} else {
|
||||
$rr = &Net_DNS_RR::new_from_array($rrdata);
|
||||
}
|
||||
return $rr;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* Net_DNS_RR::new_from_data($name, $ttl, $rrtype, $rrclass, $rdlength, $data, $offset) {{{ */
|
||||
function &new_from_data($name, $rrtype, $rrclass, $ttl, $rdlength, $data, $offset)
|
||||
{
|
||||
$rr = &new Net_DNS_RR('getRR');
|
||||
$rr->name = $name;
|
||||
$rr->type = $rrtype;
|
||||
$rr->class = $rrclass;
|
||||
$rr->ttl = $ttl;
|
||||
$rr->rdlength = $rdlength;
|
||||
$rr->rdata = substr($data, $offset, $rdlength);
|
||||
if (class_exists('Net_DNS_RR_' . $rrtype)) {
|
||||
$scn = 'Net_DNS_RR_' . $rrtype;
|
||||
$rr = new $scn($rr, $data, $offset);
|
||||
}
|
||||
return $rr;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* Net_DNS_RR::new_from_string($rrstring, $update_type = '') {{{ */
|
||||
function &new_from_string($rrstring, $update_type = '')
|
||||
{
|
||||
$rr = &new Net_DNS_RR('getRR');
|
||||
$ttl = 0;
|
||||
$parts = preg_split('/[\s]+/', $rrstring);
|
||||
while (count($parts) > 0) {
|
||||
$s = array_shift($parts);
|
||||
if (!isset($name)) {
|
||||
$name = ereg_replace('\.+$', '', $s);
|
||||
} else if (preg_match('/^\d+$/', $s)) {
|
||||
$ttl = $s;
|
||||
} else if (!isset($rrclass) && ! is_null(Net_DNS::classesbyname(strtoupper($s)))) {
|
||||
$rrclass = strtoupper($s);
|
||||
$rdata = join(' ', $parts);
|
||||
} else if (! is_null(Net_DNS::typesbyname(strtoupper($s)))) {
|
||||
$rrtype = strtoupper($s);
|
||||
$rdata = join(' ', $parts);
|
||||
break;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Do we need to do this?
|
||||
*/
|
||||
$rdata = trim(chop($rdata));
|
||||
|
||||
if (! strlen($rrtype) && strlen($rrclass) && $rrclass == 'ANY') {
|
||||
$rrtype = $rrclass;
|
||||
$rrclass = 'IN';
|
||||
} else if (! isset($rrclass)) {
|
||||
$rrclass = 'IN';
|
||||
}
|
||||
|
||||
if (! strlen($rrtype)) {
|
||||
$rrtype = 'ANY';
|
||||
}
|
||||
|
||||
if (strlen($update_type)) {
|
||||
$update_type = strtolower($update_type);
|
||||
if ($update_type == 'yxrrset') {
|
||||
$ttl = 0;
|
||||
if (! strlen($rdata)) {
|
||||
$rrclass = 'ANY';
|
||||
}
|
||||
} else if ($update_type == 'nxrrset') {
|
||||
$ttl = 0;
|
||||
$rrclass = 'NONE';
|
||||
$rdata = '';
|
||||
} else if ($update_type == 'yxdomain') {
|
||||
$ttl = 0;
|
||||
$rrclass = 'ANY';
|
||||
$rrtype = 'ANY';
|
||||
$rdata = '';
|
||||
} else if ($update_type == 'nxdomain') {
|
||||
$ttl = 0;
|
||||
$rrclass = 'NONE';
|
||||
$rrtype = 'ANY';
|
||||
$rdata = '';
|
||||
} else if (preg_match('/^(rr_)?add$/', $update_type)) {
|
||||
$update_type = 'add';
|
||||
if (! $ttl) {
|
||||
$ttl = 86400;
|
||||
}
|
||||
} else if (preg_match('/^(rr_)?del(ete)?$/', $update_type)) {
|
||||
$update_type = 'del';
|
||||
$ttl = 0;
|
||||
$rrclass = $rdata ? 'NONE' : 'ANY';
|
||||
}
|
||||
}
|
||||
|
||||
if (strlen($rrtype)) {
|
||||
$rr->name = $name;
|
||||
$rr->type = $rrtype;
|
||||
$rr->class = $rrclass;
|
||||
$rr->ttl = $ttl;
|
||||
$rr->rdlength = 0;
|
||||
$rr->rdata = '';
|
||||
|
||||
if (class_exists('Net_DNS_RR_' . $rrtype)) {
|
||||
$scn = 'Net_DNS_RR_' . $rrtype;
|
||||
return new $scn($rr, $rdata);
|
||||
} else {
|
||||
return $rr;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* Net_DNS_RR::new_from_array($rrarray) {{{ */
|
||||
function &new_from_array($rrarray)
|
||||
{
|
||||
$rr = &new Net_DNS_RR('getRR');
|
||||
foreach ($rrarray as $k => $v) {
|
||||
$rr->{strtolower($k)} = $v;
|
||||
}
|
||||
|
||||
if (! strlen($rr->name)) {
|
||||
return null;
|
||||
}
|
||||
if (! strlen($rr->type)){
|
||||
return null;
|
||||
}
|
||||
if (! $rr->ttl) {
|
||||
$rr->ttl = 0;
|
||||
}
|
||||
if (! strlen($rr->class)) {
|
||||
$rr->class = 'IN';
|
||||
}
|
||||
if (strlen($rr->rdata)) {
|
||||
$rr->rdlength = strlen($rr->rdata);
|
||||
}
|
||||
if (class_exists('Net_DNS_RR_' . $rr->rrtype)) {
|
||||
$scn = 'Net_DNS_RR_' . $rr->rrtype;
|
||||
return new $scn($rr, $rr->rdata);
|
||||
} else {
|
||||
return $rr;
|
||||
}
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* Net_DNS_RR::display() {{{ */
|
||||
function display()
|
||||
{
|
||||
echo $this->string() . "\n";
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* Net_DNS_RR::string() {{{ */
|
||||
function string()
|
||||
{
|
||||
return $this->name . ".\t" . (strlen($this->name) < 16 ? "\t" : '') .
|
||||
$this->ttl . "\t" .
|
||||
$this->class. "\t" .
|
||||
$this->type . "\t" .
|
||||
$this->rdatastr();
|
||||
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* Net_DNS_RR::rdatastr() {{{ */
|
||||
function rdatastr()
|
||||
{
|
||||
if ($this->rdlength) {
|
||||
return '; rdlength = ' . $this->rdlength;
|
||||
}
|
||||
return '; no data';
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* Net_DNS_RR::rdata() {{{ */
|
||||
function rdata(&$packetORrdata, $offset = '')
|
||||
{
|
||||
if ($offset) {
|
||||
return $this->rr_rdata($packetORrdata, $offset);
|
||||
} else if (strlen($this->rdata)) {
|
||||
return $this->rdata;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* Net_DNS_RR::rr_rdata($packet, $offset) {{{ */
|
||||
function rr_rdata(&$packet, $offset)
|
||||
{
|
||||
return (strlen($this->rdata) ? $this->rdata : '');
|
||||
}
|
||||
/* }}} */
|
||||
/* Net_DNS_RR::data() {{{ */
|
||||
function data(&$packet, $offset)
|
||||
{
|
||||
$data = $packet->dn_comp($this->name, $offset);
|
||||
$data .= pack('n', Net_DNS::typesbyname(strtoupper($this->type)));
|
||||
$data .= pack('n', Net_DNS::classesbyname(strtoupper($this->class)));
|
||||
$data .= pack('N', $this->ttl);
|
||||
|
||||
$offset += strlen($data) + 2; // The 2 extra bytes are for rdlength
|
||||
|
||||
$rdata = $this->rdata($packet, $offset);
|
||||
$data .= pack('n', strlen($rdata));
|
||||
$data .= $rdata;
|
||||
|
||||
return $data;
|
||||
}
|
||||
/* }}} */
|
||||
}
|
||||
/* }}} */
|
||||
/* 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 et
|
||||
* vim<600: sw=4 ts=4
|
||||
* }}} */
|
||||
?>
|
@ -1,109 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* License Information:
|
||||
*
|
||||
* Net_DNS: A resolver library for PHP
|
||||
* Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
|
||||
/* Net_DNS_RR_A object definition {{{ */
|
||||
/**
|
||||
* A representation of a resource record of type <b>A</b>
|
||||
*
|
||||
* @package Net_DNS
|
||||
*/
|
||||
class Net_DNS_RR_A extends Net_DNS_RR
|
||||
{
|
||||
/* class variable definitions {{{ */
|
||||
var $name;
|
||||
var $type;
|
||||
var $class;
|
||||
var $ttl;
|
||||
var $rdlength;
|
||||
var $rdata;
|
||||
var $address;
|
||||
/* }}} */
|
||||
/* class constructor - Net_DNS_RR_A(&$rro, $data, $offset = '') {{{ */
|
||||
function Net_DNS_RR_A(&$rro, $data, $offset = '')
|
||||
{
|
||||
$this->name = $rro->name;
|
||||
$this->type = $rro->type;
|
||||
$this->class = $rro->class;
|
||||
$this->ttl = $rro->ttl;
|
||||
$this->rdlength = $rro->rdlength;
|
||||
$this->rdata = $rro->rdata;
|
||||
|
||||
if ($offset) {
|
||||
if ($this->rdlength > 0) {
|
||||
/*
|
||||
* We don't have inet_ntoa in PHP?
|
||||
*/
|
||||
$aparts = unpack('C4b', $this->rdata);
|
||||
$addr = $aparts['b1'] . '.' .
|
||||
$aparts['b2'] . '.' .
|
||||
$aparts['b3'] . '.' .
|
||||
$aparts['b4'];
|
||||
$this->address = $addr;
|
||||
}
|
||||
} else {
|
||||
if (strlen($data) && ereg("([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)[ \t]*$", $data, $regs)) {
|
||||
if (($regs[1] >= 0 && $regs[1] <= 255) &&
|
||||
($regs[2] >= 0 && $regs[2] <= 255) &&
|
||||
($regs[3] >= 0 && $regs[3] <= 255) &&
|
||||
($regs[4] >= 0 && $regs[4] <= 255)) {
|
||||
$this->address = $regs[1] . '.' . $regs[2] . '.' . $regs[3] . '.' .$regs[4];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* Net_DNS_RR_A::rdatastr() {{{ */
|
||||
function rdatastr()
|
||||
{
|
||||
if (strlen($this->address)) {
|
||||
return $this->address;
|
||||
}
|
||||
return '; no data';
|
||||
}
|
||||
/* }}} */
|
||||
/* Net_DNS_RR_A::rr_rdata($packet, $offset) {{{ */
|
||||
function rr_rdata($packet, $offset)
|
||||
{
|
||||
$aparts = split('\.', $this->address);
|
||||
if (count($aparts) == 4) {
|
||||
return pack('c4', $aparts[0], $aparts[1], $aparts[2], $aparts[3]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
}
|
||||
/* }}} */
|
||||
/* 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 et
|
||||
* vim<600: sw=4 ts=4
|
||||
* }}} */
|
||||
?>
|
@ -1,141 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* License Information:
|
||||
*
|
||||
* Net_DNS: A resolver library for PHP
|
||||
* Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
|
||||
/* Net_DNS_RR_AAAA object definition {{{ */
|
||||
/**
|
||||
* A representation of a resource record of type <b>AAAA</b>
|
||||
*
|
||||
* @package Net_DNS
|
||||
*/
|
||||
class Net_DNS_RR_AAAA extends Net_DNS_RR
|
||||
{
|
||||
/* class variable definitions {{{ */
|
||||
var $name;
|
||||
var $type;
|
||||
var $class;
|
||||
var $ttl;
|
||||
var $rdlength;
|
||||
var $rdata;
|
||||
var $address;
|
||||
|
||||
/* }}} */
|
||||
/* class constructor - Net_DNS_RR_AAAA(&$rro, $data, $offset = '') {{{ */
|
||||
function Net_DNS_RR_AAAA(&$rro, $data, $offset = '')
|
||||
{
|
||||
$this->name = $rro->name;
|
||||
$this->type = $rro->type;
|
||||
$this->class = $rro->class;
|
||||
$this->ttl = $rro->ttl;
|
||||
$this->rdlength = $rro->rdlength;
|
||||
$this->rdata = $rro->rdata;
|
||||
|
||||
if ($offset) {
|
||||
$this->address = Net_DNS_RR_AAAA::ipv6_decompress(substr($this->rdata, 0, $this->rdlength));
|
||||
} else {
|
||||
if (strlen($data)) {
|
||||
if (count($adata = explode(':', $data, 8)) >= 3) {
|
||||
foreach($adata as $addr)
|
||||
if (!preg_match('/^[0-9A-F]{0,4}$/i', $addr)) return;
|
||||
$this->address = trim($data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* Net_DNS_RR_AAAA::rdatastr() {{{ */
|
||||
function rdatastr()
|
||||
{
|
||||
if (strlen($this->address)) {
|
||||
return $this->address;
|
||||
}
|
||||
return '; no data';
|
||||
}
|
||||
/* }}} */
|
||||
/* Net_DNS_RR_AAAA::rr_rdata($packet, $offset) {{{ */
|
||||
function rr_rdata($packet, $offset)
|
||||
{
|
||||
return Net_DNS_RR_AAAA::ipv6_compress($this->address);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* Net_DNS_RR_AAAA::ipv6_compress($addr) {{{ */
|
||||
function ipv6_compress($addr)
|
||||
{
|
||||
$numparts = count(explode(':', $addr));
|
||||
if ($numparts < 3 || $numparts > 8 ||
|
||||
!preg_match('/^([0-9A-F]{0,4}:){0,7}(:[0-9A-F]{0,4}){0,7}$/i', $addr)) {
|
||||
/* Non-sensical IPv6 address */
|
||||
return pack('n8', 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
if (strpos($addr, '::') !== false) {
|
||||
/* First we have to normalize the address, turn :: into :0:0:0:0: */
|
||||
$filler = str_repeat(':0', 9 - $numparts) . ':';
|
||||
if (substr($addr, 0, 2) == '::') {
|
||||
$filler = "0$filler";
|
||||
}
|
||||
if (substr($addr, -2, 2) == '::') {
|
||||
$filler .= '0';
|
||||
}
|
||||
$addr = str_replace('::', $filler, $addr);
|
||||
}
|
||||
$aparts = explode(':', $addr);
|
||||
return pack('n8', hexdec($aparts[0]), hexdec($aparts[1]), hexdec($aparts[2]), hexdec($aparts[3]),
|
||||
hexdec($aparts[4]), hexdec($aparts[5]), hexdec($aparts[6]), hexdec($aparts[7]));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* Net_DNS_RR_AAAA::ipv6_decompress($pack) {{{ */
|
||||
function ipv6_decompress($pack)
|
||||
{
|
||||
if (strlen($pack) != 16) {
|
||||
/* Must be 8 shorts long */
|
||||
return '::';
|
||||
}
|
||||
$a = unpack('n8', $pack);
|
||||
$addr = vsprintf("%x:%x:%x:%x:%x:%x:%x:%x", $a);
|
||||
/* Shorthand the first :0:0: set into a :: */
|
||||
/* TODO: Make this is a single replacement pattern */
|
||||
if (substr($addr, -4) == ':0:0') {
|
||||
return preg_replace('/((:0){2,})$/', '::', $addr);
|
||||
} elseif (substr($addr, 0, 4) == '0:0:') {
|
||||
return '0:0:'. substr($addr, 4);
|
||||
} else {
|
||||
return preg_replace('/(:(0:){2,})/', '::', $addr);
|
||||
}
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
}
|
||||
/* }}} */
|
||||
/* 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 et
|
||||
* vim<600: sw=4 ts=4
|
||||
* }}} */
|
||||
?>
|
@ -1,94 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* License Information:
|
||||
*
|
||||
* Net_DNS: A resolver library for PHP
|
||||
* Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/* Net_DNS_RR_CNAME definition {{{ */
|
||||
/**
|
||||
* A representation of a resource record of type <b>CNAME</b>
|
||||
*
|
||||
* @package Net_DNS
|
||||
*/
|
||||
class Net_DNS_RR_CNAME extends Net_DNS_RR
|
||||
{
|
||||
/* class variable definitions {{{ */
|
||||
var $name;
|
||||
var $type;
|
||||
var $class;
|
||||
var $ttl;
|
||||
var $rdlength;
|
||||
var $rdata;
|
||||
var $cname;
|
||||
|
||||
/* }}} */
|
||||
/* class constructor - RR(&$rro, $data, $offset = '') {{{ */
|
||||
function Net_DNS_RR_CNAME(&$rro, $data, $offset = '')
|
||||
{
|
||||
$this->name = $rro->name;
|
||||
$this->type = $rro->type;
|
||||
$this->class = $rro->class;
|
||||
$this->ttl = $rro->ttl;
|
||||
$this->rdlength = $rro->rdlength;
|
||||
$this->rdata = $rro->rdata;
|
||||
|
||||
if ($offset) {
|
||||
if ($this->rdlength > 0) {
|
||||
list($cname, $offset) = Net_DNS_Packet::dn_expand($data, $offset);
|
||||
$this->cname = $cname;
|
||||
}
|
||||
} else {
|
||||
$this->cname = ereg_replace("[ \t]+(.+)[\. \t]*$", '\\1', $data);
|
||||
}
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* Net_DNS_RR_CNAME::rdatastr() {{{ */
|
||||
function rdatastr()
|
||||
{
|
||||
if (strlen($this->cname)) {
|
||||
return $this->cname . '.';
|
||||
}
|
||||
return '; no data';
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* Net_DNS_RR_CNAME::rr_rdata($packet, $offset) {{{ */
|
||||
function rr_rdata($packet, $offset)
|
||||
{
|
||||
if (strlen($this->cname)) {
|
||||
return $packet->dn_comp($this->cname, $offset);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
}
|
||||
/* }}} */
|
||||
/* 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 et
|
||||
* vim<600: sw=4 ts=4
|
||||
* }}} */
|
||||
?>
|
@ -1,110 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* License Information:
|
||||
*
|
||||
* Net_DNS: A resolver library for PHP
|
||||
* Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/* Net_DNS_RR_HINFO definition {{{ */
|
||||
/**
|
||||
* A representation of a resource record of type <b>HINFO</b>
|
||||
*
|
||||
* @package Net_DNS
|
||||
*/
|
||||
class Net_DNS_RR_HINFO extends Net_DNS_RR
|
||||
{
|
||||
/* class variable definitions {{{ */
|
||||
var $name;
|
||||
var $type;
|
||||
var $class;
|
||||
var $ttl;
|
||||
var $rdlength;
|
||||
var $rdata;
|
||||
var $cpu;
|
||||
var $os;
|
||||
|
||||
/* }}} */
|
||||
/* class constructor - RR(&$rro, $data, $offset = '') {{{ */
|
||||
function Net_DNS_RR_HINFO(&$rro, $data, $offset = '')
|
||||
{
|
||||
$this->name = $rro->name;
|
||||
$this->type = $rro->type;
|
||||
$this->class = $rro->class;
|
||||
$this->ttl = $rro->ttl;
|
||||
$this->rdlength = $rro->rdlength;
|
||||
$this->rdata = $rro->rdata;
|
||||
|
||||
if ($offset) {
|
||||
if ($this->rdlength > 0) {
|
||||
list($cpu, $offset) = Net_DNS_Packet::label_extract($data, $offset);
|
||||
list($os, $offset) = Net_DNS_Packet::label_extract($data, $offset);
|
||||
|
||||
$this->cpu = $cpu;
|
||||
$this->os = $os;
|
||||
}
|
||||
} else {
|
||||
$data = str_replace('\\\\', chr(1) . chr(1), $data); /* disguise escaped backslash */
|
||||
$data = str_replace('\\"', chr(2) . chr(2), $data); /* disguise \" */
|
||||
|
||||
ereg('("[^"]*"|[^ \t]*)[ \t]+("[^"]*"|[^ \t]*)[ \t]*$', $data, $regs);
|
||||
foreach($regs as $idx => $value) {
|
||||
$value = str_replace(chr(2) . chr(2), '\\"', $value);
|
||||
$value = str_replace(chr(1) . chr(1), '\\\\', $value);
|
||||
$regs[$idx] = stripslashes($value);
|
||||
}
|
||||
|
||||
$this->cpu = $regs[1];
|
||||
$this->os = $regs[2];
|
||||
}
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* Net_DNS_RR_HINFO::rdatastr() {{{ */
|
||||
function rdatastr()
|
||||
{
|
||||
if ($this->text) {
|
||||
return '"' . addslashes($this->cpu) . '" "' . addslashes($this->os) . '"';
|
||||
} else return '; no data';
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* Net_DNS_RR_HINFO::rr_rdata($packet, $offset) {{{ */
|
||||
function rr_rdata($packet, $offset)
|
||||
{
|
||||
if ($this->text) {
|
||||
$rdata = pack('C', strlen($this->cpu)) . $this->cpu;
|
||||
$rdata .= pack('C', strlen($this->os)) . $this->os;
|
||||
return $rdata;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
}
|
||||
/* }}} */
|
||||
/* 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 et
|
||||
* vim<600: sw=4 ts=4
|
||||
* }}} */
|
||||
?>
|
@ -1,102 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* License Information:
|
||||
*
|
||||
* Net_DNS: A resolver library for PHP
|
||||
* Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/* Net_DNS_RR_MX definition {{{ */
|
||||
/**
|
||||
* A representation of a resource record of type <b>MX</b>
|
||||
*
|
||||
* @package Net_DNS
|
||||
*/
|
||||
class Net_DNS_RR_MX extends Net_DNS_RR
|
||||
{
|
||||
/* class variable definitions {{{ */
|
||||
var $name;
|
||||
var $type;
|
||||
var $class;
|
||||
var $ttl;
|
||||
var $rdlength;
|
||||
var $rdata;
|
||||
var $preference;
|
||||
var $exchange;
|
||||
|
||||
/* }}} */
|
||||
/* class constructor - RR(&$rro, $data, $offset = '') {{{ */
|
||||
function Net_DNS_RR_MX(&$rro, $data, $offset = '')
|
||||
{
|
||||
$this->name = $rro->name;
|
||||
$this->type = $rro->type;
|
||||
$this->class = $rro->class;
|
||||
$this->ttl = $rro->ttl;
|
||||
$this->rdlength = $rro->rdlength;
|
||||
$this->rdata = $rro->rdata;
|
||||
|
||||
if ($offset) {
|
||||
if ($this->rdlength > 0) {
|
||||
$a = unpack("@$offset/npreference", $data);
|
||||
$offset += 2;
|
||||
list($exchange, $offset) = Net_DNS_Packet::dn_expand($data, $offset);
|
||||
$this->preference = $a['preference'];
|
||||
$this->exchange = $exchange;
|
||||
}
|
||||
} else {
|
||||
ereg("([0-9]+)[ \t]+(.+)[ \t]*$", $data, $regs);
|
||||
$this->preference = $regs[1];
|
||||
$this->exchange = ereg_replace('(.*)\.$', '\\1', $regs[2]);
|
||||
}
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* Net_DNS_RR_MX::rdatastr() {{{ */
|
||||
function rdatastr()
|
||||
{
|
||||
if (preg_match('/^[0-9]+$/', $this->preference)) {
|
||||
return $this->preference . ' ' . $this->exchange . '.';
|
||||
}
|
||||
return '; no data';
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* Net_DNS_RR_MX::rr_rdata($packet, $offset) {{{ */
|
||||
function rr_rdata($packet, $offset)
|
||||
{
|
||||
if (preg_match('/^[0-9]+$/', $this->preference)) {
|
||||
$rdata = pack('n', $this->preference);
|
||||
$rdata .= $packet->dn_comp($this->exchange, $offset + strlen($rdata));
|
||||
return $rdata;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
}
|
||||
/* }}} */
|
||||
/* 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 et
|
||||
* vim<600: sw=4 ts=4
|
||||
* }}} */
|
||||
?>
|
@ -1,128 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* License Information:
|
||||
*
|
||||
* Net_DNS: A resolver library for PHP
|
||||
* Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/* Net_DNS_RR_NAPTR definition {{{ */
|
||||
/**
|
||||
* A representation of a resource record of type <b>NAPTR</b>
|
||||
*
|
||||
* @package Net_DNS
|
||||
*/
|
||||
class Net_DNS_RR_NAPTR extends Net_DNS_RR
|
||||
{
|
||||
/* class variable definitions {{{ */
|
||||
var $name;
|
||||
var $type;
|
||||
var $class;
|
||||
var $ttl;
|
||||
var $rdlength;
|
||||
var $rdata;
|
||||
var $order;
|
||||
var $preference;
|
||||
var $flags;
|
||||
var $services;
|
||||
var $regex;
|
||||
var $replacement;
|
||||
|
||||
/* }}} */
|
||||
/* class constructor - RR(&$rro, $data, $offset = '') {{{ */
|
||||
function Net_DNS_RR_NAPTR(&$rro, $data, $offset = '')
|
||||
{
|
||||
$this->name = $rro->name;
|
||||
$this->type = $rro->type;
|
||||
$this->class = $rro->class;
|
||||
$this->ttl = $rro->ttl;
|
||||
$this->rdlength = $rro->rdlength;
|
||||
$this->rdata = $rro->rdata;
|
||||
|
||||
if ($offset) {
|
||||
if ($this->rdlength > 0) {
|
||||
$a = unpack("@$offset/norder/npreference", $data);
|
||||
$offset += 4;
|
||||
list($flags, $offset) = Net_DNS_Packet::label_extract($data, $offset);
|
||||
list($services, $offset) = Net_DNS_Packet::label_extract($data, $offset);
|
||||
list($regex, $offset) = Net_DNS_Packet::label_extract($data, $offset);
|
||||
list($replacement, $offset) = Net_DNS_Packet::dn_expand($data, $offset);
|
||||
|
||||
$this->order = $a['order'];
|
||||
$this->preference = $a['preference'];
|
||||
$this->flags = $flags;
|
||||
$this->services = $services;
|
||||
$this->regex = $regex;
|
||||
$this->replacement = $replacement;
|
||||
}
|
||||
} else {
|
||||
$data = str_replace('\\\\', chr(1) . chr(1), $data); /* disguise escaped backslash */
|
||||
$data = str_replace('\\"', chr(2) . chr(2), $data); /* disguise \" */
|
||||
ereg('([0-9]+)[ \t]+([0-9]+)[ \t]+("[^"]*"|[^ \t]*)[ \t]+("[^"]*"|[^ \t]*)[ \t]+("[^"]*"|[^ \t]*)[ \t]+(.*?)[ \t]*$', $data, $regs);
|
||||
$this->preference = $regs[1];
|
||||
$this->weight = $regs[2];
|
||||
foreach($regs as $idx => $value) {
|
||||
$value = str_replace(chr(2) . chr(2), '\\"', $value);
|
||||
$value = str_replace(chr(1) . chr(1), '\\\\', $value);
|
||||
$regs[$idx] = stripslashes($value);
|
||||
}
|
||||
$this->flags = $regs[3];
|
||||
$this->services = $regs[4];
|
||||
$this->regex = $regs[5];
|
||||
$this->replacement = $regs[6];
|
||||
}
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* Net_DNS_RR_NAPTR::rdatastr() {{{ */
|
||||
function rdatastr()
|
||||
{
|
||||
if ($this->rdata) {
|
||||
return intval($this->order) . ' ' . intval($this->preference) . ' "' . addslashes($this->flags) . '" "' .
|
||||
addslashes($this->services) . '" "' . addslashes($this->regex) . '" "' . addslashes($this->replacement) . '"';
|
||||
} else return '; no data';
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* Net_DNS_RR_NAPTR::rr_rdata($packet, $offset) {{{ */
|
||||
function rr_rdata($packet, $offset)
|
||||
{
|
||||
if ($this->preference) {
|
||||
$rdata = pack('nn', $this->order, $this->preference);
|
||||
$rdata .= pack('C', strlen($this->flags)) . $this->flags;
|
||||
$rdata .= pack('C', strlen($this->services)) . $this->services;
|
||||
$rdata .= pack('C', strlen($this->regex)) . $this->regex;
|
||||
$rdata .= $packet->dn_comp($this->replacement, $offset + strlen($rdata));
|
||||
return $rdata;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
}
|
||||
/* }}} */
|
||||
/* 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 et
|
||||
* vim<600: sw=4 ts=4
|
||||
* }}} */
|
||||
?>
|
@ -1,95 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* License Information:
|
||||
*
|
||||
* Net_DNS: A resolver library for PHP
|
||||
* Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/* Net_DNS_RR_NS definition {{{ */
|
||||
/**
|
||||
* A representation of a resource record of type <b>NS</b>
|
||||
*
|
||||
* @package Net_DNS
|
||||
*/
|
||||
class Net_DNS_RR_NS extends Net_DNS_RR
|
||||
{
|
||||
/* class variable defintiions {{{ */
|
||||
var $name;
|
||||
var $type;
|
||||
var $class;
|
||||
var $ttl;
|
||||
var $rdlength;
|
||||
var $rdata;
|
||||
var $nsdname;
|
||||
|
||||
/* }}} */
|
||||
/* class constructor - RR(&$rro, $data, $offset = '') {{{ */
|
||||
function Net_DNS_RR_NS(&$rro, $data, $offset = '')
|
||||
{
|
||||
$this->name = $rro->name;
|
||||
$this->type = $rro->type;
|
||||
$this->class = $rro->class;
|
||||
$this->ttl = $rro->ttl;
|
||||
$this->rdlength = $rro->rdlength;
|
||||
$this->rdata = $rro->rdata;
|
||||
|
||||
|
||||
if ($offset) {
|
||||
if ($this->rdlength > 0) {
|
||||
list($nsdname, $offset) = Net_DNS_Packet::dn_expand($data, $offset);
|
||||
$this->nsdname = $nsdname;
|
||||
}
|
||||
} else {
|
||||
$this->nsdname = ereg_replace("[ \t]+(.+)[ \t]*$", '\\1', $data);
|
||||
}
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* Net_DNS_RR_NS::rdatastr() {{{ */
|
||||
function rdatastr()
|
||||
{
|
||||
if (strlen($this->nsdname)) {
|
||||
return $this->nsdname . '.';
|
||||
}
|
||||
return '; no data';
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* Net_DNS_RR_NS::rr_rdata($packet, $offset) {{{ */
|
||||
function rr_rdata($packet, $offset)
|
||||
{
|
||||
if (strlen($this->nsdname)) {
|
||||
return $packet->dn_comp($this->nsdname, $offset);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
}
|
||||
/* }}} */
|
||||
/* 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 et
|
||||
* vim<600: sw=4 ts=4
|
||||
* }}} */
|
||||
?>
|
@ -1,95 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* License Information:
|
||||
*
|
||||
* Net_DNS: A resolver library for PHP
|
||||
* Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/* Net_DNS_RR_PTR definition {{{ */
|
||||
/**
|
||||
* A representation of a resource record of type <b>PTR</b>
|
||||
*
|
||||
* @package Net_DNS
|
||||
*/
|
||||
class Net_DNS_RR_PTR extends Net_DNS_RR
|
||||
{
|
||||
/* class variable definitions {{{ */
|
||||
var $name;
|
||||
var $type;
|
||||
var $class;
|
||||
var $ttl;
|
||||
var $rdlength;
|
||||
var $rdata;
|
||||
var $ptrdname;
|
||||
|
||||
/* }}} */
|
||||
/* class constructor - RR(&$rro, $data, $offset = '') {{{ */
|
||||
function Net_DNS_RR_PTR(&$rro, $data, $offset = '')
|
||||
{
|
||||
$this->name = $rro->name;
|
||||
$this->type = $rro->type;
|
||||
$this->class = $rro->class;
|
||||
$this->ttl = $rro->ttl;
|
||||
$this->rdlength = $rro->rdlength;
|
||||
$this->rdata = $rro->rdata;
|
||||
|
||||
|
||||
if ($offset) {
|
||||
if ($this->rdlength > 0) {
|
||||
list($ptrdname, $offset) = Net_DNS_Packet::dn_expand($data, $offset);
|
||||
$this->ptrdname = $ptrdname;
|
||||
}
|
||||
} else {
|
||||
$this->ptrdname = ereg_replace("[ \t]+(.+)[ \t]*$", '\\1', $data);
|
||||
}
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* Net_DNS_RR_PTR::rdatastr() {{{ */
|
||||
function rdatastr()
|
||||
{
|
||||
if (strlen($this->ptrdname)) {
|
||||
return $this->ptrdname . '.';
|
||||
}
|
||||
return '; no data';
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* Net_DNS_RR_PTR::rr_rdata($packet, $offset) {{{ */
|
||||
function rr_rdata($packet, $offset)
|
||||
{
|
||||
if (strlen($this->ptrdname)) {
|
||||
return $packet->dn_comp($this->ptrdname, $offset);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
}
|
||||
/* }}} */
|
||||
/* 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 et
|
||||
* vim<600: sw=4 ts=4
|
||||
* }}} */
|
||||
?>
|
@ -1,137 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* License Information:
|
||||
*
|
||||
* Net_DNS: A resolver library for PHP
|
||||
* Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/* Net_DNS_RR_SOA definition {{{ */
|
||||
/**
|
||||
* A representation of a resource record of type <b>SOA</b>
|
||||
*
|
||||
* @package Net_DNS
|
||||
*/
|
||||
class Net_DNS_RR_SOA extends Net_DNS_RR
|
||||
{
|
||||
/* class variable definitions {{{ */
|
||||
var $name;
|
||||
var $type;
|
||||
var $class;
|
||||
var $ttl;
|
||||
var $rdlength;
|
||||
var $rdata;
|
||||
var $mname;
|
||||
var $rname;
|
||||
var $serial;
|
||||
var $refresh;
|
||||
var $retry;
|
||||
var $expire;
|
||||
var $minimum;
|
||||
|
||||
/* }}} */
|
||||
/* class constructor - RR(&$rro, $data, $offset = '') {{{ */
|
||||
function Net_DNS_RR_SOA(&$rro, $data, $offset = '')
|
||||
{
|
||||
$this->name = $rro->name;
|
||||
$this->type = $rro->type;
|
||||
$this->class = $rro->class;
|
||||
$this->ttl = $rro->ttl;
|
||||
$this->rdlength = $rro->rdlength;
|
||||
$this->rdata = $rro->rdata;
|
||||
|
||||
if ($offset) {
|
||||
if ($this->rdlength > 0) {
|
||||
list($mname, $offset) = Net_DNS_Packet::dn_expand($data, $offset);
|
||||
list($rname, $offset) = Net_DNS_Packet::dn_expand($data, $offset);
|
||||
|
||||
$a = unpack("@$offset/N5soavals", $data);
|
||||
$this->mname = $mname;
|
||||
$this->rname = $rname;
|
||||
$this->serial = $a['soavals1'];
|
||||
$this->refresh = $a['soavals2'];
|
||||
$this->retry = $a['soavals3'];
|
||||
$this->expire = $a['soavals4'];
|
||||
$this->minimum = $a['soavals5'];
|
||||
}
|
||||
} else {
|
||||
if (ereg("([^ \t]+)[ \t]+([^ \t]+)[ \t]+([0-9]+)[^ \t]+([0-9]+)[^ \t]+([0-9]+)[^ \t]+([0-9]+)[^ \t]*$", $string, $regs))
|
||||
{
|
||||
$this->mname = ereg_replace('(.*)\.$', '\\1', $regs[1]);
|
||||
$this->rname = ereg_replace('(.*)\.$', '\\1', $regs[2]);
|
||||
$this->serial = $regs[3];
|
||||
$this->refresh = $regs[4];
|
||||
$this->retry = $regs[5];
|
||||
$this->expire = $regs[6];
|
||||
$this->minimum = $regs[7];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* Net_DNS_RR_SOA::rdatastr($pretty = 0) {{{ */
|
||||
function rdatastr($pretty = 0)
|
||||
{
|
||||
if (strlen($this->mname)) {
|
||||
if ($pretty) {
|
||||
$rdatastr = $this->mname . '. ' . $this->rname . ". (\n";
|
||||
$rdatastr .= "\t\t\t\t\t" . $this->serial . "\t; Serial\n";
|
||||
$rdatastr .= "\t\t\t\t\t" . $this->refresh . "\t; Refresh\n";
|
||||
$rdatastr .= "\t\t\t\t\t" . $this->retry . "\t; Retry\n";
|
||||
$rdatastr .= "\t\t\t\t\t" . $this->expire . "\t; Expire\n";
|
||||
$rdatastr .= "\t\t\t\t\t" . $this->minimum . " )\t; Minimum TTL";
|
||||
} else {
|
||||
$rdatastr = $this->mname . '. ' . $this->rname . '. ' .
|
||||
$this->serial . ' ' . $this->refresh . ' ' . $this->retry . ' ' .
|
||||
$this->expire . ' ' . $this->minimum;
|
||||
}
|
||||
return $rdatastr;
|
||||
}
|
||||
return '; no data';
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* Net_DNS_RR_SOA::rr_rdata($packet, $offset) {{{ */
|
||||
function rr_rdata($packet, $offset)
|
||||
{
|
||||
if (strlen($this->mname)) {
|
||||
$rdata = $packet->dn_comp($this->mname, $offset);
|
||||
$rdata .= $packet->dn_comp($this->rname, $offset + strlen($rdata));
|
||||
$rdata .= pack('N5', $this->serial,
|
||||
$this->refresh,
|
||||
$this->retry,
|
||||
$this->expire,
|
||||
$this->minimum);
|
||||
return $rdata;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
}
|
||||
/* }}} */
|
||||
/* 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 et
|
||||
* vim<600: sw=4 ts=4
|
||||
* }}} */
|
||||
?>
|
@ -1,108 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* License Information:
|
||||
*
|
||||
* Net_DNS: A resolver library for PHP
|
||||
* Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/* Net_DNS_RR_SRV definition {{{ */
|
||||
/**
|
||||
* A representation of a resource record of type <b>SRV</b>
|
||||
*
|
||||
* @package Net_DNS
|
||||
*/
|
||||
class Net_DNS_RR_SRV extends Net_DNS_RR
|
||||
{
|
||||
/* class variable definitions {{{ */
|
||||
var $name;
|
||||
var $type;
|
||||
var $class;
|
||||
var $ttl;
|
||||
var $rdlength;
|
||||
var $rdata;
|
||||
var $preference;
|
||||
var $weight;
|
||||
var $port;
|
||||
var $target;
|
||||
|
||||
/* }}} */
|
||||
/* class constructor - RR(&$rro, $data, $offset = '') {{{ */
|
||||
function Net_DNS_RR_SRV(&$rro, $data, $offset = '')
|
||||
{
|
||||
$this->name = $rro->name;
|
||||
$this->type = $rro->type;
|
||||
$this->class = $rro->class;
|
||||
$this->ttl = $rro->ttl;
|
||||
$this->rdlength = $rro->rdlength;
|
||||
$this->rdata = $rro->rdata;
|
||||
|
||||
if ($offset) {
|
||||
if ($this->rdlength > 0) {
|
||||
$a = unpack("@$offset/npreference/nweight/nport", $data);
|
||||
$offset += 6;
|
||||
list($target, $offset) = Net_DNS_Packet::dn_expand($data, $offset);
|
||||
$this->preference = $a['preference'];
|
||||
$this->weight = $a['weight'];
|
||||
$this->port = $a['port'];
|
||||
$this->target = $target;
|
||||
}
|
||||
} else {
|
||||
ereg("([0-9]+)[ \t]+([0-9]+)[ \t]+([0-9]+)[ \t]+(.+)[ \t]*$", $data, $regs);
|
||||
$this->preference = $regs[1];
|
||||
$this->weight = $regs[2];
|
||||
$this->port = $regs[3];
|
||||
$this->target = ereg_replace('(.*)\.$', '\\1', $regs[4]);
|
||||
}
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* Net_DNS_RR_SRV::rdatastr() {{{ */
|
||||
function rdatastr()
|
||||
{
|
||||
if ($this->port) {
|
||||
return intval($this->preference) . ' ' . intval($this->weight) . ' ' . intval($this->port) . ' ' . $this->target . '.';
|
||||
}
|
||||
return '; no data';
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* Net_DNS_RR_SRV::rr_rdata($packet, $offset) {{{ */
|
||||
function rr_rdata($packet, $offset)
|
||||
{
|
||||
if (isset($this->preference)) {
|
||||
$rdata = pack('nnn', $this->preference, $this->weight, $this->port);
|
||||
$rdata .= $packet->dn_comp($this->target, $offset + strlen($rdata));
|
||||
return $rdata;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
}
|
||||
/* }}} */
|
||||
/* 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 et
|
||||
* vim<600: sw=4 ts=4
|
||||
* }}} */
|
||||
?>
|
@ -1,236 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* License Information:
|
||||
*
|
||||
* Net_DNS: A resolver library for PHP
|
||||
* Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
define('NET_DNS_DEFAULT_ALGORITHM', 'hmac-md5.sig-alg.reg.int');
|
||||
define('NET_DNS_DEFAULT_FUDGE', 300);
|
||||
|
||||
/* Net_DNS_RR_TSIG definition {{{ */
|
||||
/**
|
||||
* A representation of a resource record of type <b>TSIG</b>
|
||||
*
|
||||
* @package Net_DNS
|
||||
*/
|
||||
class Net_DNS_RR_TSIG extends Net_DNS_RR
|
||||
{
|
||||
/* class variable definitions {{{ */
|
||||
var $name;
|
||||
var $type;
|
||||
var $class;
|
||||
var $ttl;
|
||||
var $rdlength;
|
||||
var $rdata;
|
||||
var $time_signed;
|
||||
var $fudge;
|
||||
var $mac_size;
|
||||
var $mac;
|
||||
var $original_id;
|
||||
var $error;
|
||||
var $other_len;
|
||||
var $other_data;
|
||||
var $key;
|
||||
|
||||
/* }}} */
|
||||
/* class constructor - RR(&$rro, $data, $offset = '') {{{ */
|
||||
function Net_DNS_RR_TSIG(&$rro, $data, $offset = '')
|
||||
{
|
||||
$this->name = $rro->name;
|
||||
$this->type = $rro->type;
|
||||
$this->class = $rro->class;
|
||||
$this->ttl = $rro->ttl;
|
||||
$this->rdlength = $rro->rdlength;
|
||||
$this->rdata = $rro->rdata;
|
||||
|
||||
if ($offset) {
|
||||
if ($this->rdlength > 0) {
|
||||
list($alg, $offset) = Net_DNS_Packet::dn_expand($data, $offset);
|
||||
$this->algorithm = $alg;
|
||||
|
||||
$d = unpack("\@$offset/nth/Ntl/nfudge/nmac_size", $data);
|
||||
$time_high = $d['th'];
|
||||
$time_low = $d['tl'];
|
||||
$this->time_signed = $time_low;
|
||||
$this->fudge = $d['fudge'];
|
||||
$this->mac_size = $d['mac_size'];
|
||||
$offset += 10;
|
||||
|
||||
$this->mac = substr($data, $offset, $this->mac_size);
|
||||
$offset += $this->mac_size;
|
||||
|
||||
$d = unpack("@$offset/noid/nerror/nolen", $data);
|
||||
$this->original_id = $d['oid'];
|
||||
$this->error = $d['error'];
|
||||
$this->other_len = $d['olen'];
|
||||
$offset += 6;
|
||||
|
||||
$odata = substr($data, $offset, $this->other_len);
|
||||
$d = unpack('nodata_high/Nodata_low', $odata);
|
||||
$this->other_data = $d['odata_low'];
|
||||
}
|
||||
} else {
|
||||
if (strlen($data) && preg_match('/^(.*)$/', $data, $regs)) {
|
||||
$this->key = $regs[1];
|
||||
}
|
||||
|
||||
$this->algorithm = NET_DNS_DEFAULT_ALGORITHM;
|
||||
$this->time_signed = time();
|
||||
|
||||
$this->fudge = NET_DNS_DEFAULT_FUDGE;
|
||||
$this->mac_size = 0;
|
||||
$this->mac = '';
|
||||
$this->original_id = 0;
|
||||
$this->error = 0;
|
||||
$this->other_len = 0;
|
||||
$this->other_data = '';
|
||||
|
||||
// RFC 2845 Section 2.3
|
||||
$this->class = 'ANY';
|
||||
}
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* Net_DNS_RR_TSIG::rdatastr() {{{ */
|
||||
function rdatastr()
|
||||
{
|
||||
$error = $this->error;
|
||||
if (! $error) {
|
||||
$error = 'UNDEFINED';
|
||||
}
|
||||
|
||||
if (strlen($this->algorithm)) {
|
||||
$rdatastr = $this->algorithm . '. ' . $this->time_signed . ' ' .
|
||||
$this->fudge . ' ';
|
||||
if ($this->mac_size && strlen($this->mac)) {
|
||||
$rdatastr .= ' ' . $this->mac_size . ' ' . base64_encode($this->mac);
|
||||
} else {
|
||||
$rdatastr .= ' 0 ';
|
||||
}
|
||||
$rdatastr .= ' ' . $this->original_id . ' ' . $error;
|
||||
if ($this->other_len && strlen($this->other_data)) {
|
||||
$rdatastr .= ' ' . $this->other_data;
|
||||
} else {
|
||||
$rdatastr .= ' 0 ';
|
||||
}
|
||||
} else {
|
||||
$rdatastr = '; no data';
|
||||
}
|
||||
|
||||
return $rdatastr;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* Net_DNS_RR_TSIG::rr_rdata($packet, $offset) {{{ */
|
||||
function rr_rdata($packet, $offset)
|
||||
{
|
||||
$rdata = '';
|
||||
$sigdata = '';
|
||||
|
||||
if (strlen($this->key)) {
|
||||
$key = $this->key;
|
||||
$key = ereg_replace(' ', '', $key);
|
||||
$key = base64_decode($key);
|
||||
|
||||
$newpacket = $packet;
|
||||
$newoffset = $offset;
|
||||
array_pop($newpacket->additional);
|
||||
$newpacket->header->arcount--;
|
||||
$newpacket->compnames = array();
|
||||
|
||||
/*
|
||||
* Add the request MAC if present (used to validate responses).
|
||||
*/
|
||||
if (isset($this->request_mac)) {
|
||||
$sigdata .= pack('H*', $this->request_mac);
|
||||
}
|
||||
$sigdata .= $newpacket->data();
|
||||
|
||||
/*
|
||||
* Don't compress the record (key) name.
|
||||
*/
|
||||
$tmppacket = new Net_DNS_Packet;
|
||||
$sigdata .= $tmppacket->dn_comp(strtolower($this->name), 0);
|
||||
|
||||
$sigdata .= pack('n', Net_DNS::classesbyname(strtoupper($this->class)));
|
||||
$sigdata .= pack('N', $this->ttl);
|
||||
|
||||
/*
|
||||
* Don't compress the algorithm name.
|
||||
*/
|
||||
$tmppacket->compnames = array();
|
||||
$sigdata .= $tmppacket->dn_comp(strtolower($this->algorithm), 0);
|
||||
|
||||
$sigdata .= pack('nN', 0, $this->time_signed);
|
||||
$sigdata .= pack('n', $this->fudge);
|
||||
$sigdata .= pack('nn', $this->error, $this->other_len);
|
||||
|
||||
if (strlen($this->other_data)) {
|
||||
$sigdata .= pack('nN', 0, $this->other_data);
|
||||
}
|
||||
|
||||
$this->mac = mhash(MHASH_MD5, $sigdata, $key);
|
||||
$this->mac_size = strlen($this->mac);
|
||||
|
||||
/*
|
||||
* Don't compress the algorithm name.
|
||||
*/
|
||||
unset($tmppacket);
|
||||
$tmppacket = new Net_DNS_Packet;
|
||||
$rdata .= $tmppacket->dn_comp(strtolower($this->algorithm), 0);
|
||||
|
||||
$rdata .= pack('nN', 0, $this->time_signed);
|
||||
$rdata .= pack('nn', $this->fudge, $this->mac_size);
|
||||
$rdata .= $this->mac;
|
||||
|
||||
$rdata .= pack('nnn',$packet->header->id,
|
||||
$this->error,
|
||||
$this->other_len);
|
||||
|
||||
if ($this->other_data) {
|
||||
$rdata .= pack('nN', 0, $this->other_data);
|
||||
}
|
||||
}
|
||||
return $rdata;
|
||||
}
|
||||
/* }}} */
|
||||
/* Net_DNS_RR_TSIG::error() {{{ */
|
||||
function error()
|
||||
{
|
||||
if ($this->error != 0) {
|
||||
$rcode = Net_DNS::rcodesbyval($error);
|
||||
}
|
||||
return $rcode;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
}
|
||||
/* }}} */
|
||||
/* VIM settings {{{
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* soft-stop-width: 4
|
||||
* c indent on
|
||||
* expandtab on
|
||||
* End:
|
||||
* vim600: sw=4 ts=4 sts=4 cindent fdm=marker et
|
||||
* vim<600: sw=4 ts=4
|
||||
* }}} */
|
||||
?>
|
@ -1,113 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* License Information:
|
||||
*
|
||||
* Net_DNS: A resolver library for PHP
|
||||
* Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/* Net_DNS_RR_TXT definition {{{ */
|
||||
/**
|
||||
* A representation of a resource record of type <b>TXT</b>
|
||||
*
|
||||
* @package Net_DNS
|
||||
*/
|
||||
class Net_DNS_RR_TXT extends Net_DNS_RR
|
||||
{
|
||||
/* class variable definitions {{{ */
|
||||
var $name;
|
||||
var $type;
|
||||
var $class;
|
||||
var $ttl;
|
||||
var $rdlength;
|
||||
var $rdata;
|
||||
var $text;
|
||||
|
||||
/* }}} */
|
||||
/* class constructor - RR(&$rro, $data, $offset = '') {{{ */
|
||||
function Net_DNS_RR_TXT(&$rro, $data, $offset = '')
|
||||
{
|
||||
$this->name = $rro->name;
|
||||
$this->type = $rro->type;
|
||||
$this->class = $rro->class;
|
||||
$this->ttl = $rro->ttl;
|
||||
$this->rdlength = $rro->rdlength;
|
||||
$this->rdata = $rro->rdata;
|
||||
|
||||
if ($offset) {
|
||||
if ($this->rdlength > 0) {
|
||||
$maxoffset = $this->rdlength + $offset;
|
||||
while ($maxoffset > $offset) {
|
||||
list($text, $offset) = Net_DNS_Packet::label_extract($data, $offset);
|
||||
$this->text[] = $text;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$data = str_replace('\\\\', chr(1) . chr(1), $data); /* disguise escaped backslash */
|
||||
$data = str_replace('\\"', chr(2) . chr(2), $data); /* disguise \" */
|
||||
|
||||
ereg('("[^"]*"|[^ \t]*)[ \t]*$', $data, $regs);
|
||||
$regs[1] = str_replace(chr(2) . chr(2), '\\"', $regs[1]);
|
||||
$regs[1] = str_replace(chr(1) . chr(1), '\\\\', $regs[1]);
|
||||
$regs[1] = stripslashes($regs[1]);
|
||||
|
||||
$this->text = $regs[1];
|
||||
}
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* Net_DNS_RR_TXT::rdatastr() {{{ */
|
||||
function rdatastr()
|
||||
{
|
||||
if ($this->text) {
|
||||
if (is_array($this->text)) {
|
||||
$tmp = array();
|
||||
foreach ($this->text as $t) {
|
||||
$tmp[] = '"'.addslashes($t).'"';
|
||||
}
|
||||
return implode(' ',$tmp);
|
||||
} else {
|
||||
return '"' . addslashes($this->text) . '"';
|
||||
}
|
||||
} else return '; no data';
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* Net_DNS_RR_TXT::rr_rdata($packet, $offset) {{{ */
|
||||
function rr_rdata($packet, $offset)
|
||||
{
|
||||
if ($this->text) {
|
||||
$rdata = pack('C', strlen($this->text)) . $this->text;
|
||||
return $rdata;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
}
|
||||
/* }}} */
|
||||
/* 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 et
|
||||
* vim<600: sw=4 ts=4
|
||||
* }}} */
|
||||
?>
|
File diff suppressed because it is too large
Load Diff
@ -1,13 +0,0 @@
|
||||
- Replace:
|
||||
SURBL.php
|
||||
require_once 'Cache/Lite.php';
|
||||
require_once dirname(__FILE__) . '/../../Cache/Lite.php';
|
||||
|
||||
require_once 'HTTP/Request.php';
|
||||
require_once dirname(__FILE__) . '/../../HTTP/Request.php';
|
||||
|
||||
require_once 'Net/CheckIP.php';
|
||||
require_once dirname(__FILE__) . '/../CheckIP.php';
|
||||
|
||||
require_once 'Net/DNSBL.php';
|
||||
require_once dirname(__FILE__) . '/../DNSBL.php';
|
@ -1,177 +0,0 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* PEAR::Net_DNSBL
|
||||
*
|
||||
* This class acts as interface to generic Realtime Blocking Lists
|
||||
* (RBL)
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.01 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_01.txt. If you did not receive a copy of
|
||||
* the PHP License and are unable to obtain it through the web, please
|
||||
* send a note to license@php.net so we can mail you a copy immediately.
|
||||
*
|
||||
* Net_DNSBL looks up an supplied host if it's listed in 1-n supplied
|
||||
* Blacklists
|
||||
*
|
||||
* @category Net
|
||||
* @package DNSBL
|
||||
* @author Sebastian Nohn <sebastian@nohn.net>
|
||||
* @author Ammar Ibrahim <fixxme@fixme.com>
|
||||
* @copyright 2004-2007 Sebastian Nohn <sebastian@nohn.net>
|
||||
* @license http://www.php.net/license/3_01.txt PHP License 3.01
|
||||
* @version CVS: $Id: SURBL.php,v 1.4 2006/12/25 10:40:59 nohn Exp $
|
||||
* @link http://pear.php.net/package/Net_DNSBL
|
||||
* @see Net_DNS
|
||||
* @since File available since Release 1.0.0
|
||||
*/
|
||||
|
||||
require_once 'Cache/Lite.php';
|
||||
require_once 'HTTP/Request.php';
|
||||
require_once 'Net/CheckIP.php';
|
||||
require_once 'Net/DNSBL.php';
|
||||
|
||||
/**
|
||||
* PEAR::Net_DNSBL_SURBL
|
||||
*
|
||||
* This class acts as interface to the SURBL - Spam URI Realtime Blocklists.
|
||||
*
|
||||
* Services_SURBL looks up an supplied URI if it's listed in a
|
||||
* Spam URI Realtime Blocklists.
|
||||
*
|
||||
* @author Sebastian Nohn <sebastian@nohn.net>
|
||||
* @package Net_DNSBL
|
||||
* @license http://www.php.net/license/3_01.txt
|
||||
* @version 1.2.0
|
||||
*/
|
||||
|
||||
class Net_DNSBL_SURBL extends Net_DNSBL {
|
||||
|
||||
/**
|
||||
* Array of blacklists.
|
||||
*
|
||||
* Must have one or more elements.
|
||||
*
|
||||
* @var string[]
|
||||
* @access protected
|
||||
*/
|
||||
var $blacklists = array('multi.surbl.org');
|
||||
|
||||
/**
|
||||
* File containing whitelisted hosts.
|
||||
*
|
||||
* There are some whitelisted hosts (co.uk for example). This
|
||||
* requires the package to not ask the domain name but the host
|
||||
* name (spammer.co.uk instead of co.uk).
|
||||
*
|
||||
* @var string
|
||||
* @see $twoLevelCcTld
|
||||
* @access protected
|
||||
*/
|
||||
var $doubleCcTldFile = 'http://spamcheck.freeapp.net/two-level-tlds';
|
||||
|
||||
/**
|
||||
* Array of whitelisted hosts.
|
||||
*
|
||||
* @var array
|
||||
* @see $twoLevelCcTldFile
|
||||
* @access private
|
||||
*/
|
||||
var $twoLevelCcTld = array();
|
||||
|
||||
/**
|
||||
* Check if the last two parts of the FQDN are whitelisted.
|
||||
*
|
||||
* @param string Host to check if it is whitelisted
|
||||
* @access protected
|
||||
* @return boolean True if the host is whitelisted
|
||||
*/
|
||||
function isDoubleCcTld($fqdn)
|
||||
{
|
||||
// 30 Days should be way enough
|
||||
$options = array(
|
||||
'lifeTime' => '2592000',
|
||||
'automaticSerialization' => true
|
||||
);
|
||||
$id = md5($this->doubleCcTldFile);
|
||||
|
||||
$cache = new Cache_Lite($options);
|
||||
if ($data = $cache->get($id)) {
|
||||
// Cache hit
|
||||
} else {
|
||||
// Cache miss
|
||||
$http = &new HTTP_Request($this->doubleCcTldFile);
|
||||
if (!PEAR::isError($http->sendRequest())) {
|
||||
$data = $http->getResponseBody();
|
||||
}
|
||||
$data = explode("\n", $data);
|
||||
$data = array_flip($data);
|
||||
$cache->save($data, $id);
|
||||
} // if
|
||||
if (array_key_exists($fqdn, $data)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
} // if
|
||||
} // function
|
||||
|
||||
/**
|
||||
* Get Hostname to ask for.
|
||||
*
|
||||
* Performs the following steps:
|
||||
*
|
||||
* (1) Extract the hostname from the given URI
|
||||
* (2) Check if the "hostname" is an ip
|
||||
* (3a) IS_IP Reverse the IP (1.2.3.4 -> 4.3.2.1)
|
||||
* (3b) IS_FQDN Check if is in "CC-2-level-TLD"
|
||||
* (3b1) IS_IN_2LEVEL: we want the last three names
|
||||
* (3b2) IS_NOT_2LEVEL: we want the last two names
|
||||
* (4) return the FQDN to query.
|
||||
*
|
||||
* @param string URL to check.
|
||||
* @access protected
|
||||
* @return string Host to lookup
|
||||
*/
|
||||
function getHostForLookup($uri, $blacklist)
|
||||
{
|
||||
$host = '';
|
||||
// (1) Extract the hostname from the given URI
|
||||
$parsed_uri = parse_url($uri);
|
||||
$host = $parsed_uri['host'];
|
||||
// (2) Check if the "hostname" is an ip
|
||||
if (Net_CheckIP::check_ip($host)) {
|
||||
// (3a) IS_IP Reverse the IP (1.2.3.4 -> 4.3.2.1)
|
||||
$host = $this->reverseIp($host);
|
||||
} else {
|
||||
$host_elements = explode('.', $host);
|
||||
while (count($host_elements) > 3) {
|
||||
array_shift($host_elements);
|
||||
} // while
|
||||
$host_3_elements = implode('.', $host_elements);
|
||||
|
||||
$host_elements = explode('.', $host);
|
||||
while (count($host_elements) > 2) {
|
||||
array_shift($host_elements);
|
||||
} // while
|
||||
$host_2_elements = implode('.', $host_elements);
|
||||
|
||||
// (3b) IS_FQDN Check if is in "CC-2-level-TLD"
|
||||
if ($this->isDoubleCcTld($host_2_elements)) {
|
||||
// (3b1) IS_IN_2LEVEL: we want the last three names
|
||||
$host = $host_3_elements;
|
||||
} else {
|
||||
// (3b2) IS_NOT_2LEVEL: we want the last two names
|
||||
$host = $host_2_elements;
|
||||
} // if
|
||||
} // if
|
||||
// (4) return the FQDN to query
|
||||
$host .= '.'.$blacklist;
|
||||
return $host;
|
||||
} // function
|
||||
|
||||
} // class
|
||||
?>
|
Reference in New Issue
Block a user