确定数据结构

This commit is contained in:
fengfeng 2026-02-05 13:51:06 +08:00
parent be36cefd4b
commit 0c5668838f

View File

@ -4,52 +4,42 @@ export type AppNode = Node<NodeData>;
export type AppEdge = Edge<EdgeData>; export type AppEdge = Edge<EdgeData>;
export interface GroupAllowRule { export class SubNetRouter {
kind: 'group' private _nodes : Record<string, string | undefined> = {};
allowGroup: number
}
export interface HostAllowRule { constructor(
kind: 'host' public subnet: string,
allowHost: number ) {}
} }
export interface CustomAllowRule {
kind: 'custom'
allow: string
}
export type AllowRule = GroupAllowRule | HostAllowRule | CustomAllowRule
export type NodeData = { export type NodeData = {
// basic id: string;
label: string; label: string;
privateKey: string; privateKey: string;
groupId: number; ipv4Address?: string;
hostId: number; ipv6Address?: string;
disallowIPs?: string;
// host options
postUp?: string; postUp?: string;
postDown?: string; postDown?: string;
mtu?: number; mtu?: number;
notes?: string;
listenPort?: number; listenPort?: number;
dnsServers?: string; dnsServers?: string;
notes?: string;
// peer options
// allowRules?: AllowRule[];
// persistentKeepalive?: string; todo: 加到边上
} }
export type Settings = { export type Settings = {
v4SubNetPrefix: [number, number];
listenPort: number; listenPort: number;
mtu: number;
// options
v6SubNetPrefix?: [string, string, string, string]; ipv4Subnet?: string;
mtu?: number; ipv4SubnetRouter?: SubNetRouter;
ipv6Subnet?: string;
ipv6SubnetRouter?: SubNetRouter;
} }
export type EdgeData = { export type EdgeData = {
isTwoWayEdge: boolean isTwoWayEdge: boolean;
persistentKeepalive?: string;
} }