Skip to content

Commit b57bfc5

Browse files
authored
feat: check keep-alive response cookie (#556)
Fixes #555
1 parent 5b50c6e commit b57bfc5

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

protocol/keepalive/client.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,14 @@ func (c *Client) messageHandler(msg protocol.Message) error {
115115

116116
func (c *Client) handleKeepAliveResponse(msgGeneric protocol.Message) error {
117117
msg := msgGeneric.(*MsgKeepAliveResponse)
118+
if msg.Cookie != c.config.Cookie {
119+
return fmt.Errorf(
120+
"%s: unexpected cookie in response, expected %d but received %d",
121+
ProtocolName,
122+
c.config.Cookie,
123+
msg.Cookie,
124+
)
125+
}
118126
if c.config != nil && c.config.KeepAliveResponseFunc != nil {
119127
// Call the user callback function
120128
return c.config.KeepAliveResponseFunc(msg.Cookie)

0 commit comments

Comments
 (0)