Skip to content

Commit

Permalink
Merge pull request #837 from gamagoat/mask-pass
Browse files Browse the repository at this point in the history
Mask password in logs
  • Loading branch information
schollz authored Nov 13, 2024
2 parents 53323cb + 3252f2a commit d616b8f
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 d616b8f

Please sign in to comment.