Update.
This commit is contained in:
parent
7da095f1d2
commit
cda52d8bd1
@ -1,5 +1,6 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import asyncio
|
import asyncio
|
||||||
|
from concurrent.futures import ThreadPoolExecutor as Executor
|
||||||
|
|
||||||
from shadowssh.app import Application
|
from shadowssh.app import Application
|
||||||
|
|
||||||
@ -19,6 +20,12 @@ def parse_args():
|
|||||||
def serve():
|
def serve():
|
||||||
args = parse_args()
|
args = parse_args()
|
||||||
app = Application()
|
app = Application()
|
||||||
|
|
||||||
|
executor = Executor(max_workers=500)
|
||||||
|
|
||||||
|
loop = asyncio.get_event_loop()
|
||||||
|
loop.set_default_executor(executor)
|
||||||
|
|
||||||
asyncio.run(
|
asyncio.run(
|
||||||
app.serve(
|
app.serve(
|
||||||
args.host,
|
args.host,
|
||||||
|
@ -25,7 +25,7 @@ class Application(BaseApplication):
|
|||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
async def connect(self, host, port):
|
async def connect(self, host, port):
|
||||||
log.info(f"Connected to {host}:{port}.")
|
log.info(f"Forwarding to {host}:{port}.")
|
||||||
reader, writer = await asyncio.open_connection(host, port)
|
reader, writer = await asyncio.open_connection(host, port)
|
||||||
return reader, writer
|
return reader, writer
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ class Application(BaseApplication):
|
|||||||
chunk = await reader.read(BUFFER_SIZE)
|
chunk = await reader.read(BUFFER_SIZE)
|
||||||
if not chunk:
|
if not chunk:
|
||||||
writer.close()
|
writer.close()
|
||||||
log.info("Forward connection closed.")
|
log.debug("Forward connection closed.")
|
||||||
return
|
return
|
||||||
writer.write(chunk)
|
writer.write(chunk)
|
||||||
await writer.drain()
|
await writer.drain()
|
||||||
|
Loading…
Reference in New Issue
Block a user