From 12a23b0c0de010bd4c6f168be4ef3c0b06b3ad3e Mon Sep 17 00:00:00 2001 From: Stephen Birch Date: Thu, 10 Jun 2021 14:03:26 +0100 Subject: [PATCH] Add new DOS bit flag (#14) Add new DOS bit flag for TF2V8 New bit has been added in pos 6 for if its under a DOS attack, add this to MarshallJSON --- lib/svrquery/protocol/titanfall/types.go | 9 ++++++++- lib/svrquery/protocol/titanfall/types_test.go | 5 +++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/svrquery/protocol/titanfall/types.go b/lib/svrquery/protocol/titanfall/types.go index 87f065e..c86543c 100644 --- a/lib/svrquery/protocol/titanfall/types.go +++ b/lib/svrquery/protocol/titanfall/types.go @@ -54,7 +54,7 @@ type InstanceInfo struct { RandomServerID uint64 } -// InstanceInfo represents instance information contained in a query response. +// InstanceInfoV8 represents instance information contained in a query response. type InstanceInfoV8 struct { Retail byte InstanceType byte @@ -78,6 +78,7 @@ func (a HealthFlags) MarshalJSON() ([]byte, error) { PacketChokedOut bool SlowServerFrames bool Hitching bool + DOS bool }{} obj.None = a.None() obj.PacketLossIn = a.PacketLossIn() @@ -86,6 +87,7 @@ func (a HealthFlags) MarshalJSON() ([]byte, error) { obj.PacketChokedOut = a.PacketChokedOut() obj.SlowServerFrames = a.SlowServerFrames() obj.Hitching = a.Hitching() + obj.DOS = a.DOS() return json.Marshal(obj) } @@ -125,6 +127,11 @@ func (a HealthFlags) Hitching() bool { return (a>>5)&1 == 1 } +// DOS health flag +func (a HealthFlags) DOS() bool { + return (a>>6)&1 == 1 +} + // BasicInfo represents basic information contained in a query response. type BasicInfo struct { Port uint16 diff --git a/lib/svrquery/protocol/titanfall/types_test.go b/lib/svrquery/protocol/titanfall/types_test.go index 51c8ef3..ba0927a 100644 --- a/lib/svrquery/protocol/titanfall/types_test.go +++ b/lib/svrquery/protocol/titanfall/types_test.go @@ -17,6 +17,7 @@ func TestHealthFlags(t *testing.T) { expPacketChokedOut bool expSlowServerFrames bool expHitching bool + expDOS bool }{ { input: 0, @@ -46,6 +47,10 @@ func TestHealthFlags(t *testing.T) { input: 1 << 5, expHitching: true, }, + { + input: 1 << 6, + expDOS: true, + }, } for _, tc := range testCases {