Skip to content

Commit 66b8daa

Browse files
committed
fix(my.servers): improve DNS resolution robustness for backup server
Add multiple fallback methods for DNS resolution when checking backup.unraid.net
1 parent 441e180 commit 66b8daa

File tree

1 file changed

+24
-2
lines changed
  • plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/include

1 file changed

+24
-2
lines changed

plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/include/UpdateFlashBackup.php

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,9 +594,31 @@ function deleteLocalRepo() {
594594
set_git_config('user.name', 'gitbot');
595595

596596
// ensure dns can resolve backup.unraid.net
597-
if (! checkdnsrr("backup.unraid.net","A") ) {
597+
$dnsResolved = false;
598+
599+
// Try multiple DNS resolution methods
600+
if (function_exists('dns_get_record')) {
601+
$dnsRecords = dns_get_record("backup.unraid.net", DNS_A);
602+
$dnsResolved = !empty($dnsRecords);
603+
}
604+
605+
// Fallback to gethostbyname if dns_get_record fails
606+
if (!$dnsResolved) {
607+
$ip = gethostbyname("backup.unraid.net");
608+
$dnsResolved = ($ip !== "backup.unraid.net");
609+
}
610+
611+
// Final fallback to system nslookup
612+
if (!$dnsResolved) {
613+
$output = [];
614+
$return_var = 0;
615+
exec('nslookup backup.unraid.net 2>/dev/null', $output, $return_var);
616+
$dnsResolved = ($return_var === 0 && !empty($output));
617+
}
618+
619+
if (!$dnsResolved) {
598620
$arrState['loading'] = '';
599-
$arrState['error'] = 'DNS is unable to resolve backup.unraid.net';
621+
$arrState['error'] = 'DNS resolution failed for backup.unraid.net - PHP DNS functions (checkdnsrr, dns_get_record, gethostbyname) and system nslookup all failed to resolve the hostname. This indicates a DNS configuration issue on your Unraid server. Check your DNS settings in Settings > Network Settings.';
600622
response_complete(406, array('error' => $arrState['error']));
601623
}
602624

0 commit comments

Comments
 (0)