Can define network filters
This commit is contained in:
56
virtweb_frontend/src/api/NWFilterApi.ts
Normal file
56
virtweb_frontend/src/api/NWFilterApi.ts
Normal 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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user