|
|
@@ -32,6 +32,19 @@ const (
|
|
|
NetLTE // 蜂窝网络
|
|
|
)
|
|
|
|
|
|
+func (n NetType) String() string {
|
|
|
+ switch n {
|
|
|
+ case NetNone:
|
|
|
+ return "无网络"
|
|
|
+ case NetEth:
|
|
|
+ return "有线网络"
|
|
|
+ case NetLTE:
|
|
|
+ return "蜂窝网络"
|
|
|
+ default:
|
|
|
+ return "未知网络"
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
const (
|
|
|
interval1 = time.Duration(1) * time.Second
|
|
|
interval2 = time.Duration(5) * time.Second
|
|
|
@@ -61,7 +74,7 @@ func serviceRun() {
|
|
|
|
|
|
// 3.2, 联网检测-看结果
|
|
|
dnsOK, pingOK, tcpOK, httpOK := CheckNetwork()
|
|
|
- baseapp.Logger.Infof("[%s] 联网检测: DNS OK=%v, PING OK=%v, TCP OK=%v, HTTP OK=%v", MODULE_NAME, dnsOK, pingOK, tcpOK, httpOK)
|
|
|
+ baseapp.Logger.Infof("[%s] 联网类型: %s, 检测结果: DNS OK=%v, PING OK=%v, TCP OK=%v, HTTP OK=%v", MODULE_NAME, curNetType.String(), dnsOK, pingOK, tcpOK, httpOK)
|
|
|
|
|
|
// 3.3, 联网成功-在线时
|
|
|
if dnsOK && pingOK && tcpOK {
|