Skip to content

Commit

Permalink
Redact password in Stringer of packets.ConnectPacket
Browse files Browse the repository at this point in the history
  • Loading branch information
besedad committed Apr 28, 2021
1 parent c15e250 commit fc07c1a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packets/connect.go
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 fc07c1a

Please sign in to comment.