Skip to content

Commit

Permalink
fix: kill ghost clients when they're afk
Browse files Browse the repository at this point in the history
  • Loading branch information
jeenyuhs committed Jul 9, 2024
1 parent a138255 commit b80a074
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
5 changes: 3 additions & 2 deletions events/bancho.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,11 @@ async def login(req: Request) -> Response:
services.bcrypt_cache[user_password] = password_md5

if target := services.players.get(user_info["username"]):
# user is already online? sus
timeago_format = datetime.fromtimestamp(target.last_update)
return failed_login(
LoginResponse.INCORRECT_LOGIN,
msg=f"A user tried to sign in to {target!r} which is already online. ",
msg=f"A user tried to sign in to {target!r} which is already online. "
f"(last session update was {timeago.format(timeago_format)}))",
extra=writer.notification(ALREADY_ONLINE),
)

Expand Down
8 changes: 2 additions & 6 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,12 @@ def decorator(cb: Callable) -> None:
return decorator


@register_task(delay=1)
@register_task(delay=5)
async def removed_expired_tokens() -> None:
for player in services.players:
# doesn't look like afk players get the afk thingy thing thing
# ^^^ bro what?
if (
time.time() - player.last_update >= TOKEN_EXPIRATION
and not player.bot
and player.status != ActionStatus.AFK
):
if time.time() - player.last_update >= TOKEN_EXPIRATION and not player.bot:
await player.logout()
services.logger.info(
f"{player.username} has been logged out, due to loss of connection."
Expand Down

0 comments on commit b80a074

Please sign in to comment.