Skip to content

Commit

Permalink
Make Dns::getSrvRecors being more generic
Browse files Browse the repository at this point in the history
The `target' property of a returned service record is too specific and causes
other properties being ignored.
  • Loading branch information
majentsch authored and Johannes Meyer committed Oct 9, 2014
1 parent dd21b7b commit df69fd2
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions library/Icinga/Protocol/Dns.php
Expand Up @@ -9,29 +9,19 @@
*/
class Dns
{

/**
* Discover all service records on a given domain
*
* @param string $domain The domain to search
* @param string $service The type of the service, like for example 'ldaps' or 'ldap'
* @param string $protocol The transport protocol used by the service, defaults to 'tcp'
*
* @return array|null An array of all service domains
* @return array An array of all found service records
*/
public static function getSrvRecords($domain, $service, $protocol = 'tcp')
{
$records = dns_get_record('_' . $service . '._' . $protocol . '.' . $domain, DNS_SRV);
if ($records === false) {
return null;
}
$targets = array();
foreach ($records as $record) {
if (array_key_exists('target', $record)) {
$targets[] = $record['target'];
}
}
return $targets;
return $records === false ? array() : $records;
}

/**
Expand Down

0 comments on commit df69fd2

Please sign in to comment.