From c5bb70cf52f54ff86fba70b0a6c7aecd968baa8f Mon Sep 17 00:00:00 2001 From: eson <474420502@qq.com> Date: Tue, 18 Dec 2018 02:53:09 +0800 Subject: [PATCH] set serverkeepalives is false --- dip.go | 6 ++---- switch.go | 5 +++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/dip.go b/dip.go index 5a6db35..bea3ce2 100644 --- a/dip.go +++ b/dip.go @@ -8,8 +8,7 @@ import ( "sync" "time" - "github.com/levigross/grequests" - + "474420502.top/eson/requests" "gopkg.in/yaml.v2" ) @@ -75,11 +74,10 @@ func (group *DIPGroup) Choose(addr string) { SetAddrForward(group.IPTableNum, addr, ip) } else { restartAddr := "http://" + group.Current.Host + ":8800/pppoe/restart" - if resp, err := grequests.Get(restartAddr, nil); err != nil { + if _, err := requests.NewSession().Get(restartAddr).Execute(); err != nil { log.Println(err) group.Current.ActiveTime += 12 } else { - defer resp.Close() group.Current = dhost group.Current.ActiveTime = now // log.Println("new set addr:", group.Current.Host, "restartAddr:", restartAddr, "resp", resp.Content()) diff --git a/switch.go b/switch.go index 097044f..92c89db 100644 --- a/switch.go +++ b/switch.go @@ -77,8 +77,9 @@ func (swi *Switch) Run(addr string, ipregion string) { } } - http.ListenAndServe(addr, nil) - + server := &http.Server{Addr: addr, Handler: nil} + server.SetKeepAlivesEnabled(false) + server.ListenAndServe() } // timeToSwitch 计算是否到切换时间