|
1 | 1 | """Flask app that serves the web GUI for browsing sessions.""" |
2 | 2 |
|
3 | | -__version__ = "0.1.0" |
| 3 | +__version__ = "0.1.0.dev0" |
4 | 4 |
|
5 | 5 | import argparse |
6 | 6 | import os |
|
15 | 15 | from utils.exclusion_rules import resolve_exclusion_rules_path, load_rules |
16 | 16 |
|
17 | 17 |
|
| 18 | +def _normalize_bind_host(host: str) -> str: |
| 19 | + """Lowercase host for checks; strip optional IPv6 brackets (e.g. ``[::1]`` → ``::1``).""" |
| 20 | + h = (host or "").strip().lower() |
| 21 | + if len(h) >= 2 and h.startswith("[") and h.endswith("]"): |
| 22 | + return h[1:-1] |
| 23 | + return h |
| 24 | + |
| 25 | + |
18 | 26 | def is_loopback_host(host: str) -> bool: |
19 | 27 | """True if ``host`` binds only to the local machine (safe with ``--debug``). |
20 | 28 |
|
21 | | - Accepts ``127.0.0.1``, ``localhost``, ``::1``, and other ``127.x.x.x`` addresses. |
| 29 | + Accepts ``127.0.0.1``, ``localhost``, ``::1``, ``[::1]``, and other ``127.x.x.x`` addresses. |
22 | 30 | Rejects all-interfaces forms such as ``0.0.0.0`` and bare ``::`` (not loopback). |
23 | 31 | """ |
24 | | - h = (host or "").strip().lower() |
| 32 | + h = _normalize_bind_host(host) |
25 | 33 | if h in ("127.0.0.1", "localhost", "::1"): |
26 | 34 | return True |
27 | 35 | if h.startswith("127.") and h.count(".") == 3: |
@@ -52,7 +60,7 @@ def validate_startup_cli(args: argparse.Namespace) -> None: |
52 | 60 | if args.debug and not is_loopback_host(args.host): |
53 | 61 | print( |
54 | 62 | "error: --debug is only allowed with a loopback --host " |
55 | | - "(127.0.0.1, localhost, ::1, or 127.x.x.x). " |
| 63 | + "(127.0.0.1, localhost, ::1, [::1], or 127.x.x.x). " |
56 | 64 | "Combining --debug with a network-visible --host exposes the " |
57 | 65 | "Werkzeug debugger and session data to other machines.", |
58 | 66 | file=sys.stderr, |
|
0 commit comments