Skip to content

Commit

Permalink
bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
fdkevin0 committed Mar 11, 2022
1 parent c7a716f commit 19fdab8
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions cmd/net/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,6 @@ var loginCmd = &cobra.Command{
log.Printf("start daemon: check every %d seconds\n", interval)
startTime := time.Now()
for {
//检测是否能访问互联网,如果不能,则退出登录并尝试重新登录
if !portalServer.Internet() {
log.Println("internet is not available, try to login again")
if _, err := portalServer.PortalLogout(); err != nil {
log.Println(err)
}
}

//检测是否登录成功,如果登录过期则重新登录
info, err := portalServer.GetUserInfo()
cobra.CheckErr(err)
Expand All @@ -115,7 +107,15 @@ var loginCmd = &cobra.Command{
}
log.Printf("check succed: live time %fs\n", time.Now().Sub(startTime).Seconds())

time.Sleep(time.Second * time.Duration(interval))
//检测是否能访问互联网,如果不能,则退出登录并尝试重新登录
if !portalServer.Internet() {
log.Println("internet is not available, try to login again")
if _, err := portalServer.PortalLogout(); err != nil {
log.Println(err)
}
} else {
time.Sleep(time.Second * time.Duration(interval))
}
}
}

Expand Down

0 comments on commit 19fdab8

Please sign in to comment.