summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorSeth Mos <seth.mos@xs4all.nl>2007-09-25 21:11:10 +0000
committerSeth Mos <seth.mos@xs4all.nl>2007-09-25 21:11:10 +0000
commit581e772e6764482242a9b601d439b5c853395541 (patch)
tree16c5dbc42c6484f278e52cbafdba886cde6d3ec9 /etc
parent5ed54b93ee8dac2a0499bc9acaca90839d17e51a (diff)
downloadpfsense-581e772e6764482242a9b601d439b5c853395541.zip
pfsense-581e772e6764482242a9b601d439b5c853395541.tar.gz
Change function add_hostname_to_watch() to use host so we handle multiple IP addresses
Diffstat (limited to 'etc')
-rw-r--r--etc/inc/pfsense-utils.inc30
1 files changed, 22 insertions, 8 deletions
diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc
index c3e9652..c76fe30 100644
--- a/etc/inc/pfsense-utils.inc
+++ b/etc/inc/pfsense-utils.inc
@@ -3687,16 +3687,30 @@ function is_wan_interface_up($interface) {
}
function add_hostname_to_watch($hostname) {
- error_reporting(0);
- if(is_hostname($hostname)) {
- $dnshost = gethostbyname($hostname);
- if(!is_dir("/var/db/dnscache"))
+ if(is_fqdn($hostname)) {
+ $domrecords = array();
+ $domips = array();
+ exec("host -t A $hostname", $domrecords, $rethost);
+ if($rethost == 0) {
+ foreach($domrecords as $domr) {
+ $doml = explode(" ", $domr);
+ $domip = $doml[3];
+ /* fill array with domain ip addresses */
+ if(is_ipaddr($domip)) {
+ $domips[] = $domip;
+ }
+ }
+ }
+ sort($domips);
+ if(!is_dir("/var/db/dnscache")) {
mkdir("/var/db/dnscache");
- if($dnshost)
- if(is_ipaddr($dnshost))
- exec("echo $dnshost > /var/db/dnscache/$hostname");
+ }
+ $contents = "";
+ if(! empty($domips)) {
+ $contents = implode("\n", $domips);
+ }
+ file_put_contents("/var/db/dnscache/$hostname", $contents);
}
- error_reporting(1);
}
function find_dns_aliases() {
OpenPOWER on IntegriCloud