Merge branch 'master' of https://git.kmlabz.com/BiztProtoBois/client into master
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
commit
48fd34117d
@ -56,13 +56,13 @@ def printCommand():
|
|||||||
' List content of current directory -> LST \n' +
|
' List content of current directory -> LST \n' +
|
||||||
' Upload file to current directory -> UPL <filename> \n' +
|
' Upload file to current directory -> UPL <filename> \n' +
|
||||||
' Download file from current directory -> DNL <filename> \n' +
|
' Download file from current directory -> DNL <filename> \n' +
|
||||||
' Login -> LIN <username> \n' +
|
' Login -> LIN <username> <password> \n' +
|
||||||
' Logout -> LOUT \n')
|
' Logout -> LOUT \n')
|
||||||
|
|
||||||
|
|
||||||
def printCommandsWihtoutLogin():
|
def printCommandsWihtoutLogin():
|
||||||
print('\nYou must log in before issuing other commads!\n',
|
print('\nYou must log in before issuing other commads!\n',
|
||||||
' Login -> LIN <username> \n',
|
' Login -> LIN <username> <password> \n',
|
||||||
' Exit -> EXIT\n')
|
' Exit -> EXIT\n')
|
||||||
|
|
||||||
|
|
||||||
@ -89,6 +89,7 @@ if not os.path.isfile(CONFIG_LOCATION) or os.stat(CONFIG_LOCATION).st_size == 0:
|
|||||||
SERVER_PUBLIC_KEY = loadPublicKey()
|
SERVER_PUBLIC_KEY = loadPublicKey()
|
||||||
CLIENT_PRIVATE_KEY = loadPrivateKey(PASSPHRASE)
|
CLIENT_PRIVATE_KEY = loadPrivateKey(PASSPHRASE)
|
||||||
CLIENT_ADDRESS = loadAddress()
|
CLIENT_ADDRESS = loadAddress()
|
||||||
|
LOGGED_IN = False
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
command = input("Type a command:")
|
command = input("Type a command:")
|
||||||
@ -99,15 +100,25 @@ while True:
|
|||||||
print("Invalid command format!")
|
print("Invalid command format!")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if separatedCommand[0] == 'LIN' and len(separatedCommand) == 2:
|
if not LOGGED_IN:
|
||||||
|
if separatedCommand[0] == 'LIN' and len(separatedCommand) == 3:
|
||||||
network = NetWrapper(CLIENT_PRIVATE_KEY, CLIENT_ADDRESS, separatedCommand[1], SERVER_PUBLIC_KEY)
|
network = NetWrapper(CLIENT_PRIVATE_KEY, CLIENT_ADDRESS, separatedCommand[1], SERVER_PUBLIC_KEY)
|
||||||
try:
|
try:
|
||||||
network.connectToServer(separatedCommand[2])
|
network.connectToServer(separatedCommand[2])
|
||||||
|
response = network.recieveMessage().decode('UTF-8')
|
||||||
|
print(response)
|
||||||
|
if response == 'OK':
|
||||||
|
LOGGED_IN = True
|
||||||
|
else:
|
||||||
|
LOGGED_IN = False
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Error: "+str(e))
|
print("Error: "+str(e))
|
||||||
|
LOGGED_IN = False
|
||||||
continue
|
continue
|
||||||
LOGGED_IN = True
|
|
||||||
continue
|
continue
|
||||||
|
else:
|
||||||
|
print('You are already logged in!')
|
||||||
|
|
||||||
|
|
||||||
if separatedCommand[0] == 'EXIT':
|
if separatedCommand[0] == 'EXIT':
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
@ -181,3 +192,4 @@ while True:
|
|||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('Error: ' + str(e))
|
print('Error: ' + str(e))
|
||||||
|
continue
|
||||||
|
Loading…
Reference in New Issue
Block a user