diff --git a/rest_api/admin.py b/rest_api/admin.py index 6da89b6..3dca416 100644 --- a/rest_api/admin.py +++ b/rest_api/admin.py @@ -710,7 +710,7 @@ async def ban_user(username, data: UpdateUserBanBody): data.state == "temp_ban" and data.expires > time.time() ): for client in app.cl.usernames.get(username, []): - client.kick() + await client.websocket.close() else: app.cl.send_event("update_config", {"ban": data.model_dump()}, usernames=[username]) @@ -1217,7 +1217,7 @@ async def create_netblock(cidr, data: NetblockBody): if data.type == 0: for client in copy(app.cl.clients): if blocked_ips.search_best(client.ip): - client.kick() + await client.websocket.close() # Add log security.add_audit_log( @@ -1319,7 +1319,7 @@ async def kick_all_clients(): # Kick all clients for client in copy(app.cl.clients): - client.kick() + await client.websocket.close() # Add log security.add_audit_log("kicked_all", request.user, request.ip, {}) @@ -1341,7 +1341,7 @@ async def enable_repair_mode(): # Kick all clients for client in copy(app.cl.clients): - client.kick() + await client.websocket.close() # Add log security.add_audit_log("enabled_repair_mode", request.user, request.ip, {}) diff --git a/supporter.py b/supporter.py index 9dacc86..d79d713 100644 --- a/supporter.py +++ b/supporter.py @@ -1,6 +1,6 @@ from threading import Thread from typing import Optional, Iterable, Any -import uuid, time, msgpack, pymongo, re, copy +import uuid, time, msgpack, pymongo, re, copy, asyncio from cloudlink import CloudlinkServer from database import db, rdb @@ -134,7 +134,7 @@ def listen_for_admin_pubsub(self): for c in self.cl.usernames.get(msg["user"], []): if "sid" in msg and msg["sid"] != c.acc_session_id: continue - c.kick() + asyncio.run(c.kick()) case "alert_user": self.create_post("inbox", msg["user"], msg["content"]) case "ban_user": @@ -168,7 +168,7 @@ def listen_for_admin_pubsub(self): # Logout user (can't kick because of async stuff) for c in self.cl.usernames.get(username, []): - c.kick() + asyncio.run(c.kick()) except: continue