Skip to content

Commit 33426dd

Browse files
committed
go/login: provide a Stringer on the v1 GLOME URLResponse
1 parent 3b327f5 commit 33426dd

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

go/login/login.go

+15
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 (u *URLResponse) String() string {
178+
var sb strings.Builder
179+
fmt.Fprintf(&sb, "Version: %d\n", resp.V)
180+
fmt.Fprintf(&sb, "Handshake:\n")
181+
fmt.Fprintf(&sb, " Prefix: %x\n", u.HandshakeInfo.Prefix)
182+
fmt.Fprintf(&sb, " User key: %x\n", u.HandshakeInfo.UserKey)
183+
fmt.Fprintf(&sb, " Message tag prefix: %x\n", u.HandshakeInfo.MessageTagPrefix)
184+
fmt.Fprintf(&sb, "Message:\n")
185+
fmt.Fprintf(&sb, " Host ID type: %s\n", u.Msg.HostIDType)
186+
fmt.Fprintf(&sb, " Host ID: %s\n", u.Msg.HostID)
187+
fmt.Fprintf(&sb, " Action: %s", u.Msg.Action)
188+
return sb
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)