Commit 3478c162 authored by aleajactaest's avatar aleajactaest

adding check file msg.xml & database.xml (compare server and client)

parent 16113852
......@@ -41,6 +41,7 @@ import lzma
import socket
import struct
import xml.etree.ElementTree as ET
import hashlib
class BitStream():
......@@ -144,10 +145,10 @@ class BitStream():
self.pushChar(x)
#y = ord(x)
#self.internalSerial(y, 8)
def pushArrayChar(self, valeur, size):
def pushArrayUint8(self, valeur, size):
' ex.: pushArrayChar([0,1,3,4]) '
for i in valeur:
self.pushChar(i)
self.pushUint8(i)
# ------------------------------------
def readSerial(self, nbits):
......@@ -240,10 +241,10 @@ class BitStream():
tmp += x
_size -= 1
return tmp
def readArrayChar(self, size):
def readArrayUint8(self, size):
ret = []
for i in range(0, size):
ret.append(self.readChar())
ret.append(self.readUint8())
return ret
# ------------------------------------
......@@ -277,8 +278,18 @@ class BitStream():
return ret
def getTextMD5(dataRawXml):
log = logging.getLogger('myLogger')
dataNew = ''
for data in dataRawXml:
pass
if data != '\r': # '\015' ignore caractère \r\n =>
dataNew += data
else:
log.debug("***** data:%d" % (ord(data)))
m = hashlib.md5()
m.update(dataNew.encode('utf-8'))
#print(m.hexdigest())
#print(m.digest())
return m.digest()
def Test():
a = BitStream()
......@@ -1488,6 +1499,8 @@ class ClientNetworkConnection:
self._LastAckInLongAck = 0
self._MsgXmlMD5 = None
self._DatabaseXmlMD5 = None
self.msgXml = None
self.databaseXml = None
def cookiesInit(self, UserAddr, UserKey, UserId):
self.UserAddr = UserAddr
......@@ -1581,10 +1594,20 @@ class ClientNetworkConnection:
_LatestSync = msg.readUint32()
self.log.debug("%d %d %d" %(_Synchronize, stime, _LatestSync))
# khanat-opennel-code/code/ryzom/client/src/network_connection.cpp : void CNetworkConnection::receiveSystemSync(CBitMemStream &msgin)
MsgData = msg.readArrayChar(16)
DatabaseData = msg.readArrayChar(16)
MsgData = msg.readArrayUint8(16)
DatabaseData = msg.readArrayUint8(16)
self.log.debug("MsgData:" + str(MsgData))
self.log.debug("DatabaseData:" + str(DatabaseData))
md5Msg = bytes(MsgData)
md5Database = bytes(DatabaseData)
if md5Msg == self._MsgXmlMD5:
self.log.info("Check MD5 msg.xml : OK")
else:
self.log.error("Check MD5 msg.xml : KO")
if md5Database == self._DatabaseXmlMD5:
self.log.info("Check MD5 database.xml : OK")
else:
self.log.error("Check MD5 database.xml : KO")
self.log.error("TODO")
#self.sendSystemAckSync()
......@@ -1592,10 +1615,10 @@ class ClientNetworkConnection:
pass
def EmulateFirst(self, msgRawXml, databaseRawXml):
msgXml = ET.fromstring(msgRawXml)
ET.dump(msgXml)
databaseXml = ET.fromstring(databaseRawXml)
ET.dump(databaseXml)
self.msgXml = ET.fromstring(msgRawXml)
#ET.dump(msgXml)
self.databaseXml = ET.fromstring(databaseRawXml)
#ET.dump(databaseXml)
self._MsgXmlMD5 = getTextMD5(msgRawXml)
self._DatabaseXmlMD5 = getTextMD5(databaseRawXml)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment