mirror of
https://github.com/itdoginfo/podkop.git
synced 2025-12-09 04:56:51 +03:00
♻️ refactor(podkop): simplify DoH URL determination logic
This commit is contained in:
@@ -702,20 +702,6 @@ get_doh_url() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Try standard DoH path first (most common)
|
|
||||||
url="https://$dns_server/dns-query"
|
|
||||||
if curl --connect-timeout 3 -s -o /dev/null -w "%{http_code}" -H "accept: application/dns-json" "$url?name=example.com&type=A" 2>/dev/null | grep -q "200"; then
|
|
||||||
echo "$url"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Try alternative path
|
|
||||||
url="https://$dns_server/resolve"
|
|
||||||
if curl --connect-timeout 3 -s -o /dev/null -w "%{http_code}" -H "accept: application/dns-json" "$url?name=example.com&type=A" 2>/dev/null | grep -q "200"; then
|
|
||||||
echo "$url"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Try root path
|
# Try root path
|
||||||
url="https://$dns_server"
|
url="https://$dns_server"
|
||||||
if curl --connect-timeout 3 -s -o /dev/null -w "%{http_code}" -H "accept: application/dns-json" "$url?name=example.com&type=A" 2>/dev/null | grep -q "200"; then
|
if curl --connect-timeout 3 -s -o /dev/null -w "%{http_code}" -H "accept: application/dns-json" "$url?name=example.com&type=A" 2>/dev/null | grep -q "200"; then
|
||||||
@@ -723,9 +709,10 @@ get_doh_url() {
|
|||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If no paths worked, return error
|
# Try standard DoH path first (most common)
|
||||||
echo "error: no working DoH endpoint found for $dns_server"
|
url="https://$dns_server/dns-query"
|
||||||
return 1
|
echo "$url"
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
sing_box_dns() {
|
sing_box_dns() {
|
||||||
@@ -755,10 +742,6 @@ sing_box_dns() {
|
|||||||
local dns_address=""
|
local dns_address=""
|
||||||
if [ "$dns_type" = "doh" ]; then
|
if [ "$dns_type" = "doh" ]; then
|
||||||
dns_address=$(get_doh_url "$dns_server")
|
dns_address=$(get_doh_url "$dns_server")
|
||||||
if [ $? -ne 0 ] || [ "${dns_address#error:}" != "$dns_address" ]; then
|
|
||||||
log "[critical] Failed to get working DoH URL for $dns_server"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
elif [ "$dns_type" = "dot" ]; then
|
elif [ "$dns_type" = "dot" ]; then
|
||||||
dns_address="tls://$dns_server"
|
dns_address="tls://$dns_server"
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user