Revision 6002af93
Added by NewEraCracker almost 9 years ago
src/usr/local/www/diag_dns.php | ||
---|---|---|
94 | 94 |
} |
95 | 95 |
} |
96 | 96 |
error_reporting($errreporting);// restore original php warning/error settings. |
97 |
|
|
97 |
|
|
98 | 98 |
foreach ($dnsresult as $item) { |
99 | 99 |
$newitem = array(); |
100 | 100 |
$newitem['type'] = $item['type']; |
... | ... | |
111 | 111 |
$newitem['data'] = $item['ipv6']; |
112 | 112 |
$resolved[] = $newitem; |
113 | 113 |
break; |
114 |
|
|
115 | 114 |
} |
116 | 115 |
} |
117 | 116 |
return $resolved; |
... | ... | |
184 | 183 |
} |
185 | 184 |
|
186 | 185 |
$type = "unknown"; |
187 |
$resolved = "";
|
|
186 |
$resolved = array();
|
|
188 | 187 |
$ipaddr = ""; |
189 | 188 |
if (!$input_errors) { |
190 | 189 |
if (is_ipaddr($host)) { |
... | ... | |
199 | 198 |
} |
200 | 199 |
} elseif (is_hostname($host)) { |
201 | 200 |
$type = "hostname"; |
202 |
$resolved = gethostbyname($host); |
|
203 |
if ($host != $resolved) { |
|
204 |
$resolved = resolve_host_addresses($host); |
|
205 |
foreach ($resolved as $item) { |
|
206 |
if ($item['type'] == 'A') { |
|
207 |
$ipaddr = $item['data']; |
|
208 |
break; |
|
209 |
} |
|
210 |
} |
|
211 |
} |
|
212 |
} |
|
213 |
|
|
214 |
if ($host == $resolved) { |
|
215 |
$resolved = gettext("No record found"); |
|
201 |
$ipaddr = gethostbyname($host); |
|
202 |
$resolved = resolve_host_addresses($host); |
|
216 | 203 |
} |
217 | 204 |
} |
218 | 205 |
} |
219 | 206 |
|
220 |
if (($_POST['host']) && ($_POST['dialog_output'])) { |
|
221 |
display_host_results ($host, $resolved, $dns_speeds); |
|
207 |
if ($_POST['host'] && $_POST['dialog_output']) { |
|
208 |
$host = (isset($resolvedptr) ? $resolvedptr : $host); |
|
209 |
display_host_results ($ipaddr, $host, $dns_speeds); |
|
222 | 210 |
exit; |
223 | 211 |
} |
224 | 212 |
|
... | ... | |
300 | 288 |
<div class="panel panel-default"> |
301 | 289 |
<div class="panel-heading"><h2 class="panel-title"><?=gettext('Results')?></h2></div> |
302 | 290 |
<div class="panel-body"> |
303 |
|
|
291 |
|
|
304 | 292 |
<table class="table"> |
305 | 293 |
<thead> |
306 | 294 |
<tr> |
Also available in: Unified diff
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.
(cherry picked from commit df7f65a318f407b30627eabe77052d7d0b857786)