From 4642aec56b30953eb5257d765360679d96dbce66 Mon Sep 17 00:00:00 2001 From: Rossen Georgiev Date: Tue, 15 Nov 2016 13:31:01 +0200 Subject: [PATCH] refactor msg.py into multiple modules --- steam/core/msg.py | 577 ++++---------------------------------- steam/core/msg_headers.py | 182 ++++++++++++ steam/core/msg_structs.py | 242 ++++++++++++++++ steam/core/msg_unified.py | 65 +++++ 4 files changed, 539 insertions(+), 527 deletions(-) create mode 100644 steam/core/msg_headers.py create mode 100644 steam/core/msg_structs.py create mode 100644 steam/core/msg_unified.py diff --git a/steam/core/msg.py b/steam/core/msg.py index 5afafa6..90ce482 100644 --- a/steam/core/msg.py +++ b/steam/core/msg.py @@ -1,128 +1,71 @@ -from importlib import import_module -import re -import struct import fnmatch -from steam.enums import EResult, EUniverse +from steam.core.msg_unified import get_um +from steam.core.msg_structs import get_struct +from steam.core.msg_headers import MsgHdr, ExtendedMsgHdr, MsgHdrProtoBuf, GCMsgHdr, GCMsgHdrProto from steam.enums.emsg import EMsg from steam.protobufs import steammessages_base_pb2 from steam.protobufs import steammessages_clientserver_pb2 from steam.protobufs import steammessages_clientserver_2_pb2 -from steam.protobufs import gc_pb2 -from steam.util import set_proto_bit, clear_proto_bit -class MsgHdr: - _size = struct.calcsize(" 8: - self.challenge = data[8:] - - def __str__(self): - return '\n'.join(["protocolVersion: %s" % self.protocolVersion, - "universe: %s" % repr(self.universe), - "challenge: %s" % repr(self.challenge), - ]) - - -class ChannelEncryptResponse: - protocolVersion = 1 - keySize = 128 - key = '' - crc = 0 - - def __init__(self, data=None): - if data: - self.load(data) - - def serialize(self): - return struct.pack(" 8: + self.challenge = data[8:] + + def __str__(self): + return '\n'.join(["protocolVersion: %s" % self.protocolVersion, + "universe: %s" % repr(self.universe), + "challenge: %s" % repr(self.challenge), + ]) + +class ChannelEncryptResponse(StructMessage): + protocolVersion = 1 + keySize = 128 + key = '' + crc = 0 + + def __init__(self, data=None): + if data: + self.load(data) + + def serialize(self): + return struct.pack("