diff --git a/dip.go b/dip.go index b129902..03a3323 100644 --- a/dip.go +++ b/dip.go @@ -79,10 +79,16 @@ func (group *DIPGroup) Choose(addr string) { imokURL := "http://" + dhost.Host + ":8800/pppoe/imok" ses := requests.NewSession() - ses.SetConfig(requests.CRequestTimeout, 5) + ses.SetConfig(requests.CRequestTimeout, 4) if _, err := ses.Get(imokURL).Execute(); err != nil { log.Println(err) + if i == 2 { + // 下个需要切换的DHost错误 + group.Current.ActiveTime = now + 15 + delete(group.Ready, ip) + return // 不执行下面的 切换操作 for ip, dhost := range group.Ready + } } else { // 如果ping 通下个切换的主机就切换 for ii := 0; ii < 3; ii++ { restartURL := "http://" + group.Current.Host + ":8800/pppoe/restart" @@ -96,13 +102,6 @@ func (group *DIPGroup) Choose(addr string) { } } - if i == 3 { - // 下个需要切换的DHost错误 - group.Current.ActiveTime = now + 15 - delete(group.Ready, ip) - return // 不执行下面的 切换操作 for ip, dhost := range group.Ready - } - } group.Current = dhost