This commit is contained in:
Torma Kristóf 2021-04-25 17:51:08 +02:00
commit 0874645719
Signed by: tormakris
GPG Key ID: DC83C4F2C41B1047
2 changed files with 13 additions and 3 deletions

View File

@ -135,14 +135,14 @@ class Authetication:
return dictionary
def loadServerPrivateKey(self) -> RsaKey:
def loadServerPrivateKey(self, passphrase: str) -> RsaKey:
with open(self.CONFIG_FILE_LOCATION) as json_file:
data = json.load(json_file)
key = data['serverPrivateKey']
key = bytes.fromhex(key)
try:
rsaKey = RSA.import_key(key)
rsaKey = RSA.import_key(key, passphrase)
except ValueError:
print('Invalid server private key!')
return rsaKey

View File

@ -107,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)