Skip to content

Commit

Permalink
fix: show logs when connected to the internet (#1086)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeessy2 authored Apr 22, 2024
1 parent a83c600 commit 903c047
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions util/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
5 changes: 5 additions & 0 deletions util/wait_internet.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,21 @@ import (
func WaitInternet(addresses []string) {
delay := time.Second * 5
retryTimes := 0
failed := false

for {
for _, addr := range addresses {

err := LookupHost(addr)
// Internet is connected.
if err == nil {
if failed {
Log("网络已连接")
}
return
}

failed = true
Log("等待网络连接: %s", err)
Log("%s 后重试...", delay)

Expand Down

0 comments on commit 903c047

Please sign in to comment.