From 22b0877179ec84e208f8f93f015373d0142c4099 Mon Sep 17 00:00:00 2001 From: gekigek99 <53654579+gekigek99@users.noreply.github.com> Date: Thu, 9 Mar 2023 19:41:52 +0100 Subject: [PATCH] conn: prot: included normal ping resp in getPing() --- lib/conn/conn-prot.go | 4 ++++ lib/conn/conn-prot_test.go | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/lib/conn/conn-prot.go b/lib/conn/conn-prot.go index 9f37b353..cb542fdf 100644 --- a/lib/conn/conn-prot.go +++ b/lib/conn/conn-prot.go @@ -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 diff --git a/lib/conn/conn-prot_test.go b/lib/conn/conn-prot_test.go index dfdd2cdd..47bb3bc9 100644 --- a/lib/conn/conn-prot_test.go +++ b/lib/conn/conn-prot_test.go @@ -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{