From 2e8654687b48ec912ac603ce313c63867e973549 Mon Sep 17 00:00:00 2001 From: Tom van der Lee Date: Wed, 14 Dec 2022 11:46:54 +0100 Subject: Added arguments for headers --- ttun/__main__.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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 @@ import asyncio +import re +import time from argparse import ArgumentDefaultsHelpFormatter from argparse import ArgumentParser from asyncio import FIRST_EXCEPTION from asyncio.exceptions import CancelledError from asyncio.exceptions import TimeoutError +from typing import Dict +from typing import Tuple from ttun.client import Client from ttun.inspect_server import Server @@ -13,6 +17,13 @@ from ttun.settings import SERVER_USING_SSL inspect_queue = asyncio.Queue() +header_regex = re.compile("(?P
\w+)") + + +def header(v) -> Tuple[str, str]: + return v + + def main(): parser = ArgumentParser(prog="ttun", formatter_class=ArgumentDefaultsHelpFormatter) parser.add_argument("port", help="The local port to expose") @@ -39,6 +50,15 @@ def main(): action="store_true", default=False, ) + + parser.add_argument( + "-H", + "--header", + help='A header to send with each request to the proxied server. Should be in the format of "
: " You can add multiple.', + action="append", + type=header, + ) + args = parser.parse_args() client = Client( -- cgit v1.2.3