2026-03-31 15:31:16 +00:00
|
|
|
import * as plugins from '../../plugins.js';
|
|
|
|
|
import { DcRouterDb } from '../classes.dcrouter-db.js';
|
|
|
|
|
|
|
|
|
|
const getDb = () => DcRouterDb.getInstance().getDb();
|
|
|
|
|
|
|
|
|
|
@plugins.smartdata.Collection(() => getDb())
|
|
|
|
|
export class VpnClientDoc extends plugins.smartdata.SmartDataDbDoc<VpnClientDoc, VpnClientDoc> {
|
|
|
|
|
@plugins.smartdata.unI()
|
|
|
|
|
@plugins.smartdata.svDb()
|
|
|
|
|
public clientId!: string;
|
|
|
|
|
|
|
|
|
|
@plugins.smartdata.svDb()
|
|
|
|
|
public enabled!: boolean;
|
|
|
|
|
|
|
|
|
|
@plugins.smartdata.svDb()
|
|
|
|
|
public serverDefinedClientTags?: string[];
|
|
|
|
|
|
|
|
|
|
@plugins.smartdata.svDb()
|
|
|
|
|
public description?: string;
|
|
|
|
|
|
|
|
|
|
@plugins.smartdata.svDb()
|
|
|
|
|
public assignedIp?: string;
|
|
|
|
|
|
|
|
|
|
@plugins.smartdata.svDb()
|
|
|
|
|
public noisePublicKey!: string;
|
|
|
|
|
|
|
|
|
|
@plugins.smartdata.svDb()
|
|
|
|
|
public wgPublicKey!: string;
|
|
|
|
|
|
|
|
|
|
@plugins.smartdata.svDb()
|
|
|
|
|
public wgPrivateKey?: string;
|
|
|
|
|
|
|
|
|
|
@plugins.smartdata.svDb()
|
|
|
|
|
public createdAt!: number;
|
|
|
|
|
|
|
|
|
|
@plugins.smartdata.svDb()
|
|
|
|
|
public updatedAt!: number;
|
|
|
|
|
|
|
|
|
|
@plugins.smartdata.svDb()
|
|
|
|
|
public expiresAt?: string;
|
|
|
|
|
|
2026-04-01 05:13:01 +00:00
|
|
|
@plugins.smartdata.svDb()
|
|
|
|
|
public forceDestinationSmartproxy: boolean = true;
|
|
|
|
|
|
|
|
|
|
@plugins.smartdata.svDb()
|
|
|
|
|
public destinationAllowList?: string[];
|
|
|
|
|
|
|
|
|
|
@plugins.smartdata.svDb()
|
|
|
|
|
public destinationBlockList?: string[];
|
|
|
|
|
|
|
|
|
|
@plugins.smartdata.svDb()
|
|
|
|
|
public useHostIp?: boolean;
|
|
|
|
|
|
|
|
|
|
@plugins.smartdata.svDb()
|
|
|
|
|
public useDhcp?: boolean;
|
|
|
|
|
|
|
|
|
|
@plugins.smartdata.svDb()
|
|
|
|
|
public staticIp?: string;
|
|
|
|
|
|
|
|
|
|
@plugins.smartdata.svDb()
|
|
|
|
|
public forceVlan?: boolean;
|
|
|
|
|
|
|
|
|
|
@plugins.smartdata.svDb()
|
|
|
|
|
public vlanId?: number;
|
|
|
|
|
|
2026-03-31 15:31:16 +00:00
|
|
|
constructor() {
|
|
|
|
|
super();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static async findByClientId(clientId: string): Promise<VpnClientDoc | null> {
|
|
|
|
|
return await VpnClientDoc.getInstance({ clientId });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static async findAll(): Promise<VpnClientDoc[]> {
|
|
|
|
|
return await VpnClientDoc.getInstances({});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static async findEnabled(): Promise<VpnClientDoc[]> {
|
|
|
|
|
return await VpnClientDoc.getInstances({ enabled: true });
|
|
|
|
|
}
|
|
|
|
|
}
|