gates / gates (push) Successful in 2m27s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
41 lines
2.9 KiB
Python
41 lines
2.9 KiB
Python
import sys, time, json, secrets
|
|
sys.path.insert(0, "/mnt/5_hdd/felhom.eu/git/app-catalog-felhom.eu/scripts")
|
|
import box_walk as w
|
|
APP, SUB = "vikunja", "tasks"; H = f"{SUB}.{w.DOMAIN}"
|
|
EVF = open(f"{w.EV}/vikunja.txt", "a", buffering=1)
|
|
def say(*a):
|
|
w.say(*a); EVF.write(" ".join(map(str, a)) + "\n")
|
|
def tun(v, f, body):
|
|
q = lambda s: "'" + s.replace("'", "'\\''") + "'"
|
|
return w.guest(f"docker run --rm --network felhom-tunnel --ip 172.16.253.2 -v /root/tun.sh:/t.sh:ro curlimages/curl:8.11.1 "
|
|
f"sh /t.sh {H} {v} {f} POST /api/v1/login {q(body)} application/json").strip().splitlines()[-1]
|
|
pw = "Drill-" + secrets.token_hex(10)
|
|
open(f"{w.SC}/.vkpw", "w").write(pw)
|
|
def rounds(label):
|
|
say(f"## {label} — {time.strftime('%FT%TZ', time.gmtime())}")
|
|
bad = json.dumps({"username": "household", "password": "wrong"})
|
|
r = [tun("198.51.100.66", f"10.5.0.{i}", bad) for i in range(1, 15)]
|
|
say(" stranger 198.51.100.66, 14 wrong logins, a new forged leftmost each:", r)
|
|
good = json.dumps({"username": "household", "password": pw})
|
|
say(" household 203.0.113.10, the right password, at once:", tun("203.0.113.10", "203.0.113.10", good))
|
|
w.login()
|
|
say(f"##### vikunja on 9202 — controller {w.guest('docker inspect felhom-controller --format {{.Config.Image}}').strip()}")
|
|
say("deploy ->", w.deploy(APP, SUB))
|
|
w.wait_app(SUB, "/api/v1/info", tries=40)
|
|
rc, code, body = w.app_curl(SUB, "/api/v1/register", "-H", "Content-Type: application/json", method="POST",
|
|
data=json.dumps({"username": "household", "email": "household@example.com", "password": pw}))
|
|
say("register the household's account (before the gate opens) ->", code)
|
|
c, d = w.ctl("POST", f"/apps/{APP}/setup-gate/open", {}); say("setup-gate/open ->", c)
|
|
time.sleep(20); w.wait_app(SUB, "/api/v1/info", tries=40)
|
|
say("env:", w.guest("docker exec vikunja printenv VIKUNJA_SERVICE_IPEXTRACTIONMETHOD").strip())
|
|
rounds("WITH the fix (VIKUNJA_SERVICE_IPEXTRACTIONMETHOD=xff)")
|
|
D = "/opt/docker/stacks/vikunja"
|
|
say("## CONTROL: the line removed from the stack's compose, restart through the product", w.guest(f"cp -p {D}/docker-compose.yml /root/vk.with; sed -i '/IPEXTRACTIONMETHOD/d' {D}/docker-compose.yml; grep -c IPEXTRACTION {D}/docker-compose.yml").strip())
|
|
say(" waiting 70 s for the minute window"); time.sleep(70)
|
|
c, d = w.ctl("POST", f"/api/stacks/{APP}/restart"); say(" restart ->", c); time.sleep(10); w.wait_app(SUB, "/api/v1/info", tries=40)
|
|
say(" env:", w.guest("docker exec vikunja printenv VIKUNJA_SERVICE_IPEXTRACTIONMETHOD || echo '(unset)'").strip())
|
|
rounds("CONTROL — the template before R-776 (direct)")
|
|
say("## put the template's compose back:", w.guest(f"cp -p /root/vk.with {D}/docker-compose.yml; grep -c IPEXTRACTION {D}/docker-compose.yml").strip())
|
|
c, d = w.ctl("POST", f"/api/stacks/{APP}/restart"); say(" restart ->", c); time.sleep(10)
|
|
say(" env back:", w.guest("docker exec vikunja printenv VIKUNJA_SERVICE_IPEXTRACTIONMETHOD").strip())
|