diff options
author | PiBa-NL <pba_2k3@yahoo.com> | 2015-06-24 21:12:47 +0200 |
---|---|---|
committer | PiBa-NL <pba_2k3@yahoo.com> | 2015-06-24 21:16:53 +0200 |
commit | 8d74433d9b8da1fc508f03ad2eb27fd8ea3ba504 (patch) | |
tree | 683234e171bc77df91cc6ba4fd3882a968fc7308 /config/haproxy-devel | |
parent | 51aa815ed0a53798ef56899daf5fd21bb8ceef81 (diff) | |
download | pfsense-packages-8d74433d9b8da1fc508f03ad2eb27fd8ea3ba504.tar.gz pfsense-packages-8d74433d9b8da1fc508f03ad2eb27fd8ea3ba504.tar.bz2 pfsense-packages-8d74433d9b8da1fc508f03ad2eb27fd8ea3ba504.zip |
haproxy-devel, fix dns resolving dns_get_record does not properly resolve if not all requested types are present..
Diffstat (limited to 'config/haproxy-devel')
-rw-r--r-- | config/haproxy-devel/pkg/haproxy_utils.inc | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/config/haproxy-devel/pkg/haproxy_utils.inc b/config/haproxy-devel/pkg/haproxy_utils.inc index 3d841a25..ec72b986 100644 --- a/config/haproxy-devel/pkg/haproxy_utils.inc +++ b/config/haproxy-devel/pkg/haproxy_utils.inc @@ -39,32 +39,37 @@ class haproxy_utils { public function query_dns($host, $querytype="A,AAAA") { $result = array(); $types = explode(',',$querytype); - $recordtypes = 0; + $recordtype = 0; foreach($types as $type){ switch ($type) { case 'A': - $recordtypes += DNS_A; + $recordtype = DNS_A; break; case 'AAAA': - $recordtypes += DNS_AAAA; + $recordtype = DNS_AAAA; break; } - } - if ($recordtypes == 0) - return $result; - - $dnsresult = dns_get_record($host, $recordtypes); - foreach($dnsresult as $item) { - $newitem["typeid"] = $item['type']; - switch ($item['type']) { - case 'A': - $newitem["data"] = $item['ip']; - break; - case 'AAAA': - $newitem["data"] = $item['ipv6']; - break; + if ($recordtype != 0) { + //query one type at a time, querying multiple types in one call dns_get_record fails if one is not present.. + $errreporting = error_reporting(); + error_reporting($errreporting & ~E_WARNING);// dns_get_record throws a warning if nothing is resolved.. + $dnsresult = dns_get_record($host, $recordtype); + error_reporting($errreporting); + if (is_array($dnsresult)) { + foreach($dnsresult as $item) { + $newitem["typeid"] = $item['type']; + switch ($item['type']) { + case 'A': + $newitem["data"] = $item['ip']; + break; + case 'AAAA': + $newitem["data"] = $item['ipv6']; + break; + } + $result[] = $newitem; + } + } } - $result[] = $newitem; } return $result; } |