diff --git a/vps/owrt-remote-hub.py b/vps/owrt-remote-hub.py index 9896293..243cf66 100644 --- a/vps/owrt-remote-hub.py +++ b/vps/owrt-remote-hub.py @@ -699,6 +699,23 @@ def current_router_cookie(router_id): return f"{ROUTER_COOKIE}={urllib.parse.quote(router_id)}; HttpOnly; SameSite=Lax; Path=/" +def strip_access_prefix(path, router_id): + prefix = f"/access/{urllib.parse.quote(router_id)}" + if path == prefix: + return "/" + if path.startswith(prefix + "/"): + return path[len(prefix):] or "/" + return path or "/" + + +def rewrite_forward_url(value, router_id, port): + if not value: + return value + parsed = urllib.parse.urlsplit(value) + path = strip_access_prefix(parsed.path, router_id) + return urllib.parse.urlunsplit(("http", f"127.0.0.1:{port}", path, parsed.query, parsed.fragment)) + + def ws_accept_value(key): raw = hashlib.sha1((key + WS_GUID).encode("ascii")).digest() return base64.b64encode(raw).decode("ascii") @@ -1163,37 +1180,46 @@ def ssh_terminal_html(row): :root{{color-scheme:dark;--bg:#07040f;--panel:rgba(19,14,32,.92);--text:#f7f2ff;--muted:#b9adc9;--line:rgba(169,126,255,.28);--green:#22c55e;--blue:#7c3aed;--red:#fb7185;--grid:rgba(168,85,247,.13)}} *{{box-sizing:border-box}} body{{min-height:100vh;margin:0;background-color:var(--bg);background-image:radial-gradient(circle at 16% 10%,rgba(168,85,247,.45),transparent 30%),radial-gradient(circle at 88% 16%,rgba(59,130,246,.28),transparent 32%),linear-gradient(145deg,#07040f,#120a24 48%,#05030a),repeating-linear-gradient(0deg,transparent 0 30px,var(--grid) 31px),repeating-linear-gradient(90deg,transparent 0 30px,var(--grid) 31px);background-attachment:fixed;color:var(--text);font:14px/1.45 system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;padding:18px}} -.wrap{{max-width:1180px;margin:0 auto}} -.top{{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:12px}} -h1{{margin:0;font-size:24px;line-height:1.15}}.muted{{color:var(--muted)}} -.badge,.btn{{display:inline-flex;align-items:center;justify-content:center;gap:8px;border:1px solid var(--line);border-radius:999px;padding:8px 13px;background:rgba(255,255,255,.08);color:#f3e8ff;text-decoration:none;font-weight:850}} +.wrap{{height:calc(100vh - 20px);max-width:1280px;margin:0 auto;display:flex;flex-direction:column;gap:8px}} +.top{{display:flex;align-items:center;justify-content:space-between;gap:10px;min-height:42px}} +h1{{margin:0;font-size:18px;line-height:1.15}}.muted{{color:var(--muted)}}.chips{{display:flex;align-items:center;gap:8px;flex-wrap:wrap}}.chip{{border:1px solid var(--line);border-radius:999px;padding:6px 10px;background:rgba(255,255,255,.07);color:var(--muted);font-size:12px;font-weight:800}} +.badge,.btn{{display:inline-flex;align-items:center;justify-content:center;gap:8px;border:1px solid var(--line);border-radius:999px;padding:7px 12px;background:rgba(255,255,255,.08);color:#f3e8ff;text-decoration:none;font-weight:850;font-size:13px}} .dot{{width:8px;height:8px;border-radius:50%;background:var(--green);box-shadow:0 0 13px var(--green)}} -.termBox{{border:1px solid var(--line);border-radius:8px;background:linear-gradient(180deg,rgba(255,255,255,.08),rgba(255,255,255,.045)),var(--panel);box-shadow:0 22px 64px rgba(0,0,0,.38);overflow:hidden}} -.bar{{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:10px 12px;border-bottom:1px solid var(--line);background:rgba(255,255,255,.05)}} -#term{{height:calc(100vh - 145px);min-height:430px;margin:0;padding:14px;overflow:auto;white-space:pre-wrap;word-break:break-word;outline:none;background:rgba(0,0,0,.32);font:13px/1.38 "Cascadia Mono","Consolas","Liberation Mono",monospace;color:#e9d5ff}} +.termBox{{flex:1;min-height:0;display:flex;flex-direction:column;border:1px solid var(--line);border-radius:8px;background:linear-gradient(180deg,rgba(255,255,255,.08),rgba(255,255,255,.045)),var(--panel);box-shadow:0 22px 64px rgba(0,0,0,.38);overflow:hidden}} +.bar{{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:7px 10px;border-bottom:1px solid var(--line);background:rgba(255,255,255,.05)}} +#term{{flex:1;min-height:0;margin:0;padding:12px;overflow:auto;white-space:pre-wrap;word-break:break-word;outline:none;background:rgba(0,0,0,.42);font:13px/1.34 "Cascadia Mono","Consolas","Liberation Mono",monospace;color:#e9d5ff}} .bad{{color:#fecdd3}} -@media(max-width:680px){{body{{padding:12px}}.top{{align-items:flex-start;flex-direction:column}}#term{{height:calc(100vh - 178px);min-height:360px}}}} +@media(max-width:680px){{body{{padding:10px}}.wrap{{height:calc(100vh - 20px)}}.top{{align-items:flex-start;flex-direction:column}}.chips{{width:100%}}.btn{{width:100%}}}}