Make Dns::getSrvRecors being more generic
The `target' property of a returned service record is too specific and causes other properties being ignored.
This commit is contained in:
parent
dd21b7b5d1
commit
df69fd2264
|
@ -9,7 +9,6 @@ namespace Icinga\Protocol;
|
||||||
*/
|
*/
|
||||||
class Dns
|
class Dns
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Discover all service records on a given domain
|
* Discover all service records on a given domain
|
||||||
*
|
*
|
||||||
|
@ -17,21 +16,12 @@ class Dns
|
||||||
* @param string $service The type of the service, like for example 'ldaps' or 'ldap'
|
* @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'
|
* @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')
|
public static function getSrvRecords($domain, $service, $protocol = 'tcp')
|
||||||
{
|
{
|
||||||
$records = dns_get_record('_' . $service . '._' . $protocol . '.' . $domain, DNS_SRV);
|
$records = dns_get_record('_' . $service . '._' . $protocol . '.' . $domain, DNS_SRV);
|
||||||
if ($records === false) {
|
return $records === false ? array() : $records;
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$targets = array();
|
|
||||||
foreach ($records as $record) {
|
|
||||||
if (array_key_exists('target', $record)) {
|
|
||||||
$targets[] = $record['target'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $targets;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue