Compare commits

..

No commits in common. "4bd161de547594ab79a41c93aacc1186c3b51ed8" and "f6461273ab67a08ab15ef6e272f1482c8a65d9a9" have entirely different histories.

3 changed files with 16 additions and 12 deletions

View File

@ -3,5 +3,4 @@ from server import Server
if __name__ == '__main__':
server = Server()
server.initServer()
server.startServer()

View File

@ -36,7 +36,7 @@ class NetWrapper:
cipher = PKCS1_OAEP.new(self.currentClientPublicKey)
identMsg = json.dumps(
{'type': 'IDY', 'source': self.network.own_addr,
'message': b64encode(cipher.encrypt(retmsg.encode('UTF-8')))}).decode(
'message': b64encode(cipher.encrypt(retmsg.encode('UTF-8')))}).encode(
'ASCII')
self.network.send_msg(self.clientAddr, identMsg)

View File

@ -12,18 +12,13 @@ class Server:
self.sessionTimeout = sessionTimeout
self.availableServer = availableServer
self.executor = Executor(homeDirectory)
def initServer(self):
print("Please enter your private key passphrase")
passphrase = input()
self.auth = Authetication()
self.networkInstance = NetWrapper(self.auth.loadUserPublicKeys(), self.auth.loadServerPrivateKey(passphrase),
self)
self.auth=Authetication()
self.networkInstance = NetWrapper(self.auth.loadUserPublicKeys(),self.auth.loadServerPrivateKey(),self)
def login(self, username: str, password: str) -> bool:
self.isAuthenticated = True
home_directory = self.auth.login(username, password)
self.executor.baseDir = Executor(home_directory)
self.executor.baseDir=Executor(home_directory)
if not home_directory:
return False
else:
@ -33,7 +28,7 @@ class Server:
self.isAuthenticated = False
self.availableServer = False
self.homeDirectory = ""
self.executor.baseDir = Executor(self.homeDirectory)
self.executor.baseDir=Executor(self.homeDirectory)
def parseCommand(self, command: str) -> str:
if command == "LINOK":
@ -112,4 +107,14 @@ class Server:
def startServer(self):
while True:
message = self.networkInstance.recieveMessage().decode('UTF-8')
self.parseCommand(message)
command = self.parseCommand(message)
#ha LINOK vagy LINERROR donothing
if command == "LINERROR" or command == "LINOK" or command == "ERROR":
print("not right commands")
elif len(command) == 1:
execute_message = self.execute(self,command, "", "")
elif len(command) == 2:
execute_message = self.execute(self, command, command[1], "")
elif len(command) == 3:
execute_message = self.execute(self, command, command[1], command[2])
self.networkInstance.sendMessage(self, execute_message)