确定数据结构

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