28 lines
712 B
Python
28 lines
712 B
Python
# x-run: cd .. && python -m bta_proxy '201:4f8c:4ea:0:71ec:6d7:6f1b:a4f9'
|
|
import asyncio
|
|
from argparse import ArgumentParser
|
|
from sys import argv
|
|
|
|
from bta_proxy.proxy import BTAProxy
|
|
|
|
MAX_SIZE = 0x400000
|
|
|
|
|
|
|
|
async def main(args: list[str]):
|
|
loop = asyncio.get_running_loop()
|
|
port: int = 25565
|
|
if len(args) >= 2:
|
|
port = int(args[1])
|
|
server = await asyncio.start_server(BTAProxy(args[0], port, loop).handle_client, "localhost", 25565)
|
|
|
|
print("listening on", str.join(", ", [str(s.getsockname()) for s in server.sockets]))
|
|
print("forwarding to", args[0], port)
|
|
|
|
async with server:
|
|
await server.serve_forever()
|
|
|
|
|
|
if __name__ == '__main__':
|
|
asyncio.run(main(argv[1:]))
|