55 lines
1.0 KiB
TypeScript
55 lines
1.0 KiB
TypeScript
import { Node, Edge } from '@xyflow/react';
|
|
import { createContext } from 'react';
|
|
import { CIDR } from '../utils/iputils';
|
|
|
|
export type AppNode = Node<NodeData>;
|
|
|
|
export type AppEdge = Edge<EdgeData>;
|
|
|
|
export type NodeData = {
|
|
readonly id: string;
|
|
} & NodeDataUpdate
|
|
|
|
export type NodeDataUpdate = {
|
|
label: string;
|
|
privateKey: string;
|
|
ipv4Address?: string;
|
|
ipv6Address?: string;
|
|
disallowIPs?: string;
|
|
postUp?: string;
|
|
postDown?: string;
|
|
mtu?: number;
|
|
listenAddress?: string;
|
|
listenPort?: number;
|
|
dnsServers?: string;
|
|
notes?: string;
|
|
}
|
|
|
|
export type EdgeData = {
|
|
readonly id: string;
|
|
isTwoWayEdge: boolean;
|
|
} & EdgeDataUpdate
|
|
|
|
export type EdgeDataUpdate = {
|
|
persistentKeepalive?: number;
|
|
}
|
|
|
|
export interface SubnetInfo {
|
|
subnet: CIDR;
|
|
nodes: Record<string, CIDR | undefined>;
|
|
}
|
|
|
|
export interface Settings {
|
|
listenPort: number;
|
|
mtu: number;
|
|
|
|
subnets: SubnetInfo[];
|
|
}
|
|
|
|
export const initialSettings : Settings = {
|
|
listenPort: 38894,
|
|
mtu: 1420,
|
|
subnets: []
|
|
};
|
|
|
|
export const SettingsContext = createContext<Settings>(initialSettings); |