修改切换失败的处理, 延时间切换
This commit is contained in:
parent
627cca4dbf
commit
abbfb5fbd9
15
dip.go
15
dip.go
|
@ -75,33 +75,32 @@ func (group *DIPGroup) Choose(addr string) {
|
|||
} else {
|
||||
|
||||
i := 0
|
||||
for ; i < 3; i++ {
|
||||
for ; i < 2; i++ {
|
||||
|
||||
imokURL := "http://" + dhost.Host + ":8800/pppoe/imok"
|
||||
if _, err := requests.NewSession().Get(imokURL).Execute(); err != nil {
|
||||
ses := requests.NewSession()
|
||||
ses.SetConfig(requests.CRequestTimeout, 5)
|
||||
|
||||
if _, err := ses.Get(imokURL).Execute(); err != nil {
|
||||
log.Println(err)
|
||||
|
||||
} else { // 如果ping 通下个切换的主机就切换
|
||||
|
||||
for ii := 0; ii < 3; ii++ {
|
||||
restartURL := "http://" + group.Current.Host + ":8800/pppoe/restart"
|
||||
if _, err := requests.NewSession().Get(restartURL).Execute(); err != nil {
|
||||
if _, err := ses.Get(restartURL).Execute(); err != nil {
|
||||
log.Println(err)
|
||||
} else {
|
||||
break // 可以切换 ii := 0; ii < 3; ii++
|
||||
}
|
||||
}
|
||||
|
||||
break // for ; i < 3; i++ {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if i == 3 {
|
||||
// 下个需要切换的DHost错误
|
||||
group.Current.ActiveTime = now + 15
|
||||
delete(group.Ready, ip)
|
||||
continue // 不执行下面的 切换操作 for ip, dhost := range group.Ready
|
||||
return // 不执行下面的 切换操作 for ip, dhost := range group.Ready
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user