一键打包生成oem项目exe
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

52 lines
1.2 KiB

package initFunc
import (
"errors"
"fmt"
"net"
"time"
)
//设备自检
//1.检测网络是否正常,如果不正常,提示用户检查主控箱电源是否跳闸 宽带是否欠费 网络接线是否有问题
func CheckNetwork() error {
err := pingNet("www.baidu.com")
return err
}
//2 检测路由器 192.168.881 检测主机 192.168.88.2 检测监控 192.168.88.7 检测AP 192.168.88.9 检测开关路由器 192.168.88.8 检测速哇服务器 mp.suwa3d.com
func CheckDevice() map[string]string {
arrIpDevices := map[string]string{
"路由器":"192.168.88.1",
"主机":"192.168.8.2",
"AP":"192.168.88.9",
"开关路由器":"192.168.88.8",
"速哇服务器":"mp.suwa3d.com",
"监控":"192.168.88.7",
}
errIpDevices := map[string]string{}
for k,v := range arrIpDevices {
err := pingNet(v)
if err != nil {
errIpDevices[k] = v
}
}
return errIpDevices
}
//ping ip的方法
func pingNet(ip string) error {
ipInfo := net.ParseIP(ip)
if ipInfo == nil {
return errors.New("IP信息有误")
}
// 创建 TCP 连接
conn, err := net.DialTimeout("tcp", fmt.Sprintf("%s:80", ipInfo), time.Second*1)
if err != nil {
return errors.New("连接失败-"+err.Error())
}
defer conn.Close()
// ping 成功
return nil
}