Skip to content

Commit

Permalink
Add new DOS bit flag (#14)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
StephenBirch authored Jun 10, 2021
1 parent 23664e9 commit 12a23b0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/svrquery/protocol/titanfall/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand All @@ -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)
}
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions lib/svrquery/protocol/titanfall/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ func TestHealthFlags(t *testing.T) {
expPacketChokedOut bool
expSlowServerFrames bool
expHitching bool
expDOS bool
}{
{
input: 0,
Expand Down Expand Up @@ -46,6 +47,10 @@ func TestHealthFlags(t *testing.T) {
input: 1 << 5,
expHitching: true,
},
{
input: 1 << 6,
expDOS: true,
},
}

for _, tc := range testCases {
Expand Down

0 comments on commit 12a23b0

Please sign in to comment.