mirror of
https://github.com/nadoo/glider.git
synced 2026-11-19 07:09:42 +08:00
dns: switch upstream when dial error occurred
This commit is contained in:
1 parent
2fe9c3990b
commit
48e059db6c
5 files changed
+32
-19
No files matched your search
@@ -23,6 +23,14 @@ func (u *UpStream) Switch() string {
|
||||
return u.servers[atomic.AddUint32(&u.index, 1)%uint32(len(u.servers))]
|
||||
}
|
||||
|
||||
// SwitchIf switches to the next dns server if needed.
|
||||
func (u *UpStream) SwitchIf(server string) string {
|
||||
if u.Server() == server {
|
||||
return u.Switch()
|
||||
}
|
||||
return u.Server()
|
||||
}
|
||||
|
||||
// Len returns the number of dns servers.
|
||||
func (u *UpStream) Len() int {
|
||||
return len(u.servers)
|
||||
|
||||
Reference in new issue
Block a user