fix: connectivity panel rearrangement. LXD VM for repeatable tests.
This commit is contained in:
1 parent
85a1ffa21f
commit
da889b4865
15 files changed
+363
-47
No files matched your search
@@ -13,29 +13,48 @@ const LAYOUT_KEY = 'linux-manager-ui.network-layout'
|
||||
const readDetails = () => request<RouterDetails>('GET', '/config', DETAILS_SHAPE)
|
||||
|
||||
/**
|
||||
* The server's network, from its /config: the external and the internal interface with their addresses, the internal
|
||||
* gateway and the local CIDRs, and the IPv4 routes. The panels are on a board whose layout is kept in the browser.
|
||||
* The server's network, from its /config: the interfaces but loopback, external when they hold an IPv4 default route
|
||||
* and internal otherwise; the internal gateway and the local CIDRs while the router is on; and the IPv4 routes. The
|
||||
* panels are on a board whose layout is kept in the browser.
|
||||
*/
|
||||
export default function NetworkPanel() {
|
||||
const { data: details, error, busy, refresh } = useRead(readDetails)
|
||||
const board = useBoard(LAYOUT_KEY)
|
||||
|
||||
const network = details?.network
|
||||
const router = details?.configuration.router?.enabled === true
|
||||
// An interface holding an IPv4 default route is external, every other one internal.
|
||||
const external = new Set(network?.routes?.filter((route) => route.dst === 'default').map((route) => route.dev))
|
||||
const panels: BoardPanel[] = network ? [
|
||||
{
|
||||
id: 'network',
|
||||
title: 'Network',
|
||||
id: 'interfaces',
|
||||
title: 'Interfaces',
|
||||
content: (
|
||||
<Grid
|
||||
head={['Name', 'Type', 'State', 'IPv4 addresses', 'IPv6 addresses', 'MAC address']}
|
||||
rows={network.interfaces?.map((link) => [
|
||||
link.name,
|
||||
external.has(link.name) ? 'external' : 'internal',
|
||||
text(link.state),
|
||||
text(link.ipv4),
|
||||
text(link.ipv6),
|
||||
text(link.mac),
|
||||
])}
|
||||
/>
|
||||
),
|
||||
},
|
||||
...(router ? [{
|
||||
id: 'router',
|
||||
title: 'Router',
|
||||
content: (
|
||||
<Pairs
|
||||
rows={[
|
||||
['External interface', `${network.external_interface ?? '-'}: ${text(network.external_addresses)}`],
|
||||
['Internal interface', `${network.internal_interface ?? '-'}: ${text(network.internal_address)}`],
|
||||
['Internal gateway', text(network.internal_gateway)],
|
||||
['Local CIDRs', text(network.local_cidrs)],
|
||||
]}
|
||||
/>
|
||||
),
|
||||
},
|
||||
}] : []),
|
||||
{
|
||||
id: 'routes',
|
||||
title: 'Routes',
|
||||
|
||||
+10
-1
@@ -73,7 +73,9 @@ export type RouterDetails = {
|
||||
local_cidrs?: string[]
|
||||
/** Each site-to-site connection with the identities and subnets the server resolved for it. */
|
||||
site_to_site?: { name: string; local_identity: string; remote_identity: string; local_cidrs: string[]; remote_cidrs: string[] }[]
|
||||
routes: { dst: string; gateway?: string; dev: string; protocol?: string; scope?: string; prefsrc?: string; metric?: number; flags: string[] }[] | null
|
||||
/** The interfaces but loopback, with their IPv4 and global IPv6 addresses as address/prefix; null when ip fails. */
|
||||
interfaces?: { name: string; state: string | null; mac: string | null; ipv4: string[]; ipv6: string[] }[] | null
|
||||
routes:{ dst: string; gateway?: string; dev: string; protocol?: string; scope?: string; prefsrc?: string; metric?: number; flags: string[] }[] | null
|
||||
}
|
||||
/** Objects of swanctl --list-conns and --list-sas; the values are strings as swanctl prints them. */
|
||||
ipsec: {
|
||||
@@ -635,6 +637,13 @@ export const DETAILS_SHAPE = object({
|
||||
local_cidrs: list(string),
|
||||
remote_cidrs: list(string),
|
||||
}))),
|
||||
interfaces: optional(nullable(list(object({
|
||||
name: string,
|
||||
state: nullable(string),
|
||||
mac: nullable(string),
|
||||
ipv4: list(string),
|
||||
ipv6: list(string),
|
||||
})))),
|
||||
routes: nullable(list(object({
|
||||
dst: string,
|
||||
gateway: optional(string),
|
||||
|
||||
Reference in new issue
Block a user