Moduled Firegex, Merging pt2 (to finish and test)
This commit is contained in:
@@ -2,11 +2,10 @@ import { Button, Group, Space, TextInput, Notification, Switch, NativeSelect, Mo
|
||||
import { useForm } from '@mantine/hooks';
|
||||
import React, { useState } from 'react';
|
||||
import { RegexAddForm } from '../js/models';
|
||||
import { addregex, b64decode, b64encode, fireUpdateRequest, okNotify } from '../js/utils';
|
||||
import { b64decode, b64encode, getapiobject, okNotify } from '../js/utils';
|
||||
import { ImCross } from "react-icons/im"
|
||||
import FilterTypeSelector from './FilterTypeSelector';
|
||||
|
||||
|
||||
type RegexAddInfo = {
|
||||
regex:string,
|
||||
type:string,
|
||||
@@ -54,11 +53,10 @@ function AddNewRegex({ opened, onClose, service }:{ opened:boolean, onClose:()=>
|
||||
active: !values.deactive
|
||||
}
|
||||
setSubmitLoading(false)
|
||||
addregex(request).then( res => {
|
||||
getapiobject().regexesadd(request).then( res => {
|
||||
if (!res){
|
||||
setSubmitLoading(false)
|
||||
close();
|
||||
fireUpdateRequest();
|
||||
okNotify(`Regex ${b64decode(request.regex)} has been added`, `Successfully added ${request.is_case_sensitive?"case sensitive":"case insensitive"} ${request.is_blacklist?"blacklist":"whitelist"} regex to ${request.service_id} service`)
|
||||
}else if (res.toLowerCase() === "invalid regex"){
|
||||
setSubmitLoading(false)
|
||||
@@ -3,8 +3,6 @@ import React from "react";
|
||||
import { FaListAlt } from "react-icons/fa";
|
||||
import { TiCancel } from "react-icons/ti";
|
||||
|
||||
|
||||
|
||||
export default function FilterTypeSelector(props:any){
|
||||
return <SegmentedControl
|
||||
data={[
|
||||
|
||||
@@ -1,123 +0,0 @@
|
||||
import { Button, Group, Space, TextInput, Notification, Switch, NativeSelect, Modal } from '@mantine/core';
|
||||
import { useForm } from '@mantine/hooks';
|
||||
import React, { useState } from 'react';
|
||||
import { RegexAddForm } from '../../js/models';
|
||||
import { b64decode, b64encode, nfregex, okNotify } from '../../js/utils';
|
||||
import { ImCross } from "react-icons/im"
|
||||
import FilterTypeSelector from '../FilterTypeSelector';
|
||||
|
||||
|
||||
type RegexAddInfo = {
|
||||
regex:string,
|
||||
type:string,
|
||||
mode:string,
|
||||
is_case_insensitive:boolean,
|
||||
deactive:boolean
|
||||
}
|
||||
|
||||
function AddNewRegex({ opened, onClose, service }:{ opened:boolean, onClose:()=>void, service:string }) {
|
||||
|
||||
const form = useForm({
|
||||
initialValues: {
|
||||
regex:"",
|
||||
type:"blacklist",
|
||||
mode:"C -> S",
|
||||
is_case_insensitive:false,
|
||||
deactive:false
|
||||
},
|
||||
validationRules:{
|
||||
regex: (value) => value !== "",
|
||||
type: (value) => ["blacklist","whitelist"].includes(value),
|
||||
mode: (value) => ['C -> S', 'S -> C', 'C <-> S'].includes(value)
|
||||
}
|
||||
})
|
||||
|
||||
const close = () =>{
|
||||
onClose()
|
||||
form.reset()
|
||||
setError(null)
|
||||
}
|
||||
|
||||
const [submitLoading, setSubmitLoading] = useState(false)
|
||||
const [error, setError] = useState<string|null>(null)
|
||||
|
||||
const submitRequest = (values:RegexAddInfo) => {
|
||||
setSubmitLoading(true)
|
||||
const filter_mode = ({'C -> S':'C', 'S -> C':'S', 'C <-> S':'B'}[values.mode])
|
||||
|
||||
const request:RegexAddForm = {
|
||||
is_blacklist:values.type !== "whitelist",
|
||||
is_case_sensitive: !values.is_case_insensitive,
|
||||
service_id: service,
|
||||
mode: filter_mode?filter_mode:"B",
|
||||
regex: b64encode(values.regex),
|
||||
active: !values.deactive
|
||||
}
|
||||
setSubmitLoading(false)
|
||||
nfregex.regexesadd(request).then( res => {
|
||||
if (!res){
|
||||
setSubmitLoading(false)
|
||||
close();
|
||||
okNotify(`Regex ${b64decode(request.regex)} has been added`, `Successfully added ${request.is_case_sensitive?"case sensitive":"case insensitive"} ${request.is_blacklist?"blacklist":"whitelist"} regex to ${request.service_id} service`)
|
||||
}else if (res.toLowerCase() === "invalid regex"){
|
||||
setSubmitLoading(false)
|
||||
form.setFieldError("regex", "Invalid Regex")
|
||||
}else{
|
||||
setSubmitLoading(false)
|
||||
setError("Error: [ "+res+" ]")
|
||||
}
|
||||
}).catch( err => {
|
||||
setSubmitLoading(false)
|
||||
setError("Request Failed! [ "+err+" ]")
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
||||
return <Modal size="xl" title="Add a new regex filter" opened={opened} onClose={close} closeOnClickOutside={false} centered>
|
||||
<form onSubmit={form.onSubmit(submitRequest)}>
|
||||
<TextInput
|
||||
label="Regex"
|
||||
placeholder="[A-Z0-9]{31}="
|
||||
{...form.getInputProps('regex')}
|
||||
/>
|
||||
<Space h="md" />
|
||||
<Switch
|
||||
label="Case insensitive"
|
||||
{...form.getInputProps('is_case_insensitive', { type: 'checkbox' })}
|
||||
/>
|
||||
<Space h="md" />
|
||||
<Switch
|
||||
label="Deactivate"
|
||||
{...form.getInputProps('deactive', { type: 'checkbox' })}
|
||||
/>
|
||||
<Space h="md" />
|
||||
<NativeSelect
|
||||
data={['C -> S', 'S -> C', 'C <-> S']}
|
||||
label="Choose the source of the packets to filter"
|
||||
variant="filled"
|
||||
{...form.getInputProps('mode')}
|
||||
/>
|
||||
<Space h="md" />
|
||||
<FilterTypeSelector
|
||||
size="md"
|
||||
color="gray"
|
||||
{...form.getInputProps('type')}
|
||||
/>
|
||||
<Group position="right" mt="md">
|
||||
<Button loading={submitLoading} type="submit">Add Filter</Button>
|
||||
</Group>
|
||||
|
||||
<Space h="md" />
|
||||
|
||||
{error?<>
|
||||
<Notification icon={<ImCross size={14} />} color="red" onClose={()=>{setError(null)}}>
|
||||
Error: {error}
|
||||
</Notification><Space h="md" /></>:null}
|
||||
|
||||
</form>
|
||||
</Modal>
|
||||
|
||||
}
|
||||
|
||||
export default AddNewRegex;
|
||||
@@ -1,8 +1,9 @@
|
||||
import { Button, Group, NumberInput, Space, TextInput, Notification, Modal, Switch, SegmentedControl, Autocomplete, AutocompleteItem } from '@mantine/core';
|
||||
import { useForm } from '@mantine/hooks';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { okNotify, regex_ipv4, regex_ipv6, getipinterfaces, nfregex } from '../../js/utils';
|
||||
import { okNotify, regex_ipv4, regex_ipv6, getipinterfaces } from '../../js/utils';
|
||||
import { ImCross } from "react-icons/im"
|
||||
import { nfregex } from './utils';
|
||||
|
||||
type ServiceAddForm = {
|
||||
name:string,
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Button, Group, Space, TextInput, Notification, Modal } from '@mantine/core';
|
||||
import { useForm } from '@mantine/hooks';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { nfregex, okNotify } from '../../../js/utils';
|
||||
import { okNotify } from '../../../js/utils';
|
||||
import { ImCross } from "react-icons/im"
|
||||
import { Service } from '../../../js/models';
|
||||
import { nfregex, Service } from '../utils';
|
||||
|
||||
function RenameForm({ opened, onClose, service }:{ opened:boolean, onClose:()=>void, service:Service }) {
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { ActionIcon, Badge, Divider, Grid, MediaQuery, Menu, Space, Title, Tooltip } from '@mantine/core';
|
||||
import React, { useState } from 'react';
|
||||
import { FaPlay, FaStop } from 'react-icons/fa';
|
||||
import { Service } from '../../../js/models';
|
||||
import { nfregex, Service } from '../utils';
|
||||
import { MdOutlineArrowForwardIos } from "react-icons/md"
|
||||
import style from "./index.module.scss";
|
||||
import YesNoModal from '../../YesNoModal';
|
||||
import { errorNotify, nfregex, okNotify, regex_ipv4 } from '../../../js/utils';
|
||||
import { errorNotify, okNotify, regex_ipv4 } from '../../../js/utils';
|
||||
import { BsTrashFill } from 'react-icons/bs';
|
||||
import { BiRename } from 'react-icons/bi'
|
||||
import RenameForm from './RenameForm';
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { ServerResponse } from "../../js/models"
|
||||
import { RegexFilter, ServerResponse } from "../../js/models"
|
||||
import { getapi, postapi } from "../../js/utils"
|
||||
import { RegexAddForm } from "../../js/models"
|
||||
|
||||
export type GeneralStats = {
|
||||
services:number,
|
||||
@@ -30,25 +31,7 @@ export type ServiceAddResponse = {
|
||||
service_id?: string,
|
||||
}
|
||||
|
||||
export type RegexFilter = {
|
||||
id:number,
|
||||
service_id:string,
|
||||
regex:string
|
||||
is_blacklist:boolean,
|
||||
is_case_sensitive:boolean,
|
||||
mode:string //C S B => C->S S->C BOTH
|
||||
n_packets:number,
|
||||
active:boolean
|
||||
}
|
||||
|
||||
export type RegexAddForm = {
|
||||
service_id:string,
|
||||
regex:string,
|
||||
is_case_sensitive:boolean,
|
||||
is_blacklist:boolean,
|
||||
mode:string, // C->S S->C BOTH,
|
||||
active: boolean
|
||||
}
|
||||
|
||||
export const nfregex = {
|
||||
stats: async () => {
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { Button, Group, NumberInput, Space, TextInput, Notification, Modal, Switch } from '@mantine/core';
|
||||
import { useForm } from '@mantine/hooks';
|
||||
import React, { useState } from 'react';
|
||||
import { addservice, fireUpdateRequest, okNotify, startservice } from '../js/utils';
|
||||
import { fireUpdateRequest, okNotify } from '../../js/utils';
|
||||
import { ImCross } from "react-icons/im"
|
||||
import { regexproxy } from './utils';
|
||||
|
||||
type ServiceAddForm = {
|
||||
name:string,
|
||||
@@ -40,12 +41,12 @@ function AddNewService({ opened, onClose }:{ opened:boolean, onClose:()=>void })
|
||||
|
||||
const submitRequest = ({ name, port, autostart, chosenInternalPort, internalPort }:ServiceAddForm) =>{
|
||||
setSubmitLoading(true)
|
||||
addservice(chosenInternalPort?{ internalPort, name, port }:{ name, port }).then( res => {
|
||||
regexproxy.servicesadd(chosenInternalPort?{ internalPort, name, port }:{ name, port }).then( res => {
|
||||
if (res.status === "ok"){
|
||||
setSubmitLoading(false)
|
||||
close();
|
||||
fireUpdateRequest();
|
||||
if (autostart) startservice(res.id)
|
||||
if (autostart) regexproxy.servicestart(res.id)
|
||||
okNotify(`Service ${name} has been added`, `Successfully added ${res.id} with port ${port}`)
|
||||
}else{
|
||||
setSubmitLoading(false)
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
|
||||
@use "../../vars" as *;
|
||||
|
||||
.box{
|
||||
padding:30px;
|
||||
margin:5px;
|
||||
}
|
||||
|
||||
.regex_text{
|
||||
padding: 10px;
|
||||
background-color: $third_color;
|
||||
border-radius: 15px;
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
import { Grid, Text, Title, Badge, Space, ActionIcon, Tooltip } from '@mantine/core';
|
||||
import React, { useState } from 'react';
|
||||
import { RegexFilter } from '../../js/models';
|
||||
import { activateregex, b64decode, deactivateregex, deleteregex, errorNotify, fireUpdateRequest, okNotify } from '../../js/utils';
|
||||
import style from "./RegexView.module.scss";
|
||||
import { BsTrashFill } from "react-icons/bs"
|
||||
import YesNoModal from '../YesNoModal';
|
||||
import FilterTypeSelector from '../FilterTypeSelector';
|
||||
import { FaPause, FaPlay } from 'react-icons/fa';
|
||||
|
||||
|
||||
function RegexView({ regexInfo }:{ regexInfo:RegexFilter }) {
|
||||
|
||||
const mode_string = regexInfo.mode === "C"? "C -> S":
|
||||
regexInfo.mode === "S"? "S -> C":
|
||||
regexInfo.mode === "B"? "S <-> C": "🤔"
|
||||
|
||||
let regex_expr = b64decode(regexInfo.regex);
|
||||
|
||||
const [deleteModal, setDeleteModal] = useState(false);
|
||||
const [deleteTooltipOpened, setDeleteTooltipOpened] = useState(false);
|
||||
const [statusTooltipOpened, setStatusTooltipOpened] = useState(false);
|
||||
|
||||
const deleteRegex = () => {
|
||||
deleteregex(regexInfo.id).then(res => {
|
||||
if(!res){
|
||||
okNotify(`Regex ${regex_expr} deleted successfully!`,`Regex '${regex_expr}' ID:${regexInfo.id} has been deleted!`)
|
||||
fireUpdateRequest()
|
||||
}else{
|
||||
errorNotify(`Regex ${regex_expr} deleation failed!`,`Error: ${res}`)
|
||||
}
|
||||
}).catch( err => errorNotify(`Regex ${regex_expr} deleation failed!`,`Error: ${err}`))
|
||||
}
|
||||
|
||||
const changeRegexStatus = () => {
|
||||
|
||||
(regexInfo.active?deactivateregex:activateregex)(regexInfo.id).then(res => {
|
||||
if(!res){
|
||||
okNotify(`Regex ${regex_expr} ${regexInfo.active?"deactivated":"activated"} successfully!`,`Regex '${regex_expr}' ID:${regexInfo.id} has been ${regexInfo.active?"deactivated":"activated"}!`)
|
||||
fireUpdateRequest()
|
||||
}else{
|
||||
errorNotify(`Regex ${regex_expr} ${regexInfo.active?"deactivation":"activation"} failed!`,`Error: ${res}`)
|
||||
}
|
||||
}).catch( err => errorNotify(`Regex ${regex_expr} ${regexInfo.active?"deactivation":"activation"} failed!`,`Error: ${err}`))
|
||||
|
||||
}
|
||||
|
||||
return <div className={style.box}>
|
||||
<Grid>
|
||||
<Grid.Col span={2}>
|
||||
<Title order={2} style={{color:"#FFF"}}>Regex:</Title>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={8}>
|
||||
<Text className={style.regex_text}> {regex_expr}</Text>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={2} className='center-flex'>
|
||||
<Space w="xs" />
|
||||
<Tooltip label={regexInfo.active?"Deactivate":"Activate"} zIndex={0} transition="pop" transitionDuration={200} /*openDelay={500}*/ transitionTimingFunction="ease" color={regexInfo.active?"orange":"teal"} opened={statusTooltipOpened}>
|
||||
<ActionIcon color={regexInfo.active?"orange":"teal"} onClick={changeRegexStatus} size="xl" radius="md" variant="filled"
|
||||
onFocus={() => setStatusTooltipOpened(false)} onBlur={() => setStatusTooltipOpened(false)}
|
||||
onMouseEnter={() => setStatusTooltipOpened(true)} onMouseLeave={() => setStatusTooltipOpened(false)}
|
||||
>{regexInfo.active?<FaPause size="20px" />:<FaPlay size="20px" />}</ActionIcon>
|
||||
</Tooltip>
|
||||
<Space w="xs" />
|
||||
<Tooltip label="Delete regex" zIndex={0} transition="pop" transitionDuration={200} /*openDelay={500}*/ transitionTimingFunction="ease" color="red" opened={deleteTooltipOpened} >
|
||||
<ActionIcon color="red" onClick={()=>setDeleteModal(true)} size="xl" radius="md" variant="filled"
|
||||
onFocus={() => setDeleteTooltipOpened(false)} onBlur={() => setDeleteTooltipOpened(false)}
|
||||
onMouseEnter={() => setDeleteTooltipOpened(true)} onMouseLeave={() => setDeleteTooltipOpened(false)}
|
||||
><BsTrashFill size={22} /></ActionIcon>
|
||||
</Tooltip>
|
||||
|
||||
</Grid.Col>
|
||||
<Grid.Col span={2} />
|
||||
<Grid.Col className='center-flex-row' span={4}>
|
||||
<Space h="xs" />
|
||||
<FilterTypeSelector
|
||||
size="md"
|
||||
color="gray"
|
||||
disabled
|
||||
value={regexInfo.is_blacklist?"blacklist":"whitelist"}
|
||||
/>
|
||||
<Space h="md" />
|
||||
<div className='center-flex'>
|
||||
<Badge size="md" color="cyan" variant="filled">Service: {regexInfo.service_id}</Badge>
|
||||
<Space w="xs" />
|
||||
<Badge size="md" color={regexInfo.active?"lime":"red"} variant="filled">{regexInfo.active?"ACTIVE":"DISABLED"}</Badge>
|
||||
<Space w="xs" />
|
||||
<Badge size="md" color="gray" variant="filled">ID: {regexInfo.id}</Badge>
|
||||
|
||||
</div>
|
||||
</Grid.Col>
|
||||
<Grid.Col style={{width:"100%"}} span={6}>
|
||||
<Space h="xs" />
|
||||
<div className='center-flex-row'>
|
||||
<Badge size="md" color={regexInfo.is_case_sensitive?"grape":"pink"} variant="filled">Case: {regexInfo.is_case_sensitive?"SENSIIVE":"INSENSITIVE"}</Badge>
|
||||
<Space h="xs" />
|
||||
<Badge size="md" color="yellow" variant="filled">Packets filtered: {regexInfo.n_packets}</Badge>
|
||||
<Space h="xs" />
|
||||
<Badge size="md" color="blue" variant="filled">Mode: {mode_string}</Badge>
|
||||
</div>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
<YesNoModal
|
||||
title='Are you sure to delete this regex?'
|
||||
description={`You are going to delete the regex '${regex_expr}'.`}
|
||||
onClose={()=>setDeleteModal(false)}
|
||||
action={deleteRegex}
|
||||
opened={deleteModal}
|
||||
/>
|
||||
|
||||
</div>
|
||||
}
|
||||
|
||||
export default RegexView;
|
||||
@@ -1,10 +1,10 @@
|
||||
import { Button, Group, NumberInput, Space, Notification, Modal, Center, Title } from '@mantine/core';
|
||||
import { useForm } from '@mantine/hooks';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { changeports, fireUpdateRequest, okNotify } from '../../js/utils';
|
||||
import { ImCross } from "react-icons/im"
|
||||
import { Service } from '../../js/models';
|
||||
import { FaLongArrowAltDown } from 'react-icons/fa';
|
||||
import { regexproxy, Service } from '../utils';
|
||||
import { fireUpdateRequest, okNotify } from '../../../js/utils';
|
||||
|
||||
type InputForm = {
|
||||
internalPort:number,
|
||||
@@ -39,7 +39,7 @@ function ChangePortModal({ service, opened, onClose }:{ service:Service, opened:
|
||||
|
||||
const submitRequest = (data:InputForm) =>{
|
||||
setSubmitLoading(true)
|
||||
changeports(service.id, data).then( res => {
|
||||
regexproxy.servicechangeport(service.id, data).then( res => {
|
||||
if (!res){
|
||||
setSubmitLoading(false)
|
||||
close();
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Button, Group, Space, TextInput, Notification, Modal } from '@mantine/core';
|
||||
import { useForm } from '@mantine/hooks';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { fireUpdateRequest, okNotify, renameservice } from '../../js/utils';
|
||||
import { fireUpdateRequest, okNotify } from '../../../js/utils';
|
||||
import { ImCross } from "react-icons/im"
|
||||
import { Service } from '../../js/models';
|
||||
import { regexproxy, Service } from '../utils';
|
||||
|
||||
function RenameForm({ opened, onClose, service }:{ opened:boolean, onClose:()=>void, service:Service }) {
|
||||
|
||||
@@ -25,7 +25,7 @@ function RenameForm({ opened, onClose, service }:{ opened:boolean, onClose:()=>v
|
||||
|
||||
const submitRequest = ({ name }:{ name:string }) => {
|
||||
setSubmitLoading(true)
|
||||
renameservice(service.id, name).then( res => {
|
||||
regexproxy.servicerename(service.id, name).then( res => {
|
||||
if (!res){
|
||||
setSubmitLoading(false)
|
||||
close();
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import { ActionIcon, Badge, Divider, Grid, MediaQuery, Menu, Space, Title, Tooltip } from '@mantine/core';
|
||||
import React, { useState } from 'react';
|
||||
import { FaPause, FaPlay, FaStop } from 'react-icons/fa';
|
||||
import { Service } from '../../js/models';
|
||||
import { MdOutlineArrowForwardIos } from "react-icons/md"
|
||||
import style from "./ServiceRow.module.scss";
|
||||
import YesNoModal from '../YesNoModal';
|
||||
import { deleteservice, errorNotify, fireUpdateRequest, okNotify, pauseservice, regenport, startservice, stopservice } from '../../js/utils';
|
||||
import YesNoModal from '../../YesNoModal';
|
||||
import { errorNotify, fireUpdateRequest, okNotify } from '../../../js/utils';
|
||||
import { BsArrowRepeat, BsTrashFill } from 'react-icons/bs';
|
||||
import { TbNumbers } from 'react-icons/tb';
|
||||
import { BiRename } from 'react-icons/bi'
|
||||
import ChangePortModal from './ChangePortModal';
|
||||
import RenameForm from './RenameForm';
|
||||
import { regexproxy, Service } from '../utils';
|
||||
|
||||
//"status":"stop"/"wait"/"active"/"pause",
|
||||
function ServiceRow({ service, onClick }:{ service:Service, onClick?:()=>void }) {
|
||||
@@ -33,7 +33,7 @@ function ServiceRow({ service, onClick }:{ service:Service, onClick?:()=>void })
|
||||
|
||||
const stopService = async () => {
|
||||
setButtonLoading(true)
|
||||
await stopservice(service.id).then(res => {
|
||||
await regexproxy.servicestop(service.id).then(res => {
|
||||
if(!res){
|
||||
okNotify(`Service ${service.id} stopped successfully!`,`The service ${service.name} has been stopped!`)
|
||||
fireUpdateRequest();
|
||||
@@ -48,7 +48,7 @@ function ServiceRow({ service, onClick }:{ service:Service, onClick?:()=>void })
|
||||
|
||||
const startService = async () => {
|
||||
setButtonLoading(true)
|
||||
await startservice(service.id).then(res => {
|
||||
await regexproxy.servicestart(service.id).then(res => {
|
||||
if(!res){
|
||||
okNotify(`Service ${service.id} started successfully!`,`The service ${service.name} has been started!`)
|
||||
fireUpdateRequest();
|
||||
@@ -63,7 +63,7 @@ function ServiceRow({ service, onClick }:{ service:Service, onClick?:()=>void })
|
||||
|
||||
const pauseService = async () => {
|
||||
setButtonLoading(true)
|
||||
await pauseservice(service.id).then(res => {
|
||||
await regexproxy.servicepause(service.id).then(res => {
|
||||
if(!res){
|
||||
okNotify(`Service ${service.id} paused successfully!`,`The service ${service.name} has been paused (Transparent mode)!`)
|
||||
fireUpdateRequest();
|
||||
@@ -78,7 +78,7 @@ function ServiceRow({ service, onClick }:{ service:Service, onClick?:()=>void })
|
||||
}
|
||||
|
||||
const deleteService = () => {
|
||||
deleteservice(service.id).then(res => {
|
||||
regexproxy.servicedelete(service.id).then(res => {
|
||||
if (!res){
|
||||
okNotify("Service delete complete!",`The service ${service.id} has been deleted!`)
|
||||
fireUpdateRequest();
|
||||
@@ -91,7 +91,7 @@ function ServiceRow({ service, onClick }:{ service:Service, onClick?:()=>void })
|
||||
}
|
||||
|
||||
const changePort = () => {
|
||||
regenport(service.id).then(res => {
|
||||
regexproxy.serviceregenport(service.id).then(res => {
|
||||
if (!res){
|
||||
okNotify("Service port regeneration completed!",`The service ${service.id} has changed the internal port!`)
|
||||
fireUpdateRequest();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ServerResponse } from "../../js/models"
|
||||
import { RegexAddForm, RegexFilter, ServerResponse } from "../../js/models"
|
||||
import { getapi, postapi } from "../../js/utils"
|
||||
|
||||
export type GeneralStats = {
|
||||
@@ -33,26 +33,6 @@ export type ChangePort = {
|
||||
internalPort?: number
|
||||
}
|
||||
|
||||
export type RegexFilter = {
|
||||
id:number,
|
||||
service_id:string,
|
||||
regex:string
|
||||
is_blacklist:boolean,
|
||||
is_case_sensitive:boolean,
|
||||
mode:string //C S B => C->S S->C BOTH
|
||||
n_packets:number,
|
||||
active:boolean
|
||||
}
|
||||
|
||||
export type RegexAddForm = {
|
||||
service_id:string,
|
||||
regex:string,
|
||||
is_case_sensitive:boolean,
|
||||
is_blacklist:boolean,
|
||||
mode:string, // C->S S->C BOTH,
|
||||
active: boolean
|
||||
}
|
||||
|
||||
export const regexproxy = {
|
||||
stats: async () => {
|
||||
return await getapi("regexproxy/stats") as GeneralStats;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
@use "../../../vars" as *;
|
||||
@use "../../vars" as *;
|
||||
|
||||
.box{
|
||||
padding:30px;
|
||||
@@ -1,11 +1,11 @@
|
||||
import { Grid, Text, Title, Badge, Space, ActionIcon, Tooltip } from '@mantine/core';
|
||||
import React, { useState } from 'react';
|
||||
import { RegexFilter } from '../../../js/models';
|
||||
import { b64decode, errorNotify, nfregex, okNotify } from '../../../js/utils';
|
||||
import { RegexFilter } from '../../js/models';
|
||||
import { b64decode, errorNotify, getapiobject, okNotify } from '../../js/utils';
|
||||
import style from "./index.module.scss";
|
||||
import { BsTrashFill } from "react-icons/bs"
|
||||
import YesNoModal from '../../YesNoModal';
|
||||
import FilterTypeSelector from '../../FilterTypeSelector';
|
||||
import YesNoModal from '../YesNoModal';
|
||||
import FilterTypeSelector from '../FilterTypeSelector';
|
||||
import { FaPause, FaPlay } from 'react-icons/fa';
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ function RegexView({ regexInfo }:{ regexInfo:RegexFilter }) {
|
||||
const [statusTooltipOpened, setStatusTooltipOpened] = useState(false);
|
||||
|
||||
const deleteRegex = () => {
|
||||
nfregex.regexdelete(regexInfo.id).then(res => {
|
||||
getapiobject().regexdelete(regexInfo.id).then(res => {
|
||||
if(!res){
|
||||
okNotify(`Regex ${regex_expr} deleted successfully!`,`Regex '${regex_expr}' ID:${regexInfo.id} has been deleted!`)
|
||||
}else{
|
||||
@@ -32,15 +32,13 @@ function RegexView({ regexInfo }:{ regexInfo:RegexFilter }) {
|
||||
}
|
||||
|
||||
const changeRegexStatus = () => {
|
||||
|
||||
(regexInfo.active?nfregex.regexdisable:nfregex.regexenable)(regexInfo.id).then(res => {
|
||||
(regexInfo.active?getapiobject().regexdisable:getapiobject().regexenable)(regexInfo.id).then(res => {
|
||||
if(!res){
|
||||
okNotify(`Regex ${regex_expr} ${regexInfo.active?"deactivated":"activated"} successfully!`,`Regex '${regex_expr}' ID:${regexInfo.id} has been ${regexInfo.active?"deactivated":"activated"}!`)
|
||||
}else{
|
||||
errorNotify(`Regex ${regex_expr} ${regexInfo.active?"deactivation":"activation"} failed!`,`Error: ${res}`)
|
||||
}
|
||||
}).catch( err => errorNotify(`Regex ${regex_expr} ${regexInfo.active?"deactivation":"activation"} failed!`,`Error: ${err}`))
|
||||
|
||||
}
|
||||
|
||||
return <div className={style.box}>
|
||||
Reference in New Issue
Block a user