Minor updates..

This commit is contained in:
Maxim Khomutov 2023-07-23 23:06:29 +03:00
parent 2368fec501
commit 43fd56f327
3 changed files with 17 additions and 15 deletions

View File

@ -112,7 +112,7 @@ class Client:
if not reason: if not reason:
reason = "Kicked!" reason = "Kicked!"
else: else:
reason = f"{reason!r}" reason = f"{reason}"
if not self.__alive: if not self.__alive:
self.log.debug(f"{self.nick}.kick('{reason}') skipped: Not alive;") self.log.debug(f"{self.nick}.kick('{reason}') skipped: Not alive;")
return return

View File

@ -157,7 +157,6 @@ class Core:
"version": self.BeamMP_version, "clientversion": self.client_major_version, "version": self.BeamMP_version, "clientversion": self.client_major_version,
"name": config.Server["name"], "modlist": modlist, "modstotalsize": modstotalsize, "name": config.Server["name"], "modlist": modlist, "modstotalsize": modstotalsize,
"modstotal": modstotal, "playerslist": "", "desc": config.Server['description'], "pass": False} "modstotal": modstotal, "playerslist": "", "desc": config.Server['description'], "pass": False}
self.log.debug(f"Auth: data {data}")
# Sentry? # Sentry?
ok = False ok = False
@ -169,7 +168,6 @@ class Core:
async with session.post(url, data=data, headers={"api-v": "2"}) as response: async with session.post(url, data=data, headers={"api-v": "2"}) as response:
code = response.status code = response.status
body = await response.json() body = await response.json()
self.log.debug(f"Auth: code {code}, body {body}")
ok = True ok = True
break break
except Exception as e: except Exception as e:
@ -183,19 +181,22 @@ class Core:
self.log.error("Missing/invalid json members in backend response") self.log.error("Missing/invalid json members in backend response")
raise KeyboardInterrupt raise KeyboardInterrupt
if test: status = body.get("status")
status = body.get("status") msg = body.get("msg")
msg = body.get("msg") if status == "2000":
if status == "2000": if test:
# TODO: i18n # TODO: i18n
self.log.info(f"Authenticated! {msg}") self.log.info(f"Authenticated! {msg}")
elif status == "200": elif status == "200":
if test:
self.log.info(f"Resumed authenticated session. {msg}") self.log.info(f"Resumed authenticated session. {msg}")
else: else:
self.log.error(f"Backend REFUSED the auth key. Reason: " self.log.debug(f"Auth: data {data}")
f"{msg or 'Backend did not provide a reason'}") self.log.debug(f"Auth: code {code}, body {body}")
self.log.info(f"Server still runnig, but only in Direct connect mode.") self.log.error(f"Backend REFUSED the auth key. Reason: "
self.direct = True f"{msg or 'Backend did not provide a reason'}")
self.log.info(f"Server still runnig, but only in Direct connect mode.")
self.direct = True
else: else:
self.direct = True self.direct = True
if test: if test:

View File

@ -23,8 +23,9 @@ class UDPServer(asyncio.DatagramTransport):
self.port = port self.port = port
self.run = False self.run = False
def connection_made(self, transport): def connection_made(self, *args, **kwargs): ...
... def pause_writing(self, *args, **kwargs): ...
def resume_writing(self, *args, **kwargs): ...
async def handle_datagram(self, data, addr): async def handle_datagram(self, data, addr):
try: try: