Browse Source

add LZMA decompression for chunks

pull/191/head
Rossen Georgiev 6 years ago
parent
commit
5d0efb4bf2
  1. 21
      steam/client/cdn.py

21
steam/client/cdn.py

@ -1,4 +1,6 @@
from zipfile import ZipFile
from io import BytesIO
from collections import OrderedDict, deque from collections import OrderedDict, deque
from six import itervalues from six import itervalues
import vdf import vdf
@ -6,9 +8,14 @@ import vdf
from steam import webapi from steam import webapi
from steam.enums import EResult, EServerType from steam.enums import EResult, EServerType
from steam.util.web import make_requests_session from steam.util.web import make_requests_session
from stema.core.crypto symmetric_decrypt from steam.core.crypto import symmetric_decrypt
from steam.core.manifest import DepotManifest from steam.core.manifest import DepotManifest
try:
import lzma
except ImportError:
from backports import lzma
def get_content_servers_from_cs(host, port, cell_id, num_servers=20, session=None): def get_content_servers_from_cs(host, port, cell_id, num_servers=20, session=None):
proto = 'https' if port == 443 else 'http' proto = 'https' if port == 443 else 'http'
@ -161,13 +168,12 @@ class CDNClient(object):
if resp.ok: if resp.ok:
data = symmetric_decrypt(resp.content, self.get_depot_key(depot_id)) data = symmetric_decrypt(resp.content, self.get_depot_key(depot_id))
if data[:2] == b'VZ': if data[:3] == b'VZa':
raise Exception("Implement LZMA lol") f = lzma._decode_filter_properties(lzma.FILTER_LZMA1, data[7:12])
return lzma.LZMADecompressor(lzma.FORMAT_RAW, filters=[f]).decompress(data[12:-10])
else: else:
with ZipFile(BytesIO(data)) as zf: with ZipFile(BytesIO(data)) as zf:
data = zf.read(zf.filelist[0]) return zf.read(zf.filelist[0])
return data
class ContentServer(object): class ContentServer(object):
@ -189,6 +195,3 @@ class ContentServer(object):
repr(self.type), repr(self.type),
repr(self.cell_id), repr(self.cell_id),
) )

Loading…
Cancel
Save