From aaa53b54e4892bab25fb3fb1817017bb2010d5bd Mon Sep 17 00:00:00 2001 From: huangsimin Date: Sat, 29 Dec 2018 10:08:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=94=99=E8=AF=AFready?= =?UTF-8?q?=E4=B8=8D=E5=8F=AF=E8=BE=BE=E5=88=B0=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dip.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) 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