Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: when local dns error occurs try every dns #1063

Merged
merged 2 commits into from
Mar 28, 2024
Merged

Conversation

jeessy2
Copy link
Owner

@jeessy2 jeessy2 commented Mar 28, 2024

What does this PR do?

when local dns error occurs try every dns

Motivation

Additional Notes

improve #1057

Comment on lines 30 to 31
if isDNSErr(err) || errTimes > 0 {
dns := BackupDNS[errTimes%len(BackupDNS)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if isDNSErr(err) || errTimes > 0 {
dns := BackupDNS[errTimes%len(BackupDNS)]
if isDNSErr(err) && len(BackupDNS) > 0 {
dns := BackupDNS[0]
BackupDNS = BackupDNS[1:]

这样用完一个删一个是不是更好些?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有没有可能删除最后,也不通。也许在下一次循环就通了

Copy link
Contributor

@WaterLemons2k WaterLemons2k Mar 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有没有可能删除最后,也不通。也许在下一次循环就通了

// Rotate the backup DNS for reuse.
dns := BackupDNS[0]
BackupDNS = append(BackupDNS[1:], dns)

不删除了,轮换吧。

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

最好不去改BackupDNS

Copy link
Contributor

@WaterLemons2k WaterLemons2k Mar 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

那就没什么需要改的了,把 errTimes 这个命名改的更贴近用例就行了。因为并不是所有错误都会 ++,retryTimes 怎么样?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以

@jeessy2 jeessy2 merged commit 8474a5a into master Mar 28, 2024
8 checks passed
@jeessy2 jeessy2 deleted the InitBackupDNS branch March 28, 2024 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants