diff --git a/Net/DNS2.php b/Net/DNS2.php index 63561c3..ca52761 100644 --- a/Net/DNS2.php +++ b/Net/DNS2.php @@ -124,7 +124,7 @@ class Net_DNS2 /* * enable cache; either "shared", "file" or "none" */ - public $cache_type = "shared"; + public $cache_type = 'none'; /* * file name to use for shared memory segment or file cache @@ -162,14 +162,14 @@ class Net_DNS2 protected $cache = null; /* - * the last erro message returned by the sockets class + * internal setting for enabling cache */ - private $_last_socket_error = ''; + protected $use_cache = false; /* - * internal setting for enabling cache + * the last erro message returned by the sockets class */ - public $_use_cache = false; + private $_last_socket_error = ''; /** * Constructor - base constructor for the Resolver and Updater @@ -209,33 +209,32 @@ public function __construct(array $options = null) // make sure it's been initialized // switch($this->cache_type) { - case 'shared': - if (extension_loaded("shmop")) { + case 'shared': + if (extension_loaded("shmop")) { - $this->cache = new Net_DNS2_Cache_Shm; - $this->_use_cache = true; - } else { + $this->cache = new Net_DNS2_Cache_Shm; + $this->use_cache = true; + } else { - throw new Net_DNS2_Exception( - 'shmop library is not available for cache' - ); - } - break; - case 'file': + throw new Net_DNS2_Exception( + 'shmop library is not available for cache' + ); + } + break; + case 'file': - $this->cache = new Net_DNS2_Cache_File; - $this->_use_cache = true; + $this->cache = new Net_DNS2_Cache_File; + $this->use_cache = true; - break; - case 'none': - $this->_use_cache = false; - break; - default: + break; + case 'none': + $this->use_cache = false; + break; + default: - throw new Net_DNS2_Exception( - 'un-supported cache type: ' . $this->cache_type - ); - break; + throw new Net_DNS2_Exception( + 'un-supported cache type: ' . $this->cache_type + ); } } @@ -354,6 +353,8 @@ public function setServers($nameservers) /** * checks the list of name servers to make sure they're set * + * @param mixed $default a path to a resolv.conf file or an array of servers. + * * @return boolean * @throws Net_DNS2_Exception * @access protected @@ -399,13 +400,13 @@ public function signTSIG($keyname, $signature = "") $this->auth_signature = $keyname; - // - // otherwise create the TSIG RR, but don't add it just yet; TSIG needs - // to be added as the last additional entry- so we'll add it just - // before we send. - // } else { + // + // otherwise create the TSIG RR, but don't add it just yet; TSIG needs + // to be added as the last additional entry- so we'll add it just + // before we send. + // $this->auth_signature = Net_DNS2_RR::fromString( strtolower(trim($keyname)) . ' TSIG '. $signature @@ -418,8 +419,7 @@ public function signTSIG($keyname, $signature = "") /** * adds a SIG RR object for authentication * - * @param string $keyname the key name to use for the TSIG RR - * @param string $signature the key to sign the request. + * @param string $filename the name of a file to load the signature from. * * @return boolean * @throws Net_DNS2_Exception @@ -446,13 +446,10 @@ public function signSIG0($filename) $this->auth_signature = $filename; - // - // otherwise, it's filename which needs to be parsed and processed. - // } else { // - // parse the signature file + // otherwise, it's filename which needs to be parsed and processed. // $private = new Net_DNS2_PrivateKey($filename); @@ -500,14 +497,13 @@ public function signSIG0($filename) // only RSAMD5 and RSASHA1 are supported for SIG(0) // switch($this->auth_signature->algorithm) { - case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSAMD5: - case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSASHA1: - //case Net_DNS2_Lookups::DNSSEC_ALGORITHM_DSA: - break; - default: - throw new Net_DNS2_Exception( - 'only asymmetric algorithms work with SIG(0)!' - ); + case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSAMD5: + case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSASHA1: + break; + default: + throw new Net_DNS2_Exception( + 'only asymmetric algorithms work with SIG(0)!' + ); } return true; diff --git a/Net/DNS2/Cache.php b/Net/DNS2/Cache.php index eeb7ab4..1b571c6 100644 --- a/Net/DNS2/Cache.php +++ b/Net/DNS2/Cache.php @@ -217,7 +217,7 @@ protected function resize() // if (strlen($cache) > $this->cache_size) { - while(strlen($cache) > $this->cache_size) { + while (strlen($cache) > $this->cache_size) { // // go through the data, and remove the entries closed to diff --git a/Net/DNS2/Cache/File.php b/Net/DNS2/Cache/File.php index 58d6587..d7d88cf 100644 --- a/Net/DNS2/Cache/File.php +++ b/Net/DNS2/Cache/File.php @@ -65,11 +65,12 @@ class Net_DNS2_Cache_File extends Net_DNS2_Cache /** * open a cache object * - * @param string $cache_file path to a file to use for cache storage + * @param string $cache_file path to a file to use for cache storage * @param integer $size the size of the shared memory segment to create * * @throws Net_DNS2_Exception * @access public + * @return void * */ public function open($cache_file, $size) @@ -81,7 +82,8 @@ public function open($cache_file, $size) // check that the file exists first // if ( (file_exists($this->cache_file) == true) - && (filesize($this->cache_file) > 0) ) { + && (filesize($this->cache_file) > 0) + ) { // // open the file for reading diff --git a/Net/DNS2/Cache/Shm.php b/Net/DNS2/Cache/Shm.php index 91cd30d..744a931 100644 --- a/Net/DNS2/Cache/Shm.php +++ b/Net/DNS2/Cache/Shm.php @@ -80,6 +80,7 @@ class Net_DNS2_Cache_Shm extends Net_DNS2_Cache * * @throws Net_DNS2_Exception * @access public + * @return void * */ public function open($cache_file, $size) @@ -225,8 +226,8 @@ public function __destruct() $this->_cache_id = @shmop_open( $this->_cache_file_tok, 'c', 0644, $this->cache_size ); - if ($this->_cache_id === false) - { + if ($this->_cache_id === false) { + // // not much to do here // diff --git a/Net/DNS2/Packet/Request.php b/Net/DNS2/Packet/Request.php index d93d428..2868aa8 100644 --- a/Net/DNS2/Packet/Request.php +++ b/Net/DNS2/Packet/Request.php @@ -130,8 +130,9 @@ public function set($name, $type = 'A', $class = 'IN') if ( (!isset(Net_DNS2_Lookups::$rr_types_by_name[$type])) || (!isset(Net_DNS2_Lookups::$classes_by_name[$class])) ) { - throw new InvalidArgumentException('invalid type (' . $type . - ') or class (' . $class . ') specified.'); + throw new InvalidArgumentException( + 'invalid type (' . $type . ') or class (' . $class . ') specified.' + ); } // diff --git a/Net/DNS2/PrivateKey.php b/Net/DNS2/PrivateKey.php index 8a45c9b..7f97873 100644 --- a/Net/DNS2/PrivateKey.php +++ b/Net/DNS2/PrivateKey.php @@ -259,7 +259,7 @@ public function parseFile($file) if ($this->algorithm != $value) { throw new Net_DNS2_Exception( 'Algorithm mis-match! filename is ' . $this->algorithm . - ', contents say ' . $value + ', contents say ' . $value ); } break; diff --git a/Net/DNS2/Question.php b/Net/DNS2/Question.php index 3eac55e..6f5e358 100644 --- a/Net/DNS2/Question.php +++ b/Net/DNS2/Question.php @@ -157,7 +157,8 @@ public function set(Net_DNS2_Packet &$packet) if ($packet->rdlength < ($packet->offset + 4)) { throw new InvalidArgumentException( - 'invalid question question section: to small'); + 'invalid question question section: to small' + ); } // @@ -177,7 +178,8 @@ public function set(Net_DNS2_Packet &$packet) if ( (!isset($type_name)) || (!isset($class_name)) ) { throw new InvalidArgumentException( 'invalid question section: invalid type (' . $type . - ') or class (' . $class . ') specified.'); + ') or class (' . $class . ') specified.' + ); } // @@ -215,7 +217,8 @@ public function get(Net_DNS2_Packet &$packet, $offset) if ( (!isset($type)) || (!isset($class)) ) { throw new InvalidArgumentException( 'invalid question section: invalid type (' . $this->qtype . - ') or class (' . $this->qclass . ') specified.'); + ') or class (' . $this->qclass . ') specified.' + ); } return $packet->compress($this->qname, $offset) . chr($type << 8) . diff --git a/Net/DNS2/RR.php b/Net/DNS2/RR.php index 066110a..aeeac5c 100644 --- a/Net/DNS2/RR.php +++ b/Net/DNS2/RR.php @@ -390,12 +390,14 @@ public static function parse(Net_DNS2_Packet &$packet) if (is_null($object['name'])) { throw new Net_DNS2_Exception( - 'failed to parse resource record: failed to expand name.'); + 'failed to parse resource record: failed to expand name.' + ); } if ($packet->rdlength < ($packet->offset + 10)) { throw new Net_DNS2_Exception( - 'failed to parse resource record: packet too small.'); + 'failed to parse resource record: packet too small.' + ); } // @@ -433,8 +435,9 @@ public static function parse(Net_DNS2_Packet &$packet) } } else { - throw new Net_DNS2_Exception('un-implemented resource record type: ' . - $object['type']); + throw new Net_DNS2_Exception( + 'un-implemented resource record type: ' . $object['type'] + ); } return $o; @@ -516,7 +519,8 @@ public static function fromString($line) break; default: throw new InvalidArgumentException( - 'invalid config line provided: unknown file: ' . $value); + 'invalid config line provided: unknown file: ' . $value + ); } } @@ -546,19 +550,22 @@ public static function fromString($line) if ($o->rrFromString($values) === false) { throw new Net_DNS2_Exception( - 'failed to parse rdata for config: ' . $line); + 'failed to parse rdata for config: ' . $line + ); } } else { throw new Net_DNS2_Exception( - 'failed to create new RR record for type: ' . $type); + 'failed to create new RR record for type: ' . $type + ); } } else { throw new Net_DNS2_Exception( - 'un-implemented resource record type: '. $type); + 'un-implemented resource record type: '. $type + ); } return $o; diff --git a/Net/DNS2/RR/SIG.php b/Net/DNS2/RR/SIG.php index 25e5792..f6f8a34 100644 --- a/Net/DNS2/RR/SIG.php +++ b/Net/DNS2/RR/SIG.php @@ -364,7 +364,8 @@ protected function rrGet(Net_DNS2_Packet &$packet) // case Net_DNS2_Lookups::DNSSEC_ALGORITHM_DSA: // - // DSA won't work in PHP until the OpenSSL extension has better DSA support + // DSA won't work in PHP until the OpenSSL extension has + // better DSA support // case Net_DNS2_Lookups::DSNSEC_ALGORITHM_RSASHA1NSEC3SHA1: case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSASHA256: @@ -378,7 +379,9 @@ protected function rrGet(Net_DNS2_Packet &$packet) // // sign the data // - if (openssl_sign($sigdata, $this->signature, $this->private_key->instance, $algorithm) == false) { + if (openssl_sign( + $sigdata, $this->signature, $this->private_key->instance, $algorithm + ) == false) { throw new Net_DNS2_Exception(openssl_error_string()); } diff --git a/Net/DNS2/Resolver.php b/Net/DNS2/Resolver.php index c597862..3a5be51 100644 --- a/Net/DNS2/Resolver.php +++ b/Net/DNS2/Resolver.php @@ -131,9 +131,9 @@ public function query($name, $type = 'A', $class = 'IN') // if caching is turned on, then check then hash the question, and // do a cache lookup. // - $packet_hash = ""; + $packet_hash = ''; - if ($this->_use_cache == true) { + if ($this->use_cache == true) { // // open the cache @@ -143,7 +143,9 @@ public function query($name, $type = 'A', $class = 'IN') // // build the key and check for it in the cache. // - $packet_hash = md5($packet->question[0]->qname . '|' . $packet->question[0]->qtype); + $packet_hash = md5( + $packet->question[0]->qname . '|' . $packet->question[0]->qtype + ); if ($this->cache->has($packet_hash)) { @@ -154,8 +156,10 @@ public function query($name, $type = 'A', $class = 'IN') // // send the packet and get back the response // - $response = $this->sendPacket($packet, ($type == 'AXFR') ? true : $this->use_tcp); - if ($this->_use_cache == true) { + $response = $this->sendPacket( + $packet, ($type == 'AXFR') ? true : $this->use_tcp + ); + if ($this->use_cache == true) { $this->cache->put($packet_hash, $response); } diff --git a/Net/DNS2/Updater.php b/Net/DNS2/Updater.php index 4326ea1..1584fae 100644 --- a/Net/DNS2/Updater.php +++ b/Net/DNS2/Updater.php @@ -120,7 +120,8 @@ private function _checkName($name) throw new InvalidArgumentException( 'name provided (' . $name . ') does not match zone name (' . - $this->_packet->question[0]->qname . ')'); + $this->_packet->question[0]->qname . ')' + ); } return true; @@ -228,7 +229,8 @@ public function deleteAny($name, $type) if (!isset($class)) { throw new InvalidArgumentException( - 'unknown or un-supported resource record type: ' . $type); + 'unknown or un-supported resource record type: ' . $type + ); } $rr = new $class; @@ -318,7 +320,8 @@ public function checkExists($name, $type) if (!isset($class)) { throw new InvalidArgumentException( - 'unknown or un-supported resource record type: ' . $type); + 'unknown or un-supported resource record type: ' . $type + ); } $rr = new $class; @@ -403,7 +406,8 @@ public function checkNotExists($name, $type) if (!isset($class)) { throw new InvalidArgumentException( - 'unknown or un-supported resource record type: ' . $type); + 'unknown or un-supported resource record type: ' . $type + ); } $rr = new $class;