fixed error handling
This commit is contained in:
parent
887ce6c81d
commit
1bf9988bef
@ -169,12 +169,20 @@ def networkParse(ipAddr, port, aesKey):
|
|||||||
socket.setsockopt(zmq.SUBSCRIBE, b'') # subscribe to topic of all (needed or else it won't work)
|
socket.setsockopt(zmq.SUBSCRIBE, b'') # subscribe to topic of all (needed or else it won't work)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
if socket.poll(10) != 0: # check if there is a message on the socket
|
if socket.poll(10) != 0:
|
||||||
msg = socket.recv() # grab the message
|
msg = socket.recv()
|
||||||
|
# Extracts data from network socket
|
||||||
extractedData = dataExtractor(msg.hex())
|
extractedData = dataExtractor(msg.hex())
|
||||||
|
# Decrypts the payload
|
||||||
decryptedData = dataDecryptor(extractedData, aesKey)
|
decryptedData = dataDecryptor(extractedData, aesKey)
|
||||||
# print(decryptedData)
|
# Decodes the Protobuf if possible
|
||||||
print(decodeProtobuf(decryptedData))
|
protobufMessage = decodeProtobuf(decryptedData)
|
||||||
|
if(protobufMessage == "INVALID PROTOBUF:"):
|
||||||
|
print("INVALID PROTOBUF: ", end = '')
|
||||||
|
print(decryptedData)
|
||||||
|
else:
|
||||||
|
print(protobufMessage)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
time.sleep(0.1) # wait 100ms and try again
|
time.sleep(0.1) # wait 100ms and try again
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user