Skip to content

Commit

Permalink
Mask password in logs
Browse files Browse the repository at this point in the history
  • Loading branch information
gamagoat committed Nov 13, 2024
1 parent 53323cb commit 3252f2a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/tcp/tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,17 @@ func Run(debugLevel, host, port, password string, banner ...string) (err error)

func (s *server) start() (err error) {
log.SetLevel(s.debugLevel)
log.Debugf("starting with password '%s'", s.password)

// Mask our password in logs
maskedPassword := ""
if len(s.password) > 2 {
maskedPassword = fmt.Sprintf("%c***%c", s.password[0], s.password[len(s.password)-1])
} else {
maskedPassword = s.password
}

log.Debugf("starting with password '%s'", maskedPassword)

s.rooms.Lock()
s.rooms.rooms = make(map[string]roomInfo)
s.rooms.Unlock()
Expand Down

0 comments on commit 3252f2a

Please sign in to comment.