Skip to content

Commit

Permalink
fix: rename DNSList to BackupDNS (#1058)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeessy2 committed Mar 26, 2024
1 parent 4623bb5 commit e0fd348
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions util/net_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions util/wait_internet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit e0fd348

Please sign in to comment.