fix: 优化网络检查逻辑

This commit is contained in:
Mmx
2021-12-02 22:45:41 +08:00
parent d08f2e115c
commit 0cabf771c9

View File

@@ -11,13 +11,14 @@ var Checker checker
// NetOk 网络状况检查 // NetOk 网络状况检查
func (checker) NetOk(timeout uint) bool { func (checker) NetOk(timeout uint) bool {
h, _, e := tool.HTTP.GetBytes(&tool.GetRequest{ h, i, e := tool.HTTP.GetReader(&tool.GetRequest{
Url: "https://www.baidu.com/", Url: "https://www.baidu.com/",
Redirect: false, Redirect: false,
Timeout: time.Duration(timeout) * time.Second, Timeout: time.Duration(timeout) * time.Second,
}) })
if e != nil || h.Get("Location") != "" { if e != nil {
return false return false
} }
return true _ = i.Close()
return h.Get("Location") == ""
} }