names are only lowercase

This commit is contained in:
Jonas Weinz 2019-03-22 23:04:32 +01:00
parent 56f4fecdcd
commit 049cb43264
2 changed files with 12 additions and 7 deletions

View File

@ -145,7 +145,7 @@ class ConnectionHandler(object):
return None
elif msg['type'] == 'temp_session':
name = msg['data']['name']
name = msg['data']['name'].lower()
if len(self.session_manager.get_session_by_temp_user(name)) == 0:
if len(self.user_manager.get_user(name)) == 0:
if len(msg['data']['name']) < 16 and ';' not in name and '\'' not in name and '\"' not in name:
@ -188,7 +188,7 @@ class ConnectionHandler(object):
try:
name = msg['data']['name']
name = msg['data']['name'].lower()
pw = msg['data']['pw']
if len(name) <= 16 and len(pw) <= 32 and len(name) > 0 and len(pw) > 0:
@ -320,7 +320,7 @@ class ConnectionHandler(object):
)
else:
opponent = data['player']
opponent = data['player'].lower()
if opponent == conn.user_name:
await conn.websocket.send(
json.dumps(

13
main.py
View File

@ -64,11 +64,16 @@ async def socket_worker(websocket, path):
id = "unknown_user"
print("close connection to user: " + id)
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
ssl_context.load_cert_chain(cert_file, keyfile=key_file)
if cert_file is not None and key_file is not None:
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
ssl_context.load_cert_chain(cert_file, keyfile=key_file)
start_server = websockets.serve(
socket_worker, host='', port=server_port, ssl=ssl_context)
start_server = websockets.serve(
socket_worker, host='', port=server_port, ssl=ssl_context)
else:
start_server = websockets.serve(
socket_worker, host='', port=server_port)
asyncio.get_event_loop().run_until_complete(start_server)
asyncio.get_event_loop().run_forever()