[agent][wdd] - 初始化项目

This commit is contained in:
zeaslity
2025-02-10 15:07:44 +08:00
parent a0811d62e7
commit b8f0b14852
12 changed files with 455 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
package config
import (
"net/http"
"time"
)
// CanConnectInternet 判定主机能否上网 请求 www.google.com 如果请求正常 返回2 如果超时三秒 请求baidu.com如果没有错误返回1 如果错误返回0
func CanConnectInternet() int {
client := http.Client{
Timeout: 3 * time.Second,
}
_, err := client.Get("https://www.google.com")
if err == nil {
return 2
}
_, err = client.Get("https://www.baidu.com")
if err == nil {
return 1
}
return 0
}