Add Go VPN admin panel with Docker Compose and Postgres 17.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,331 @@
|
||||
:root {
|
||||
--bg: #0b1220;
|
||||
--bg-2: #111a2e;
|
||||
--surface: rgba(18, 28, 48, 0.86);
|
||||
--line: rgba(148, 175, 210, 0.16);
|
||||
--text: #e8eef8;
|
||||
--muted: #93a4bf;
|
||||
--accent: #3dd6c6;
|
||||
--accent-2: #4f8cff;
|
||||
--danger: #ff6b7a;
|
||||
--ok: #3dd6c6;
|
||||
--off: #7a879c;
|
||||
--radius: 14px;
|
||||
--font: "DM Sans", sans-serif;
|
||||
--mono: "JetBrains Mono", ui-monospace, monospace;
|
||||
}
|
||||
|
||||
* { box-sizing: border-box; }
|
||||
html, body { margin: 0; min-height: 100%; }
|
||||
body {
|
||||
font-family: var(--font);
|
||||
color: var(--text);
|
||||
background: var(--bg);
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
a { color: inherit; text-decoration: none; }
|
||||
code {
|
||||
font-family: var(--mono);
|
||||
font-size: 0.85em;
|
||||
background: rgba(255,255,255,0.06);
|
||||
padding: 0.15em 0.4em;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.home-bg {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background:
|
||||
radial-gradient(900px 500px at 12% 10%, rgba(61, 214, 198, 0.18), transparent 55%),
|
||||
radial-gradient(800px 480px at 88% 18%, rgba(79, 140, 255, 0.2), transparent 50%),
|
||||
linear-gradient(160deg, #070d18 0%, #0d1730 45%, #0a1424 100%);
|
||||
z-index: -1;
|
||||
}
|
||||
|
||||
.brand {
|
||||
font-weight: 700;
|
||||
letter-spacing: -0.03em;
|
||||
font-size: 1.15rem;
|
||||
}
|
||||
.brand-center { display: block; text-align: center; margin-bottom: 1.25rem; }
|
||||
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 0.4rem;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 999px;
|
||||
padding: 0.7rem 1.2rem;
|
||||
font: inherit;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: transform .15s ease, background .15s ease, border-color .15s ease;
|
||||
}
|
||||
.btn:hover { transform: translateY(-1px); }
|
||||
.btn-primary {
|
||||
background: linear-gradient(135deg, var(--accent), #2bb8d4);
|
||||
color: #04131a;
|
||||
}
|
||||
.btn-ghost {
|
||||
background: transparent;
|
||||
border-color: var(--line);
|
||||
color: var(--text);
|
||||
}
|
||||
.btn-ghost:hover { border-color: rgba(61,214,198,0.45); }
|
||||
.btn-sm { padding: 0.45rem 0.9rem; font-size: 0.9rem; }
|
||||
.btn-block { width: 100%; }
|
||||
|
||||
.page-home { min-height: 100vh; }
|
||||
.home-top {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 1.25rem 2rem;
|
||||
}
|
||||
.home-hero {
|
||||
max-width: 760px;
|
||||
padding: 12vh 2rem 4rem;
|
||||
animation: rise .7s ease both;
|
||||
}
|
||||
.brand-mark {
|
||||
margin: 0 0 0.75rem;
|
||||
font-size: clamp(2.4rem, 7vw, 4.4rem);
|
||||
font-weight: 700;
|
||||
letter-spacing: -0.05em;
|
||||
background: linear-gradient(120deg, #fff 20%, var(--accent) 70%, var(--accent-2));
|
||||
-webkit-background-clip: text;
|
||||
background-clip: text;
|
||||
color: transparent;
|
||||
}
|
||||
.home-hero h1 {
|
||||
margin: 0 0 1rem;
|
||||
font-size: clamp(1.35rem, 3vw, 1.85rem);
|
||||
font-weight: 600;
|
||||
letter-spacing: -0.02em;
|
||||
}
|
||||
.lead { color: var(--muted); font-size: 1.05rem; max-width: 34rem; }
|
||||
.cta-row { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 1.75rem; }
|
||||
|
||||
.page-login { min-height: 100vh; display: grid; place-items: center; padding: 2rem; }
|
||||
.login-wrap { width: min(100%, 400px); animation: rise .55s ease both; }
|
||||
.login-form {
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: calc(var(--radius) + 4px);
|
||||
padding: 1.5rem;
|
||||
backdrop-filter: blur(12px);
|
||||
}
|
||||
.login-form h1 { margin: 0 0 0.35rem; font-size: 1.35rem; }
|
||||
.muted { color: var(--muted); margin: 0 0 1rem; }
|
||||
.alert {
|
||||
background: rgba(255,107,122,0.12);
|
||||
border: 1px solid rgba(255,107,122,0.35);
|
||||
color: #ffb4bc;
|
||||
padding: 0.7rem 0.85rem;
|
||||
border-radius: 10px;
|
||||
margin-bottom: 1rem;
|
||||
font-size: 0.95rem;
|
||||
}
|
||||
label {
|
||||
display: grid;
|
||||
gap: 0.35rem;
|
||||
margin-bottom: 0.9rem;
|
||||
font-size: 0.9rem;
|
||||
color: var(--muted);
|
||||
}
|
||||
input {
|
||||
width: 100%;
|
||||
border: 1px solid var(--line);
|
||||
background: rgba(0,0,0,0.25);
|
||||
color: var(--text);
|
||||
border-radius: 10px;
|
||||
padding: 0.75rem 0.9rem;
|
||||
font: inherit;
|
||||
}
|
||||
input:focus {
|
||||
outline: none;
|
||||
border-color: rgba(61,214,198,0.55);
|
||||
box-shadow: 0 0 0 3px rgba(61,214,198,0.12);
|
||||
}
|
||||
|
||||
.page-admin {
|
||||
display: grid;
|
||||
grid-template-columns: 240px 1fr;
|
||||
min-height: 100vh;
|
||||
background:
|
||||
radial-gradient(700px 400px at 100% 0%, rgba(79,140,255,0.12), transparent 50%),
|
||||
var(--bg);
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.5rem;
|
||||
padding: 1.5rem 1.1rem;
|
||||
border-right: 1px solid var(--line);
|
||||
background: rgba(8, 14, 26, 0.75);
|
||||
}
|
||||
.sidebar nav { display: grid; gap: 0.35rem; }
|
||||
.sidebar nav a {
|
||||
padding: 0.65rem 0.85rem;
|
||||
border-radius: 10px;
|
||||
color: var(--muted);
|
||||
font-weight: 500;
|
||||
}
|
||||
.sidebar nav a:hover,
|
||||
.sidebar nav a.active {
|
||||
background: rgba(61,214,198,0.1);
|
||||
color: var(--text);
|
||||
}
|
||||
.sidebar-foot {
|
||||
margin-top: auto;
|
||||
display: grid;
|
||||
gap: 0.5rem;
|
||||
padding-top: 1rem;
|
||||
border-top: 1px solid var(--line);
|
||||
}
|
||||
.user-chip {
|
||||
font-size: 0.9rem;
|
||||
color: var(--muted);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.link-btn {
|
||||
background: none;
|
||||
border: 0;
|
||||
color: var(--accent);
|
||||
font: inherit;
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.admin-main { padding: 1.75rem 2rem 2.5rem; }
|
||||
.admin-header h1 { margin: 0; font-size: 1.7rem; letter-spacing: -0.03em; }
|
||||
.admin-header .muted { margin-top: 0.35rem; }
|
||||
|
||||
.stats {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 0.9rem;
|
||||
margin: 1.5rem 0 2rem;
|
||||
}
|
||||
.stat {
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius);
|
||||
padding: 1rem 1.1rem;
|
||||
}
|
||||
.stat-label { display: block; color: var(--muted); font-size: 0.85rem; margin-bottom: 0.35rem; }
|
||||
.stat-value { font-size: 1.8rem; font-weight: 700; letter-spacing: -0.04em; }
|
||||
.stat-value.accent { color: var(--accent); }
|
||||
|
||||
.panel-section { margin-top: 0.5rem; }
|
||||
.section-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
.section-head h2 { margin: 0; font-size: 1.15rem; }
|
||||
|
||||
.proto-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
|
||||
gap: 0.85rem;
|
||||
}
|
||||
.proto-card {
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius);
|
||||
padding: 1rem;
|
||||
animation: rise .45s ease both;
|
||||
}
|
||||
.proto-card.is-off { opacity: 0.72; }
|
||||
.proto-top {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
margin-bottom: 0.45rem;
|
||||
}
|
||||
.proto-top h3 { margin: 0; font-size: 1.05rem; }
|
||||
.proto-card p {
|
||||
margin: 0 0 0.85rem;
|
||||
color: var(--muted);
|
||||
font-size: 0.9rem;
|
||||
min-height: 2.7em;
|
||||
}
|
||||
.proto-meta {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
color: var(--muted);
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
|
||||
.badge {
|
||||
font-size: 0.72rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.04em;
|
||||
padding: 0.25rem 0.55rem;
|
||||
border-radius: 999px;
|
||||
}
|
||||
.badge.on { background: rgba(61,214,198,0.15); color: var(--ok); }
|
||||
.badge.off { background: rgba(122,135,156,0.18); color: var(--off); }
|
||||
|
||||
.table-wrap {
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius);
|
||||
overflow: auto;
|
||||
margin-top: 1.25rem;
|
||||
}
|
||||
.data-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
min-width: 680px;
|
||||
}
|
||||
.data-table th,
|
||||
.data-table td {
|
||||
text-align: left;
|
||||
padding: 0.95rem 1rem;
|
||||
border-bottom: 1px solid var(--line);
|
||||
vertical-align: top;
|
||||
}
|
||||
.data-table th {
|
||||
color: var(--muted);
|
||||
font-size: 0.8rem;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.04em;
|
||||
}
|
||||
.data-table tr:last-child td { border-bottom: 0; }
|
||||
.cell-desc {
|
||||
color: var(--muted);
|
||||
font-size: 0.85rem;
|
||||
margin-top: 0.25rem;
|
||||
max-width: 360px;
|
||||
}
|
||||
.actions { width: 1%; white-space: nowrap; }
|
||||
|
||||
@keyframes rise {
|
||||
from { opacity: 0; transform: translateY(12px); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
}
|
||||
|
||||
@media (max-width: 860px) {
|
||||
.page-admin { grid-template-columns: 1fr; }
|
||||
.sidebar {
|
||||
border-right: 0;
|
||||
border-bottom: 1px solid var(--line);
|
||||
}
|
||||
.sidebar nav { grid-auto-flow: column; grid-auto-columns: max-content; overflow-x: auto; }
|
||||
.sidebar-foot { display: flex; align-items: center; justify-content: space-between; }
|
||||
.stats { grid-template-columns: 1fr; }
|
||||
.admin-main { padding: 1.25rem; }
|
||||
.home-top, .home-hero { padding-left: 1.25rem; padding-right: 1.25rem; }
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<!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 class="{{if eq .Active "dashboard"}}active{{end}}" href="/admin">Обзор</a>
|
||||
<a class="{{if eq .Active "protocols"}}active{{end}}" 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">
|
||||
<h1>Обзор</h1>
|
||||
<p class="muted">Состояние панели и активные протоколы</p>
|
||||
</header>
|
||||
|
||||
<section class="stats">
|
||||
<div class="stat">
|
||||
<span class="stat-label">Протоколов</span>
|
||||
<span class="stat-value">{{.Stats.ProtocolsTotal}}</span>
|
||||
</div>
|
||||
<div class="stat">
|
||||
<span class="stat-label">Включено</span>
|
||||
<span class="stat-value accent">{{.Stats.ProtocolsEnabled}}</span>
|
||||
</div>
|
||||
<div class="stat">
|
||||
<span class="stat-label">Админов</span>
|
||||
<span class="stat-value">{{.Stats.AdminsTotal}}</span>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="panel-section">
|
||||
<div class="section-head">
|
||||
<h2>Протоколы</h2>
|
||||
<a href="/admin/protocols" class="btn btn-ghost btn-sm">Управление</a>
|
||||
</div>
|
||||
<div class="proto-grid">
|
||||
{{range .Protocols}}
|
||||
<article class="proto-card {{if .Enabled}}is-on{{else}}is-off{{end}}">
|
||||
<div class="proto-top">
|
||||
<h3>{{.Name}}</h3>
|
||||
<span class="badge {{if .Enabled}}on{{else}}off{{end}}">{{if .Enabled}}ON{{else}}OFF{{end}}</span>
|
||||
</div>
|
||||
<p>{{.Description}}</p>
|
||||
<div class="proto-meta">
|
||||
<code>{{.Code}}</code>
|
||||
<span>порт {{.Port}}</span>
|
||||
</div>
|
||||
</article>
|
||||
{{end}}
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,29 @@
|
||||
<!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;1,9..40,400&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="/static/css/app.css">
|
||||
</head>
|
||||
<body class="page-home">
|
||||
<div class="home-bg" aria-hidden="true"></div>
|
||||
<header class="home-top">
|
||||
<a class="brand" href="/">VPN Panel</a>
|
||||
<a class="btn btn-ghost" href="/login">Войти</a>
|
||||
</header>
|
||||
|
||||
<main class="home-hero">
|
||||
<p class="brand-mark">VPN Panel</p>
|
||||
<h1>Админ-панель управления VPN-протоколами</h1>
|
||||
<p class="lead">WireGuard, OpenVPN, VLESS, VMess, Trojan, Shadowsocks и Hysteria2 — в одном месте.</p>
|
||||
<div class="cta-row">
|
||||
<a class="btn btn-primary" href="/login">Открыть админку</a>
|
||||
<a class="btn btn-ghost" href="/admin/protocols">Протоколы</a>
|
||||
</div>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,34 @@
|
||||
<!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-login">
|
||||
<div class="home-bg" aria-hidden="true"></div>
|
||||
<main class="login-wrap">
|
||||
<a class="brand brand-center" href="/">VPN Panel</a>
|
||||
<form class="login-form" method="POST" action="/login" autocomplete="on">
|
||||
<h1>Вход в админку</h1>
|
||||
<p class="muted">Используйте данные из <code>.env</code></p>
|
||||
{{if .Error}}
|
||||
<div class="alert">{{.Error}}</div>
|
||||
{{end}}
|
||||
<label>
|
||||
Email
|
||||
<input type="email" name="email" required value="{{.Email}}" placeholder="admin@panel.local" autofocus>
|
||||
</label>
|
||||
<label>
|
||||
Пароль
|
||||
<input type="password" name="password" required placeholder="••••••••">
|
||||
</label>
|
||||
<button class="btn btn-primary btn-block" type="submit">Войти</button>
|
||||
</form>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,68 @@
|
||||
<!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 class="{{if eq .Active "dashboard"}}active{{end}}" href="/admin">Обзор</a>
|
||||
<a class="{{if eq .Active "protocols"}}active{{end}}" 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">
|
||||
<h1>Протоколы</h1>
|
||||
<p class="muted">Включение и отключение VPN-протоколов</p>
|
||||
</header>
|
||||
|
||||
<div class="table-wrap">
|
||||
<table class="data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Протокол</th>
|
||||
<th>Код</th>
|
||||
<th>Порт</th>
|
||||
<th>Статус</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{range .Protocols}}
|
||||
<tr>
|
||||
<td>
|
||||
<strong>{{.Name}}</strong>
|
||||
<div class="cell-desc">{{.Description}}</div>
|
||||
</td>
|
||||
<td><code>{{.Code}}</code></td>
|
||||
<td>{{.Port}}</td>
|
||||
<td>
|
||||
<span class="badge {{if .Enabled}}on{{else}}off{{end}}">{{if .Enabled}}Включён{{else}}Выключен{{end}}</span>
|
||||
</td>
|
||||
<td class="actions">
|
||||
<form method="POST" action="/admin/protocols/{{.ID}}/toggle">
|
||||
<button type="submit" class="btn btn-sm {{if .Enabled}}btn-ghost{{else}}btn-primary{{end}}">
|
||||
{{if .Enabled}}Выключить{{else}}Включить{{end}}
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user