refactor: extract magic number 4096 as named BUFFER_SIZE constant

Replace the hardcoded buffer size literal 4096 with a named constant BUFFER_SIZE
to improve code readability and maintainability. The constant is defined at the
module level and used in all buffer allocation sites.
This commit is contained in:
retoor 2024-12-12 01:41:47 +00:00
parent db228856f9
commit c1a1d043d5

View File

@ -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.")