Commit 7bcc88ce authored by Franco Fichtner's avatar Franco Fichtner

system: there is no dnscache

parent a9c0cd37
...@@ -525,7 +525,6 @@ function ipsec_configure() ...@@ -525,7 +525,6 @@ function ipsec_configure()
if (!is_ipaddr($rg)) { if (!is_ipaddr($rg)) {
$filterdns_list[] = "{$rg}"; $filterdns_list[] = "{$rg}";
add_hostname_to_watch($rg);
if(! file_exists("/var/run/booting")) { if(! file_exists("/var/run/booting")) {
$rg = resolve_retry($rg); $rg = resolve_retry($rg);
} }
......
...@@ -215,39 +215,6 @@ function reload_ttys() ...@@ -215,39 +215,6 @@ function reload_ttys()
exec('/bin/kill -HUP 1'); exec('/bin/kill -HUP 1');
} }
function add_hostname_to_watch($hostname) {
if (!is_dir("/var/db/dnscache")) {
mkdir("/var/db/dnscache");
}
$result = array();
if((is_fqdn($hostname)) && (!is_ipaddr($hostname))) {
$domrecords = array();
$domips = array();
exec("host -t A " . escapeshellarg($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);
$contents = "";
if(! empty($domips)) {
foreach($domips as $ip) {
$contents .= "$ip\n";
}
}
file_put_contents("/var/db/dnscache/$hostname", $contents);
/* Remove empty elements */
$result = array_filter(explode("\n", $contents), 'strlen');
}
return $result;
}
function is_fqdn($fqdn) { function is_fqdn($fqdn) {
$hostname = false; $hostname = false;
if (preg_match("/[-A-Z0-9\.]+\.[-A-Z0-9\.]+/i", $fqdn)) { if (preg_match("/[-A-Z0-9\.]+\.[-A-Z0-9\.]+/i", $fqdn)) {
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
/* /*
Copyright (C) 2016 Franco Fichtner <franco@opnsense.org> Copyright (C) 2016 Franco Fichtner <franco@opnsense.org>
Copyright (C) 2004-2007 Scott Ullrich <sullrich@gmail.com>
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net> Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>
All rights reserved. All rights reserved.
...@@ -583,19 +584,10 @@ function system_routing_configure($interface = '') ...@@ -583,19 +584,10 @@ function system_routing_configure($interface = '')
return 0; return 0;
} }
/* Compare the current hostname DNS to the DNS cache we made function add_hostname_to_watch($hostname)
* if it has changed we return the old records {
* if no change we return false */ $result = array();
function compare_hostname_to_dnscache($hostname) {
if(!is_dir("/var/db/dnscache")) {
mkdir("/var/db/dnscache");
}
$hostname = trim($hostname);
if(is_readable("/var/db/dnscache/{$hostname}")) {
$oldcontents = file_get_contents("/var/db/dnscache/{$hostname}");
} else {
$oldcontents = "";
}
if((is_fqdn($hostname)) && (!is_ipaddr($hostname))) { if((is_fqdn($hostname)) && (!is_ipaddr($hostname))) {
$domrecords = array(); $domrecords = array();
$domips = array(); $domips = array();
...@@ -617,14 +609,12 @@ function compare_hostname_to_dnscache($hostname) { ...@@ -617,14 +609,12 @@ function compare_hostname_to_dnscache($hostname) {
$contents .= "$ip\n"; $contents .= "$ip\n";
} }
} }
}
if(trim($oldcontents) != trim($contents)) { /* Remove empty elements */
log_error(sprintf('DNSCACHE: Found old IP %s and new IP %s', $oldcontents, $contents)); $result = array_filter(explode("\n", $contents), 'strlen');
return ($oldcontents);
} else {
return false;
} }
return $result;
} }
function system_staticroutes_configure($interface = '') function system_staticroutes_configure($interface = '')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment