summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom van der Lee <tom@vanderlee.io>2022-12-14 11:46:54 +0100
committerGravatar Tom van der Lee <tom@vanderlee.io>2022-12-19 13:56:59 +0100
commit2e8654687b48ec912ac603ce313c63867e973549 (patch)
tree8bc015d70d5f927fe0f91a1e682c1a261fd8f35f
parent41ff244abc26517a789b992a74d09f4a852e75ad (diff)
downloadclient-2e8654687b48ec912ac603ce313c63867e973549.tar.gz
client-2e8654687b48ec912ac603ce313c63867e973549.tar.bz2
client-2e8654687b48ec912ac603ce313c63867e973549.zip
Added arguments for headers
-rw-r--r--ttun/__main__.py20
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 @@
1import asyncio 1import asyncio
2import re
3import time
2from argparse import ArgumentDefaultsHelpFormatter 4from argparse import ArgumentDefaultsHelpFormatter
3from argparse import ArgumentParser 5from argparse import ArgumentParser
4from asyncio import FIRST_EXCEPTION 6from asyncio import FIRST_EXCEPTION
5from asyncio.exceptions import CancelledError 7from asyncio.exceptions import CancelledError
6from asyncio.exceptions import TimeoutError 8from asyncio.exceptions import TimeoutError
9from typing import Dict
10from typing import Tuple
7 11
8from ttun.client import Client 12from ttun.client import Client
9from ttun.inspect_server import Server 13from ttun.inspect_server import Server
@@ -13,6 +17,13 @@ from ttun.settings import SERVER_USING_SSL
13inspect_queue = asyncio.Queue() 17inspect_queue = asyncio.Queue()
14 18
15 19
20header_regex = re.compile("(?P<header>\w+)")
21
22
23def header(v) -> Tuple[str, str]:
24 return v
25
26
16def main(): 27def 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(