feat(fleet): add shared WireGuard profiles and bounded rover transport

Add portable shared WireGuard profiles while retaining Tailscale and Worker boundaries. Bound rover command/telemetry delivery, recovery and diagnostic capture across Core and Node.
This commit is contained in:
DCCONSTRUCTIONS
2026-10-29 09:10:01 +03:00
parent bec20d63e2
commit e06ff9a214
180 changed files with 20140 additions and 400 deletions
@@ -0,0 +1,31 @@
import {useRef} from 'react';
import {Button,Icon,Select,SettingsCard,StatusBadge} from '@nodedc/ui-react';
import {useBoardNetwork,type NetworkProvider} from '../../core/fleet/useBoardNetwork';
import {InstallerCard} from './equipment/InstallerCard';
export function BoardNetworkSettings({network}:{network:ReturnType<typeof useBoardNetwork>}){
const input=useRef<HTMLInputElement>(null);
const {value,provider,profileId,busy,applying,error}=network;
const current=value?.node;
const selected=value?.profiles.find(p=>p.id===profileId);
const progress=value?.operation?.state;
const label=progress==='rolling_back'?'Восстанавливаем прежнее подключение':progress==='applying'?'Проверяем связь с бортом':!value?.available?'Нет свежего подтверждения борта':current?.provider==='wireguard'?'WireGuard подключён':'Tailscale подключён';
return <div className="fleet-form">
<SettingsCard title="Связь с Core" description="Профиль связи этого бортового компьютера с Mission Core. Вычислительный Worker сохраняет своё подключение." actions={<StatusBadge tone={applying?'warning':value?.available?'success':'neutral'}>{label}</StatusBadge>}>
<Select label="Способ подключения" value={provider} options={[{value:'tailscale',label:'Tailscale'},{value:'wireguard',label:'WireGuard · VPS'}]} onChange={v=>network.setProvider(v as NetworkProvider)} disabled={busy||applying}/>
{provider==='tailscale'?<p>{current?.tailscale_endpoint?`Сохранённое подключение: ${current.tailscale_endpoint}`:current?'Подключите Tailscale в приложении Node.':'Параметры появятся после получения настроек БК.'}</p>:<>
<Select label="Общий профиль VPS" value={profileId} options={[{value:'',label:'Выберите профиль'},...(value?.profiles??[]).filter(p=>p.state==='ready').map(p=>({value:p.id,label:p.name,description:`Подключено бортов: ${p.boards} · ${p.endpoint}`}))]} onChange={network.setProfileId} disabled={busy||applying}/>
{selected&&<StatusBadge tone={selected.state==='ready'?'success':'warning'}>{selected.state==='ready'?`VPS подключён · Подключено бортов: ${selected.boards}`:'Подключение VPS не завершено'}</StatusBadge>}
<p>Один профиль используется всем парком. У каждого борта будет отдельное защищённое подключение.</p>
</>}
{!value?.available&&<p>Для изменения настроек нужен доступный БК с актуальной версией Node.</p>}
{(error||value?.operation?.error||current?.error)&&<StatusBadge tone="danger">{error||value?.operation?.error||current?.error}</StatusBadge>}
</SettingsCard>
{provider==='wireguard'&&<>
<SettingsCard title="Подключить VPS" description="Если сервер уже подготовлен, загрузите полученный на нём файл подключения. Для нового сервера сначала скачайте и запустите установщик.">
<input ref={input} type="file" accept=".json,application/json" hidden onChange={event=>{const file=event.currentTarget.files?.[0];event.currentTarget.value='';if(file)void network.importing(file);}}/>
<Button icon={<Icon name="upload"/>} disabled={busy||applying} loading={busy} onClick={()=>input.current?.click()}>Загрузить файл подключения</Button>
</SettingsCard>
<InstallerCard kind="vps-wireguard"/>
</>}
</div>;
}