Skip to content
This repository has been archived by the owner on Nov 12, 2023. It is now read-only.

Commit

Permalink
fix assigning username
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabio1988 committed Oct 4, 2023
1 parent f138239 commit 25e6522
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion routes/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func handleGetAccount(c *gin.Context, req ControllerBody, workerState *worker.St
respondWithError(c, NoAccountLeft)
return
}
workerState.Username = account.Username
workerState.SetUsername(account.Username)
host := c.RemoteIP()
if loginDelay := config.Config.Worker.LoginDelay; loginDelay > 0 {
now := time.Now().Unix()
Expand Down
6 changes: 6 additions & 0 deletions worker/workerState.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ func (ws *State) Unlock() {
ws.mu.Unlock()
}

func (ws *State) SetUsername(username string) {
ws.Lock()
defer ws.Unlock()
ws.Username = username
}

func (ws *State) ResetUsername() {
ws.Lock()
defer ws.Unlock()
Expand Down

0 comments on commit 25e6522

Please sign in to comment.