fix:完善守护机制
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func Guardian(output bool) {
|
func Guardian(output bool) {
|
||||||
|
var c = make(chan bool)
|
||||||
for {
|
for {
|
||||||
global.Status.Output = output
|
global.Status.Output = output
|
||||||
time.Sleep(time.Duration(global.Config.Settings.Guardian) * time.Second)
|
time.Sleep(time.Duration(global.Config.Settings.Guardian) * time.Second)
|
||||||
@@ -19,8 +20,14 @@ func Guardian(output bool) {
|
|||||||
if !util.Checker.NetOk() {
|
if !util.Checker.NetOk() {
|
||||||
util.Log.Println("Network down, trying to login")
|
util.Log.Println("Network down, trying to login")
|
||||||
_ = Login(false)
|
_ = Login(false)
|
||||||
|
} else {
|
||||||
|
if global.Config.Settings.DemoMode {
|
||||||
|
util.Log.Println("Network ok")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
c <- false
|
||||||
}()
|
}()
|
||||||
|
<-c
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ func ErrHandler(err error) {
|
|||||||
func NetDailEr() func(ctx context.Context, network, address string) (net.Conn, error) {
|
func NetDailEr() func(ctx context.Context, network, address string) (net.Conn, error) {
|
||||||
return func(ctx context.Context, network, address string) (net.Conn, error) {
|
return func(ctx context.Context, network, address string) (net.Conn, error) {
|
||||||
d := net.Dialer{
|
d := net.Dialer{
|
||||||
Timeout: 5 * time.Second,
|
Deadline: time.Now().Add(5 * time.Second),
|
||||||
}
|
}
|
||||||
return d.DialContext(ctx, "udp", global.Config.Settings.Dns+":53")
|
return d.DialContext(ctx, "udp", global.Config.Settings.Dns+":53")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user