frostschutz / SourceLib

Python implementation of Valve Source Dedicated Server Query/RCON/Log protocols.
39 stars 20 forks source link

Bug when querying some servers #2

Closed cookednoodles closed 14 years ago

cookednoodles commented 14 years ago

I initially picked your lib because it worked a lot better than other libs for l4d, unfortunately it seems to have some bugs of its own on certain games.

import SourceQuery server = SourceQuery.SourceQuery('81.93.240.69', 27105) server_info = server.info()

File "xxxxxxxxxx/SourceQuery.py", line 237, in info edf = packet.getByte() File "xxxxxxxxxx/SourceQuery.py", line 70, in getByte return struct.unpack('<B', self.read(1))[0] struct.error: unpack requires a string argument of length 1

frostschutz commented 14 years ago

SourceLib expects the edf to be present (only tested with TF2 where this always was the case), however http://developer.valvesoftware.com/wiki/Server_queries says "Extra Data Flag (EDF) byte if present this specifies which additional data fields will be included"

Guess I overlooked the "if present" part, heh.

If you want a quick and dirty workaround for this problem, find the edf in SourceQuery.py line 237, and wrap the entire thing in a try: except: pass block.

I'm sorry to say that this library is in a rather unfinished state. The project I originally made it for died before it even existed; I tried to switch over to Twisted in the middle of things without really understanding its concepts, and Twisted doesn't offer much convenience for UDP anyway; and the Source protocol itself is crappy and was changed in a not-backward-compatible way.

Feel free to report bugs here and I'll take a look at it and see if it can be worked around somehow, if you want something more elaborate please fork it :)

cookednoodles commented 14 years ago

Perfect thanks! Even in a half finished state, your lib is a lot better than the others I've come across.