diff options
author | Renato Botelho <renato@netgate.com> | 2016-09-02 08:47:31 -0300 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2016-09-02 08:51:08 -0300 |
commit | 8402a8de579e3cd69761bcf7b900963b29f0c87e (patch) | |
tree | 0b8318298b811c433d294f943576086895314937 /src | |
parent | 3c09378ed6d1cbae03ec064fd4269e49a6a544b6 (diff) | |
download | pfsense-8402a8de579e3cd69761bcf7b900963b29f0c87e.zip pfsense-8402a8de579e3cd69761bcf7b900963b29f0c87e.tar.gz |
Fix diag_dns ipaddr set to use in IP WHOIS and IP Info
- Do not call resolve_host_addresses() when hostname cannot be resolved
by gethostbyname(). The old check was considering gethostbyname would
return NULL in this case but it returns a string with the hostname
passed on parameter
- Since resolve_host_addresses() always return an array, look for the
first A record to set $ipaddr, which will be used later to link with
IP WHOIS and IP Info
Based on Pull Request #3100 submitted by @NewEraCracker
Diffstat (limited to 'src')
-rw-r--r-- | src/usr/local/www/diag_dns.php | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/usr/local/www/diag_dns.php b/src/usr/local/www/diag_dns.php index 4447787..bb6ffb5 100644 --- a/src/usr/local/www/diag_dns.php +++ b/src/usr/local/www/diag_dns.php @@ -200,11 +200,14 @@ if ($_POST) { } elseif (is_hostname($host)) { $type = "hostname"; $resolved = gethostbyname($host); - if ($resolved) { - $resolved = resolve_host_addresses($host); - } if ($host != $resolved) { - $ipaddr = $resolved[0]; + $resolved = resolve_host_addresses($host); + foreach ($resolved as $item) { + if ($item['type'] == 'A') { + $ipaddr = $item['data']; + break; + } + } } } |