From 903c047a7ffa98b6001b0a42db5b10109b236f86 Mon Sep 17 00:00:00 2001 From: jeessy2 <6205259+jeessy2@users.noreply.github.com> Date: Mon, 22 Apr 2024 02:21:58 -0700 Subject: [PATCH] fix: show logs when connected to the internet (#1086) --- util/messages.go | 1 + util/wait_internet.go | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/util/messages.go b/util/messages.go index b354e2e24..c2fc02e52 100644 --- a/util/messages.go +++ b/util/messages.go @@ -87,6 +87,7 @@ func init() { message.SetString(language.English, "本机DNS异常! 将默认使用 %s, 可参考文档通过 -dns 自定义 DNS 服务器", "Local DNS exception! Will use %s by default, you can use -dns to customize DNS server") message.SetString(language.English, "等待网络连接: %s", "Waiting for network connection: %s") message.SetString(language.English, "%s 后重试...", "Retry after %s") + message.SetString(language.English, "网络已连接", "The network is connected") // main message.SetString(language.English, "监听端口发生异常, 请检查端口是否被占用! %s", "Listen port failed, please check if the port is occupied! %s") diff --git a/util/wait_internet.go b/util/wait_internet.go index 82f30a6c3..6432cbc3b 100644 --- a/util/wait_internet.go +++ b/util/wait_internet.go @@ -14,6 +14,7 @@ import ( func WaitInternet(addresses []string) { delay := time.Second * 5 retryTimes := 0 + failed := false for { for _, addr := range addresses { @@ -21,9 +22,13 @@ func WaitInternet(addresses []string) { err := LookupHost(addr) // Internet is connected. if err == nil { + if failed { + Log("网络已连接") + } return } + failed = true Log("等待网络连接: %s", err) Log("%s 后重试...", delay)