Compare commits

..
3 Commits
Author SHA1 Message Date
retoor 415c16b4ef Formatting. 2024-12-08 10:34:11 +01:00
retoor 0dffc6bdd8 Initial commit. 2024-12-08 10:32:43 +01:00
retoor 5d3d6a0247 Initial commit 2024-12-08 08:45:33 +00:00
2 changed files with 4 additions and 13 deletions
+1 -8
View File
@@ -1,6 +1,5 @@
import argparse
import asyncio
from concurrent.futures import ThreadPoolExecutor as Executor
from shadowssh.app import Application
@@ -13,19 +12,13 @@ def parse_args():
parser.add_argument("--host-service", type=str, required=False, default="127.0.0.1")
parser.add_argument("--port-service", type=int, required=False, default=4433)
parser.add_argument("--host-ssh", type=str, required=False, default="127.0.0.1")
parser.add_argument("--port-ssh", type=int, required=False, default=222)
parser.add_argument("--port-ssh", type=int, required=False, default=22)
return parser.parse_args()
def serve():
args = parse_args()
app = Application()
executor = Executor(max_workers=500)
loop = asyncio.get_event_loop()
loop.set_default_executor(executor)
asyncio.run(
app.serve(
args.host,
+3 -5
View File
@@ -4,8 +4,6 @@ from app.app import Application as BaseApplication
from shadowssh import log
BUFFER_SIZE = 4096
class Application(BaseApplication):
@@ -25,16 +23,16 @@ class Application(BaseApplication):
super().__init__(*args, **kwargs)
async def connect(self, host, port):
log.info(f"Forwarding to {host}:{port}.")
log.info(f"Connected to {host}:{port}.")
reader, writer = await asyncio.open_connection(host, port)
return reader, writer
async def stream(self, reader, writer, port):
while True:
chunk = await reader.read(BUFFER_SIZE)
chunk = await reader.read(4096)
if not chunk:
writer.close()
log.debug("Forward connection closed.")
log.info("Forward connection closed.")
return
writer.write(chunk)
await writer.drain()