fix:完善守护机制

This commit is contained in:
Mmx
2021-07-11 13:53:23 +08:00
parent 17748b88a0
commit 5a0137c6cd
2 changed files with 8 additions and 1 deletions

View File

@@ -9,6 +9,7 @@ import (
)
func Guardian(output bool) {
var c = make(chan bool)
for {
global.Status.Output = output
time.Sleep(time.Duration(global.Config.Settings.Guardian) * time.Second)
@@ -19,8 +20,14 @@ func Guardian(output bool) {
if !util.Checker.NetOk() {
util.Log.Println("Network down, trying to login")
_ = Login(false)
} else {
if global.Config.Settings.DemoMode {
util.Log.Println("Network ok")
}
}
c <- false
}()
<-c
}
}

View File

@@ -65,7 +65,7 @@ func ErrHandler(err error) {
func NetDailEr() func(ctx context.Context, network, address string) (net.Conn, error) {
return func(ctx context.Context, network, address string) (net.Conn, error) {
d := net.Dialer{
Timeout: 5 * time.Second,
Deadline: time.Now().Add(5 * time.Second),
}
return d.DialContext(ctx, "udp", global.Config.Settings.Dns+":53")
}