bugfix
This commit is contained in:
parent
a04d9a53c4
commit
a4b95f1c8c
@ -88,11 +88,11 @@ class DataEncoder:
|
|||||||
pubkey = self.public_keys.get(peer_id)
|
pubkey = self.public_keys.get(peer_id)
|
||||||
return pubkey
|
return pubkey
|
||||||
|
|
||||||
def pack(self, peer_id, data):
|
def pack(self, peer_id, data, uncrypt=False):
|
||||||
pk = self.get_peer_pubkey(peer_id)
|
pk = self.get_peer_pubkey(peer_id)
|
||||||
print(peer_id, 'pk=', pk)
|
print(peer_id, 'pk=', pk)
|
||||||
t, d = self.identify_datatype(data)
|
t, d = self.identify_datatype(data)
|
||||||
if pk is None:
|
if uncrypt:
|
||||||
return zlib.compress(b'\x00' * 18 + \
|
return zlib.compress(b'\x00' * 18 + \
|
||||||
bytes(chr(t),'utf-8') + \
|
bytes(chr(t),'utf-8') + \
|
||||||
data)
|
data)
|
||||||
@ -112,8 +112,9 @@ class DataEncoder:
|
|||||||
def unpack(self, peer_id, data):
|
def unpack(self, peer_id, data):
|
||||||
data = zlib.decompress(data)
|
data = zlib.decompress(data)
|
||||||
if data[:18] == b'\x00' * 18:
|
if data[:18] == b'\x00' * 18:
|
||||||
t = ord(data[18])
|
data = data[18:]
|
||||||
d = data[19:]
|
t = ord(data[0])
|
||||||
|
d = data[1:]
|
||||||
if t == DATA_TYPE_BYTES:
|
if t == DATA_TYPE_BYTES:
|
||||||
return d
|
return d
|
||||||
d = d.decode('utf-8')
|
d = d.decode('utf-8')
|
||||||
|
Loading…
Reference in New Issue
Block a user