diff --git a/Net/DNS2.php b/Net/DNS2.php index a20a9aa..672e1cb 100644 --- a/Net/DNS2.php +++ b/Net/DNS2.php @@ -866,43 +866,9 @@ public static function isIPv6($_address) */ public static function expandIPv6($_address) { - if (strpos($_address, '::') !== false) { - - $part = explode('::', $_address); - $part[0] = explode(':', $part[0]); - $part[1] = explode(':', $part[1]); - - $missing = array(); - - $x = (8 - (count($part[0]) + count($part[1]))); - for ($i = 0; $i < $x; $i++) { - - array_push($missing, '0000'); - } - - $missing = array_merge($part[0], $missing); - $part = array_merge($missing, $part[1]); - - } else { - - $part = explode(':', $_address); - } - - foreach ($part as &$p) { - while (strlen($p) < 4) { - $p = '0' . $p; - } - } - - unset($p); + $hex = unpack('H*hex', inet_pton($_address)); - $result = implode(':', $part); - - if (strlen($result) == 39) { - return $result; - } else { - return false; - } + return substr(preg_replace('/([A-f0-9]{4})/', "$1:", $hex['hex']), 0, -1); } /** diff --git a/Net/DNS2/Lookups.php b/Net/DNS2/Lookups.php index 242257c..48ee3a6 100644 --- a/Net/DNS2/Lookups.php +++ b/Net/DNS2/Lookups.php @@ -130,13 +130,15 @@ class Net_DNS2_Lookups // 11-15 reserved - const RCODE_BADSIG = 16; // RFC 2845 + const RCODE_BADSIG = 16; // RFC 2845 + const RCODE_BADVERS = 16; // RFC 6891 const RCODE_BADKEY = 17; // RFC 2845 const RCODE_BADTIME = 18; // RFC 2845 const RCODE_BADMODE = 19; // RFC 2930 const RCODE_BADNAME = 20; // RFC 2930 const RCODE_BADALG = 21; // RFC 2930 const RCODE_BADTRUNC = 22; // RFC 4635 + const RCODE_BADCOOKIE = 23; // RFC 7873 /* * internal errors codes returned by the exceptions class @@ -162,6 +164,7 @@ class Net_DNS2_Lookups const E_DNS_BADNAME = self::RCODE_BADNAME; const E_DNS_BADALG = self::RCODE_BADALG; const E_DNS_BADTRUNC = self::RCODE_BADTRUNC; + const E_DNS_BADCOOKIE = self::RCODE_BADCOOKIE; // other error conditions @@ -185,6 +188,24 @@ class Net_DNS2_Lookups const E_CACHE_SHM_FILE = 501; const E_CACHE_SHM_UNAVAIL = 502; + /* + * EDNS0 Option Codes (OPT) + */ + // 0 - Reserved + const EDNS0_OPT_LLQ = 1; + const EDNS0_OPT_UL = 2; + const EDNS0_OPT_NSID = 3; + // 4 - Reserved + const EDNS0_OPT_DAU = 5; + const EDNS0_OPT_DHU = 6; + const EDNS0_OPT_N3U = 7; + const EDNS0_OPT_CLIENT_SUBNET = 8; + const EDNS0_OPT_EXPIRE = 9; + const EDNS0_OPT_COOKIE = 10; + const EDNS0_OPT_TCP_KEEPALIVE = 11; + const EDNS0_OPT_PADDING = 12; + const EDNS0_OPT_CHAIN = 13; + /* * DNSSEC Algorithms */ @@ -273,8 +294,9 @@ class Net_DNS2_Lookups 'NSEC3' => 50, // RFC 5155 'NSEC3PARAM' => 51, // RFC 5155 'TLSA' => 52, // RFC 6698 + 'SMIMEA' => 53, // draft-ietf-dane-smime-10 - // 53 - 54 unassigned + // 54 unassigned 'HIP' => 55, // RFC 5205 'NINFO' => 56, // Not implemented @@ -282,7 +304,7 @@ class Net_DNS2_Lookups 'TALINK' => 58, // 'CDS' => 59, // RFC 7344 'CDNSKEY' => 60, // RFC 7344 - 'OPENPGPKEY' => 61, // IETF (draft-ietf-dane-openpgpkey) + 'OPENPGPKEY' => 61, // RFC 7929 'CSYNC' => 62, // RFC 7477 // 63 - 98 unassigned @@ -310,8 +332,9 @@ class Net_DNS2_Lookups 'ANY' => 255, // RFC 1035 - we support both 'ANY' and '*' 'URI' => 256, // tools.ietf.org/html/draft-faltstrom-uri-06 'CAA' => 257, // tools.ietf.org/html/draft-ietf-pkix-caa-03 + 'AVC' => 258, // Application Visibility and Control - // 258 - 32767 unassigned + // 259 - 32767 unassigned 'TA' => 32768, // same as DS 'DLV' => 32769 // RFC 4431 @@ -384,6 +407,7 @@ class Net_DNS2_Lookups 50 => 'Net_DNS2_RR_NSEC3', 51 => 'Net_DNS2_RR_NSEC3PARAM', 52 => 'Net_DNS2_RR_TLSA', + 53 => 'Net_DNS2_RR_SMIMEA', 55 => 'Net_DNS2_RR_HIP', 58 => 'Net_DNS2_RR_TALINK', 59 => 'Net_DNS2_RR_CDS', @@ -407,6 +431,7 @@ class Net_DNS2_Lookups 255 => 'Net_DNS2_RR_ANY', 256 => 'Net_DNS2_RR_URI', 257 => 'Net_DNS2_RR_CAA', + 258 => 'Net_DNS2_RR_AVC', 32768 => 'Net_DNS2_RR_TA', 32769 => 'Net_DNS2_RR_DLV' ); diff --git a/Net/DNS2/Packet.php b/Net/DNS2/Packet.php index f3aacde..08e9bf8 100644 --- a/Net/DNS2/Packet.php +++ b/Net/DNS2/Packet.php @@ -422,21 +422,6 @@ public function reset() return true; } - - /** - * formats an IPv6 IP address in the preferred format - * - * @param string $address The IPv6 IP address to format - * - * @return string The IPv6 IP address formatted in the new format - * @access public - * @deprecated function deprecated in 1.1.3 - * - */ - public static function formatIPv6($address) - { - return Net_DNS2::expandIPv6($address); - } } /* diff --git a/Net/DNS2/RR/OPENPGPKEY.php b/Net/DNS2/RR/OPENPGPKEY.php index c77db1c..e38c738 100644 --- a/Net/DNS2/RR/OPENPGPKEY.php +++ b/Net/DNS2/RR/OPENPGPKEY.php @@ -115,7 +115,7 @@ protected function rrSet(Net_DNS2_Packet &$packet) { if ($this->rdlength > 0) { - $this->key = base64_encode($this->rdata); + $this->key = base64_encode(substr($this->rdata, 0, $this->rdlength)); return true; } diff --git a/package.php b/package.php index 26882a1..93666f9 100644 --- a/package.php +++ b/package.php @@ -2,7 +2,7 @@ date_default_timezone_set('America/Toronto'); -ini_set("include_path", ".:/usr/local/php/lib/php/:/usr/local/php/lib/php/PEAR/PackageFileManager"); +ini_set("include_path", ".:/usr/local/php/lib/php/:/usr/share/pear/"); require_once 'PEAR/PackageFileManager/File.php'; require_once 'PEAR/PackageFileManager2.php'; @@ -11,7 +11,7 @@ $e = $pkg->setOptions(array( 'baseinstalldir' => '/', - 'packagedirectory' => '/u/devel/www/Net_DNS2/', + 'packagedirectory' => '/u/devel/www/net_dns/Net_DNS2/', 'ignore' => array( 'package.php', 'package.xml', @@ -40,11 +40,17 @@ "- changed the role for the README.md file to doc\n" . "- parse the resolv.conf options line; right now I just support the timeout and rotate options.\n" . "- the options values only work if you set the new option use_resolv_options to true; this is to keep backwards compatibility.\n" . -"- Adds support for RFC 6594; support for SHA-256 and ECDSA in the SSHFP resource record.\n" +"- added support for RFC 6594; support for SHA-256 and ECDSA in the SSHFP resource record.\n" . +"- added the SMIMEA resource record; this just extends the TLSA record.\n" . +"- added the AVC resource records; this just extends the TXT record.\n" . +"- added error and EDNS0 defines for DNS Cookies (RFC7873)\n" . +"- added EDNS0 defines to the lookup class\n" . +"- dropped the Net_DNS2_Packet::formatIPv6() function; this was deprecated in v1.1.3\n" . +"- re-wrote the Net_DNS2::expandIPv6() function. Based on testing, the new version is about twice as fast.\n" ); $pkg->setPackageType('php'); $pkg->addRelease(); -$pkg->setPhpDep('5.1.2'); +$pkg->setPhpDep('5.2.1'); $pkg->setPearinstallerDep('1.4.0a12'); $pkg->addMaintainer('lead', 'mikepultz', 'Mike Pultz', 'mike@mikepultz.com'); $pkg->setLicense('BSD License', 'http://www.opensource.org/licenses/bsd-license.php'); diff --git a/package.xml b/package.xml index cfe36cb..fa5c0d6 100644 --- a/package.xml +++ b/package.xml @@ -1,5 +1,5 @@ - @@ -15,11 +15,11 @@ This release is (in most cases) 2x - 10x faster than Net_DNS, as well as include mike@mikepultz.com yes - 2015-04-13 - + 2016-08-22 + - 1.4.1 - 1.4.1 + 1.4.2 + 1.4.2 stable @@ -27,22 +27,26 @@ This release is (in most cases) 2x - 10x faster than Net_DNS, as well as include BSD License -- increased the default DNSSEC payload size value to 4000 bytes per RFC 4035 section 4.1; this is still configurable. -- fixed a bug where I was still using the DNS_MAX_UDP_SIZE default (512 bytes) for all requests, event DNSSEC, where I should have been using the dnssec_payload_size config value. -- removed the limitation that PTR records had to look like IP addresses; you can add other things to PTR records, like service discovery objects- RFC 6763. -- dropped support for using the Sockets library on Windows. There have been too many inconsistencies between versions of Windows; we'll just default to use the Streams library. -- fixed the Net_DNS2_RR_PTR class so we can pass ptrdname's with spaces in them so that we can support DNS-Based Service Discovery (RFC 6763). -- added support for the CSYNC resource record - see RFC 7477. +- changed the role for the README.md file to doc +- parse the resolv.conf options line; right now I just support the timeout and rotate options. +- the options values only work if you set the new option use_resolv_options to true; this is to keep backwards compatibility. +- added support for RFC 6594; support for SHA-256 and ECDSA in the SSHFP resource record. +- added the SMIMEA resource record; this just extends the TLSA record. +- added the AVC resource records; this just extends the TXT record. +- added error and EDNS0 defines for DNS Cookies (RFC7873) +- added EDNS0 defines to the lookup class +- dropped the Net_DNS2_Packet::formatIPv6() function; this was deprecated in v1.1.3 +- re-wrote the Net_DNS2::expandIPv6() function. Based on testing, the new version is about twice as fast. - + - - + + @@ -59,6 +63,7 @@ This release is (in most cases) 2x - 10x faster than Net_DNS, as well as include + @@ -92,7 +97,7 @@ This release is (in most cases) 2x - 10x faster than Net_DNS, as well as include - + @@ -100,10 +105,11 @@ This release is (in most cases) 2x - 10x faster than Net_DNS, as well as include + - + @@ -116,17 +122,17 @@ This release is (in most cases) 2x - 10x faster than Net_DNS, as well as include - - + + - - + + - 5.1.2 + 5.2.1 1.4.0a12 @@ -466,5 +472,29 @@ Initial Beta release of Net_DNS2 - added support for the CSYNC resource record - see RFC 7477. + + + 1.4.2 + 1.4.2 + + + stable + stable + + 2016-08-22 + BSD License + +- changed the role for the README.md file to doc +- parse the resolv.conf options line; right now I just support the timeout and rotate options. +- the options values only work if you set the new option use_resolv_options to true; this is to keep backwards compatibility. +- added support for RFC 6594; support for SHA-256 and ECDSA in the SSHFP resource record. +- added the SMIMEA resource record; this just extends the TLSA record. +- added the AVC resource records; this just extends the TXT record. +- added error and EDNS0 defines for DNS Cookies (RFC7873) +- added EDNS0 defines to the lookup class +- dropped the Net_DNS2_Packet::formatIPv6() function; this was deprecated in v1.1.3 +- re-wrote the Net_DNS2::expandIPv6() function. Based on testing, the new version is about twice as fast. + + diff --git a/tests/Net_DNS2_DNSSECTest.php b/tests/Net_DNS2_DNSSECTest.php index f9febfa..027d614 100644 --- a/tests/Net_DNS2_DNSSECTest.php +++ b/tests/Net_DNS2_DNSSECTest.php @@ -80,7 +80,7 @@ public function testDNSSEC() $r->dnssec = true; $result = $r->query('org', 'SOA', 'IN'); - +print_r($result); $this->assertTrue(($result->header->ad == 1)); $this->assertTrue(($result->additional[0] instanceof Net_DNS2_RR_OPT)); $this->assertTrue(($result->additional[0]->do == 1)); diff --git a/tests/Net_DNS2_ParserTest.php b/tests/Net_DNS2_ParserTest.php index a282d02..b7f02c2 100644 --- a/tests/Net_DNS2_ParserTest.php +++ b/tests/Net_DNS2_ParserTest.php @@ -160,6 +160,7 @@ public function testParser() 'NSEC3' => 'example.com. 300 IN NSEC3 1 1 12 AABBCCDD b4um86eghhds6nea196smvmlo4ors995 NS DS RRSIG', 'NSEC3PARAM' => 'example.com. 300 IN NSEC3PARAM 1 0 1 D399EAAB', 'TLSA' => '_443._tcp.www.example.com. 300 IN TLSA 1 1 2 92003ba34942dc74152e2f2c408d29eca5a520e7f2e06bb944f4dca346baf63c1b177615d466f6c4b71c216a50292bd58c9ebdd2f74e38fe51ffd48c43326cbc', + 'SMIMEA' => 'c93f1e400f26708f98cb19d936620da35eec8f72e57f9eec01c1afd6._smimecert.example.com. 300 IN SMIMEA 1 1 2 92003ba34942dc74152e2f2c408d29eca5a520e7f2e06bb944f4dca346baf63c1b177615d466f6c4b71c216a50292bd58c9ebdd2f74e38fe51ffd48c43326cbc', 'HIP' => 'example.com. 300 IN HIP 2 200100107B1A74DF365639CC39F1D578 AwEAAbdxyhNuSutc5EMzxTs9LBPCIkOFH8cIvM4p9+LrV4e19WzK00+CI6zBCQTdtWsuxKbWIy87UOoJTwkUs7lBu+Upr1gsNrut79ryra+bSRGQb1slImA8YVJyuIDsj7kwzG7jnERNqnWxZ48AWkskmdHaVDP4BcelrTI3rMXdXF5D rvs.example.com. another.example.com. test.domain.org.', 'TALINK' => 'example.com. 300 IN TALINK c1.example.com. c3.example.com.', 'CDS' => 'example.com. 300 IN CDS 21366 7 2 96eeb2ffd9b00cd4694e78278b5efdab0a80446567b69f634da078f0d90f01ba', @@ -175,6 +176,7 @@ public function testParser() 'TKEY' => 'example.com. 300 IN TKEY gss.microsoft.com. 3 123456.', 'URI' => 'example.com. 300 IN URI 10 1 "http://mrdns.com"', 'CAA' => 'example.com. 300 IN CAA 0 issue "ca.example.net; policy=ev"', + 'AVC' => 'example.com. 300 IN AVC "first record" "another records" "a third"', 'TA' => 'example.com. 300 IN TA 21366 7 2 96eeb2ffd9b00cd4694e78278b5efdab0a80446567b69f634da078f0d90f01ba', 'DLV' => 'example.com. 300 IN DLV 21366 7 2 96eeb2ffd9b00cd4694e78278b5efdab0a80446567b69f634da078f0d90f01ba', );