Server address
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
DESKTOP-DPA61F8\Benedek 2021-04-26 23:35:00 +02:00
parent 48fd34117d
commit 57af60ee07

View File

@ -11,6 +11,8 @@ from netwrapper import NetWrapper
ABSOLUTE_PATH = os.path.abspath(os.path.dirname(sys.argv[0]))
DOWNLOAD_LOCATION = ABSOLUTE_PATH + os.path.sep + 'download' + os.path.sep
CONFIG_LOCATION = ABSOLUTE_PATH + os.path.sep + 'config' + os.path.sep + 'config.txt'
PASSPHRASE = ''
SERVER_ADDRESS = ''
LOGGED_IN = False
@ -67,7 +69,7 @@ def printCommandsWihtoutLogin():
try:
opts, args = getopt.getopt(sys.argv[1:], 'hp:')
opts, args = getopt.getopt(sys.argv[1:], 'hp:s:')
except getopt.GetoptError:
print('Error: Unknown option detected.')
sys.exit(1)
@ -76,10 +78,13 @@ for opt, arg in opts:
if opt in '-p':
PASSPHRASE = arg
if opt in '-s':
SERVER_ADDRESS = arg
if PASSPHRASE == '':
print('Key required to start client!')
print('Usage:')
print(' client.py -p <passphrase>')
print(' client.py -p <passphrase> -s <server_address>')
sys.exit(1)
if not os.path.isfile(CONFIG_LOCATION) or os.stat(CONFIG_LOCATION).st_size == 0:
@ -91,6 +96,8 @@ CLIENT_PRIVATE_KEY = loadPrivateKey(PASSPHRASE)
CLIENT_ADDRESS = loadAddress()
LOGGED_IN = False
network = NetWrapper(CLIENT_PRIVATE_KEY, CLIENT_ADDRESS, SERVER_PUBLIC_KEY, serverAddr=SERVER_ADDRESS)
while True:
command = input("Type a command:")
separatedCommand = command.split(" ")
@ -102,7 +109,7 @@ while True:
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.username = separatedCommand[1]
try:
network.connectToServer(separatedCommand[2])
response = network.recieveMessage().decode('UTF-8')