release 1.6.0: client self-service page /u/<id>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
## 1.6.0 — 2026-11-21
|
||||
- **Личная страница клиента.** В окне «Подключение» у каждого клиента есть ссылка на его страницу: отправьте её человеку. Там статус (в сети или нет), срок подписки с остатком дней, трафик за месяц, кнопки «Скачать приложение» и «Добавить профиль» для Android, вариант для iPhone, QR для другого устройства и файл .conf. Вход в панель не нужен; ссылка защищена личным токеном клиента, чужой токен даёт 403.
|
||||
|
||||
## 1.5.3 — 2026-11-21
|
||||
- **Экран обновления в стиле Джарвиса с любой страницы.** Кнопка «Обновить» в зелёном баннере на «Сессиях», «Клиентах» и других страницах теперь запускает HUD-обновление; раньше HUD был только в «Настройках», а с других страниц шёл обычный перезапрос без прогресса. Окно с описанием версии закрывается при старте. Повторное нажатие во время обновления больше не красит экран в «сбой»: панель подхватывает уже идущее обновление.
|
||||
|
||||
|
||||
87
app.py
87
app.py
@@ -1265,6 +1265,92 @@ def phone_sub(cid):
|
||||
return jsonify({"servers": phone_sub_servers(cid)})
|
||||
|
||||
|
||||
def personal_url(cid):
|
||||
from urllib.parse import quote
|
||||
return f"{request.host_url}u/{quote(cid)}?t={phone_sub_token(cid)}"
|
||||
|
||||
|
||||
def _personal_ok(cid):
|
||||
import hmac
|
||||
return (hmac.compare_digest(request.args.get("t", ""), phone_sub_token(cid))
|
||||
and any(c.get("client_id") == cid for c in get_clients()))
|
||||
|
||||
|
||||
@app.route("/u/<cid>/conf")
|
||||
def personal_conf(cid):
|
||||
"""Plain .conf for the client's own page (token-protected, no panel login)."""
|
||||
if not _personal_ok(cid):
|
||||
return ("forbidden", 403)
|
||||
conf, _l = build_phone_config(cid, "android")
|
||||
if conf is None:
|
||||
return ("not found", 404)
|
||||
conf = "\n".join(ln for ln in conf.split("\n") if ln.partition("=")[2].strip().lower() != "none")
|
||||
return (conf, 200, {"Content-Type": "text/plain; charset=utf-8",
|
||||
"Content-Disposition": 'attachment; filename="phobos.conf"'})
|
||||
|
||||
|
||||
@app.route("/u/<cid>")
|
||||
def personal_page(cid):
|
||||
"""Client's own page: status, term, monthly traffic, QR and app links. One link from the admin."""
|
||||
if not _personal_ok(cid):
|
||||
return ("forbidden", 403)
|
||||
e = html_lib.escape
|
||||
s = load_settings()
|
||||
c = next(x for x in get_clients() if x.get("client_id") == cid)
|
||||
pub = c.get("public_key", "")
|
||||
online = any(p == pub and is_peer_online(i.get("latest handshake", "")) for p, i in get_wg_peers().items())
|
||||
sub = s.get("subscriptions", {}).get(cid, {})
|
||||
term, term_cls = tr("без ограничения срока", "no expiry"), "ok"
|
||||
if sub.get("expiry"):
|
||||
try:
|
||||
left = (datetime.strptime(sub["expiry"], "%Y-%m-%d").date() - datetime.now().date()).days
|
||||
term = f'{tr("до","until")} {e(sub["expiry"])} · ' + (tr(f"осталось {left} дн.", f"{left} days left") if left > 0 else tr("срок истёк", "expired"))
|
||||
term_cls = "bad" if left <= 0 else ("warn" if left <= 3 else "ok")
|
||||
except ValueError:
|
||||
pass
|
||||
u = _traffic_load().get("usage", {}).get(cid)
|
||||
traffic = f'↓ {_fmt_bytes(u[1])} · ↑ {_fmt_bytes(u[0])}' if u else "—"
|
||||
conf, link = build_phone_config(cid, "android")
|
||||
qr = qr_datauri(link or conf or "")
|
||||
apk = f"{PCA_GIT}/releases/download/{APK_TAG}/PCA-Phobos-VPN.apk"
|
||||
iphone = ""
|
||||
if apple_apps():
|
||||
tf = (s.get("testflight_url") or "https://testflight.apple.com/join/tHqjPg1p").strip()
|
||||
iphone = (f'<a class="b" href="{e(link)}">{tr("Открыть в PCA Phobos VPN","Open in PCA Phobos VPN")}</a>'
|
||||
f'<a class="b g" href="{e(tf)}" target="_blank" rel="noopener">TestFlight</a>')
|
||||
else:
|
||||
iphone = (f'<a class="b g" href="https://apps.apple.com/app/wireguard/id1441195209" target="_blank" rel="noopener">WireGuard</a>'
|
||||
f'<p class="m">{tr("Без обфускации: работает, если провайдер не режет WireGuard.","No obfuscation: works if your ISP does not block WireGuard.")}</p>')
|
||||
q = f"?t={e(request.args.get('t', ''))}"
|
||||
return f"""<!doctype html><html lang="{'ru' if tr('a','b') == 'a' else 'en'}"><head><meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1"><meta name="robots" content="noindex">
|
||||
<title>PCA Phobos · {e(cid)}</title><style>
|
||||
:root{{--bg:#f1f5f9;--card:#fff;--fg:#0f172a;--m:#64748b;--ac:#2563eb;--ok:#16a34a;--warn:#d97706;--bad:#dc2626;--ln:#e2e8f0}}
|
||||
@media (prefers-color-scheme:dark){{:root{{--bg:#0b1220;--card:#111a2e;--fg:#e2e8f0;--m:#94a3b8;--ac:#60a5fa;--ln:#1e293b}}}}
|
||||
*{{box-sizing:border-box}}body{{margin:0;background:var(--bg);color:var(--fg);font:16px/1.5 -apple-system,Segoe UI,Roboto,sans-serif}}
|
||||
.w{{max-width:560px;margin:0 auto;padding:16px}}.c{{background:var(--card);border:1px solid var(--ln);border-radius:14px;padding:18px;margin-bottom:14px}}
|
||||
h1{{font-size:1.3em;margin:0 0 4px}}h2{{font-size:1em;margin:0 0 10px}}.m{{color:var(--m);font-size:.88em;margin:6px 0}}
|
||||
.st{{display:inline-block;padding:2px 10px;border-radius:99px;font-size:.85em;font-weight:600}}
|
||||
.ok{{color:var(--ok)}}.warn{{color:var(--warn)}}.bad{{color:var(--bad)}}.st.ok{{background:rgba(22,163,74,.12)}}.st.off{{background:rgba(100,116,139,.15);color:var(--m)}}
|
||||
.row{{display:flex;justify-content:space-between;gap:10px;padding:6px 0;border-top:1px solid var(--ln)}}.row:first-of-type{{border-top:0}}
|
||||
.b{{display:block;text-align:center;background:var(--ac);color:#fff;text-decoration:none;padding:11px;border-radius:10px;margin:8px 0;font-weight:600}}.b.g{{background:#475569}}
|
||||
img.qr{{display:block;width:100%;max-width:280px;margin:6px auto;background:#fff;padding:10px;border-radius:10px;image-rendering:pixelated}}
|
||||
</style></head><body><div class="w">
|
||||
<div class="c"><h1>{e(c.get("client_name") or cid)}</h1>
|
||||
<span class="st {'ok' if online else 'off'}">{tr("в сети","online") if online else tr("не в сети","offline")}</span>
|
||||
<div style="margin-top:12px"><div class="row"><span>{tr("Срок","Term")}</span><span class="{term_cls}">{term}</span></div>
|
||||
<div class="row"><span>{tr("Трафик за месяц","Traffic this month")}</span><span>{traffic}</span></div></div></div>
|
||||
<div class="c"><h2>Android</h2>
|
||||
<a class="b" href="{e(apk)}">{tr("1. Скачать PCA Phobos VPN","1. Download PCA Phobos VPN")}</a>
|
||||
<a class="b" href="{e(link)}">{tr("2. Добавить профиль в приложение","2. Add the profile to the app")}</a>
|
||||
<p class="m">{tr("Откройте эту страницу на телефоне и нажмите кнопки по порядку. Серверы переключаются сами.","Open this page on the phone and tap the buttons in order. Servers switch automatically.")}</p></div>
|
||||
<div class="c"><h2>iPhone</h2>{iphone}</div>
|
||||
<div class="c"><h2>{tr("QR для другого устройства","QR for another device")}</h2><img class="qr" src="{qr}" alt="QR">
|
||||
<a class="b g" href="/u/{e(cid)}/conf{q}">{tr("Скачать файл .conf","Download .conf file")}</a></div>
|
||||
<p class="m" style="text-align:center">{tr("Ссылку на эту страницу никому не передавайте.","Do not share the link to this page.")}</p>
|
||||
</div></body></html>"""
|
||||
|
||||
|
||||
def panel_version():
|
||||
try:
|
||||
return open(os.path.join(PANEL_DIR, ".version")).read().strip()
|
||||
@@ -3823,6 +3909,7 @@ def clients_page():
|
||||
</form></div></div>
|
||||
<div class="modal" id="mc-{cid}"><div class="mbox wide">
|
||||
<div class="mh"><h3>{tr("Подключение","Connection")}: {cid}</h3><button class="x" onclick="closeM('mc-{cid}')">×</button></div>
|
||||
<div style="padding:10px 16px 0;font-size:.88em">{tr("Личная страница клиента (отправьте человеку):","Client's own page (send it to the user):")} <input readonly onclick="this.select()" value="{_html_attr(personal_url(cid))}" style="width:100%;font-size:.85em"></div>
|
||||
<div class="tabs"><a class="on" data-t="android" onclick="loadConn('{cid}','android')">Android</a>{apple_tabs.replace('{cid}', cid)}<a data-t="windows" onclick="loadConn('{cid}','windows')">Windows</a><a data-t="router" onclick="loadConn('{cid}','router')">Router</a><a data-t="hr" onclick="loadConn('{cid}','hr')">HR</a></div>
|
||||
<div class="mb conn" id="cb-{cid}"></div></div></div>
|
||||
<div class="modal" id="mr-{cid}"><div class="mbox">
|
||||
|
||||
Reference in New Issue
Block a user