From 5a0137c6cdb87c4bca0d94adda56e9da63055507 Mon Sep 17 00:00:00 2001 From: Mmx <1624045573@qq.com> Date: Sun, 11 Jul 2021 13:53:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=AE=8C=E5=96=84=E5=AE=88=E6=8A=A4?= =?UTF-8?q?=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/guardian.go | 7 +++++++ util/util.go | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/controllers/guardian.go b/controllers/guardian.go index 90d81d1..4553608 100644 --- a/controllers/guardian.go +++ b/controllers/guardian.go @@ -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 } } diff --git a/util/util.go b/util/util.go index ae9e5f5..92628cc 100644 --- a/util/util.go +++ b/util/util.go @@ -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") }