diff --git a/apps/web/src/routes/_auth/firewall.tsx b/apps/web/src/routes/_auth/firewall.tsx index 5498179..b035e79 100644 --- a/apps/web/src/routes/_auth/firewall.tsx +++ b/apps/web/src/routes/_auth/firewall.tsx @@ -20,7 +20,10 @@ import { } from '@evobgp/ui/components/table' import { PageHeader } from '@/components/page-header' +import { CommunitySelect } from '@/components/modules/community-select' import { StatusBadge } from '@/components/status-badge' +import { communityLabel } from '@/lib/modules/helpers' +import { directoriesCommunitiesQueryOptions } from '@/queries/directories' import { firewallClientsQueryOptions, firewallInstallContextQueryOptions, @@ -29,7 +32,7 @@ import { useCreateFirewallRule, useDeleteFirewallRule, } from '@/queries/firewall' -import type { FirewallClient } from '@/types/api' +import type { BgpCommunity, FirewallClient } from '@/types/api' export const Route = createFileRoute('/_auth/firewall')({ component: FirewallPage, @@ -37,6 +40,7 @@ export const Route = createFileRoute('/_auth/firewall')({ function FirewallPage() { const installCtxQ = useQuery(firewallInstallContextQueryOptions()) + const communitiesQ = useQuery(directoriesCommunitiesQueryOptions()) const clientsQ = useQuery(firewallClientsQueryOptions()) const rulesQ = useQuery(firewallRulesQueryOptions('tenant')) const approve = useApproveFirewallClient() @@ -60,8 +64,11 @@ function FirewallPage() { } }, [installCtx?.bundle_seed, installCtx?.suggested_cp_url]) const [ruleAction, setRuleAction] = useState<'block' | 'accept'>('block') + const [ruleCommunityId, setRuleCommunityId] = useState(null) const [ruleComment, setRuleComment] = useState('') + const communities = communitiesQ.data?.items ?? [] + const clients = clientsQ.data?.items ?? [] const pending = clients.filter((c) => c.status === 'pending') const rules = rulesQ.data?.items ?? [] @@ -117,8 +124,9 @@ function FirewallPage() { Политика - Только явный block добавляет IP в blocklist. Правила accept сами по себе - не создают block all. Default — accept. + Правила сопоставляются с BGP community префиксов опубликованной revision.{' '} + block добавляет префиксы community в kernel; accept — не блокирует. + Community «Все» — правило для любого community. Default без совпадений — accept. @@ -179,7 +187,7 @@ function FirewallPage() { -
+
- setRuleComment(e.target.value)} + +
+ + setRuleComment(e.target.value)} + /> +
- deleteRule.mutate(id)} /> + deleteRule.mutate(id)} + /> @@ -279,9 +306,11 @@ function ClientsTable({ function RulesTable({ rules, + communities, onDelete, }: { - rules: { id: string; priority: number; action: string; comment?: string }[] + rules: { id: string; priority: number; action: string; community_id?: string | null; comment?: string }[] + communities: BgpCommunity[] onDelete: (id: string) => void }) { if (rules.length === 0) { @@ -293,6 +322,7 @@ function RulesTable({ # Действие + Community Комментарий @@ -304,6 +334,9 @@ function RulesTable({ + + {r.community_id ? communityLabel(r.community_id, communities) : 'Все'} + {r.comment || '—'}