From abbfb5fbd922f7ce5fad992a0c2bc67f5cda70b6 Mon Sep 17 00:00:00 2001 From: huangsimin Date: Fri, 28 Dec 2018 10:52:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=87=E6=8D=A2=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E7=9A=84=E5=A4=84=E7=90=86,=20=E5=BB=B6=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E5=88=87=E6=8D=A2?= 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 07390a5..b129902 100644 --- a/dip.go +++ b/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 } }