From e0fd3488b510ff52338335b899f0dcc88f2db303 Mon Sep 17 00:00:00 2001 From: jeessy2 <6205259+jeessy2@users.noreply.github.com> Date: Mon, 25 Mar 2024 23:43:53 -0700 Subject: [PATCH] fix: rename DNSList to BackupDNS (#1058) --- util/net_resolver.go | 10 +++++----- util/wait_internet.go | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/util/net_resolver.go b/util/net_resolver.go index b8a0f089b..2a62ce79c 100644 --- a/util/net_resolver.go +++ b/util/net_resolver.go @@ -7,21 +7,21 @@ import ( "golang.org/x/text/language" ) -// dnsList is a list of DNS servers. -var DNSList = []string{} +// BackupDNS will be used if DNS error occurs. +var BackupDNS = []string{} func InitDefaultDNS(customDNS, lang string) { if customDNS != "" { - DNSList = []string{customDNS} + BackupDNS = []string{customDNS} return } if lang == language.Chinese.String() { - DNSList = []string{"223.5.5.5", "114.114.114.114"} + BackupDNS = []string{"223.5.5.5", "114.114.114.114"} return } - DNSList = []string{"1.1.1.1", "8.8.8.8"} + BackupDNS = []string{"1.1.1.1", "8.8.8.8"} } // SetDNS sets the dialer.Resolver to use the given DNS server. diff --git a/util/wait_internet.go b/util/wait_internet.go index 29655b686..897144acc 100644 --- a/util/wait_internet.go +++ b/util/wait_internet.go @@ -27,8 +27,8 @@ func WaitInternet(addresses []string) { Log("等待网络连接: %s", err) Log("%s 后重试...", delay) - if isDNSErr(err) && len(DNSList) > 0 { - dns := DNSList[rand.Intn(len(DNSList))] + if isDNSErr(err) && len(BackupDNS) > 0 { + dns := BackupDNS[rand.Intn(len(BackupDNS))] Log("本机DNS异常! 将默认使用 %s, 可参考文档通过 -dns 自定义 DNS 服务器", dns) SetDNS(dns) }