From eca394e7b7ba1a1817f6f4548c0e86bb8dd76484 Mon Sep 17 00:00:00 2001 From: "DESKTOP-DPA61F8\\Benedek" Date: Fri, 23 Apr 2021 18:13:38 +0200 Subject: [PATCH] no message --- client/netwrapper.py | 61 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 client/netwrapper.py diff --git a/client/netwrapper.py b/client/netwrapper.py new file mode 100644 index 0000000..1f19b65 --- /dev/null +++ b/client/netwrapper.py @@ -0,0 +1,61 @@ +#!/usr/bin/env python3 +from netsim import network_interface + + +class NetWrapper: + SERVER_ADDRESS = 'A' + + + + def __init__(self, publicKey: str, privateKey: str, clientAddress: str, cipherKey: str = ""): + # Create network_interface: network_interface(path, addr) path root is shared with network / addr is own address + self.network = network_interface('./network/',clientAddress) + + self.publicKey = publicKey + self.privateKey = privateKey + self.cipherKey = cipherKey + + def identifyServer(self,message: bytes) -> bytes: + #Message is coded with Server RSA public key in string byte format + #Creat json with format: + # json = { + # 'type':'IDY', + # 'source':self.network.own_addr, + # 'message': message + # } + #message = json.dump() + #message.encode('utf-8') + #network_interface.send_msg(self.SERVER_ADDRESS,message) + #Listen for response + #status, msg = network_interface.receive_msg(blocking=True) -> status is boolean flag, msg is message + #return status, msg + pass + + + def authenticate(self, username: str, password: str): + # json = { + # 'type':'AUT', + # 'source':self.network.own_addr, + # 'message': message + # } + # + pass + + + def sendMessage(self, message: bytes): + #message: encoding message with chacha20 + #json = { + # 'type':'CMD', + # 'source':self.network.own_addr, + # 'message': message + #} + #message = json.dump() + #message.encode('utf-8') + #network_interface.send_msg(self.SERVER_ADDRESS,message) + pass + + + def recieveMessage(self, message: bytes): + #status, msg = network_interface.receive_msg(blocking=True) -> status is boolean flag, msg is message + #Decode the message with chacha20 + pass