diff --git a/.allowed.example b/.allowed.example new file mode 100644 index 0000000..5fb1a2d --- /dev/null +++ b/.allowed.example @@ -0,0 +1 @@ +{"ALLOWED_IPS": ["127.0.0.1"]} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 1d17dae..895cc8d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .venv +.allowed diff --git a/trio_http_proxy.py b/trio_http_proxy.py index 732f6c2..816636a 100755 --- a/trio_http_proxy.py +++ b/trio_http_proxy.py @@ -15,12 +15,15 @@ from textwrap import indent from traceback import format_exc import h11 import trio +import json DEFAULT_PORT = 8080 PORT = int(getenv('PORT', DEFAULT_PORT)) # List of allowed IP addresses -ALLOWED_IPS = ['127.0.0.1', '82.66.241.83', '136.243.50.102', '178.254.72.180'] + [f'192.168.1.{i}' for i in range(1, 254)] +with open('.allowed') as f: + ALLOWED_IPS = json.load(f)['ALLOWED_IPS'] +ALLOWED_IPS = ALLOWED_IPS + [f'192.168.1.{i}' for i in range(1, 254)] prn = partial(print, end='') indented = partial(indent, prefix=' ')