aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorPiBa-NL <pba_2k3@yahoo.com>2015-05-25 14:58:52 +0200
committerPiBa-NL <pba_2k3@yahoo.com>2015-05-25 14:58:52 +0200
commit7856d788bc6474e0635f5be497b087e9626349eb (patch)
tree61092410b6a4a3405b5a882d2a88c650bb2b545d /config
parent73979c69ecf2680ab9fa76a56f9a26302593b793 (diff)
downloadpfsense-packages-7856d788bc6474e0635f5be497b087e9626349eb.tar.gz
pfsense-packages-7856d788bc6474e0635f5be497b087e9626349eb.tar.bz2
pfsense-packages-7856d788bc6474e0635f5be497b087e9626349eb.zip
haprxy-devel, replace dig/drill by php native dns_get_record
Diffstat (limited to 'config')
-rw-r--r--config/haproxy-devel/pkg/haproxy_utils.inc35
1 files changed, 19 insertions, 16 deletions
diff --git a/config/haproxy-devel/pkg/haproxy_utils.inc b/config/haproxy-devel/pkg/haproxy_utils.inc
index 08065abc..1e5a23fc 100644
--- a/config/haproxy-devel/pkg/haproxy_utils.inc
+++ b/config/haproxy-devel/pkg/haproxy_utils.inc
@@ -36,26 +36,29 @@ require_once("config.inc");
class haproxy_utils {
public static $pf_version;
- public function query_dns($host, $querytype="A,AAAA", $dnsserver = "127.0.0.1") {
+ public function query_dns($host, $querytype="A,AAAA") {
$result = array();
- $host = trim($host, " \t\n\r\0\x0B[];\"'");
- $host_esc = escapeshellarg($host);
$types = explode(',',$querytype);
+ $recordtypes = 0;
foreach($types as $type){
- $resolved = gethostbyname($host);
- if($resolved) {
- $resolved = array();
- if (haproxy_utils::$pf_version < '2.2')
- exec("/usr/bin/dig {$host_esc} $type @$dnsserver | /usr/bin/grep {$host_esc} | /usr/bin/grep -v ';' | /usr/bin/awk '{ print $5 }'", $resolved);
- else
- exec("/usr/bin/drill {$host_esc} $type @$dnsserver | /usr/bin/awk '{ if($1!=\";;\" && $4==\"{$type}\") print $5 }'", $resolved);
- foreach($resolved as $item) {
- $newitem = array();
- $newitem["typeid"] = $type;
- $newitem["data"] = $item;
- $result[] = $newitem;
- }
+ switch ($type) {
+ case 'A': $recordtypes += DNS_A; break;
+ case 'AAAA': $recordtypes += DNS_AAAA; break;
+ }
+ }
+ $dnsresult = dns_get_record($host, $recordtypes);
+ foreach($dnsresult as $item) {
+ $type = $item['type'];
+ $newitem["typeid"] = $type;
+ switch ($type) {
+ case 'A':
+ $newitem["data"] = $item['ip'];
+ break;
+ case 'AAAA':
+ $newitem["data"] = $item['ipv6'];
+ break;
}
+ $result[] = $newitem;
}
return $result;
}