Files
MoShiro/web/shared/ipVersions.tsx
T
justme 84f9d211bc
ci/woodpecker/pr/verify Pipeline failed
ci/woodpecker/pr/web-build unknown status
backend: require confirmation for signed channel updates [CI]
2026-10-07 12:57:20 +08:00

22 lines
1.2 KiB
TypeScript

import { Segmented } from './ui'
export type IpVersion = 'ipv4' | 'ipv6'
export const ipVersionOf = (value: string | null | undefined): IpVersion => value === 'ipv6' ? 'ipv6' : 'ipv4'
export const IP_VERSIONS: { value: IpVersion; label: string }[] = [{ value: 'ipv4', label: 'IPv4' }, { value: 'ipv6', label: 'IPv6' }]
export const lineIdFor = (id: string, version: IpVersion): string => id.replace(/~ipv6$/, '') + (version === 'ipv6' ? '~ipv6' : '')
export const IPV6_STATES: Record<string, string> = {
ready: 'IPv6 网络已就绪',
address_not_configured: '面板未配置 IPv6 地址',
unsupported: '运行环境不支持 IPv6',
no_global_address: '机器或容器未获得全局 IPv6 地址',
not_listening: 'Agent 只监听 IPv4,请检查 listen.bind',
no_default_route: '缺少 IPv6 默认路由',
unknown: '尚未取得 IPv6 诊断,请检查 Agent 版本',
container_network_not_ready: '宿主有 IPv6,但容器网络未就绪,请检查网络模式',
}
export function IpVersionPicker({ value, onChange }: { value: IpVersion; onChange: (value: IpVersion) => void }) {
return <Segmented options={IP_VERSIONS} value={value} onChange={onChange} />
}