From 7fce47e67cd3b96e60256def7ab736d6b36867cd Mon Sep 17 00:00:00 2001 From: AleaJactaEst Date: Sun, 19 May 2019 15:29:43 +0200 Subject: [PATCH] add option to downlaod all patch file, and quit client after 20 loop --- client.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/client.py b/client.py index f71985e..c51af50 100755 --- a/client.py +++ b/client.py @@ -1385,14 +1385,14 @@ class ClientNetworkConnection: msg = BitStream() self.buildSystemHeader(msg) msg.pushUint8(8) # SYSTEM_LOGIN_CODE - msg.pushSint32(_QuitId) # _QuitId + msg.pushSint32(self._QuitId) # _QuitId self._sock.sendto(msg.bytes(), self.frontend) self._ConnectionState = TConnectionState.Quit def EmulateFirst(self): self.sendSystemLogin() - while True: + for _ in range(1, 20): # while True: data, addr = self._sock.recvfrom(1024) # buffer size is 1024 bytes print( "received message:", data) self.sendSystemQuit() @@ -1406,12 +1406,15 @@ class ClientKhanat: clientApp="Lirria", LanguageCode="fr", url="/login/r2_login.php", - suffix = None): + suffix = None, + download_patch = False): self.log = logging.getLogger('myLogger') if suffix is None: suffix = str(random.randrange(1, 9999)) self.log.debug("suffix : %s" % suffix) + + self.download_patch = download_patch self.khanaturl = khanaturl self.login = login + suffix self.password = password @@ -1594,6 +1597,7 @@ class ClientKhanat: return dstName def downloadAllPatch(self): + # TODO - check where client search file to download for file in self.khanat_idx.CBNPFile: tmp = self.getServerFile("%05d/%s.lzma" % (int(self.r2serverversion), file.FileName), False, "") with lzma.open(tmp) as fin: @@ -1615,7 +1619,8 @@ class ClientKhanat: self.khanat_idx.show() # Todo analyze patch and download if necessary or update if incremental - see category # Download all file in patch - login_patch.cpp:2578 # void CPatchThread::processFile (CPatchManager::SFileToPatch &rFTP) - #self.downloadAllPatch() + if self.download_patch: + self.downloadAllPatch() self.clientNetworkConnection.EmulateFirst() @@ -1628,6 +1633,7 @@ def main(): parser.add_argument("--khanaturl", help="khanat URL to auhtenticate", default='localhost') parser.add_argument("--suffix", help="define suffix") parser.add_argument("-d", "--debug", help="show debug message", action='store_true') + parser.add_argument("-p", "--download-patch", help="show debug message", action='store_true') args = parser.parse_args() if args.debug: @@ -1636,7 +1642,7 @@ def main(): level = logging.getLevelName('INFO') log.setLevel(level) - client = ClientKhanat(args.khanaturl, suffix=args.suffix) + client = ClientKhanat(args.khanaturl, suffix=args.suffix, download_patch=args.download_patch) client.Emulate() log.info("End")