fix: 优化网络检查逻辑
This commit is contained in:
@@ -11,13 +11,14 @@ var Checker checker
|
||||
|
||||
// NetOk 网络状况检查
|
||||
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/",
|
||||
Redirect: false,
|
||||
Timeout: time.Duration(timeout) * time.Second,
|
||||
})
|
||||
if e != nil || h.Get("Location") != "" {
|
||||
if e != nil {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
_ = i.Close()
|
||||
return h.Get("Location") == ""
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user