From 5f32db609e618bebd568d48d151a80d865e55859 Mon Sep 17 00:00:00 2001 From: Tom van der Lee Date: Wed, 10 Jun 2026 08:36:16 +0200 Subject: Added support for passing multiple subdomains within one session --- ttun/__main__.py | 11 +++++++++-- ttun/client.py | 12 +++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/ttun/__main__.py b/ttun/__main__.py index dd83e53..8d77480 100644 --- a/ttun/__main__.py +++ b/ttun/__main__.py @@ -42,6 +42,7 @@ def main(): "--subdomain", default=None, help="The subdomain of the ttun tunnel", + action="append", ) parser.add_argument( "-t", @@ -68,7 +69,7 @@ def main(): client = Client( port=args.port, - subdomain=args.subdomain, + subdomains=args.subdomain, server=args.server, to=args.to, https=args.https, @@ -85,7 +86,13 @@ def main(): def print_info(server: Server): print("Tunnel created:") - print(f'{client.config["url"]} -> {client.proxy_origin}') + + if "urls" in client.config: + for url in client.config["urls"]: + print(f"{url} -> {client.proxy_origin}") + else: + print(f'{client.config["url"]} -> {client.proxy_origin}') + print("") print(f"Inspect requests:") print(f"http://localhost:{server.port}") diff --git a/ttun/client.py b/ttun/client.py index 0cc5012..6aed814 100644 --- a/ttun/client.py +++ b/ttun/client.py @@ -46,14 +46,14 @@ class Client: self, port: int, server: str, - subdomain: str = None, + subdomains: List[str] = None, to: str = "127.0.0.1", https: bool = False, headers: List[Tuple[str, str]] = None, ): self.version = __version__ self.server = server - self.subdomain = subdomain + self.subdomains = subdomains self.config: Optional[Config] = None self.connection: ClientConnection = None @@ -90,7 +90,13 @@ class Client: async def connect(self) -> ClientConnection: self.connection = await websockets.connect(f"{self.server}/tunnel/") - await self.send({"subdomain": self.subdomain, "version": self.version}) + await self.send( + { + "subdomain": self.subdomains[0] if self.subdomains else None, + "subdomains": self.subdomains, + "version": self.version, + } + ) self.config = await self.receive() -- cgit v1.2.3