Skip to content
Snippets Groups Projects
Unverified Commit 7ea9e28c authored by Mathieu Parent's avatar Mathieu Parent
Browse files

Imported Upstream version 1.4.1

parent d838b083
No related branches found
No related tags found
No related merge requests found
Showing
with 509 additions and 446 deletions
<?php
//
// This test suite assumes that Net_DNS2 will be in the include path, otherwise it
// will fail. There's no other way to hardcode a include_path in here that would make
// it work everywhere.
//
error_reporting(E_ALL | E_STRICT);
if (!defined('PHPUnit_MAIN_METHOD')) {
define('PHPUnit_MAIN_METHOD', 'Net_DNS2_AllTests::main');
}
require_once 'PHPUnit/TextUI/TestRunner.php';
require_once 'Net_DNS2_ParserTest.php';
require_once 'Net_DNS2_ResolverTest.php';
require_once 'Net_DNS2_DNSSECTest.php';
class Net_DNS2_AllTests
{
public static function main()
{
PHPUnit_TextUI_TestRunner::run(self::suite());
}
public static function suite()
{
$suite = new PHPUnit_Framework_TestSuite('PEAR - Net_DNS2');
$suite->addTestSuite('Net_DNS2_ParserTest');
$suite->addTestSuite('Net_DNS2_ResolverTest');
$suite->addTestSuite('Net_DNS2_DNSSECTest');
return $suite;
}
}
if (PHPUnit_MAIN_METHOD == 'Net_DNS2_AllTests::main') {
Net_DNS2_AllTests::main();
}
?>
<?php
require_once 'Net/DNS2.php';
class Net_DNS2_DNSSECTest extends PHPUnit_Framework_TestCase
{
public function testTSIG()
{
$r = new Net_DNS2_Resolver(array('nameservers' => array('8.8.8.8', '8.8.4.4')));
$r->dnssec = true;
$result = $r->query('org', 'SOA', 'IN');
$this->assertTrue(($result->header->ad == 1));
$this->assertTrue(($result->additional[0] instanceof Net_DNS2_RR_OPT));
$this->assertTrue(($result->additional[0]->do == 1));
}
};
?>
<?php
require_once 'Net/DNS2.php';
//
// This test uses the Google public DNS servers to perform a resolution test; this should work on
// *nix and Windows, but will require an internet connection.
//
class Net_DNS2_ResolverTest extends PHPUnit_Framework_TestCase
{
public function testResolver()
{
$r = new Net_DNS2_Resolver(array('nameservers' => array('8.8.8.8', '8.8.4.4')));
$result = $r->query('google.com', 'MX');
$this->assertSame($result->header->qr, Net_DNS2_Lookups::QR_RESPONSE);
$this->assertSame(count($result->question), 1);
$this->assertTrue(count($result->answer) > 0);
$this->assertTrue($result->answer[0] instanceof Net_DNS2_RR_MX);
}
}
?>
File moved
This diff is collapsed.
......@@ -43,7 +43,7 @@
* @author Mike Pultz <mike@mikepultz.com>
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @version SVN: $Id: BitMap.php 198 2013-05-26 05:05:22Z mike.pultz $
* @version SVN: $Id$
* @link http://pear.php.net/package/Net_DNS2
* @since File available since Release 0.6.0
*
......
......@@ -43,7 +43,7 @@
* @author Mike Pultz <mike@mikepultz.com>
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @version SVN: $Id: Cache.php 218 2013-11-28 22:34:20Z mike.pultz $
* @version SVN: $Id$
* @link http://pear.php.net/package/Net_DNS2
* @since File available since Release 1.1.0
*
......
......@@ -43,7 +43,7 @@
* @author Mike Pultz <mike@mikepultz.com>
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @version SVN: $Id: File.php 160 2012-07-18 03:57:32Z mike.pultz $
* @version SVN: $Id$
* @link http://pear.php.net/package/Net_DNS2
* @since File available since Release 1.1.0
*
......
......@@ -43,7 +43,7 @@
* @author Mike Pultz <mike@mikepultz.com>
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @version SVN: $Id: Shm.php 160 2012-07-18 03:57:32Z mike.pultz $
* @version SVN: $Id$
* @link http://pear.php.net/package/Net_DNS2
* @since File available since Release 1.1.0
*
......
......@@ -43,7 +43,7 @@
* @author Mike Pultz <mike@mikepultz.com>
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @version SVN: $Id: Exception.php 197 2013-04-22 00:28:00Z mike.pultz $
* @version SVN: $Id$
* @link http://pear.php.net/package/Net_DNS2
* @since File available since Release 0.6.0
*/
......@@ -92,7 +92,17 @@ class Net_DNS2_Exception extends Exception
//
// call the parent constructor
//
parent::__construct($message, $code, $previous);
// the "previous" argument was added in PHP 5.3.0
//
// https://code.google.com/p/netdns2/issues/detail?id=25
//
if (version_compare(PHP_VERSION, '5.3.0', '>=') == true) {
parent::__construct($message, $code, $previous);
} else {
parent::__construct($message, $code);
}
}
/**
......
......@@ -43,7 +43,7 @@
* @author Mike Pultz <mike@mikepultz.com>
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @version SVN: $Id: Header.php 198 2013-05-26 05:05:22Z mike.pultz $
* @version SVN: $Id$
* @link http://pear.php.net/package/Net_DNS2
* @since File available since Release 0.6.0
*
......
......@@ -43,7 +43,7 @@
* @author Mike Pultz <mike@mikepultz.com>
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @version SVN: $Id: Lookups.php 215 2013-10-28 04:20:36Z mike.pultz $
* @version SVN: $Id$
* @link http://pear.php.net/package/Net_DNS2
* @since File available since Release 0.6.0
*
......@@ -168,6 +168,7 @@ class Net_DNS2_Lookups
const E_NS_INVALID_FILE = 200;
const E_NS_INVALID_ENTRY = 201;
const E_NS_FAILED = 202;
const E_NS_SOCKET_FAILED = 203;
const E_PACKET_INVALID = 300;
const E_PARSE_ERROR = 301;
......@@ -273,15 +274,18 @@ class Net_DNS2_Lookups
'NSEC3PARAM' => 51, // RFC 5155
'TLSA' => 52, // RFC 6698
// 52 - 54 unassigned
// 53 - 54 unassigned
'HIP' => 55, // RFC 5205
'NINFO' => 56, // Not implemented
'RKEY' => 57, // Not implemented
'TALINK' => 58, // IETF (draft-barwood-dnsop-ds-publish-02)
'CDS' => 59, // IETF (draft-barwood-dnsop-ds-publish-02)
'TALINK' => 58, //
'CDS' => 59, // RFC 7344
'CDNSKEY' => 60, // RFC 7344
'OPENPGPKEY' => 61, // IETF (draft-ietf-dane-openpgpkey)
'CSYNC' => 62, // RFC 7477
// 60 - 98 unassigned
// 63 - 98 unassigned
'SPF' => 99, // RFC 4408
'UINFO' => 100, // no RFC, Not implemented
......@@ -383,6 +387,9 @@ class Net_DNS2_Lookups
55 => 'Net_DNS2_RR_HIP',
58 => 'Net_DNS2_RR_TALINK',
59 => 'Net_DNS2_RR_CDS',
60 => 'Net_DNS2_RR_CDNSKEY',
61 => 'Net_DNS2_RR_OPENPGPKEY',
62 => 'Net_DNS2_RR_CSYNC',
99 => 'Net_DNS2_RR_SPF',
104 => 'Net_DNS2_RR_NID',
105 => 'Net_DNS2_RR_L32',
......
......@@ -43,7 +43,7 @@
* @author Mike Pultz <mike@mikepultz.com>
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @version SVN: $Id: Packet.php 218 2013-11-28 22:34:20Z mike.pultz $
* @version SVN: $Id$
* @link http://pear.php.net/package/Net_DNS2
* @since File available since Release 0.6.0
*
......
......@@ -43,7 +43,7 @@
* @author Mike Pultz <mike@mikepultz.com>
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @version SVN: $Id: Request.php 155 2012-05-06 23:45:23Z mike.pultz $
* @version SVN: $Id$
* @link http://pear.php.net/package/Net_DNS2
* @since File available since Release 0.6.0
*
......@@ -104,9 +104,15 @@ class Net_DNS2_Packet_Request extends Net_DNS2_Packet
//
$q = new Net_DNS2_Question();
$name = trim(strtolower($name), " \t\n\r\0\x0B.");
$type = strtoupper(trim($type));
$class = strtoupper(trim($class));
//
// allow queries directly to . for the root name servers
//
if ($name != '.') {
$name = trim(strtolower($name), " \t\n\r\0\x0B.");
}
$type = strtoupper(trim($type));
$class = strtoupper(trim($class));
//
// check that the input string has some data in it
......@@ -139,12 +145,15 @@ class Net_DNS2_Packet_Request extends Net_DNS2_Packet
);
}
//
// if it's a PTR request for an IP address, then make sure we tack on
// the arpa domain
//
if ($type == 'PTR') {
//
// if it's a PTR request for an IP address, then make sure we tack on
// the arpa domain.
//
// there are other types of PTR requests, so if an IP adress doesn't match,
// then just let it flow through and assume it's a hostname
//
if (Net_DNS2::isIPv4($name) == true) {
//
......@@ -174,19 +183,6 @@ class Net_DNS2_Packet_Request extends Net_DNS2_Packet
Net_DNS2_Lookups::E_PACKET_INVALID
);
}
} else if (preg_match('/arpa$/', $name) == true) {
//
// an already formatted IPv4 or IPv6 address in the arpa domain
//
} else {
throw new Net_DNS2_Exception(
'unsupported PTR value: ' . $name,
Net_DNS2_Lookups::E_PACKET_INVALID
);
}
}
......
......@@ -43,7 +43,7 @@
* @author Mike Pultz <mike@mikepultz.com>
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @version SVN: $Id: Response.php 198 2013-05-26 05:05:22Z mike.pultz $
* @version SVN: $Id$
* @link http://pear.php.net/package/Net_DNS2
* @since File available since Release 0.6.0
*
......@@ -74,6 +74,11 @@ class Net_DNS2_Packet_Response extends Net_DNS2_Packet
*/
public $answer_socket_type;
/*
* The query response time in microseconds
*/
public $response_time = 0;
/**
* Constructor - builds a new Net_DNS2_Packet_Response object
*
......
......@@ -43,7 +43,7 @@
* @author Mike Pultz <mike@mikepultz.com>
* @copyright 2011 Mike Pultz <mike@mikepultz.com>
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @version SVN: $Id: PrivateKey.php 133 2011-12-03 23:42:24Z mike.pultz $
* @version SVN: $Id$
* @link http://pear.php.net/package/Net_DNS2
* @since File available since Release 1.1.0
*
......@@ -134,27 +134,27 @@ class Net_DNS2_PrivateKey
/*
* DSA: prime
*/
//private $_prime;
public $prime;
/*
* DSA: subprime
*/
//private $_subprime;
public $subprime;
/*
* DSA: base
*/
//private $_base;
public $base;
/*
* DSA: private value
*/
//private $_private_value;
public $private_value;
/*
* DSA: public value
*/
//private $_public_value;
public $public_value;
/**
* Constructor - base constructor the private key container class
......@@ -308,26 +308,26 @@ class Net_DNS2_PrivateKey
//
// DSA - this won't work in PHP until the OpenSSL extension is better
//
/*case 'prime(p)':
$this->_prime = $value;
case 'prime(p)':
$this->prime = $value;
break;
case 'subprime(q)':
$this->_subprime = $value;
$this->subprime = $value;
break;
case 'base(g)':
$this->_base = $value;
$this->base = $value;
break;
case 'private_value(x)':
$this->_private_value = $value;
$this->private_value = $value;
break;
case 'public_value(y)':
$this->_public_value = $value;
$this->public_value = $value;
break;
*/
default:
throw new Net_DNS2_Exception(
'unknown private key data: ' . $key . ': ' . $value,
......@@ -348,6 +348,8 @@ class Net_DNS2_PrivateKey
//
case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSAMD5:
case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSASHA1:
case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSASHA256:
case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSASHA512:
$args = array(
......@@ -369,22 +371,22 @@ class Net_DNS2_PrivateKey
//
// DSA - this won't work in PHP until the OpenSSL extension is better
//
/*case Net_DNS2_Lookups::DNSSEC_ALGORITHM_DSA:
case Net_DNS2_Lookups::DNSSEC_ALGORITHM_DSA:
$args = array(
'dsa' => array(
'p' => base64_decode($this->_prime),
'q' => base64_decode($this->_subprime),
'g' => base64_decode($this->_base),
'priv_key' => base64_decode($this->_private_value),
'pub_key' => base64_decode($this->_public_value)
'p' => base64_decode($this->prime),
'q' => base64_decode($this->subprime),
'g' => base64_decode($this->base),
'priv_key' => base64_decode($this->private_value),
'pub_key' => base64_decode($this->public_value)
)
);
break;
*/
default:
throw new Net_DNS2_Exception(
'we only currently support RSAMD5 and RSASHA1 encryption.',
......
......@@ -43,7 +43,7 @@
* @author Mike Pultz <mike@mikepultz.com>
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @version SVN: $Id: Question.php 124 2011-12-02 23:23:15Z mike.pultz $
* @version SVN: $Id$
* @link http://pear.php.net/package/Net_DNS2
* @since File available since Release 0.6.0
*
......
......@@ -43,7 +43,7 @@
* @author Mike Pultz <mike@mikepultz.com>
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @version SVN: $Id: RR.php 188 2013-03-31 01:25:46Z mike.pultz $
* @version SVN: $Id$
* @link http://pear.php.net/package/Net_DNS2
* @since File available since Release 0.6.0
*
......
......@@ -43,7 +43,7 @@
* @author Mike Pultz <mike@mikepultz.com>
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @version SVN: $Id: A.php 113 2011-07-25 02:54:19Z mike.pultz $
* @version SVN: $Id$
* @link http://pear.php.net/package/Net_DNS2
* @since File available since Release 0.6.0
*
......
......@@ -43,7 +43,7 @@
* @author Mike Pultz <mike@mikepultz.com>
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @version SVN: $Id: AAAA.php 179 2012-11-23 05:49:01Z mike.pultz $
* @version SVN: $Id$
* @link http://pear.php.net/package/Net_DNS2
* @since File available since Release 0.6.0
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment