You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

109 lines
2.0 KiB

import type { SessionConfig } from 'h3';
export type Lang = 'en' | 'fr';
export type IpTables = {
PreUp: string;
PostUp: string;
PreDown: string;
PostDown: string;
};
export type WGInterface = {
privateKey: string;
publicKey: string;
address4: string;
address6: string;
mtu: number;
port: number;
device: string;
};
export type WGConfig = {
mtu: number;
persistentKeepalive: number;
address4Range: string;
address6Range: string;
defaultDns: string[];
allowedIps: string[];
host: string;
port: number;
};
export enum ChartType {
None = 0,
Line = 1,
Area = 2,
Bar = 3,
}
export type Statistics = {
enabled: boolean;
chartType: ChartType;
};
export type Prometheus = {
enabled: boolean;
password: string | null;
};
export type Feature = {
enabled: boolean;
};
export type Metrics = {
prometheus: Prometheus;
};
export type General = {
sessionTimeout: number;
lang: Lang;
};
export type Features = {
clientExpiration: Feature;
oneTimeLinks: Feature;
sortClients: Feature;
};
export const AvailableFeatures: (keyof Features)[] = [
'clientExpiration',
'oneTimeLinks',
'sortClients',
] as const;
/**
* Representing the WireGuard network configuration data structure of a computer interface system.
*/
export type System = {
general: General;
interface: WGInterface;
userConfig: WGConfig;
iptables: IpTables;
features: Features;
statistics: Statistics;
metrics: Metrics;
sessionConfig: SessionConfig;
};
/**
* Interface for system-related database operations.
* This interface provides methods for retrieving system configuration data
* and specific system properties, such as the language setting, from the database.
*/
export abstract class SystemRepository {
/**
* Retrieves the system configuration data from the database.
*/
abstract get(): Promise<System>;
abstract updateFeatures(features: Record<string, Feature>): Promise<void>;
abstract updateStatistics(statistics: Statistics): Promise<void>;
}