Skip to content

Commit 4abe368

Browse files
authored
Merge pull request #203 from google/go-stringer
go/login: provide a Stringer on the v1 GLOME URLResponse
2 parents 3b327f5 + 6821c0a commit 4abe368

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

go/login/login.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,21 @@ func (r *URLResponse) EncToken() string {
173173
return base64.URLEncoding.EncodeToString(r.Tag(glome.MaxTagSize)) // TODO: passing the tag len as param?
174174
}
175175

176+
// String returns a string representing the URLResponse.
177+
func (r *URLResponse) String() string {
178+
var sb strings.Builder
179+
fmt.Fprintf(&sb, "Version: %d\n", r.V)
180+
fmt.Fprintf(&sb, "Handshake:\n")
181+
fmt.Fprintf(&sb, " Prefix: %x\n", r.HandshakeInfo.Prefix)
182+
fmt.Fprintf(&sb, " User key: %x\n", r.HandshakeInfo.UserKey)
183+
fmt.Fprintf(&sb, " Message tag prefix: %x\n", r.HandshakeInfo.MessageTagPrefix)
184+
fmt.Fprintf(&sb, "Message:\n")
185+
fmt.Fprintf(&sb, " Host ID type: %s\n", r.Msg.HostIDType)
186+
fmt.Fprintf(&sb, " Host ID: %s\n", r.Msg.HostID)
187+
fmt.Fprintf(&sb, " Action: %s", r.Msg.Action)
188+
return sb.String()
189+
}
190+
176191
// Client implements the client-side of the glome-login protocol. Should be constructed under NewClient constructor.
177192
type Client struct {
178193
ServerKey glome.PublicKey // server's public key

0 commit comments

Comments
 (0)