mirror of
https://github.com/maeneko/forgetting.git
synced 2026-08-25 15:24:26 +00:00
Upstream AmneziaWG 3.x is still shifting under active development (unanswered kernel-module issues around header protection and handshake-without-data regressions), so give operators an explicit opt-out/opt-in instead of always auto-selecting 3.1, and pin the installed package so unattended-upgrades can't swap the module under a live server. Surface the running module/tools version and protocol generation through /health, the CLI status command, and the panel's server card so a mismatch is visible instead of silent.
74 lines
3.9 KiB
TypeScript
74 lines
3.9 KiB
TypeScript
// Copyright (c) 2026 Ivan Vasilev
|
|
// This source code is licensed under the MIT license found in the
|
|
// LICENSE file in the root directory of this source tree.
|
|
import { type ServerInfo, genLabel } from '../lib/shared';
|
|
import { IcoPlus, IcoRefresh } from './icons';
|
|
|
|
// Сервер-бар: карточка активного сервера + «Добавить сервер» + (на мобильной)
|
|
// перезапуск AWG под ними. Общий для вкладок — показывает (и в будущем выбирает)
|
|
// сервер, к которому относится содержимое вкладки (пиры / API-ключи).
|
|
// TODO multi-server: сейчас сервер один и всегда активен. Когда серверов
|
|
// станет несколько — карточки станут кликабельными, активная = выбранная.
|
|
export default function ServerBar({
|
|
serverInfo, serverOnline, onRestartAwg, restarting,
|
|
showAddServer = true, showRestart = true,
|
|
}: {
|
|
serverInfo: ServerInfo | null;
|
|
serverOnline: boolean;
|
|
onRestartAwg: () => void;
|
|
restarting: boolean;
|
|
showAddServer?: boolean;
|
|
showRestart?: boolean;
|
|
}) {
|
|
return (
|
|
<div className="server-bar">
|
|
{serverInfo && (
|
|
<div className="server-card server-card--active">
|
|
{/* toggle — виден на мобильном вместо чипа */}
|
|
<div
|
|
className={`server-toggle${serverOnline ? ' server-toggle--on' : ''}`}
|
|
aria-hidden="true"
|
|
>
|
|
<div className="server-toggle-thumb" />
|
|
</div>
|
|
{/* чип онлайн/офлайн — виден на десктопе */}
|
|
<span className={`chip chip--${serverOnline ? 'online' : 'offline'} server-online-chip`}>
|
|
<span className="chip-dot" />
|
|
</span>
|
|
<div className="server-card-info">
|
|
<span className="server-card-name">{serverInfo.name}</span>
|
|
<span className="server-card-ip">{serverInfo.ip}</span>
|
|
{(serverInfo.mod || serverInfo.tools) ? (
|
|
<span
|
|
className="tip-wrap server-gen-wrap"
|
|
data-tip={`модуль ${serverInfo.mod || '?'} · tools ${serverInfo.tools || '?'}`}
|
|
>
|
|
<span className="chip chip--offline server-gen-chip">{genLabel(serverInfo.gen)}</span>
|
|
</span>
|
|
) : (
|
|
<span className="chip chip--offline server-gen-chip">{genLabel(serverInfo.gen)}</span>
|
|
)}
|
|
</div>
|
|
<span className="server-card-peers">{serverInfo.peers} peers</span>
|
|
</div>
|
|
)}
|
|
{showAddServer && (
|
|
<span className="tip-wrap" data-tip="Недоступно в альфа-версии">
|
|
<button className="server-add" disabled>
|
|
<IcoPlus /> Добавить сервер
|
|
</button>
|
|
</span>
|
|
)}
|
|
{/* Перезапуск AWG — только на мобильной (на десктопе кнопка в углу). */}
|
|
{showRestart && (
|
|
<button
|
|
className={`btn btn--tonal awg-restart-mobile${restarting ? ' spinning' : ''}`}
|
|
onClick={onRestartAwg}
|
|
disabled={restarting}
|
|
>
|
|
<IcoRefresh /> {restarting ? 'Перезапуск…' : 'Перезапустить AWG'}
|
|
</button>
|
|
)}
|
|
</div>
|
|
);
|
|
} |