Can define network filters

This commit is contained in:
2024-01-02 18:56:16 +01:00
parent 2b145ebeff
commit d4ef389852
11 changed files with 349 additions and 43 deletions

View File

@ -0,0 +1,56 @@
import { APIClient } from "./ApiClient";
export interface NWFilterChain {
protocol: string;
suffix?: string;
}
export interface NWFSAll {
type: "all";
}
export interface NWFSMac {
type: "mac";
src_mac_addr?: string;
src_mac_mask?: string;
dst_mac_addr?: string;
dst_mac_mask?: string;
comment?: string;
}
// TODO : complete
export type NWFSelector = NWFSAll | NWFSMac;
export interface NWFilterRule {
action: "drop" | "reject" | "accept" | "return" | "continue";
direction: "in" | "out" | "inout";
priority?: number;
selectors: NWFSelector[];
}
export interface NWFilter {
name: string;
chain?: NWFilterChain;
priority?: number;
uuid?: string;
join_filters: string[];
rules: NWFilterRule[];
}
export class NWFilterApi {
/**
* Get the entire list of networks
*/
static async GetList(): Promise<NWFilter[]> {
const list: NWFilter[] = (
await APIClient.exec({
method: "GET",
uri: "/nwfilter/list",
})
).data;
list.sort((a, b) => a.name.localeCompare(b.name));
return list;
}
}

View File

@ -30,16 +30,30 @@ export interface VMDisk {
deleteType?: "keepfile" | "deletefile";
}
export type VMNetInterface = VMNetUserspaceSLIRPStack | VMNetDefinedNetwork;
export interface VMNetInterfaceFilterParams {
name: string;
value: string;
}
export interface VMNetInterfaceFilter {
name: string;
parameters: VMNetInterfaceFilterParams[];
}
export type VMNetInterface = (VMNetUserspaceSLIRPStack | VMNetDefinedNetwork) &
VMNetInterfaceBase;
export interface VMNetInterfaceBase {
mac: string;
nwfilterref?: VMNetInterfaceFilter;
}
export interface VMNetUserspaceSLIRPStack {
type: "UserspaceSLIRPStack";
mac: string;
}
export interface VMNetDefinedNetwork {
type: "DefinedNetwork";
mac: string;
network: string;
}