Skip to content

Commit

Permalink
Eternal mode
Browse files Browse the repository at this point in the history
  • Loading branch information
cyp0633 committed Feb 27, 2023
1 parent baff34e commit 58d400b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 6 additions & 2 deletions internal/dhcp/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ func Run() {
// TODO: 超时动作,需要每次读写设置 deadline?
conn = bufio.NewReadWriter(bufio.NewReader(c), bufio.NewWriter(c))
defer c.Close()
for {
for fail := 0; fail <= 5; {
tail, salt, err := login()
if err != nil {
time.Sleep(5 * time.Second)
util.Logger.Info("Login failed, retrying", zap.Error(err))
util.Logger.Info("Login failed, retrying", zap.Error(err), zap.Int("retry", 1))
if !util.CLI.Eternal {
fail++
}
continue
}
time.Sleep(3 * time.Second)
Expand Down Expand Up @@ -58,4 +61,5 @@ func Run() {
}
}
}
util.Logger.Error("Login failed 5 times, exiting")
}
3 changes: 0 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ func main() {
}
util.SetupLog()
util.ParseConf()
if util.CLI.Eternal {
fmt.Printf("eternal mode\n")
}
switch ctx.Command() {
case "dhcp":
dhcp.Run()
Expand Down

0 comments on commit 58d400b

Please sign in to comment.