mirror of
https://github.com/itdoginfo/podkop.git
synced 2025-12-06 11:36:50 +03:00
🐛 fix(podkop): Handle DNS check errors and timeouts properly
This commit is contained in:
@@ -813,7 +813,15 @@ function checkDNSAvailability() {
|
||||
return new Promise(async (resolve) => {
|
||||
try {
|
||||
const dnsStatusResult = await safeExec('/usr/bin/podkop', ['check_dns_available']);
|
||||
const dnsStatus = JSON.parse(dnsStatusResult.stdout || '{"dns_type":"unknown","dns_server":"unknown","is_available":0,"status":"unknown","local_dns_working":0,"local_dns_status":"unknown"}');
|
||||
if (!dnsStatusResult || !dnsStatusResult.stdout) {
|
||||
return resolve({
|
||||
remote: createStatus('error', 'DNS check timeout', 'WARNING'),
|
||||
local: createStatus('error', 'DNS check timeout', 'WARNING')
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
const dnsStatus = JSON.parse(dnsStatusResult.stdout);
|
||||
|
||||
const remoteStatus = dnsStatus.is_available ?
|
||||
createStatus('available', `${dnsStatus.dns_type.toUpperCase()} (${dnsStatus.dns_server}) available`, 'SUCCESS') :
|
||||
@@ -827,6 +835,12 @@ function checkDNSAvailability() {
|
||||
remote: remoteStatus,
|
||||
local: localStatus
|
||||
});
|
||||
} catch (parseError) {
|
||||
return resolve({
|
||||
remote: createStatus('error', 'DNS check parse error', 'WARNING'),
|
||||
local: createStatus('error', 'DNS check parse error', 'WARNING')
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
return resolve({
|
||||
remote: createStatus('error', 'DNS check error', 'WARNING'),
|
||||
|
||||
@@ -2049,14 +2049,15 @@ check_dns_available() {
|
||||
fi
|
||||
fi
|
||||
elif [ "$dns_type" = "dot" ]; then
|
||||
nc $dns_server 853 </dev/null >/dev/null 2>&1 & pid=$!
|
||||
(sleep 3; kill $pid 2>/dev/null) & killpid=$!
|
||||
wait $pid >/dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
(nc "$dns_server" 853 </dev/null >/dev/null 2>&1) & pid=$!
|
||||
sleep 2
|
||||
if kill -0 $pid 2>/dev/null; then
|
||||
kill $pid 2>/dev/null
|
||||
wait $pid 2>/dev/null
|
||||
else
|
||||
is_available=1
|
||||
status="available"
|
||||
fi
|
||||
kill $killpid 2>/dev/null
|
||||
elif [ "$dns_type" = "udp" ]; then
|
||||
if nslookup -timeout=2 itdog.info $dns_server >/dev/null 2>&1; then
|
||||
is_available=1
|
||||
|
||||
Reference in New Issue
Block a user