Merge dev into main #22

Merged
jimmy merged 5 commits from dev into main 2026-03-06 08:54:33 +08:00
Showing only changes of commit da88513456 - Show all commits
+1 -10
View File
@@ -10,7 +10,6 @@ import config
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
MAX_SESSIONS = 5 MAX_SESSIONS = 5
IDLE_TIMEOUT = 30 * 60 # 30 minutes
_active_sessions: set = set() _active_sessions: set = set()
HOSTS = { HOSTS = {
@@ -95,18 +94,10 @@ async def ws_endpoint(websocket: WebSocket, host: str = Query("nas")):
pass pass
read_task = asyncio.create_task(read_ssh()) read_task = asyncio.create_task(read_ssh())
last_activity = time.monotonic()
try: try:
while True: while True:
try: msg = await websocket.receive()
msg = await asyncio.wait_for(websocket.receive(), timeout=60)
except asyncio.TimeoutError:
if time.monotonic() - last_activity > IDLE_TIMEOUT:
await websocket.close(code=1000, reason="Idle timeout")
break
continue
last_activity = time.monotonic()
if "bytes" in msg and msg["bytes"]: if "bytes" in msg and msg["bytes"]:
data = msg["bytes"] data = msg["bytes"]
if data[0:1] == b"\x01" and len(data) == 5: if data[0:1] == b"\x01" and len(data) == 5: