diff options
author | Warren Baker <warren@decoy.co.za> | 2011-10-02 19:08:15 +0200 |
---|---|---|
committer | Warren Baker <warren@decoy.co.za> | 2011-10-02 19:08:15 +0200 |
commit | 2ee1cf7b91eeebeb4d303b168668badd95677929 (patch) | |
tree | 1cdf5ed54f35cf244c7b91503eab0c204e4e65af /etc/inc/unbound.inc | |
parent | 0f2bd251aa0b3a6d33c83ba2d5c0bab6e8c004b6 (diff) | |
download | pfsense-2ee1cf7b91eeebeb4d303b168668badd95677929.zip pfsense-2ee1cf7b91eeebeb4d303b168668badd95677929.tar.gz |
Use curl instead of dig
Diffstat (limited to 'etc/inc/unbound.inc')
-rw-r--r-- | etc/inc/unbound.inc | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/etc/inc/unbound.inc b/etc/inc/unbound.inc index f2709c0..c3bdb18 100644 --- a/etc/inc/unbound.inc +++ b/etc/inc/unbound.inc @@ -134,11 +134,11 @@ function unbound_optimization() { } /* Fetch root name servers hints file */ -function unbound_fetch_root_hints() { +function unbound_fetch_root_hints_using_dig() { global $g; $hints = "{$g['unbound_chroot_path']}/etc/root.hints"; - if (@filesize($hints) == 0 ) { + if (@filesize($hints) == 0) { $returnvar = mwexec("/usr/bin/dig +tcp +nocmd +answer +time=1 +tries=1 +retry=1 @`/usr/bin/dig +nocmd +noall +answer +short +time=1 +tries=1 +retry=1 . NS | /usr/bin/head -1` . NS > {$hints}"); if ($returnvar != 0) { @@ -150,6 +150,30 @@ function unbound_fetch_root_hints() { return true; } +function unbound_fetch_root_hints() { + global $g; + + $destination_file = "{$g['unbound_chroot_path']}/etc/root.hints"; + if (filesize($destination_file) == 0 ) { + $fout = fopen($destination_file, "w"); + $url = "ftp://ftp.internic.net/domain/named.cache"; + + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, '5'); + $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); + $data = curl_exec($ch); + curl_close($ch); + + fwrite($fout, $data); + fclose($fout); + + return ($http_code == 200) ? true : $http_code; + } else + return false; +} + /* Configure initial anchor to support DNSSEC */ function unbound_anchor_setup() { global $g; |