from pathlib import Path
path = Path("/etc/caddy/Caddyfile")
text = path.read_text()
old = "deepseek-80.tap365.org {\n    reverse_proxy localhost:48090\n}\n"
new = "deepseek-80.tap365.org {\n    reverse_proxy 127.0.0.1:48091\n}\n"
if old not in text:
    raise SystemExit("target block not found or already changed")
if text.count(old) != 1:
    raise SystemExit(f"target block count not 1: {text.count(old)}")
path.write_text(text.replace(old, new))
