This commit is contained in:
parent
30d582227e
commit
eca394e7b7
61
client/netwrapper.py
Normal file
61
client/netwrapper.py
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user