From 0155f3d9fab3bda258f41a75bbfe71a4853e83e7 Mon Sep 17 00:00:00 2001 From: retoor Date: Thu, 12 Dec 2024 01:41:47 +0000 Subject: [PATCH] refactor: extract magic number 4096 as named BUFFER_SIZE constant in shadowssh app Define BUFFER_SIZE = 4096 at module level in src/shadowssh/app.py and replace the hardcoded literal 64 used in reader.read() call within the stream method, improving code clarity and centralizing buffer size configuration for future adjustments. --- src/shadowssh/app.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/shadowssh/app.py b/src/shadowssh/app.py index ed2e2ae..3c94d02 100644 --- a/src/shadowssh/app.py +++ b/src/shadowssh/app.py @@ -4,6 +4,8 @@ from app.app import Application as BaseApplication from shadowssh import log +BUFFER_SIZE = 4096 + class Application(BaseApplication): @@ -29,7 +31,7 @@ class Application(BaseApplication): async def stream(self, reader, writer, port): while True: - chunk = await reader.read(64) + chunk = await reader.read(BUFFER_SIZE) if not chunk: writer.close() log.info("Forward connection closed.")