diff options
| -rw-r--r-- | ttun/__main__.py | 11 | ||||
| -rw-r--r-- | 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(): | |||
| 42 | "--subdomain", | 42 | "--subdomain", |
| 43 | default=None, | 43 | default=None, |
| 44 | help="The subdomain of the ttun tunnel", | 44 | help="The subdomain of the ttun tunnel", |
| 45 | action="append", | ||
| 45 | ) | 46 | ) |
| 46 | parser.add_argument( | 47 | parser.add_argument( |
| 47 | "-t", | 48 | "-t", |
| @@ -68,7 +69,7 @@ def main(): | |||
| 68 | 69 | ||
| 69 | client = Client( | 70 | client = Client( |
| 70 | port=args.port, | 71 | port=args.port, |
| 71 | subdomain=args.subdomain, | 72 | subdomains=args.subdomain, |
| 72 | server=args.server, | 73 | server=args.server, |
| 73 | to=args.to, | 74 | to=args.to, |
| 74 | https=args.https, | 75 | https=args.https, |
| @@ -85,7 +86,13 @@ def main(): | |||
| 85 | 86 | ||
| 86 | def print_info(server: Server): | 87 | def print_info(server: Server): |
| 87 | print("Tunnel created:") | 88 | print("Tunnel created:") |
| 88 | print(f'{client.config["url"]} -> {client.proxy_origin}') | 89 | |
| 90 | if "urls" in client.config: | ||
| 91 | for url in client.config["urls"]: | ||
| 92 | print(f"{url} -> {client.proxy_origin}") | ||
| 93 | else: | ||
| 94 | print(f'{client.config["url"]} -> {client.proxy_origin}') | ||
| 95 | |||
| 89 | print("") | 96 | print("") |
| 90 | print(f"Inspect requests:") | 97 | print(f"Inspect requests:") |
| 91 | print(f"http://localhost:{server.port}") | 98 | 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: | |||
| 46 | self, | 46 | self, |
| 47 | port: int, | 47 | port: int, |
| 48 | server: str, | 48 | server: str, |
| 49 | subdomain: str = None, | 49 | subdomains: List[str] = None, |
| 50 | to: str = "127.0.0.1", | 50 | to: str = "127.0.0.1", |
| 51 | https: bool = False, | 51 | https: bool = False, |
| 52 | headers: List[Tuple[str, str]] = None, | 52 | headers: List[Tuple[str, str]] = None, |
| 53 | ): | 53 | ): |
| 54 | self.version = __version__ | 54 | self.version = __version__ |
| 55 | self.server = server | 55 | self.server = server |
| 56 | self.subdomain = subdomain | 56 | self.subdomains = subdomains |
| 57 | 57 | ||
| 58 | self.config: Optional[Config] = None | 58 | self.config: Optional[Config] = None |
| 59 | self.connection: ClientConnection = None | 59 | self.connection: ClientConnection = None |
| @@ -90,7 +90,13 @@ class Client: | |||
| 90 | async def connect(self) -> ClientConnection: | 90 | async def connect(self) -> ClientConnection: |
| 91 | self.connection = await websockets.connect(f"{self.server}/tunnel/") | 91 | self.connection = await websockets.connect(f"{self.server}/tunnel/") |
| 92 | 92 | ||
| 93 | await self.send({"subdomain": self.subdomain, "version": self.version}) | 93 | await self.send( |
| 94 | { | ||
| 95 | "subdomain": self.subdomains[0] if self.subdomains else None, | ||
| 96 | "subdomains": self.subdomains, | ||
| 97 | "version": self.version, | ||
| 98 | } | ||
| 99 | ) | ||
| 94 | 100 | ||
| 95 | self.config = await self.receive() | 101 | self.config = await self.receive() |
| 96 | 102 | ||
