Improve failover startup handling and status UI
This commit is contained in:
@@ -86,6 +86,13 @@ function withDesiredServer(state: StoredState, profile: StoredProfile, serverId:
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function createConnectionService(dependencies: ConnectionServiceDependencies) {
|
export function createConnectionService(dependencies: ConnectionServiceDependencies) {
|
||||||
|
const prepareFailoverActivation = async (role: 'primary' | 'reserve') => {
|
||||||
|
try {
|
||||||
|
await dependencies.failover?.prepareActivation(role);
|
||||||
|
} catch (cause) {
|
||||||
|
throw new HarborError('PROCESS_START_FAILED', { cause });
|
||||||
|
}
|
||||||
|
};
|
||||||
const activationTarget = (
|
const activationTarget = (
|
||||||
state: StoredState,
|
state: StoredState,
|
||||||
applied: AppliedFailoverPolicy,
|
applied: AppliedFailoverPolicy,
|
||||||
@@ -158,7 +165,7 @@ export function createConnectionService(dependencies: ConnectionServiceDependenc
|
|||||||
dependencies.config.write(nextConfig);
|
dependencies.config.write(nextConfig);
|
||||||
runtimeMutationStarted = true;
|
runtimeMutationStarted = true;
|
||||||
await dependencies.runtime.start();
|
await dependencies.runtime.start();
|
||||||
if (failoverCandidate) await dependencies.failover!.prepareActivation('primary');
|
if (failoverCandidate) await prepareFailoverActivation('primary');
|
||||||
stateCommitStarted = true;
|
stateCommitStarted = true;
|
||||||
dependencies.state.update((state) => ({
|
dependencies.state.update((state) => ({
|
||||||
...withDesiredServer(state, profile, selectedServer.id),
|
...withDesiredServer(state, profile, selectedServer.id),
|
||||||
@@ -320,7 +327,7 @@ export function createConnectionService(dependencies: ConnectionServiceDependenc
|
|||||||
const command = await dependencies.runtime.restartCommand();
|
const command = await dependencies.runtime.restartCommand();
|
||||||
runtimeMutationStarted = command.mutationStarted;
|
runtimeMutationStarted = command.mutationStarted;
|
||||||
if (!command.ok) throw command.error;
|
if (!command.ok) throw command.error;
|
||||||
if (failoverCandidate) await dependencies.failover!.prepareActivation(activationRole);
|
if (failoverCandidate) await prepareFailoverActivation(activationRole);
|
||||||
stateCommitStarted = true;
|
stateCommitStarted = true;
|
||||||
dependencies.state.update((state) => ({
|
dependencies.state.update((state) => ({
|
||||||
...state,
|
...state,
|
||||||
|
|||||||
@@ -6,6 +6,25 @@ import {
|
|||||||
} from '../singbox.js';
|
} from '../singbox.js';
|
||||||
|
|
||||||
type Role = 'primary' | 'reserve';
|
type Role = 'primary' | 'reserve';
|
||||||
|
const SELECTOR_READY_ATTEMPTS = 20;
|
||||||
|
const SELECTOR_READY_DELAY_MS = 100;
|
||||||
|
|
||||||
|
const transientStartupError = (error: unknown) => (
|
||||||
|
error && typeof error === 'object' && 'code' in error
|
||||||
|
? ['ECONNREFUSED', 'ECONNRESET'].includes(String(error.code))
|
||||||
|
: false
|
||||||
|
);
|
||||||
|
|
||||||
|
async function whenReady<T>(operation: () => Promise<T>): Promise<T> {
|
||||||
|
for (let attempt = 1; ; attempt += 1) {
|
||||||
|
try {
|
||||||
|
return await operation();
|
||||||
|
} catch (error) {
|
||||||
|
if (!transientStartupError(error) || attempt === SELECTOR_READY_ATTEMPTS) throw error;
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, SELECTOR_READY_DELAY_MS));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function request(port: number, method: string, body?: unknown): Promise<unknown> {
|
function request(port: number, method: string, body?: unknown): Promise<unknown> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@@ -51,13 +70,13 @@ export function createSingboxSelectorService({
|
|||||||
send?: (method: string, body?: unknown) => Promise<unknown>;
|
send?: (method: string, body?: unknown) => Promise<unknown>;
|
||||||
}) {
|
}) {
|
||||||
async function read() {
|
async function read() {
|
||||||
const value = await send('GET') as Record<string, unknown>;
|
const value = await whenReady(() => send('GET')) as Record<string, unknown>;
|
||||||
const role = roleFor(value.now);
|
const role = roleFor(value.now);
|
||||||
if (!role) throw new Error('Sing-box selector вернул неизвестный outbound');
|
if (!role) throw new Error('Sing-box selector вернул неизвестный outbound');
|
||||||
return { role };
|
return { role };
|
||||||
}
|
}
|
||||||
async function select(role: Role) {
|
async function select(role: Role) {
|
||||||
await send('PUT', { name: tagFor(role) });
|
await whenReady(() => send('PUT', { name: tagFor(role) }));
|
||||||
const selected = await read();
|
const selected = await read();
|
||||||
if (selected.role !== role) throw new Error('Sing-box selector не подтвердил переключение');
|
if (selected.role !== role) throw new Error('Sing-box selector не подтвердил переключение');
|
||||||
return selected;
|
return selected;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
export const HARBOR_VERSIONS = Object.freeze({
|
export const HARBOR_VERSIONS = Object.freeze({
|
||||||
macClient: '0.29.0',
|
macClient: '0.29.1',
|
||||||
gatewayClient: '0.30.0',
|
gatewayClient: '0.30.1',
|
||||||
gatewayBackend: '0.30.0',
|
gatewayBackend: '0.30.1',
|
||||||
});
|
});
|
||||||
|
|
||||||
export interface ParsedVersion {
|
export interface ParsedVersion {
|
||||||
|
|||||||
@@ -796,11 +796,13 @@ export function ClientOverviewPage({
|
|||||||
? `Переключаем на ${subscriptionDomain(operationProfile.subscription.host)} · ${operationServer.label}`
|
? `Переключаем на ${subscriptionDomain(operationProfile.subscription.host)} · ${operationServer.label}`
|
||||||
: '';
|
: '';
|
||||||
const failoverIdentity = isGateway && state.failover.enabled
|
const failoverIdentity = isGateway && state.failover.enabled
|
||||||
? `${state.failover.currentRole === 'reserve'
|
? state.failover.currentRole === 'other'
|
||||||
|
? state.failover.reason === 'vpn-stopped'
|
||||||
|
? 'Резерв включится при запуске VPN'
|
||||||
|
: 'Резерв применится после перезапуска VPN'
|
||||||
|
: `${state.failover.currentRole === 'reserve'
|
||||||
? 'Резервный канал'
|
? 'Резервный канал'
|
||||||
: state.failover.currentRole === 'primary'
|
: 'Основной канал'} · ${failoverReasonLabel(state.failover.reason)}`
|
||||||
? 'Основной канал'
|
|
||||||
: 'Текущий канал вне резервной пары'} · ${failoverReasonLabel(state.failover.reason)}`
|
|
||||||
: '';
|
: '';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useEffect, useMemo, useRef, useState, type KeyboardEvent as ReactKeyboardEvent } from 'react';
|
import { useEffect, useMemo, useRef, useState, type FormEvent, type KeyboardEvent as ReactKeyboardEvent } from 'react';
|
||||||
import { flushSync } from 'react-dom';
|
import { flushSync } from 'react-dom';
|
||||||
import { CONNECTIVITY_SITES, MAX_CUSTOM_DIAGNOSTIC_SERVICES, type DiagnosticSettings } from '../../../shared/connectivityDiagnostics.js';
|
import { CONNECTIVITY_SITES, MAX_CUSTOM_DIAGNOSTIC_SERVICES, type DiagnosticSettings } from '../../../shared/connectivityDiagnostics.js';
|
||||||
import { normalizeFailoverPolicy, type FailoverPolicy, type FailoverSnapshot } from '../../../shared/failover.js';
|
import { normalizeFailoverPolicy, type FailoverPolicy, type FailoverSnapshot } from '../../../shared/failover.js';
|
||||||
@@ -72,6 +72,14 @@ const milliseconds = (value: string, fallback: number) => {
|
|||||||
return Number.isFinite(parsed) ? Math.round(parsed * 1000) : fallback;
|
return Number.isFinite(parsed) ? Math.round(parsed * 1000) : fallback;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function pulseNumber(event: FormEvent<HTMLInputElement>) {
|
||||||
|
if (matchMedia('(prefers-reduced-motion: reduce)').matches) return;
|
||||||
|
event.currentTarget.animate([
|
||||||
|
{ color: 'var(--client-accent)', textShadow: '0 0 10px color-mix(in oklch, var(--client-accent) 54%, transparent)' },
|
||||||
|
{ color: 'var(--client-text)', textShadow: '0 0 0 transparent' },
|
||||||
|
], { duration: 320, easing: 'cubic-bezier(0.16, 1, 0.3, 1)' });
|
||||||
|
}
|
||||||
|
|
||||||
const reasonLabel = (reason: string | null) => ({
|
const reasonLabel = (reason: string | null) => ({
|
||||||
'primary-healthy': 'Основной канал работает',
|
'primary-healthy': 'Основной канал работает',
|
||||||
'health-unknown': 'Ожидаем результаты проверки',
|
'health-unknown': 'Ожидаем результаты проверки',
|
||||||
@@ -270,6 +278,8 @@ export function FailoverPanel({
|
|||||||
const [serviceError, setServiceError] = useState('');
|
const [serviceError, setServiceError] = useState('');
|
||||||
const [openPicker, setOpenPicker] = useState('');
|
const [openPicker, setOpenPicker] = useState('');
|
||||||
const [removingCheckId, setRemovingCheckId] = useState('');
|
const [removingCheckId, setRemovingCheckId] = useState('');
|
||||||
|
const [advancedOpen, setAdvancedOpen] = useState(false);
|
||||||
|
const [advancedClosing, setAdvancedClosing] = useState(false);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!dirty) setDraft(snapshot.policy);
|
if (!dirty) setDraft(snapshot.policy);
|
||||||
}, [snapshot.policy, dirty]);
|
}, [snapshot.policy, dirty]);
|
||||||
@@ -374,6 +384,14 @@ export function FailoverPanel({
|
|||||||
if (!document.startViewTransition || matchMedia('(prefers-reduced-motion: reduce)').matches) finish();
|
if (!document.startViewTransition || matchMedia('(prefers-reduced-motion: reduce)').matches) finish();
|
||||||
else document.startViewTransition(finish);
|
else document.startViewTransition(finish);
|
||||||
};
|
};
|
||||||
|
const toggleAdvanced = () => {
|
||||||
|
if (!advancedOpen) {
|
||||||
|
setAdvancedOpen(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (matchMedia('(prefers-reduced-motion: reduce)').matches) setAdvancedOpen(false);
|
||||||
|
else setAdvancedClosing(true);
|
||||||
|
};
|
||||||
|
|
||||||
return <Drawer
|
return <Drawer
|
||||||
panelRef={feature.panelRef}
|
panelRef={feature.panelRef}
|
||||||
@@ -415,14 +433,20 @@ export function FailoverPanel({
|
|||||||
))?.id || '';
|
))?.id || '';
|
||||||
const healthLabel = missing
|
const healthLabel = missing
|
||||||
? 'Цель недоступна'
|
? 'Цель недоступна'
|
||||||
|
: !draft.enabled
|
||||||
|
? 'Выключен'
|
||||||
|
: snapshot.reason === 'vpn-stopped' || snapshot.activation === 'inactive'
|
||||||
|
? 'VPN выключен'
|
||||||
|
: snapshot.activation === 'pending'
|
||||||
|
? 'Ожидает запуска VPN'
|
||||||
: channel === 'primary' && snapshot.reason === 'failure-window'
|
: channel === 'primary' && snapshot.reason === 'failure-window'
|
||||||
? `Нестабилен · ${seconds(Math.max(0, Date.now() - Date.parse(snapshot.primary.stateSince || new Date().toISOString())))} из ${seconds(draft.failureWindowMs)} с`
|
? `Нестабилен · ${seconds(Math.max(0, Date.now() - Date.parse(snapshot.primary.stateSince || new Date().toISOString())))} из ${seconds(draft.failureWindowMs)} с`
|
||||||
: channel === 'primary' && snapshot.currentRole === 'reserve' && health === 'healthy' && snapshot.reason === 'recovery-hold'
|
: channel === 'primary' && snapshot.currentRole === 'reserve' && health === 'healthy' && snapshot.reason === 'recovery-hold'
|
||||||
? 'Восстанавливается'
|
? 'Восстанавливается'
|
||||||
: health === 'healthy' ? 'Работает' : health === 'unhealthy' ? 'Недоступен' : health === 'not-monitoring' ? 'Не проверяется' : 'Нет данных';
|
: health === 'healthy' ? 'Работает' : health === 'unhealthy' ? 'Недоступен' : health === 'not-monitoring' ? 'Не проверяется' : 'Ещё не проверен';
|
||||||
return <section className="client-failover-channel" key={channel}>
|
return <section className="client-failover-channel" data-channel={channel} key={channel}>
|
||||||
<div className="client-failover-channel-title">
|
<div className="client-failover-channel-title">
|
||||||
<span>{channel === 'primary' ? 'Основной' : 'Резервный'}</span>
|
<span><b>{channel === 'primary' ? 'Основной' : 'Резервный'}</b><i aria-hidden="true">=</i></span>
|
||||||
<strong className={health === 'healthy' ? 'is-healthy' : health === 'unhealthy' || missing ? 'is-unhealthy' : ''}>{healthLabel}</strong>
|
<strong className={health === 'healthy' ? 'is-healthy' : health === 'unhealthy' || missing ? 'is-unhealthy' : ''}>{healthLabel}</strong>
|
||||||
</div>
|
</div>
|
||||||
<FailoverPicker
|
<FailoverPicker
|
||||||
@@ -462,6 +486,7 @@ export function FailoverPanel({
|
|||||||
aria-label={`Таймаут проверки: ${service?.label || 'сервис недоступен'}`}
|
aria-label={`Таймаут проверки: ${service?.label || 'сервис недоступен'}`}
|
||||||
value={seconds(check.timeoutMs)}
|
value={seconds(check.timeoutMs)}
|
||||||
disabled={blocked || !draft.enabled}
|
disabled={blocked || !draft.enabled}
|
||||||
|
onInput={pulseNumber}
|
||||||
onChange={(event) => updateChecks((checks) => checks.map((item) => item.serviceId === check.serviceId
|
onChange={(event) => updateChecks((checks) => checks.map((item) => item.serviceId === check.serviceId
|
||||||
? { ...item, timeoutMs: milliseconds(event.target.value, item.timeoutMs) }
|
? { ...item, timeoutMs: milliseconds(event.target.value, item.timeoutMs) }
|
||||||
: item))}
|
: item))}
|
||||||
@@ -473,12 +498,17 @@ export function FailoverPanel({
|
|||||||
aria-label={`Убрать проверку: ${service?.label || 'сервис недоступен'}`}
|
aria-label={`Убрать проверку: ${service?.label || 'сервис недоступен'}`}
|
||||||
disabled={blocked || !draft.enabled || draft.checks.length === 1 || Boolean(removingCheckId)}
|
disabled={blocked || !draft.enabled || draft.checks.length === 1 || Boolean(removingCheckId)}
|
||||||
onClick={() => removeCheck(check.serviceId)}
|
onClick={() => removeCheck(check.serviceId)}
|
||||||
>×</button>
|
>
|
||||||
|
<svg viewBox="0 0 24 24" aria-hidden="true">
|
||||||
|
<path className="client-failover-remove-lid" d="M8 7V5h8v2m-11 0h14" />
|
||||||
|
<path d="M7 7l1 13h8l1-13M10 10v7m4-7v7" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
</div>;
|
</div>;
|
||||||
})}
|
})}
|
||||||
{!addingService && <FailoverPicker
|
{!addingService && <FailoverPicker
|
||||||
id="client-failover-service-options"
|
id="client-failover-service-options"
|
||||||
label="+ Добавить проверку"
|
label="Добавить проверку"
|
||||||
value=""
|
value=""
|
||||||
options={servicePickerOptions}
|
options={servicePickerOptions}
|
||||||
open={openPicker === 'services' && !blocked && draft.enabled}
|
open={openPicker === 'services' && !blocked && draft.enabled}
|
||||||
@@ -502,9 +532,9 @@ export function FailoverPanel({
|
|||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<section className="client-failover-timing" aria-label="Пороги переключения">
|
<section className="client-failover-timing" aria-label="Пороги переключения">
|
||||||
<label><span>Проверять каждые, сек</span><input type="number" min="15" max="900" disabled={blocked || !draft.enabled} value={seconds(draft.intervalMs)} onChange={(event) => update({ intervalMs: milliseconds(event.target.value, draft.intervalMs) })} /></label>
|
<label><span>Проверять каждые, сек</span><input type="number" min="15" max="900" disabled={blocked || !draft.enabled} value={seconds(draft.intervalMs)} onInput={pulseNumber} onChange={(event) => update({ intervalMs: milliseconds(event.target.value, draft.intervalMs) })} /></label>
|
||||||
<label><span>Сбой должен длиться, сек</span><input type="number" min={seconds(draft.intervalMs * 2)} max="1800" disabled={blocked || !draft.enabled} value={seconds(draft.failureWindowMs)} onChange={(event) => update({ failureWindowMs: milliseconds(event.target.value, draft.failureWindowMs) })} /></label>
|
<label><span>Сбой должен длиться, сек</span><input type="number" min={seconds(draft.intervalMs * 2)} max="1800" disabled={blocked || !draft.enabled} value={seconds(draft.failureWindowMs)} onInput={pulseNumber} onChange={(event) => update({ failureWindowMs: milliseconds(event.target.value, draft.failureWindowMs) })} /></label>
|
||||||
<label><span>Восстановление, сек</span><input type="number" min="60" max="86400" disabled={blocked || !draft.enabled} value={seconds(draft.recoveryWindowMs)} onChange={(event) => update({ recoveryWindowMs: milliseconds(event.target.value, draft.recoveryWindowMs) })} /></label>
|
<label><span>Восстановление, сек</span><input type="number" min="60" max="86400" disabled={blocked || !draft.enabled} value={seconds(draft.recoveryWindowMs)} onInput={pulseNumber} onChange={(event) => update({ recoveryWindowMs: milliseconds(event.target.value, draft.recoveryWindowMs) })} /></label>
|
||||||
<div className="client-failover-traffic-switch">
|
<div className="client-failover-traffic-switch">
|
||||||
<span><strong>Переключение во время работы</strong><small>{draft.trafficGuard.enabled ? 'Ждать тишины перед автоматическим переключением' : 'Переключать сразу после подтверждённого сбоя'}</small></span>
|
<span><strong>Переключение во время работы</strong><small>{draft.trafficGuard.enabled ? 'Ждать тишины перед автоматическим переключением' : 'Переключать сразу после подтверждённого сбоя'}</small></span>
|
||||||
<HarborSwitch
|
<HarborSwitch
|
||||||
@@ -514,22 +544,40 @@ export function FailoverPanel({
|
|||||||
onChange={(enabled) => update({ trafficGuard: { ...draft.trafficGuard, enabled } })}
|
onChange={(enabled) => update({ trafficGuard: { ...draft.trafficGuard, enabled } })}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<label><span>Тишина перед переключением, сек</span><input type="number" min="5" max="600" disabled={blocked || !draft.enabled || !draft.trafficGuard.enabled} value={seconds(draft.trafficGuard.quietWindowMs)} onChange={(event) => update({ trafficGuard: { ...draft.trafficGuard, quietWindowMs: milliseconds(event.target.value, draft.trafficGuard.quietWindowMs) } })} /></label>
|
<label><span>Тишина перед переключением, сек</span><input type="number" min="5" max="600" disabled={blocked || !draft.enabled || !draft.trafficGuard.enabled} value={seconds(draft.trafficGuard.quietWindowMs)} onInput={pulseNumber} onChange={(event) => update({ trafficGuard: { ...draft.trafficGuard, quietWindowMs: milliseconds(event.target.value, draft.trafficGuard.quietWindowMs) } })} /></label>
|
||||||
<label><span>Активный трафик, КБ/с</span><input type="number" min="1" max="102400" disabled={blocked || !draft.enabled || !draft.trafficGuard.enabled} value={Math.round(draft.trafficGuard.thresholdBytesPerSecond / 1024)} onChange={(event) => update({ trafficGuard: { ...draft.trafficGuard, thresholdBytesPerSecond: Number(event.target.value) * 1024 } })} /></label>
|
<label><span>Активный трафик, КБ/с</span><input type="number" min="1" max="102400" disabled={blocked || !draft.enabled || !draft.trafficGuard.enabled} value={Math.round(draft.trafficGuard.thresholdBytesPerSecond / 1024)} onInput={pulseNumber} onChange={(event) => update({ trafficGuard: { ...draft.trafficGuard, thresholdBytesPerSecond: Number(event.target.value) * 1024 } })} /></label>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<details className="client-failover-advanced"><summary>Защита от повторных сбоев</summary>
|
<section className={`client-failover-advanced${advancedOpen ? ' is-open' : ''}${advancedClosing ? ' is-closing' : ''}`}>
|
||||||
<label><span>Минимум на резерве, сек</span><input type="number" min="60" max="86400" disabled={blocked || !draft.enabled} value={seconds(draft.minimumReserveMs)} onChange={(event) => update({ minimumReserveMs: milliseconds(event.target.value, draft.minimumReserveMs) })} /></label>
|
<button type="button" aria-expanded={advancedOpen && !advancedClosing} aria-controls="client-failover-advanced-options" onClick={toggleAdvanced}>
|
||||||
<label><span>Падений до карантина</span><input type="number" min="2" max="10" disabled={blocked || !draft.enabled} value={draft.flapProtection.count} onChange={(event) => update({ flapProtection: { ...draft.flapProtection, count: Number(event.target.value) } })} /></label>
|
<i aria-hidden="true" />
|
||||||
<label><span>Окно повторных сбоев, ч</span><input type="number" min="1" max="72" disabled={blocked || !draft.enabled} value={Math.round(draft.flapProtection.windowMs / 3_600_000)} onChange={(event) => update({ flapProtection: { ...draft.flapProtection, windowMs: Number(event.target.value) * 3_600_000 } })} /></label>
|
<span>Защита от повторных сбоев</span>
|
||||||
<label><span>Карантин основного, мин</span><input type="number" min="10" max="10080" disabled={blocked || !draft.enabled} value={Math.round(draft.flapProtection.quarantineMs / 60_000)} onChange={(event) => update({ flapProtection: { ...draft.flapProtection, quarantineMs: Number(event.target.value) * 60_000 } })} /></label>
|
</button>
|
||||||
</details>
|
{advancedOpen && <div
|
||||||
|
id="client-failover-advanced-options"
|
||||||
|
className="client-failover-advanced-options"
|
||||||
|
inert={advancedClosing ? true : undefined}
|
||||||
|
onAnimationEnd={(event) => {
|
||||||
|
if (!advancedClosing || event.target !== event.currentTarget) return;
|
||||||
|
setAdvancedClosing(false);
|
||||||
|
setAdvancedOpen(false);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<label><span>Минимум на резерве, сек</span><input type="number" min="60" max="86400" disabled={blocked || !draft.enabled} value={seconds(draft.minimumReserveMs)} onInput={pulseNumber} onChange={(event) => update({ minimumReserveMs: milliseconds(event.target.value, draft.minimumReserveMs) })} /></label>
|
||||||
|
<label><span>Падений до карантина</span><input type="number" min="2" max="10" disabled={blocked || !draft.enabled} value={draft.flapProtection.count} onInput={pulseNumber} onChange={(event) => update({ flapProtection: { ...draft.flapProtection, count: Number(event.target.value) } })} /></label>
|
||||||
|
<label><span>Окно повторных сбоев, ч</span><input type="number" min="1" max="72" disabled={blocked || !draft.enabled} value={Math.round(draft.flapProtection.windowMs / 3_600_000)} onInput={pulseNumber} onChange={(event) => update({ flapProtection: { ...draft.flapProtection, windowMs: Number(event.target.value) * 3_600_000 } })} /></label>
|
||||||
|
<label><span>Карантин основного, мин</span><input type="number" min="10" max="10080" disabled={blocked || !draft.enabled} value={Math.round(draft.flapProtection.quarantineMs / 60_000)} onInput={pulseNumber} onChange={(event) => update({ flapProtection: { ...draft.flapProtection, quarantineMs: Number(event.target.value) * 60_000 } })} /></label>
|
||||||
|
</div>}
|
||||||
|
</section>
|
||||||
|
|
||||||
<div className="client-failover-runtime">
|
<div className="client-failover-runtime">
|
||||||
<strong role="status" aria-live="polite">{blocked ? 'Harbor выполняет действие…' : snapshot.activation === 'pending' ? 'Включится при следующем запуске VPN' : reasonLabel(snapshot.reason)}</strong>
|
<strong role="status" aria-live="polite">{blocked ? 'Harbor выполняет действие…' : snapshot.activation === 'pending' ? 'Включится при следующем запуске VPN' : reasonLabel(snapshot.reason)}</strong>
|
||||||
<span>Новые соединения: {role ? targetLabel(profiles, snapshot[role].target) : 'текущий канал вне настроенной пары'}</span>
|
<span>{role
|
||||||
|
? `Новые соединения: ${targetLabel(profiles, snapshot[role].target)}`
|
||||||
|
: snapshot.reason === 'vpn-stopped'
|
||||||
|
? `При запуске VPN: ${targetLabel(profiles, draft.primary)}`
|
||||||
|
: `После перезапуска VPN: ${targetLabel(profiles, draft.primary)}`}</span>
|
||||||
{snapshot.nextDecisionAt && <span>Следующее решение не раньше чем через {seconds(Math.max(0, Date.parse(snapshot.nextDecisionAt) - Date.now()))} с</span>}
|
{snapshot.nextDecisionAt && <span>Следующее решение не раньше чем через {seconds(Math.max(0, Date.parse(snapshot.nextDecisionAt) - Date.now()))} с</span>}
|
||||||
{snapshot.currentRole === 'other' && <span>Чтобы запустить автоматику, выключите VPN и включите снова на основном канале.</span>}
|
|
||||||
{activity && <span>{activity.state === 'active' ? `Активный трафик · ${Math.round(activity.totalBytesPerSecond / 1024)} КБ/с · соединений: ${activity.transmittingConnections}` : activity.state === 'quiet' ? `Проверяем тишину · ${Math.min(seconds(quietElapsed), seconds(draft.trafficGuard.quietWindowMs))} из ${seconds(draft.trafficGuard.quietWindowMs)} с` : 'Не удалось определить активность · автоматическое переключение остановлено'}</span>}
|
{activity && <span>{activity.state === 'active' ? `Активный трафик · ${Math.round(activity.totalBytesPerSecond / 1024)} КБ/с · соединений: ${activity.transmittingConnections}` : activity.state === 'quiet' ? `Проверяем тишину · ${Math.min(seconds(quietElapsed), seconds(draft.trafficGuard.quietWindowMs))} из ${seconds(draft.trafficGuard.quietWindowMs)} с` : 'Не удалось определить активность · автоматическое переключение остановлено'}</span>}
|
||||||
{activity?.blockers.slice(0, 2).map((blocker) => <small key={`${blocker.device}:${blocker.service}`}>{blocker.device} · {blocker.service} · {Math.round((blocker.uploadBytesPerSecond + blocker.downloadBytesPerSecond) / 1024)} КБ/с</small>)}
|
{activity?.blockers.slice(0, 2).map((blocker) => <small key={`${blocker.device}:${blocker.service}`}>{blocker.device} · {blocker.service} · {Math.round((blocker.uploadBytesPerSecond + blocker.downloadBytesPerSecond) / 1024)} КБ/с</small>)}
|
||||||
{activity && activity.blockers.length > 2 && <small>Ещё {activity.blockers.length - 2}</small>}
|
{activity && activity.blockers.length > 2 && <small>Ещё {activity.blockers.length - 2}</small>}
|
||||||
|
|||||||
@@ -11,12 +11,18 @@
|
|||||||
.client-failover-switch[aria-checked='true'] > span { background: var(--client-text); box-shadow: 0 0 10px color-mix(in oklch, var(--client-accent) 46%, transparent); transform: translateX(20px); }
|
.client-failover-switch[aria-checked='true'] > span { background: var(--client-text); box-shadow: 0 0 10px color-mix(in oklch, var(--client-accent) 46%, transparent); transform: translateX(20px); }
|
||||||
.client-failover-switch:disabled { cursor: default; opacity: .42; }
|
.client-failover-switch:disabled { cursor: default; opacity: .42; }
|
||||||
.client-failover-switch:focus-visible { outline: 2px solid var(--client-accent); outline-offset: 0; border-radius: 999px; }
|
.client-failover-switch:focus-visible { outline: 2px solid var(--client-accent); outline-offset: 0; border-radius: 999px; }
|
||||||
.client-failover-channel { position: relative; display: grid; gap: 6px; }
|
.client-failover-channel { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px; min-height: 52px; }
|
||||||
.client-failover-channel-title { min-height: 28px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
|
.client-failover-channel-title { display: contents; }
|
||||||
.client-failover-channel-title strong { min-width: 0; color: var(--client-muted); font: var(--type-label); letter-spacing: var(--type-label-tracking); text-transform: var(--type-label-transform); text-align: right; transition: color 600ms ease, filter 600ms ease; }
|
.client-failover-channel-title > span { display: flex; align-items: center; gap: 8px; font: var(--type-body); letter-spacing: var(--type-body-tracking); text-transform: var(--type-body-transform); }
|
||||||
|
.client-failover-channel-title > span b { font: inherit; }
|
||||||
|
.client-failover-channel-title > span i { color: var(--client-muted); font-style: normal; }
|
||||||
|
.client-failover-channel[data-channel='primary'] .client-failover-channel-title > span b { color: var(--harbor-connect); text-shadow: 0 0 9px color-mix(in oklch, var(--harbor-connect) 30%, transparent); }
|
||||||
|
.client-failover-channel[data-channel='reserve'] .client-failover-channel-title > span b { color: var(--harbor-gateway); text-shadow: 0 0 9px color-mix(in oklch, var(--harbor-gateway) 30%, transparent); }
|
||||||
|
.client-failover-channel-title strong { grid-column: 3; min-width: 0; color: var(--client-muted); font: var(--type-label); letter-spacing: var(--type-label-tracking); text-transform: var(--type-label-transform); text-align: right; white-space: nowrap; transition: color 600ms ease, filter 600ms ease; }
|
||||||
.client-failover-channel-title strong.is-healthy { color: var(--client-accent); }
|
.client-failover-channel-title strong.is-healthy { color: var(--client-accent); }
|
||||||
.client-failover-channel-title strong.is-unhealthy { color: oklch(0.68 0.15 28); }
|
.client-failover-channel-title strong.is-unhealthy { color: oklch(0.68 0.15 28); }
|
||||||
.client-failover-picker { position: relative; min-width: 0; z-index: 1; }
|
.client-failover-picker { position: relative; min-width: 0; z-index: 1; }
|
||||||
|
.client-failover-channel > .client-failover-picker { grid-column: 2; }
|
||||||
.client-failover-picker.is-open { z-index: 6; }
|
.client-failover-picker.is-open { z-index: 6; }
|
||||||
.client-failover-picker-trigger { width: 100%; min-height: 42px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 2px; border: 0; border-bottom: 1px solid var(--client-border); background: transparent; color: var(--client-text); font: var(--type-body); letter-spacing: var(--type-body-tracking); text-transform: var(--type-body-transform); text-align: left; box-shadow: 0 1px 0 transparent; cursor: pointer; transition: color 220ms ease, box-shadow 300ms ease, text-shadow 300ms ease; }
|
.client-failover-picker-trigger { width: 100%; min-height: 42px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 2px; border: 0; border-bottom: 1px solid var(--client-border); background: transparent; color: var(--client-text); font: var(--type-body); letter-spacing: var(--type-body-tracking); text-transform: var(--type-body-transform); text-align: left; box-shadow: 0 1px 0 transparent; cursor: pointer; transition: color 220ms ease, box-shadow 300ms ease, text-shadow 300ms ease; }
|
||||||
.client-failover-picker-trigger span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
.client-failover-picker-trigger span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||||
@@ -24,7 +30,7 @@
|
|||||||
.client-failover-picker.is-open .client-failover-picker-trigger { color: var(--client-accent); box-shadow: 0 1px 0 color-mix(in oklch, var(--client-accent) 64%, transparent); text-shadow: 0 0 10px color-mix(in oklch, var(--client-accent) 34%, transparent); }
|
.client-failover-picker.is-open .client-failover-picker-trigger { color: var(--client-accent); box-shadow: 0 1px 0 color-mix(in oklch, var(--client-accent) 64%, transparent); text-shadow: 0 0 10px color-mix(in oklch, var(--client-accent) 34%, transparent); }
|
||||||
.client-failover-picker.is-open .client-failover-picker-trigger svg { transform: rotate(180deg); }
|
.client-failover-picker.is-open .client-failover-picker-trigger svg { transform: rotate(180deg); }
|
||||||
.client-failover-picker-trigger:disabled { color: var(--client-muted); cursor: default; opacity: .45; }
|
.client-failover-picker-trigger:disabled { color: var(--client-muted); cursor: default; opacity: .45; }
|
||||||
.client-failover-picker-trigger:focus-visible { outline: 2px solid var(--client-accent); outline-offset: 2px; }
|
.client-failover-picker-trigger:focus-visible { outline: 0; color: var(--client-accent); box-shadow: 0 1px 0 color-mix(in oklch, var(--client-accent) 72%, transparent); text-shadow: 0 0 10px color-mix(in oklch, var(--client-accent) 34%, transparent); }
|
||||||
.client-failover-picker-list { position: absolute; top: calc(100% + 3px); left: -8px; z-index: 5; width: calc(100% + 16px); max-height: min(320px, 48vh); display: grid; gap: 1px; padding: 7px 8px; overflow-y: auto; background: color-mix(in oklch, var(--client-bg) 92%, transparent); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); opacity: 0; visibility: hidden; filter: blur(6px); transform: translateY(-6px); pointer-events: none; transition: opacity 180ms ease, filter 180ms ease, transform 180ms cubic-bezier(0.16, 1, 0.3, 1), visibility 0s 180ms; }
|
.client-failover-picker-list { position: absolute; top: calc(100% + 3px); left: -8px; z-index: 5; width: calc(100% + 16px); max-height: min(320px, 48vh); display: grid; gap: 1px; padding: 7px 8px; overflow-y: auto; background: color-mix(in oklch, var(--client-bg) 92%, transparent); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); opacity: 0; visibility: hidden; filter: blur(6px); transform: translateY(-6px); pointer-events: none; transition: opacity 180ms ease, filter 180ms ease, transform 180ms cubic-bezier(0.16, 1, 0.3, 1), visibility 0s 180ms; }
|
||||||
.client-failover-picker.is-open .client-failover-picker-list { opacity: 1; visibility: visible; filter: blur(0); transform: translateY(0); pointer-events: auto; transition: opacity 240ms ease, filter 240ms ease, transform 240ms cubic-bezier(0.16, 1, 0.3, 1), visibility 0s; }
|
.client-failover-picker.is-open .client-failover-picker-list { opacity: 1; visibility: visible; filter: blur(0); transform: translateY(0); pointer-events: auto; transition: opacity 240ms ease, filter 240ms ease, transform 240ms cubic-bezier(0.16, 1, 0.3, 1), visibility 0s; }
|
||||||
.client-failover-picker-list button { min-height: 34px; padding: 6px; border: 0; background: transparent; color: var(--client-muted); font: var(--type-label); letter-spacing: var(--type-label-tracking); text-transform: var(--type-label-transform); text-align: left; cursor: pointer; opacity: 0; filter: blur(5px); transform: translateY(-4px); transition: color 180ms ease, opacity 180ms ease, filter 180ms ease, transform 240ms cubic-bezier(0.16, 1, 0.3, 1); }
|
.client-failover-picker-list button { min-height: 34px; padding: 6px; border: 0; background: transparent; color: var(--client-muted); font: var(--type-label); letter-spacing: var(--type-label-tracking); text-transform: var(--type-label-transform); text-align: left; cursor: pointer; opacity: 0; filter: blur(5px); transform: translateY(-4px); transition: color 180ms ease, opacity 180ms ease, filter 180ms ease, transform 240ms cubic-bezier(0.16, 1, 0.3, 1); }
|
||||||
@@ -32,20 +38,25 @@
|
|||||||
.client-failover-picker-list button:hover, .client-failover-picker-list button:focus-visible, .client-failover-picker-list button[aria-selected='true'] { outline: 0; color: var(--client-accent); text-shadow: 0 0 9px color-mix(in oklch, var(--client-accent) 38%, transparent); }
|
.client-failover-picker-list button:hover, .client-failover-picker-list button:focus-visible, .client-failover-picker-list button[aria-selected='true'] { outline: 0; color: var(--client-accent); text-shadow: 0 0 9px color-mix(in oklch, var(--client-accent) 38%, transparent); }
|
||||||
.client-failover-picker-list button[aria-disabled='true'] { color: color-mix(in oklch, var(--client-muted) 58%, transparent); cursor: default; text-shadow: none; }
|
.client-failover-picker-list button[aria-disabled='true'] { color: color-mix(in oklch, var(--client-muted) 58%, transparent); cursor: default; text-shadow: none; }
|
||||||
.client-failover-timing label, .client-failover-advanced label { display: grid; grid-template-columns: minmax(0, 1fr) minmax(150px, 48%); align-items: center; gap: 16px; min-height: 38px; color: var(--client-muted); font: var(--type-label); letter-spacing: var(--type-label-tracking); text-transform: var(--type-label-transform); }
|
.client-failover-timing label, .client-failover-advanced label { display: grid; grid-template-columns: minmax(0, 1fr) minmax(150px, 48%); align-items: center; gap: 16px; min-height: 38px; color: var(--client-muted); font: var(--type-label); letter-spacing: var(--type-label-tracking); text-transform: var(--type-label-transform); }
|
||||||
.client-failover-timing input, .client-failover-advanced input { min-width: 0; min-height: 34px; border: 0; border-bottom: 1px solid var(--client-border); background: transparent; color: var(--client-text); font: var(--type-body); letter-spacing: var(--type-body-tracking); text-transform: var(--type-body-transform); }
|
.client-failover-timing input, .client-failover-advanced input { min-width: 0; min-height: 38px; padding: 0 4px; border: 0; border-bottom: 1px solid var(--client-border); border-radius: 0; background: transparent; color: var(--client-text); font: var(--type-item-title); font-variant-numeric: var(--numeric-tabular); letter-spacing: var(--type-item-title-tracking); text-align: center; text-transform: var(--type-item-title-transform); appearance: textfield; transition: color 220ms ease, border-color 220ms ease, box-shadow 220ms ease, text-shadow 220ms ease; }
|
||||||
.client-failover-timing input:disabled, .client-failover-advanced input:disabled { color: var(--client-muted); opacity: .45; }
|
.client-failover-timing input:disabled, .client-failover-advanced input:disabled { color: var(--client-muted); opacity: .45; }
|
||||||
.client-failover-services { display: grid; gap: 9px; margin: 0; padding: 0; border: 0; }
|
.client-failover-services { display: grid; gap: 9px; margin: 0; padding: 0; border: 0; }
|
||||||
.client-failover-services legend { margin-bottom: 10px; }
|
.client-failover-services legend { margin-bottom: 10px; }
|
||||||
.client-failover-service { display: grid; grid-template-columns: minmax(0, 1fr) auto 32px; align-items: center; gap: 12px; min-height: 38px; animation: failover-service-in 260ms cubic-bezier(0.16, 1, 0.3, 1) both; }
|
.client-failover-service { display: grid; grid-template-columns: minmax(0, 1fr) auto 32px; align-items: center; gap: 12px; min-height: 38px; animation: failover-service-in 260ms cubic-bezier(0.16, 1, 0.3, 1) both; }
|
||||||
.client-failover-service.is-removing { animation: failover-service-out 180ms ease both; pointer-events: none; }
|
.client-failover-service.is-removing { animation: failover-service-out 300ms ease both; pointer-events: none; }
|
||||||
.client-failover-service-name { min-width: 0; overflow: hidden; color: var(--client-text); font: var(--type-body); letter-spacing: var(--type-body-tracking); text-overflow: ellipsis; text-transform: var(--type-body-transform); white-space: nowrap; }
|
.client-failover-service-name { min-width: 0; overflow: hidden; color: var(--client-text); font: var(--type-body); letter-spacing: var(--type-body-tracking); text-overflow: ellipsis; text-transform: var(--type-body-transform); white-space: nowrap; }
|
||||||
.client-failover-service-timeout { display: flex; align-items: center; gap: 8px; color: var(--client-muted); font: var(--type-label); letter-spacing: var(--type-label-tracking); text-transform: var(--type-label-transform); }
|
.client-failover-service-timeout { display: flex; align-items: center; gap: 8px; color: var(--client-muted); font: var(--type-label); letter-spacing: var(--type-label-tracking); text-transform: var(--type-label-transform); }
|
||||||
.client-failover-service-timeout input { width: 52px; min-height: 30px; border: 0; border-bottom: 1px solid var(--client-border); background: transparent; color: var(--client-text); font: var(--type-body); letter-spacing: var(--type-body-tracking); text-transform: var(--type-body-transform); }
|
.client-failover-service-timeout input { width: 58px; min-height: 34px; padding: 0 4px; border: 0; border-bottom: 1px solid var(--client-border); border-radius: 0; background: transparent; color: var(--client-text); font: var(--type-item-title); font-variant-numeric: var(--numeric-tabular); letter-spacing: var(--type-item-title-tracking); text-align: center; text-transform: var(--type-item-title-transform); appearance: textfield; transition: color 220ms ease, border-color 220ms ease, box-shadow 220ms ease, text-shadow 220ms ease; }
|
||||||
.client-failover-remove-service { width: 32px; height: 32px; padding: 0; border: 0; background: transparent; color: var(--client-muted); font: var(--type-icon-close); cursor: pointer; transition: color 180ms ease, transform 240ms cubic-bezier(0.16, 1, 0.3, 1); }
|
.client-failover-remove-service { width: 32px; height: 32px; display: grid; place-items: center; padding: 0; border: 0; background: transparent; color: oklch(0.62 0.16 28); cursor: pointer; transition: color 180ms ease, filter 240ms ease; }
|
||||||
.client-failover-remove-service:hover:not(:disabled), .client-failover-remove-service:focus-visible { outline: 0; color: oklch(0.68 0.15 28); transform: scale(1.08); }
|
.client-failover-remove-service svg { width: 19px; height: 19px; overflow: visible; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
|
||||||
|
.client-failover-remove-lid { transform-origin: center 7px; transition: transform 260ms cubic-bezier(0.16, 1, 0.3, 1); }
|
||||||
|
.client-failover-remove-service:hover:not(:disabled), .client-failover-remove-service:focus-visible { outline: 0; color: oklch(0.7 0.18 28); filter: drop-shadow(0 0 7px oklch(0.7 0.18 28 / 0.42)); }
|
||||||
|
.client-failover-remove-service:hover:not(:disabled) .client-failover-remove-lid, .client-failover-remove-service:focus-visible .client-failover-remove-lid { transform: translateY(-2px) rotate(-8deg); }
|
||||||
.client-failover-remove-service:disabled { cursor: default; opacity: .28; }
|
.client-failover-remove-service:disabled { cursor: default; opacity: .28; }
|
||||||
.client-failover-services > .client-failover-picker { justify-self: start; min-width: 210px; }
|
.client-failover-services > .client-failover-picker { justify-self: start; min-width: 210px; }
|
||||||
.client-failover-services > .client-failover-picker .client-failover-picker-trigger { color: var(--client-accent); font: var(--type-control); letter-spacing: var(--type-control-tracking); text-transform: var(--type-control-transform); }
|
.client-failover-services > .client-failover-picker .client-failover-picker-trigger { color: var(--client-accent); font: var(--type-control); letter-spacing: var(--type-control-tracking); text-transform: var(--type-control-transform); }
|
||||||
|
.client-failover-services > .client-failover-picker .client-failover-picker-trigger::before { content: '+'; flex: 0 0 auto; width: 28px; height: 28px; display: grid; place-items: center; color: var(--client-accent); font: var(--type-drawer-title); letter-spacing: var(--type-drawer-title-tracking); text-transform: var(--type-drawer-title-transform); transition: transform 240ms cubic-bezier(0.16, 1, 0.3, 1), filter 240ms ease; }
|
||||||
|
.client-failover-services > .client-failover-picker.is-open .client-failover-picker-trigger::before { transform: rotate(45deg); filter: drop-shadow(0 0 6px color-mix(in oklch, var(--client-accent) 44%, transparent)); }
|
||||||
.client-failover-services > .client-failover-picker .client-failover-picker-list { width: max-content; min-width: calc(100% + 16px); }
|
.client-failover-services > .client-failover-picker .client-failover-picker-list { width: max-content; min-width: calc(100% + 16px); }
|
||||||
.client-failover-service-editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: 8px 12px; padding: 8px 0; animation: failover-service-in 260ms cubic-bezier(0.16, 1, 0.3, 1) both; }
|
.client-failover-service-editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: 8px 12px; padding: 8px 0; animation: failover-service-in 260ms cubic-bezier(0.16, 1, 0.3, 1) both; }
|
||||||
.client-failover-service-editor input { min-width: 0; min-height: 34px; border: 0; border-bottom: 1px solid var(--client-border); background: transparent; color: var(--client-text); font: var(--type-body); letter-spacing: var(--type-body-tracking); text-transform: var(--type-body-transform); }
|
.client-failover-service-editor input { min-width: 0; min-height: 34px; border: 0; border-bottom: 1px solid var(--client-border); background: transparent; color: var(--client-text); font: var(--type-body); letter-spacing: var(--type-body-tracking); text-transform: var(--type-body-transform); }
|
||||||
@@ -57,7 +68,16 @@
|
|||||||
.client-failover-traffic-switch > span { min-width: 0; display: grid; gap: 3px; }
|
.client-failover-traffic-switch > span { min-width: 0; display: grid; gap: 3px; }
|
||||||
.client-failover-traffic-switch strong { color: var(--client-text); font: var(--type-body); letter-spacing: var(--type-body-tracking); text-transform: var(--type-body-transform); }
|
.client-failover-traffic-switch strong { color: var(--client-text); font: var(--type-body); letter-spacing: var(--type-body-tracking); text-transform: var(--type-body-transform); }
|
||||||
.client-failover-traffic-switch small { color: var(--client-muted); font: var(--type-label); letter-spacing: var(--type-label-tracking); text-transform: var(--type-label-transform); }
|
.client-failover-traffic-switch small { color: var(--client-muted); font: var(--type-label); letter-spacing: var(--type-label-tracking); text-transform: var(--type-label-transform); }
|
||||||
.client-failover-advanced summary { min-height: 38px; color: var(--client-accent); font: var(--type-control); letter-spacing: var(--type-control-tracking); text-transform: var(--type-control-transform); cursor: pointer; }
|
.client-failover-advanced { display: grid; gap: 5px; }
|
||||||
|
.client-failover-advanced > button { width: fit-content; min-height: 42px; display: flex; align-items: center; gap: 10px; padding: 0; border: 0; background: transparent; color: var(--client-accent); font: var(--type-control); letter-spacing: var(--type-control-tracking); text-transform: var(--type-control-transform); cursor: pointer; }
|
||||||
|
.client-failover-advanced > button i { position: relative; width: 14px; height: 14px; }
|
||||||
|
.client-failover-advanced > button i::before, .client-failover-advanced > button i::after { content: ''; position: absolute; top: 6px; left: 0; width: 14px; height: 1px; background: currentColor; transform-origin: center; transition: transform 420ms cubic-bezier(0.16, 1, 0.3, 1), opacity 280ms ease; }
|
||||||
|
.client-failover-advanced > button i::after { transform: rotate(90deg); }
|
||||||
|
.client-failover-advanced.is-open > button i::before { transform: rotate(180deg); }
|
||||||
|
.client-failover-advanced.is-open > button i::after { opacity: 0; transform: rotate(180deg); }
|
||||||
|
.client-failover-advanced > button:focus-visible { outline: 0; text-shadow: 0 0 10px color-mix(in oklch, var(--client-accent) 44%, transparent); }
|
||||||
|
.client-failover-advanced-options { display: grid; gap: 5px; animation: failover-advanced-in 260ms cubic-bezier(0.16, 1, 0.3, 1) both; }
|
||||||
|
.client-failover-advanced.is-closing .client-failover-advanced-options { animation: failover-advanced-out 220ms ease both; pointer-events: none; }
|
||||||
.client-failover-runtime { min-height: 132px; display: grid; align-content: center; gap: 5px; padding: 14px 0; border-top: 1px solid color-mix(in oklch, var(--client-border) 48%, transparent); border-bottom: 1px solid color-mix(in oklch, var(--client-border) 48%, transparent); font-variant-numeric: var(--numeric-tabular); }
|
.client-failover-runtime { min-height: 132px; display: grid; align-content: center; gap: 5px; padding: 14px 0; border-top: 1px solid color-mix(in oklch, var(--client-border) 48%, transparent); border-bottom: 1px solid color-mix(in oklch, var(--client-border) 48%, transparent); font-variant-numeric: var(--numeric-tabular); }
|
||||||
.client-failover-runtime strong { font: var(--type-body); letter-spacing: var(--type-body-tracking); text-transform: var(--type-body-transform); }
|
.client-failover-runtime strong { font: var(--type-body); letter-spacing: var(--type-body-tracking); text-transform: var(--type-body-transform); }
|
||||||
.client-failover-runtime span, .client-failover-runtime small { color: var(--client-muted); font: var(--type-label); letter-spacing: var(--type-label-tracking); text-transform: var(--type-label-transform); }
|
.client-failover-runtime span, .client-failover-runtime small { color: var(--client-muted); font: var(--type-label); letter-spacing: var(--type-label-tracking); text-transform: var(--type-label-transform); }
|
||||||
@@ -69,8 +89,11 @@
|
|||||||
.client-failover-actions button { padding: 7px 0; border: 0; background: transparent; color: var(--client-accent); font: var(--type-control); letter-spacing: var(--type-control-tracking); text-transform: var(--type-control-transform); cursor: pointer; }
|
.client-failover-actions button { padding: 7px 0; border: 0; background: transparent; color: var(--client-accent); font: var(--type-control); letter-spacing: var(--type-control-tracking); text-transform: var(--type-control-transform); cursor: pointer; }
|
||||||
.client-failover-actions small { flex-basis: 100%; margin-top: -14px; color: var(--client-muted); font: var(--type-label); letter-spacing: var(--type-label-tracking); text-transform: var(--type-label-transform); }
|
.client-failover-actions small { flex-basis: 100%; margin-top: -14px; color: var(--client-muted); font: var(--type-label); letter-spacing: var(--type-label-tracking); text-transform: var(--type-label-transform); }
|
||||||
.client-failover-actions button:disabled { color: var(--client-muted); cursor: default; opacity: .45; }
|
.client-failover-actions button:disabled { color: var(--client-muted); cursor: default; opacity: .45; }
|
||||||
.client-failover-actions button:focus-visible, .client-failover-form input:focus-visible, .client-failover-advanced summary:focus-visible, .client-failover-service-editor button:focus-visible, .client-failover-discard button:focus-visible { outline: 2px solid var(--client-accent); outline-offset: 2px; }
|
.client-failover-actions button:focus-visible, .client-failover-service-editor button:focus-visible, .client-failover-discard button:focus-visible { outline: 2px solid var(--client-accent); outline-offset: 2px; }
|
||||||
|
.client-failover-form input:focus-visible { outline: 0; border-bottom-color: var(--client-accent); box-shadow: 0 1px 0 color-mix(in oklch, var(--client-accent) 60%, transparent); text-shadow: 0 0 9px color-mix(in oklch, var(--client-accent) 34%, transparent); }
|
||||||
@keyframes failover-service-in { from { opacity: 0; filter: blur(5px); transform: translateY(-4px); } to { opacity: 1; filter: blur(0); transform: translateY(0); } }
|
@keyframes failover-service-in { from { opacity: 0; filter: blur(5px); transform: translateY(-4px); } to { opacity: 1; filter: blur(0); transform: translateY(0); } }
|
||||||
@keyframes failover-service-out { from { opacity: 1; filter: blur(0); transform: translateY(0); } to { opacity: 0; filter: blur(5px); transform: translateY(-4px); } }
|
@keyframes failover-service-out { from { opacity: 1; filter: blur(0); transform: translateX(0) scale(1); } to { opacity: 0; filter: blur(6px); transform: translateX(16px) scale(.96); } }
|
||||||
@media (max-width: 560px) { .client-failover-heading { padding-right: 44px; } .client-failover-channel-title { align-items: start; } .client-failover-channel-title strong { max-width: 60%; } .client-failover-timing label, .client-failover-advanced label { grid-template-columns: 1fr; gap: 4px; } .client-failover-service { grid-template-columns: minmax(0, 1fr) 32px; gap: 6px 10px; } .client-failover-service-timeout { grid-column: 1; grid-row: 2; justify-self: start; } .client-failover-remove-service { grid-column: 2; grid-row: 1 / span 2; } .client-failover-service-editor { grid-template-columns: 1fr; gap: 2px; } }
|
@keyframes failover-advanced-in { from { opacity: 0; filter: blur(5px); transform: translateY(-5px); } to { opacity: 1; filter: blur(0); transform: translateY(0); } }
|
||||||
@media (prefers-reduced-motion: reduce) { .client-failover-channel-title strong, .client-failover-switch::before, .client-failover-switch > span, .client-failover-picker-trigger, .client-failover-picker-trigger svg, .client-failover-picker-list, .client-failover-picker-list button, .client-failover-remove-service { transition: none; } .client-failover-service, .client-failover-service-editor { animation: none; } }
|
@keyframes failover-advanced-out { from { opacity: 1; filter: blur(0); transform: translateY(0); } to { opacity: 0; filter: blur(5px); transform: translateY(-5px); } }
|
||||||
|
@media (max-width: 560px) { .client-failover-heading { padding-right: 44px; } .client-failover-channel { grid-template-columns: auto minmax(0, 1fr); gap: 5px 10px; } .client-failover-channel-title strong { grid-column: 2; grid-row: 2; text-align: left; } .client-failover-channel > .client-failover-picker { grid-column: 2; grid-row: 1; } .client-failover-timing label, .client-failover-advanced label { grid-template-columns: 1fr; gap: 4px; } .client-failover-service { grid-template-columns: minmax(0, 1fr) 32px; gap: 6px 10px; } .client-failover-service-timeout { grid-column: 1; grid-row: 2; justify-self: start; } .client-failover-remove-service { grid-column: 2; grid-row: 1 / span 2; } .client-failover-service-editor { grid-template-columns: 1fr; gap: 2px; } }
|
||||||
|
@media (prefers-reduced-motion: reduce) { .client-failover-channel-title strong, .client-failover-switch::before, .client-failover-switch > span, .client-failover-picker-trigger, .client-failover-picker-trigger::before, .client-failover-picker-trigger svg, .client-failover-picker-list, .client-failover-picker-list button, .client-failover-remove-service, .client-failover-remove-lid, .client-failover-advanced > button i::before, .client-failover-advanced > button i::after { transition: none; } .client-failover-service, .client-failover-service-editor, .client-failover-advanced-options { animation: none; } }
|
||||||
|
|||||||
@@ -364,7 +364,9 @@ test('selector activation failure rolls runtime and config back before applied t
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
const before = harness.snapshot();
|
const before = harness.snapshot();
|
||||||
await assert.rejects(harness.service.restart(), /selector failed/);
|
await assert.rejects(harness.service.restart(), (error) => (
|
||||||
|
error.code === 'PROCESS_START_FAILED' && error.cause?.message === 'selector failed'
|
||||||
|
));
|
||||||
assert.deepEqual(domain(harness.snapshot()), domain(before));
|
assert.deepEqual(domain(harness.snapshot()), domain(before));
|
||||||
assert.equal(harness.events.includes('state.update'), false);
|
assert.equal(harness.events.includes('state.update'), false);
|
||||||
assert.deepEqual(harness.events.filter((event) => event.startsWith('selector.')), ['selector.primary', 'selector.primary']);
|
assert.deepEqual(harness.events.filter((event) => event.startsWith('selector.')), ['selector.primary', 'selector.primary']);
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import test from 'node:test';
|
||||||
|
|
||||||
|
import { createSingboxSelectorService } from '../../dist/server/services/singboxSelectorService.js';
|
||||||
|
|
||||||
|
test('selector waits for the sing-box API after a fresh process start', async () => {
|
||||||
|
let attempts = 0;
|
||||||
|
const service = createSingboxSelectorService({
|
||||||
|
port: 0,
|
||||||
|
send: async (method) => {
|
||||||
|
attempts += 1;
|
||||||
|
if (attempts < 3) throw Object.assign(new Error('not ready'), { code: 'ECONNREFUSED' });
|
||||||
|
return method === 'GET' ? { now: 'channel-primary' } : {};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.deepEqual(await service.select('primary'), { role: 'primary' });
|
||||||
|
assert.equal(attempts, 4);
|
||||||
|
});
|
||||||
@@ -29,16 +29,23 @@ test('failover settings use Harbor switches, two pair pickers and added check ro
|
|||||||
assert.match(feature, /Проверять каждые, сек[\s\S]*Сбой должен длиться, сек[\s\S]*Восстановление, сек/);
|
assert.match(feature, /Проверять каждые, сек[\s\S]*Сбой должен длиться, сек[\s\S]*Восстановление, сек/);
|
||||||
assert.match(feature, /Переключение во время работы[\s\S]*Ждать тишины перед автоматическим переключением[\s\S]*Тишина перед переключением[\s\S]*Активный трафик, КБ\/с/);
|
assert.match(feature, /Переключение во время работы[\s\S]*Ждать тишины перед автоматическим переключением[\s\S]*Тишина перед переключением[\s\S]*Активный трафик, КБ\/с/);
|
||||||
assert.match(feature, /Защита от повторных сбоев[\s\S]*Окно повторных сбоев[\s\S]*Карантин основного/);
|
assert.match(feature, /Защита от повторных сбоев[\s\S]*Окно повторных сбоев[\s\S]*Карантин основного/);
|
||||||
assert.match(feature, /\+ Добавить проверку/);
|
assert.match(feature, /label="Добавить проверку"/);
|
||||||
assert.match(feature, /Новый HTTPS-сервис…/);
|
assert.match(feature, /Новый HTTPS-сервис…/);
|
||||||
assert.match(feature, /Убрать проверку:/);
|
assert.match(feature, /Убрать проверку:/);
|
||||||
|
assert.match(feature, /client-failover-remove-lid/);
|
||||||
assert.match(feature, /finishRemoveCheck/);
|
assert.match(feature, /finishRemoveCheck/);
|
||||||
assert.match(feature, /startViewTransition/);
|
assert.match(feature, /startViewTransition/);
|
||||||
|
assert.match(feature, /onInput=\{pulseNumber\}/);
|
||||||
|
assert.match(feature, /aria-controls="client-failover-advanced-options"/);
|
||||||
|
assert.doesNotMatch(feature, /<details|<summary|Нет данных|текущий канал вне настроенной пары/);
|
||||||
|
assert.doesNotMatch(page, /Текущий канал вне резервной пары/);
|
||||||
|
assert.match(page, /Резерв применится после перезапуска VPN/);
|
||||||
assert.match(feature, /Проверить оба канала/);
|
assert.match(feature, /Проверить оба канала/);
|
||||||
assert.match(feature, /beforeunload/);
|
assert.match(feature, /beforeunload/);
|
||||||
assert.match(styles, /\.client-failover-switch\[aria-checked='true'\][\s\S]*translateX\(20px\)/);
|
assert.match(styles, /\.client-failover-switch\[aria-checked='true'\][\s\S]*translateX\(20px\)/);
|
||||||
assert.match(styles, /\.client-failover-picker-list[\s\S]*opacity:\s*0[\s\S]*\.client-failover-picker\.is-open[\s\S]*opacity:\s*1/);
|
assert.match(styles, /\.client-failover-picker-list[\s\S]*opacity:\s*0[\s\S]*\.client-failover-picker\.is-open[\s\S]*opacity:\s*1/);
|
||||||
assert.match(styles, /failover-service-out 180ms[\s\S]*@media \(prefers-reduced-motion: reduce\)/);
|
assert.match(styles, /failover-service-out 300ms[\s\S]*failover-advanced-out[\s\S]*@media \(prefers-reduced-motion: reduce\)/);
|
||||||
|
assert.match(styles, /appearance:\s*textfield[\s\S]*text-align:\s*center/);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('runtime status keeps fixed geometry and explains active traffic without motion dependence', () => {
|
test('runtime status keeps fixed geometry and explains active traffic without motion dependence', () => {
|
||||||
|
|||||||
@@ -39,26 +39,26 @@ const expectedImports = [
|
|||||||
const sha256 = (value) => crypto.createHash('sha256').update(value).digest('hex');
|
const sha256 = (value) => crypto.createHash('sha256').update(value).digest('hex');
|
||||||
const acceptedLedger = {
|
const acceptedLedger = {
|
||||||
counts: {
|
counts: {
|
||||||
cascadeEdges: 1015,
|
cascadeEdges: 1053,
|
||||||
customProperties: 106,
|
customProperties: 106,
|
||||||
declarations: 3987,
|
declarations: 4094,
|
||||||
important: 0,
|
important: 0,
|
||||||
keyframes: 50,
|
keyframes: 52,
|
||||||
media: 17,
|
media: 17,
|
||||||
rules: 1085,
|
rules: 1111,
|
||||||
variableReferences: 1011,
|
variableReferences: 1030,
|
||||||
},
|
},
|
||||||
hashes: {
|
hashes: {
|
||||||
cascadeEdges: 'f90d8086d1e3e30462b4c7b9c293069940006ab2ac2be069c7e3f293b411d390',
|
cascadeEdges: '6e645a4af9c0d5631f2d20723648f863cd90fe05e08a7c38466ad1ddf37a18de',
|
||||||
customProperties: 'fd6f16069f9fe3526f09d4d574431ddae67150d8e7a8a40e04c9fd2d179ec7ac',
|
customProperties: 'fd6f16069f9fe3526f09d4d574431ddae67150d8e7a8a40e04c9fd2d179ec7ac',
|
||||||
declarations: 'dffddfea7b28b9de1a4af74f16d25920974879c9cecff19141841691e63468dd',
|
declarations: 'b5060e6b480cc565390095950396af40e1e593eca6b0d50543e58d8db7cb89c1',
|
||||||
duplicateKeyframes: '4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945',
|
duplicateKeyframes: '4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945',
|
||||||
duplicateSelectors: '8982145dba05b33bf1c93b2d54cfbe76305b276ff3c657aa020144016ada5848',
|
duplicateSelectors: '8982145dba05b33bf1c93b2d54cfbe76305b276ff3c657aa020144016ada5848',
|
||||||
keyframes: '21e640e8d2bf5921d346563823dd332cb4c0fc376292b555d10e1670cd81d74c',
|
keyframes: 'afdfc9691f8ef629fd5f263f3eebecf2373b54f0940d8deedd5e74497d55d0f3',
|
||||||
ruleDeclarationSequences: '144d9f148f8fa2b57bd7d40a02f75f6d6894d7d1e0b6a44ec6f18b22eb876055',
|
ruleDeclarationSequences: '7853d3fa55954dc279c0a8788280bea6079b8c39e8a809e3508f673e0e25ee85',
|
||||||
selectors: '279ee9d08e470259ee573e063d8dec8aabb7c43fc49f3c7942cc8d5af46e4828',
|
selectors: '12d7e3921cd5ebddbe3a0fb10a1113ca3165a7c5597c8e80d3917d19df5737e9',
|
||||||
variableReferences: '00358fb265ec9e847a36fbf157224d01b634477c546f1a6b72a70e8d05394a57',
|
variableReferences: 'e70f638b46142b1cf78cc9d82410735d9f72a32a9711bc1f0eac34e13fd653c4',
|
||||||
witnesses: 'c45f872c163e079f58d28c481db0b9cf919d5d4e1d053ddfdc00103bd20ae737',
|
witnesses: 'a033ac2b7b6c297c6876e68818a6566a0eb95095494d45af6423c85476918061',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -211,7 +211,7 @@ test('client typography uses the shared semantic scale outside the token owner',
|
|||||||
|
|
||||||
test('accepted stylesheet has pinned declaration, selector, keyframe, variable, and cascade ledgers', () => {
|
test('accepted stylesheet has pinned declaration, selector, keyframe, variable, and cascade ledgers', () => {
|
||||||
const witnesses = readStyleWitnesses(root);
|
const witnesses = readStyleWitnesses(root);
|
||||||
assert.equal(witnesses.length, 1024);
|
assert.equal(witnesses.length, 1031);
|
||||||
assert.equal(witnesses.filter((witness) => witness.unknown || witness.ancestorUnknown).length, 0);
|
assert.equal(witnesses.filter((witness) => witness.unknown || witness.ancestorUnknown).length, 0);
|
||||||
const ledger = createStyleLedger(readStyleSource(root), { witnesses });
|
const ledger = createStyleLedger(readStyleSource(root), { witnesses });
|
||||||
assert.deepEqual(ledger.counts, acceptedLedger.counts);
|
assert.deepEqual(ledger.counts, acceptedLedger.counts);
|
||||||
@@ -407,8 +407,8 @@ test('main owns one public stylesheet and the regrouped production CSS is determ
|
|||||||
assert.equal((main.match(/import ['"][^'"]+\.css['"]/g) || []).length, 1);
|
assert.equal((main.match(/import ['"][^'"]+\.css['"]/g) || []).length, 1);
|
||||||
|
|
||||||
const assets = fs.readdirSync(path.join(root, 'dist/assets')).filter((file) => file.endsWith('.css'));
|
const assets = fs.readdirSync(path.join(root, 'dist/assets')).filter((file) => file.endsWith('.css'));
|
||||||
assert.deepEqual(assets, ['index-CWWRFYvR.css']);
|
assert.deepEqual(assets, ['index-egC2pF0y.css']);
|
||||||
const built = fs.readFileSync(path.join(root, 'dist/assets', assets[0]));
|
const built = fs.readFileSync(path.join(root, 'dist/assets', assets[0]));
|
||||||
assert.equal(built.byteLength, 151327);
|
assert.equal(built.byteLength, 155655);
|
||||||
assert.equal(sha256(built), '95bdf0125b40fe1349abd6396a40462a9c6bee40ff258078d3787b62e9213028');
|
assert.equal(sha256(built), '08abd35b2cb28ad64a637a3ae45cbccb65ddba803184cd6f65bcb9bf59101a8a');
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user