Add VPN client users with inbound access and subscription links.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
orohi
2026-07-29 04:49:32 +03:00
co-authored by Cursor
parent 4991b313d7
commit c0e78ce949
16 changed files with 930 additions and 11 deletions
+108
View File
@@ -0,0 +1,108 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{.Title}} · VPN Panel</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
<link rel="stylesheet" href="/static/css/app.css">
</head>
<body class="page-admin">
<aside class="sidebar">
<a class="brand" href="/admin">VPN Panel</a>
<nav>
<a href="/admin">Обзор</a>
<a class="active" href="/admin/clients">Пользователи</a>
<a href="/admin/nodes">Ноды</a>
<a href="/admin/profiles">Профили</a>
<a href="/admin/protocols">Протоколы</a>
</nav>
<div class="sidebar-foot">
<span class="user-chip">{{.UserName}}</span>
<form method="POST" action="/logout"><button type="submit" class="link-btn">Выйти</button></form>
</div>
</aside>
<main class="admin-main">
<header class="admin-header row-head">
<div>
<h1>{{.Client.Username}}</h1>
<p class="muted"><code>{{.Client.UUID}}</code></p>
</div>
<span class="badge {{statusClass (printf "%s" .Client.Status)}}">{{.Client.StatusLabel}}</span>
</header>
{{if .Flash}}<div class="alert ok">{{.Flash}}</div>{{end}}
{{if .Error}}<div class="alert">{{.Error}}</div>{{end}}
<div class="cta-row" style="margin-bottom:1.25rem">
<form method="POST" action="/admin/clients/{{.Client.ID}}/toggle">
<button class="btn btn-ghost" type="submit">{{if eq (printf "%s" .Client.Status) "active"}}Отключить{{else}}Включить{{end}}</button>
</form>
<form method="POST" action="/admin/clients/{{.Client.ID}}/delete" onsubmit="return confirm('Удалить пользователя?');">
<button class="btn btn-ghost" type="submit">Удалить</button>
</form>
<a class="btn btn-ghost" href="/admin/clients">К списку</a>
</div>
<section class="panel-section">
<h2>Subscription</h2>
<p class="muted">Ссылка для клиента (нужны online-ноды с назначенным профилем и включёнными inbound):</p>
<pre class="code-block">{{.SubURL}}</pre>
{{if .Links}}
<h3 style="margin-top:1rem;font-size:1rem">Сгенерированные ссылки</h3>
<pre class="code-block log">{{range .Links}}{{.}}
{{end}}</pre>
{{else}}
<p class="hint">Пока нет ссылок — назначьте inbound пользователю, профиль ноде, и дождитесь Online.</p>
{{end}}
</section>
<section class="panel-section">
<h2>Редактирование</h2>
<form class="form-card" method="POST" action="/admin/clients/{{.Client.ID}}">
<div class="form-grid">
<label>Username
<input name="username" required value="{{.Client.Username}}">
</label>
<label>Email
<input name="email" type="email" value="{{.Client.Email}}">
</label>
<label>Статус
<select name="status">
<option value="active" {{if eq (printf "%s" .Client.Status) "active"}}selected{{end}}>Активен</option>
<option value="disabled" {{if eq (printf "%s" .Client.Status) "disabled"}}selected{{end}}>Отключён</option>
<option value="expired" {{if eq (printf "%s" .Client.Status) "expired"}}selected{{end}}>Истёк</option>
</select>
</label>
<label>Лимит трафика (GB, 0 = ∞)
<input name="traffic_limit_gb" type="number" step="0.1" min="0" value="{{printf "%.2f" .Client.TrafficLimitGB}}">
</label>
<label>Истекает
<input name="expire_at" type="datetime-local" value="{{formatTime .Client.ExpireAt}}">
</label>
<label>Заметка
<input name="note" value="{{.Client.Note}}">
</label>
</div>
<fieldset class="mode-pick">
<legend>Инбаунды</legend>
{{range .Inbounds}}
<label class="radio">
<input type="checkbox" name="inbound_ids" value="{{.ID}}" {{if $.Client.HasInbound .ID}}checked{{end}}>
<span><code>{{.Tag}}</code> · {{.ProtocolName}} :{{.Port}}</span>
</label>
{{else}}
<p class="muted">Нет доступных inbound — создайте в профиле.</p>
{{end}}
</fieldset>
<button class="btn btn-primary" type="submit">Сохранить</button>
</form>
</section>
</main>
</body>
</html>