-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6fea855
commit a0676df
Showing
7 changed files
with
239 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
from opengsq.binary_reader import BinaryReader | ||
from opengsq.exceptions import InvalidPacketException | ||
from opengsq.protocol_socket import UdpClient | ||
from opengsq.protocols.unreal2 import Unreal2 | ||
|
||
|
||
class KillingFloor(Unreal2): | ||
"""Killing Floor Protocol""" | ||
full_name = 'Killing Floor Protocol' | ||
|
||
async def get_details(self): | ||
response = await UdpClient.communicate(self, b'\x79\x00\x00\x00' + bytes([self._DETAILS])) | ||
|
||
# Remove the first 4 bytes \x80\x00\x00\x00 | ||
br = BinaryReader(response[4:]) | ||
header = br.read_byte() | ||
|
||
if header != self._DETAILS: | ||
raise InvalidPacketException( | ||
'Packet header mismatch. Received: {}. Expected: {}.' | ||
.format(chr(header), chr(self._DETAILS)) | ||
) | ||
|
||
details = {} | ||
details['ServerId'] = br.read_long() # 0 | ||
details['ServerIP'] = br.read_string() # empty | ||
details['GamePort'] = br.read_long() | ||
details['QueryPort'] = br.read_long() # 0 | ||
details['ServerName'] = self._read_string(br) | ||
details['MapName'] = self._read_string(br) | ||
details['GameType'] = self._read_string(br) | ||
details['NumPlayers'] = br.read_long() | ||
details['MaxPlayers'] = br.read_long() | ||
details['WaveCurrent'] = br.read_long() | ||
details['WaveTotal'] = br.read_long() | ||
details['Ping'] = br.read_long() | ||
details['Flags'] = br.read_long() | ||
details['Skill'] = self._read_string(br) | ||
|
||
return details | ||
|
||
|
||
if __name__ == '__main__': | ||
import asyncio | ||
import json | ||
|
||
async def main_async(): | ||
# killingfloor | ||
killingFloor = KillingFloor(host='104.234.65.235', port=7708, timeout=10.0) | ||
details = await killingFloor.get_details() | ||
print(json.dumps(details, indent=None) + '\n') | ||
rules = await killingFloor.get_rules() | ||
print(json.dumps(rules, indent=None) + '\n') | ||
players = await killingFloor.get_players() | ||
print(json.dumps(players, indent=None) + '\n') | ||
|
||
asyncio.run(main_async()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import os | ||
|
||
import pytest | ||
from opengsq.protocols.killingfloor import KillingFloor | ||
|
||
from .result_handler import ResultHandler | ||
|
||
handler = ResultHandler(os.path.basename(__file__)[:-3]) | ||
# handler.enable_save = True | ||
|
||
# Killing Floor | ||
test = KillingFloor(host='104.234.65.235', port=7708) | ||
|
||
@pytest.mark.asyncio | ||
async def test_get_details(): | ||
result = await test.get_details() | ||
await handler.save_result('test_get_details', result) | ||
|
||
@pytest.mark.asyncio | ||
async def test_get_rules(): | ||
result = await test.get_rules() | ||
await handler.save_result('test_get_rules', result) | ||
|
||
@pytest.mark.asyncio | ||
async def test_get_players(): | ||
result = await test.get_players() | ||
await handler.save_result('test_get_players', result) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"ServerId": 0, | ||
"ServerIP": "", | ||
"GamePort": 7707, | ||
"QueryPort": 0, | ||
"ServerName": "|uDeep|/T\\||Noi| #2 <<uINFERNA> W", | ||
"MapName": "KF-STALKER-DUTY-BASE(REMAKE)", | ||
"GameType": "KFGameType", | ||
"NumPlayers": 17, | ||
"MaxPlayers": 32, | ||
"WaveCurrent": 2, | ||
"WaveTotal": 7, | ||
"Ping": 0, | ||
"Flags": 512, | ||
"Skill": "0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
[ | ||
{ | ||
"Id": 769, | ||
"Name": "[CHL] asein", | ||
"Ping": 56, | ||
"Score": 1500, | ||
"StatsId": 536870912 | ||
}, | ||
{ | ||
"Id": 554, | ||
"Name": "[MEX] Tologuin", | ||
"Ping": 148, | ||
"Score": 1515, | ||
"StatsId": 536870912 | ||
}, | ||
{ | ||
"Id": 374, | ||
"Name": "[CHL] fafe_asta", | ||
"Ping": 60, | ||
"Score": 984, | ||
"StatsId": 536870912 | ||
}, | ||
{ | ||
"Id": 311, | ||
"Name": "[ARG] Rekiam", | ||
"Ping": 76, | ||
"Score": 1129, | ||
"StatsId": 536870912 | ||
}, | ||
{ | ||
"Id": 277, | ||
"Name": "[ARG] KFL/UFOKILLER", | ||
"Ping": 28, | ||
"Score": 1716, | ||
"StatsId": 536870912 | ||
}, | ||
{ | ||
"Id": 271, | ||
"Name": "[KOR] Bohemian", | ||
"Ping": 252, | ||
"Score": 493, | ||
"StatsId": 536870912 | ||
}, | ||
{ | ||
"Id": 199, | ||
"Name": "[BRA] Finish", | ||
"Ping": 40, | ||
"Score": 0, | ||
"StatsId": 0 | ||
}, | ||
{ | ||
"Id": 83, | ||
"Name": "[CHL] LordChalox", | ||
"Ping": 60, | ||
"Score": 2282, | ||
"StatsId": 536870912 | ||
}, | ||
{ | ||
"Id": 29, | ||
"Name": "[CHL] Kriss_Nemesis", | ||
"Ping": 52, | ||
"Score": 226, | ||
"StatsId": 536870912 | ||
}, | ||
{ | ||
"Id": 21, | ||
"Name": "[ESP] HomerO", | ||
"Ping": 176, | ||
"Score": 175, | ||
"StatsId": 536870912 | ||
}, | ||
{ | ||
"Id": 19, | ||
"Name": "[CHL] Marcelo_Kris", | ||
"Ping": 56, | ||
"Score": 229, | ||
"StatsId": 536870912 | ||
}, | ||
{ | ||
"Id": 18, | ||
"Name": "[CHL] ZuraRxx", | ||
"Ping": 92, | ||
"Score": 2046, | ||
"StatsId": 536870912 | ||
}, | ||
{ | ||
"Id": 17, | ||
"Name": "[ARG] francomaldonado", | ||
"Ping": 48, | ||
"Score": 59, | ||
"StatsId": 536870912 | ||
}, | ||
{ | ||
"Id": 15, | ||
"Name": "[SLV] memtrix", | ||
"Ping": 128, | ||
"Score": 569, | ||
"StatsId": 536870912 | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"Mutators": [ | ||
"ZNBase", | ||
"ZNBase", | ||
"ZNBase", | ||
"ZNBase", | ||
"ZNBase", | ||
"ZNBase", | ||
"ZNBase", | ||
"ZNBase", | ||
"ZNBase", | ||
"ZNBase" | ||
], | ||
"ServerMode": "dedicated", | ||
"AdminName": "AdminEmail", | ||
"ServerVersion": "1065", | ||
"IsVacSecured": "true", | ||
"MaxSpectators": "6", | ||
"MapVoting": "true", | ||
"KickVoting": "true", | ||
"SP: Version": "750", | ||
"SP: Min perk level": "6", | ||
"SP: Max perk level": "99", | ||
"SP: Num trader weapons": "140", | ||
"SP: Perk 1": "Support Specialist", | ||
"SP: Perk 2": "Berserker" | ||
} |