-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- added the ZONEMD resource record type.
- added a new PHPUnit file to test the file cache. - added a new PHPUnit file to do real-time checks against a public internal server. - muted errors from stream_select(); it's safe to mute them since the error condition is handled. - double checked the class index exists first in Net_DNS2_RR::parse() before using it. - added a typehint for Net_DNS::$last_exception in the comments so PHPStorm doesn't complain. - added a quick check to confirm all the DNS servers are IP addresses. - cleaned up the logic around binding to a local host and/or port; some cases wouldn't have worked correctly. - PHP 8.0 issue: shmop_close() is deprecated in PHP 8. - PHP 8.0 issue: strlen() generates an error if you pass in null; there's a few placing the code that wasn't testing for this first. - PHP 8.0 issue: fread() throws an exception now if you set the length to 0; so I have to check the filesize() first before reading. - PHP 8.1 issue: passing null to preg_split() generates an error; there were three cases where it was possible.
- Loading branch information
Showing
25 changed files
with
653 additions
and
236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
/** | ||
* DNS Library for handling lookups and updates. | ||
* | ||
* Copyright (c) 2022, Mike Pultz <[email protected]>. All rights reserved. | ||
* | ||
* See LICENSE for more details. | ||
* | ||
* @category Networking | ||
* @package Net_DNS2 | ||
* @author Mike Pultz <[email protected]> | ||
* @copyright 2022 Mike Pultz <[email protected]> | ||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License | ||
* @link https://netdns2.com/ | ||
* @since File available since Release 1.5.3 | ||
* | ||
*/ | ||
|
||
/** | ||
* text compression/expansion and labeling class | ||
* | ||
*/ | ||
class Net_DNS2_Names | ||
{ | ||
/** | ||
* pack a text string | ||
* | ||
* @param string $name a name to be packed | ||
* | ||
* @return string | ||
* @access public | ||
* | ||
*/ | ||
public static function pack($name) | ||
{ | ||
return (is_null($name) == true) ? null : pack('Ca*', strlen($name), $name); | ||
} | ||
|
||
/** | ||
* parses a domain string into a single string | ||
* | ||
* @param Net_DNS2_Packet &$packet the DNS packet to look in for the domain name | ||
* @param integer &$offset the offset into the given packet object | ||
* | ||
* @return mixed either a name string or null if it's not found. | ||
* @access public | ||
* | ||
*/ | ||
public static function unpack($rdata, &$offset) | ||
{ | ||
$name = ''; | ||
|
||
if (strlen($rdata) < ($offset + 1)) | ||
{ | ||
return null; | ||
} | ||
|
||
$xlen = ord($rdata[$offset]); | ||
++$offset; | ||
|
||
if (($xlen + $offset) > strlen($rdata)) { | ||
|
||
$name = substr($rdata, $offset); | ||
$offset = strlen($rdata); | ||
} else { | ||
|
||
$name = substr($rdata, $offset, $xlen); | ||
$offset += $xlen; | ||
} | ||
|
||
return trim($name, '.'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.