diff --git a/.env.example b/.env.example index 7430307..0491eef 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,4 @@ PROXY=http://nathanwoodburn:5000/ TLD=woodburn -RESTRICTED=["admin"] \ No newline at end of file +RESTRICTED=["admin"] +REPLACE=["https://nathan.woodburn.au/"] \ No newline at end of file diff --git a/README.md b/README.md index 764d037..6987a79 100644 --- a/README.md +++ b/README.md @@ -4,4 +4,4 @@ Environment variables: - `PROXY` - The proxy to use for restricted TLDs. Example: `http://localhost:3128` - `TLD` - The TLD to restrict. Example: `g` - `RESTRICTED` - List of restricted paths. Example: `["path1", "path2"]` will require the user to have a .g domain to access `path1/*`, `path2/*` - +- `REPLACE` - List of urls to replace with the host to fix redirects and links \ No newline at end of file diff --git a/main.py b/main.py index 4c12cf6..23dc15f 100644 --- a/main.py +++ b/main.py @@ -14,6 +14,8 @@ RESTRICTED = os.getenv('RESTRICTED') RESTRICTED = json.loads(RESTRICTED) RESTRICTED = [f'{i.lower()}/' for i in RESTRICTED] TLD = os.getenv('TLD') +REPLACEMENT = os.getenv('REPLACE') +REPLACEMENT = json.loads(REPLACEMENT) # Load cookies cookies = [] @@ -118,6 +120,8 @@ def catch_all(path): if 'text/html' in res.headers['Content-Type']: content = res.content.decode('utf-8') content = content.replace(URL, request.host_url) + for i in REPLACEMENT: + content = content.replace(i, request.host_url) response = make_response(content, res.status_code, headers) return response