fix(dns): использовать --doh-url https://1.1.1.1/dns-query в curl при отсутствии c-ares (--dns-servers)
- В сборках OpenWrt без c-ares libcurl не поддерживает --dns-servers, что заставляло curl использовать системный DNS (dnsmasq). - Во время рестарта или перед стартом sing-box dnsmasq был перенаправлен на неработающий порт sing-box 5335, из-за чего curl получал Could not resolve host (exit 6), создавая замкнутый круг и бесконечный падеж сервиса при скачивании подписок/списков. - Добавлен автоматический фолбэк на DoH (--doh-url https://1.1.1.1/dns-query), который работает без c-ares и считывает IP адреса серверов подписок/списков напрямую в обход падающего системного DNS.
This commit is contained in:
@@ -173,13 +173,22 @@ function command_exists(name) {
|
||||
}
|
||||
|
||||
// curl --dns-servers requires libcurl built with c-ares (not available on all OpenWrt builds).
|
||||
// Cache the result once per process lifetime.
|
||||
// Fall back to --doh-url https://1.1.1.1/dns-query if --dns-servers is unsupported.
|
||||
let _curl_has_dns_servers = null;
|
||||
let _curl_has_doh_url = null;
|
||||
function curl_push_dns_servers(args) {
|
||||
if (_curl_has_dns_servers === null)
|
||||
_curl_has_dns_servers = (system("curl --dns-servers 8.8.8.8 -V >/dev/null 2>&1") == 0);
|
||||
if (_curl_has_dns_servers)
|
||||
if (_curl_has_dns_servers) {
|
||||
push(args, "--dns-servers", "8.8.8.8,1.1.1.1");
|
||||
return;
|
||||
}
|
||||
|
||||
if (_curl_has_doh_url === null)
|
||||
_curl_has_doh_url = (system("curl --doh-url https://1.1.1.1/dns-query -V >/dev/null 2>&1") == 0);
|
||||
if (_curl_has_doh_url) {
|
||||
push(args, "--doh-url", "https://1.1.1.1/dns-query");
|
||||
}
|
||||
}
|
||||
|
||||
function now_seconds() {
|
||||
|
||||
@@ -616,13 +616,22 @@ function command_status_from_args(args) {
|
||||
}
|
||||
|
||||
// curl --dns-servers requires libcurl built with c-ares (not available on all OpenWrt builds).
|
||||
// Cache the result once per process lifetime.
|
||||
// Fall back to --doh-url https://1.1.1.1/dns-query if --dns-servers is unsupported.
|
||||
let _curl_has_dns_servers = null;
|
||||
let _curl_has_doh_url = null;
|
||||
function curl_push_dns_servers(args) {
|
||||
if (_curl_has_dns_servers === null)
|
||||
_curl_has_dns_servers = (system("curl --dns-servers 8.8.8.8 -V >/dev/null 2>&1") == 0);
|
||||
if (_curl_has_dns_servers)
|
||||
if (_curl_has_dns_servers) {
|
||||
push(args, "--dns-servers", "8.8.8.8,1.1.1.1");
|
||||
return;
|
||||
}
|
||||
|
||||
if (_curl_has_doh_url === null)
|
||||
_curl_has_doh_url = (system("curl --doh-url https://1.1.1.1/dns-query -V >/dev/null 2>&1") == 0);
|
||||
if (_curl_has_doh_url) {
|
||||
push(args, "--doh-url", "https://1.1.1.1/dns-query");
|
||||
}
|
||||
}
|
||||
|
||||
function run_silent(command) {
|
||||
|
||||
Reference in New Issue
Block a user