feat: 添加 DOH 解析服务器列表至配置文件实现自定义 DOH 服务器

This commit is contained in:
Akimio521
2024-07-05 13:55:48 +08:00
parent 35c7238ede
commit 71fe96d7f9
3 changed files with 5 additions and 9 deletions

View File

@ -22,14 +22,6 @@ _executor = concurrent.futures.ThreadPoolExecutor()
# 定义默认的DoH配置
_doh_timeout = 5
_doh_cache: Dict[str, str] = {}
_doh_resolvers = [
# https://developers.cloudflare.com/1.1.1.1/encryption/dns-over-https
"1.0.0.1",
"1.1.1.1",
# https://support.quad9.net/hc/en-us
"9.9.9.9",
"149.112.112.112"
]
def _patched_getaddrinfo(host, *args, **kwargs):
@ -47,7 +39,7 @@ def _patched_getaddrinfo(host, *args, **kwargs):
# 使用DoH解析主机
futures = []
for resolver in _doh_resolvers:
for resolver in settings.DOH_RESOLVERS.split(","):
futures.append(_executor.submit(_doh_query, resolver, host))
for future in concurrent.futures.as_completed(futures):