0

rcon: Throw more helpful exception if proto error

Addresses #1273.
This commit is contained in:
Nicolas F
2016-01-30 15:25:45 +01:00
parent 9fc050cf67
commit 8f08b3b69f

View File

@@ -68,8 +68,13 @@ class RConConnection():
if not toread:
raise RConException(self.rid, "Request timed out.")
res_len, res_id, res_type = \
struct.unpack("<iii", self.sock.recv(12, socket.MSG_WAITALL))
try:
res_len, res_id, res_type = \
struct.unpack("<iii", self.sock.recv(12, socket.MSG_WAITALL))
except Exception as e:
raise RConException(self.rid,
"RCon protocol error. Are you sure you're " + \
"talking to the RCon port? Error: %s" % e)
res_data = self.sock.recv(res_len - 4 - 4)
res_data = res_data[:-2]