set serverkeepalives is false

This commit is contained in:
eson 2018-12-18 02:53:09 +08:00
parent 1918bc3328
commit c5bb70cf52
2 changed files with 5 additions and 6 deletions

6
dip.go
View File

@ -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())

View File

@ -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 计算是否到切换时间