config if there is a name server available and do not use if not there.
pull/63/head
noud 2012-11-16 11:22:19 +01:00
parent 7ccc3a8ba6
commit 2a12a5db3e
2 changed files with 26 additions and 10 deletions

View File

@ -151,6 +151,7 @@ Configure::write('CyDefSIG.correlation', 'sql'); // correlation between a
* paginated 16759 8447 6615
* 17734 8639 8846
*/
Configure::write('CyDefSIG.dns', 'false'); // there is a nameserver available to do resolution.
/**
* The settings below can be used to set additional paths to models, views and controllers.

35
app/Model/Dns.php Normal file → Executable file
View File

@ -9,16 +9,15 @@ class Dns extends AppModel {
public $useTable = false;
/*
* Checks for a valid internet name
* Returns true if Name is an existing Domain Host Name, false otherwise
* TODO should be renamed
*
* @param unknown_type $nametotest The Domain Host Name to check for existence.
* @return boolean
*/
public function testipaddress ($nametotest) {
/**
* Checks for a valid internet name
* Returns true if Name is an existing Domain Host Name, false otherwise
* TODO should be renamed
*
* @param unknown_type $nametotest The Domain Host Name to check for existence.
* @return boolean
*/
public function testipaddress($nametotest) {
if (intval($nametotest) > 0) {
return true;
} else {
@ -32,4 +31,20 @@ class Dns extends AppModel {
}
}
/**
* Name to IP list,
* get all ip numbers given a certain domain or host $name.
*
* @param $name being a hostname
*
* @return array of ip numbers
*/
function nametoipl($name = '') {
if ('true' == Configure::read('CyDefSIG.dns')) {
if (!$ips = gethostbynamel($name)) $ips = array();
} else {
$ips = array();
}
return $ips;
}
}