allowed ips load

This commit is contained in:
√(noham)² 2024-07-27 22:17:54 +02:00
parent 21ed85c304
commit a258f92208
3 changed files with 6 additions and 1 deletions

1
.allowed.example Normal file
View File

@ -0,0 +1 @@
{"ALLOWED_IPS": ["127.0.0.1"]}

1
.gitignore vendored
View File

@ -1 +1,2 @@
.venv .venv
.allowed

View File

@ -15,12 +15,15 @@ from textwrap import indent
from traceback import format_exc from traceback import format_exc
import h11 import h11
import trio import trio
import json
DEFAULT_PORT = 8080 DEFAULT_PORT = 8080
PORT = int(getenv('PORT', DEFAULT_PORT)) PORT = int(getenv('PORT', DEFAULT_PORT))
# List of allowed IP addresses # 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='') prn = partial(print, end='')
indented = partial(indent, prefix=' ') indented = partial(indent, prefix=' ')