aboutsummaryrefslogtreecommitdiffstats
path: root/config/haproxy-devel/pkg/haproxy_utils.inc
diff options
context:
space:
mode:
authorRenato Botelho <garga@FreeBSD.org>2015-05-28 15:43:35 -0300
committerRenato Botelho <garga@FreeBSD.org>2015-05-28 15:43:35 -0300
commitb8dbf62170c67b477691f8733ada6e67bda0de70 (patch)
tree027e59291fda18952c20e6d64383f4939b9c971d /config/haproxy-devel/pkg/haproxy_utils.inc
parent901b85305f21a6526b949181bcb7393433044b2d (diff)
parent5c5fd7560c8fa5c01ae862af72a941746301227e (diff)
downloadpfsense-packages-b8dbf62170c67b477691f8733ada6e67bda0de70.tar.gz
pfsense-packages-b8dbf62170c67b477691f8733ada6e67bda0de70.tar.bz2
pfsense-packages-b8dbf62170c67b477691f8733ada6e67bda0de70.zip
Merge pull request #881 from PiBa-NL/haproxy-devel-ocsp
Diffstat (limited to 'config/haproxy-devel/pkg/haproxy_utils.inc')
-rw-r--r--config/haproxy-devel/pkg/haproxy_utils.inc41
1 files changed, 25 insertions, 16 deletions
diff --git a/config/haproxy-devel/pkg/haproxy_utils.inc b/config/haproxy-devel/pkg/haproxy_utils.inc
index d8c4faf4..3d841a25 100644
--- a/config/haproxy-devel/pkg/haproxy_utils.inc
+++ b/config/haproxy-devel/pkg/haproxy_utils.inc
@@ -36,26 +36,35 @@ 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/grep {$host_esc} | /usr/bin/grep -v ';' | /usr/bin/awk '{ 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;
+ }
+ }
+ 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;
}
+ $result[] = $newitem;
}
return $result;
}