diff options
| -rw-r--r-- | ttun/__main__.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/ttun/__main__.py b/ttun/__main__.py index 62664a3..49d8b07 100644 --- a/ttun/__main__.py +++ b/ttun/__main__.py | |||
| @@ -1,9 +1,13 @@ | |||
| 1 | import asyncio | 1 | import asyncio |
| 2 | import re | ||
| 3 | import time | ||
| 2 | from argparse import ArgumentDefaultsHelpFormatter | 4 | from argparse import ArgumentDefaultsHelpFormatter |
| 3 | from argparse import ArgumentParser | 5 | from argparse import ArgumentParser |
| 4 | from asyncio import FIRST_EXCEPTION | 6 | from asyncio import FIRST_EXCEPTION |
| 5 | from asyncio.exceptions import CancelledError | 7 | from asyncio.exceptions import CancelledError |
| 6 | from asyncio.exceptions import TimeoutError | 8 | from asyncio.exceptions import TimeoutError |
| 9 | from typing import Dict | ||
| 10 | from typing import Tuple | ||
| 7 | 11 | ||
| 8 | from ttun.client import Client | 12 | from ttun.client import Client |
| 9 | from ttun.inspect_server import Server | 13 | from ttun.inspect_server import Server |
| @@ -13,6 +17,13 @@ from ttun.settings import SERVER_USING_SSL | |||
| 13 | inspect_queue = asyncio.Queue() | 17 | inspect_queue = asyncio.Queue() |
| 14 | 18 | ||
| 15 | 19 | ||
| 20 | header_regex = re.compile("(?P<header>\w+)") | ||
| 21 | |||
| 22 | |||
| 23 | def header(v) -> Tuple[str, str]: | ||
| 24 | return v | ||
| 25 | |||
| 26 | |||
| 16 | def main(): | 27 | def main(): |
| 17 | parser = ArgumentParser(prog="ttun", formatter_class=ArgumentDefaultsHelpFormatter) | 28 | parser = ArgumentParser(prog="ttun", formatter_class=ArgumentDefaultsHelpFormatter) |
| 18 | parser.add_argument("port", help="The local port to expose") | 29 | parser.add_argument("port", help="The local port to expose") |
| @@ -39,6 +50,15 @@ def main(): | |||
| 39 | action="store_true", | 50 | action="store_true", |
| 40 | default=False, | 51 | default=False, |
| 41 | ) | 52 | ) |
| 53 | |||
| 54 | parser.add_argument( | ||
| 55 | "-H", | ||
| 56 | "--header", | ||
| 57 | help='A header to send with each request to the proxied server. Should be in the format of "<header>: <value>" You can add multiple.', | ||
| 58 | action="append", | ||
| 59 | type=header, | ||
| 60 | ) | ||
| 61 | |||
| 42 | args = parser.parse_args() | 62 | args = parser.parse_args() |
| 43 | 63 | ||
| 44 | client = Client( | 64 | client = Client( |
