diff options
author | NewEraCracker <neweracracker@gmail.com> | 2016-09-03 00:38:07 +0100 |
---|---|---|
committer | NewEraCracker <neweracracker@gmail.com> | 2016-09-08 15:49:57 +0100 |
commit | df7f65a318f407b30627eabe77052d7d0b857786 (patch) | |
tree | c244817c15109343370bdcde4c141f3b835b4318 /src | |
parent | cb437d390523de253b74db9b4d389a8817f844ca (diff) | |
download | pfsense-df7f65a318f407b30627eabe77052d7d0b857786.zip pfsense-df7f65a318f407b30627eabe77052d7d0b857786.tar.gz |
Fix diag_dns regressions
After testing diag_dns behaviour some regressions have been noticed.
1) Looking up ipv6.google.com (it only has AAAA records) doesn't work
- gethostbyname() only supports v4, ipv6.google.com only has v6
- this bug was recently and inadvertently introduced
2) Results table will always show even when domain is not resolved
- since refactoring ages ago, $resolved is an array, bad idea to replace with a string, this will cause issues
- this piece of code was 'dead' until the recent commit has 'enabled' it again, removing it as not needed
3) Parameters for display_host_results (see: fe74228f2a8a9abc45a580a01559518043ca8d0b for its introduction) weren't correctly updated
- mostly a dead function, doubt this is used for anything, keeping it just in case.
This commit fixes all aforementioned issues.
Diffstat (limited to 'src')
-rw-r--r-- | src/usr/local/www/diag_dns.php | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/src/usr/local/www/diag_dns.php b/src/usr/local/www/diag_dns.php index 9779d71..bb44e73 100644 --- a/src/usr/local/www/diag_dns.php +++ b/src/usr/local/www/diag_dns.php @@ -62,7 +62,7 @@ function resolve_host_addresses($host) { } } error_reporting($errreporting);// restore original php warning/error settings. - + foreach ($dnsresult as $item) { $newitem = array(); $newitem['type'] = $item['type']; @@ -79,7 +79,6 @@ function resolve_host_addresses($host) { $newitem['data'] = $item['ipv6']; $resolved[] = $newitem; break; - } } return $resolved; @@ -152,7 +151,7 @@ if ($_POST) { } $type = "unknown"; - $resolved = ""; + $resolved = array(); $ipaddr = ""; if (!$input_errors) { if (is_ipaddr($host)) { @@ -167,26 +166,15 @@ if ($_POST) { } } elseif (is_hostname($host)) { $type = "hostname"; - $resolved = gethostbyname($host); - if ($host != $resolved) { - $resolved = resolve_host_addresses($host); - foreach ($resolved as $item) { - if ($item['type'] == 'A') { - $ipaddr = $item['data']; - break; - } - } - } - } - - if ($host == $resolved) { - $resolved = gettext("No record found"); + $ipaddr = gethostbyname($host); + $resolved = resolve_host_addresses($host); } } } -if (($_POST['host']) && ($_POST['dialog_output'])) { - display_host_results ($host, $resolved, $dns_speeds); +if ($_POST['host'] && $_POST['dialog_output']) { + $host = (isset($resolvedptr) ? $resolvedptr : $host); + display_host_results ($ipaddr, $host, $dns_speeds); exit; } @@ -268,7 +256,7 @@ if (!$input_errors && $type) { <div class="panel panel-default"> <div class="panel-heading"><h2 class="panel-title"><?=gettext('Results')?></h2></div> <div class="panel-body"> - + <table class="table"> <thead> <tr> |