Skip to content

Commit

Permalink
conn: prot: included normal ping resp in getPing()
Browse files Browse the repository at this point in the history
  • Loading branch information
gekigek99 committed Mar 9, 2023
1 parent 5409fa5 commit 22b0877
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/conn/conn-prot.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ func getPing(clientConn net.Conn) *errco.MshLog {
}

switch {
case bytes.HasPrefix(pingData, []byte{9, 1, 0, 0, 0, 0, 0}):
// packet is [9 1 0 0 0 0 0 89 73 114]
// this is normal ping

case bytes.Equal(pingData, []byte{1, 0}):
// packet is [1 0]
// read the second packet
Expand Down
8 changes: 8 additions & 0 deletions lib/conn/conn-prot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,14 @@ func Test_getPing(t *testing.T) {

tests := []test{
// positive cases
{
"ping",
[][]byte{
{9, 1, 0, 0, 0, 0, 0, 89, 73, 114},
},
0,
[]byte{9, 1, 0, 0, 0, 0, 0, 89, 73, 114},
},
{
"2 bytes + ping",
[][]byte{
Expand Down

0 comments on commit 22b0877

Please sign in to comment.