Listen on loopback and tailnet by default; make the plain-HTTP LAN opt-in

The web proxy binds the wildcard and drops connections that are not
loopback or Tailscale at both ends. A LAN listener is opt-in (web.lan) and
refuses sign-in and signed-in pages over plain HTTP unless
web.lan_plain_login is set. Existing installs keep their bind address with
a warning. Without the LAN the mDNS advert carries only the tailnet and
public routes (lan=0).
This commit is contained in:
2026-11-10 01:02:02 +00:00
parent a706739088
commit ad6cdab418
18 changed files with 677 additions and 35 deletions
+18 -4
View File
@@ -46,10 +46,24 @@ def mdns_args(config):
"""
web = config.get("web") or {}
if web.get("port") and web.get("host") not in (None, "", "127.0.0.1", "localhost", "::1"):
return ["-mdns-port", str(web["port"])]
# Loopback + tailnet: the advert carries only the tailnet/public routes.
lan = web.get("host") != "tailnet" or web.get("lan") is True
return ["-mdns-port", str(web["port"])] + ([] if lan else ["-mdns-lan=false"])
return []
def web_listen_args(web):
"""The proxy's bind and access flags. "tailnet" (the installer default)
binds the wildcard and admits only loopback and tailnet connections, plus
the LAN when web.lan is set; sign-in over plain-HTTP LAN additionally needs
web.lan_plain_login. A literal address is bound as before, unfiltered."""
if web.get("host") != "tailnet":
return ["--host", web["host"]]
lan = web.get("lan") is True
return (["--host", "::", "--allow", "loopback,tailnet" + (",lan" if lan else "")]
+ (["--lan-plain-login"] if lan and web.get("lan_plain_login") is True else []))
def load(prefix):
prefix = Path(prefix).expanduser().resolve()
path = prefix / MARKER
@@ -218,7 +232,7 @@ def start(config):
wait_health(f"http://127.0.0.1:{config['server_port']}/healthz", timeout=75)
if config.get("web"):
web = config["web"]
host = "127.0.0.1" if web["host"] == "0.0.0.0" else web["host"]
host = "127.0.0.1" if web["host"] in ("0.0.0.0", "tailnet") else web["host"]
end = time.monotonic() + 20
while True:
try:
@@ -319,7 +333,7 @@ def report(config):
if web:
public = (config.get("opencode_env") or {}).get("PIPELINES_WEB_PUBLIC_URL")
print("== Access")
address = public or f"http://{web['host']}:{web['port']}"
address = public or f"http://{'127.0.0.1' if web['host'] == 'tailnet' else web['host']}:{web['port']}"
print(f" {'Web':<10} {address} (password in {web['auth_file']})")
root = Path(web["root"]) if web.get("root") else None
built = root is not None and (root / "index.html").is_file()
@@ -431,7 +445,7 @@ def supervise(config):
with (root / "logs/web.log").open("a") as web_log:
web_child = subprocess.Popen(
[web["node"], web["script"], "--port", str(web["port"]),
"--host", web["host"], "--pipelines", f"127.0.0.1:{config['server_port']}",
*web_listen_args(web), "--pipelines", f"127.0.0.1:{config['server_port']}",
*(["--root", web["root"]] if web.get("root") else []),
*(["--updates", web["updates"]] if web.get("updates") else [])],
env=web_env, stdout=web_log, stderr=web_log)