Skip to content

Commit

Permalink
Merge pull request #500 from besedad/besedad-redact-password
Browse files Browse the repository at this point in the history
Redact password in Stringer of packets.ConnectPacket
  • Loading branch information
MattBrittan authored Apr 28, 2021
2 parents c15e250 + fc07c1a commit 4d373b3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packets/connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ type ConnectPacket struct {
}

func (c *ConnectPacket) String() string {
return fmt.Sprintf("%s protocolversion: %d protocolname: %s cleansession: %t willflag: %t WillQos: %d WillRetain: %t Usernameflag: %t Passwordflag: %t keepalive: %d clientId: %s willtopic: %s willmessage: %s Username: %s Password: %s", c.FixedHeader, c.ProtocolVersion, c.ProtocolName, c.CleanSession, c.WillFlag, c.WillQos, c.WillRetain, c.UsernameFlag, c.PasswordFlag, c.Keepalive, c.ClientIdentifier, c.WillTopic, c.WillMessage, c.Username, c.Password)
var password string
if len(c.Password) > 0 {
password = "<redacted>"
}
return fmt.Sprintf("%s protocolversion: %d protocolname: %s cleansession: %t willflag: %t WillQos: %d WillRetain: %t Usernameflag: %t Passwordflag: %t keepalive: %d clientId: %s willtopic: %s willmessage: %s Username: %s Password: %s", c.FixedHeader, c.ProtocolVersion, c.ProtocolName, c.CleanSession, c.WillFlag, c.WillQos, c.WillRetain, c.UsernameFlag, c.PasswordFlag, c.Keepalive, c.ClientIdentifier, c.WillTopic, c.WillMessage, c.Username, password)
}

func (c *ConnectPacket) Write(w io.Writer) error {
Expand Down

0 comments on commit 4d373b3

Please sign in to comment.