nfqueue to hyperscan and stream match, removed proxyregex
This commit is contained in:
@@ -1,15 +1,12 @@
|
||||
import { Button, Group, Space, TextInput, Notification, Switch, NativeSelect, Modal, Alert } from '@mantine/core';
|
||||
import { Button, Group, Space, TextInput, Notification, Switch, NativeSelect, Modal } from '@mantine/core';
|
||||
import { useForm } from '@mantine/form';
|
||||
import { useState } from 'react';
|
||||
import { RegexAddForm } from '../js/models';
|
||||
import { b64decode, b64encode, getapiobject, okNotify } from '../js/utils';
|
||||
import { ImCross } from "react-icons/im"
|
||||
import FilterTypeSelector from './FilterTypeSelector';
|
||||
import { AiFillWarning } from 'react-icons/ai';
|
||||
|
||||
type RegexAddInfo = {
|
||||
regex:string,
|
||||
type:string,
|
||||
mode:string,
|
||||
is_case_insensitive:boolean,
|
||||
deactive:boolean
|
||||
@@ -20,14 +17,12 @@ function AddNewRegex({ opened, onClose, service }:{ opened:boolean, onClose:()=>
|
||||
const form = useForm({
|
||||
initialValues: {
|
||||
regex:"",
|
||||
type:"blacklist",
|
||||
mode:"C -> S",
|
||||
is_case_insensitive:false,
|
||||
deactive:false
|
||||
},
|
||||
validate:{
|
||||
regex: (value) => value !== "" ? null : "Regex is required",
|
||||
type: (value) => ["blacklist","whitelist"].includes(value) ? null : "Invalid type",
|
||||
mode: (value) => ['C -> S', 'S -> C', 'C <-> S'].includes(value) ? null : "Invalid mode",
|
||||
}
|
||||
})
|
||||
@@ -46,7 +41,6 @@ function AddNewRegex({ opened, onClose, service }:{ opened:boolean, onClose:()=>
|
||||
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",
|
||||
@@ -58,7 +52,7 @@ function AddNewRegex({ opened, onClose, service }:{ opened:boolean, onClose:()=>
|
||||
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`)
|
||||
okNotify(`Regex ${b64decode(request.regex)} has been added`, `Successfully added ${request.is_case_sensitive?"case sensitive":"case insensitive"} regex to ${request.service_id} service`)
|
||||
}else if (res.toLowerCase() === "invalid regex"){
|
||||
setSubmitLoading(false)
|
||||
form.setFieldError("regex", "Invalid Regex")
|
||||
@@ -98,16 +92,6 @@ function AddNewRegex({ opened, onClose, service }:{ opened:boolean, onClose:()=>
|
||||
variant="filled"
|
||||
{...form.getInputProps('mode')}
|
||||
/>
|
||||
<Space h="md" />
|
||||
<FilterTypeSelector
|
||||
size="md"
|
||||
color="gray"
|
||||
{...form.getInputProps('type')}
|
||||
/>
|
||||
{form.values.type == "whitelist"?<><Space h="md" />
|
||||
<Alert variant="light" color="yellow" radius="lg" title="You are using whitelists" icon={<AiFillWarning />}>
|
||||
Using whitelist means that EVERY packet that doesn't match the regex will be DROPPED... In most cases this cause the service interruption.
|
||||
</Alert></>:null}
|
||||
<Group align="right" mt="md">
|
||||
<Button loading={submitLoading} type="submit">Add Filter</Button>
|
||||
</Group>
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
import { Box, Center, SegmentedControl } from "@mantine/core";
|
||||
import { FaListAlt } from "react-icons/fa";
|
||||
import { TiCancel } from "react-icons/ti";
|
||||
|
||||
export default function FilterTypeSelector(props:any){
|
||||
return <SegmentedControl
|
||||
data={[
|
||||
{
|
||||
value: 'blacklist',
|
||||
label: (
|
||||
<Center style={{color:"#FFF"}}>
|
||||
<TiCancel size={23} color="red"/>
|
||||
<Box ml={10}>Blacklist</Box>
|
||||
</Center>
|
||||
),
|
||||
},
|
||||
{
|
||||
value: 'whitelist',
|
||||
label: (
|
||||
<Center style={{color:"#FFF"}}>
|
||||
<FaListAlt size={16} color="gray"/>
|
||||
<Box ml={10}>Whitelist</Box>
|
||||
</Center>
|
||||
),
|
||||
},
|
||||
]}
|
||||
{...props}
|
||||
/>
|
||||
}
|
||||
@@ -39,11 +39,6 @@ export default function NavBar() {
|
||||
<NavBarButton navigate="nfregex" closeNav={closeNav} name="Netfilter Regex" color="lime" icon={<IoMdGitNetwork />} />
|
||||
<NavBarButton navigate="firewall" closeNav={closeNav} name="Firewall Rules" color="red" icon={<PiWallLight />} />
|
||||
<NavBarButton navigate="porthijack" closeNav={closeNav} name="Hijack Port to Proxy" color="blue" icon={<GrDirections />} />
|
||||
<Divider my="xs" label="Advanced" labelPosition="center" />
|
||||
<NavBarButton closeNav={closeNav} name="Deprecated options" color="gray" icon={toggle ? <MdOutlineExpandLess /> : <MdOutlineExpandMore />} onClick={()=>setToggleState(!toggle)}/>
|
||||
<Collapse in={toggle}>
|
||||
<NavBarButton navigate="regexproxy" closeNav={closeNav} name="TCP Proxy Regex Filter" color="grape" icon={<MdTransform />} />
|
||||
</Collapse>
|
||||
</Box>
|
||||
|
||||
</AppShell.Navbar>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ServerResponse } from "../../js/models"
|
||||
import { getapi, postapi } from "../../js/utils"
|
||||
import { UseQueryOptions, useQuery } from "@tanstack/react-query"
|
||||
import { useQuery } from "@tanstack/react-query"
|
||||
|
||||
export type GeneralStats = {
|
||||
services:number
|
||||
|
||||
@@ -1,117 +0,0 @@
|
||||
import { Button, Group, Space, TextInput, Notification, Modal, Switch } from '@mantine/core';
|
||||
import { useForm } from '@mantine/form';
|
||||
import { useState } from 'react';
|
||||
import { okNotify } from '../../js/utils';
|
||||
import { ImCross } from "react-icons/im"
|
||||
import { regexproxy } from './utils';
|
||||
import PortInput from '../PortInput';
|
||||
|
||||
type ServiceAddForm = {
|
||||
name:string,
|
||||
port:number,
|
||||
autostart: boolean,
|
||||
chosenInternalPort: boolean,
|
||||
internalPort: number
|
||||
}
|
||||
|
||||
function AddNewService({ opened, onClose }:{ opened:boolean, onClose:()=>void }) {
|
||||
|
||||
const form = useForm({
|
||||
initialValues: {
|
||||
name:"",
|
||||
port:8080,
|
||||
internalPort:30001,
|
||||
chosenInternalPort:false,
|
||||
autostart: true
|
||||
},
|
||||
validate:{
|
||||
name: (value) => value !== ""? null : "Service name is required",
|
||||
port: (value) => (value>0 && value<65536) ? null : "Invalid port",
|
||||
internalPort: (value) => (value>0 && value<65536) ? null : "Invalid internal port",
|
||||
}
|
||||
})
|
||||
|
||||
const close = () =>{
|
||||
onClose()
|
||||
form.reset()
|
||||
setError(null)
|
||||
}
|
||||
|
||||
const [submitLoading, setSubmitLoading] = useState(false)
|
||||
const [error, setError] = useState<string|null>(null)
|
||||
|
||||
const submitRequest = ({ name, port, autostart, chosenInternalPort, internalPort }:ServiceAddForm) =>{
|
||||
setSubmitLoading(true)
|
||||
regexproxy.servicesadd(chosenInternalPort?{ internalPort, name, port }:{ name, port }).then( res => {
|
||||
if (res.status === "ok"){
|
||||
setSubmitLoading(false)
|
||||
close();
|
||||
if (autostart) regexproxy.servicestart(res.id)
|
||||
okNotify(`Service ${name} has been added`, `Successfully added ${res.id} with port ${port}`)
|
||||
}else{
|
||||
setSubmitLoading(false)
|
||||
setError("Invalid request! [ "+res.status+" ]")
|
||||
}
|
||||
}).catch( err => {
|
||||
setSubmitLoading(false)
|
||||
setError("Request Failed! [ "+err+" ]")
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
return <Modal size="xl" title="Add a new service" opened={opened} onClose={close} closeOnClickOutside={false} centered>
|
||||
<form onSubmit={form.onSubmit(submitRequest)}>
|
||||
<TextInput
|
||||
label="Service name"
|
||||
placeholder="Challenge 01"
|
||||
{...form.getInputProps('name')}
|
||||
/>
|
||||
<Space h="md" />
|
||||
|
||||
<PortInput
|
||||
fullWidth
|
||||
label="Public Service port"
|
||||
{...form.getInputProps('port')}
|
||||
/>
|
||||
|
||||
{form.values.chosenInternalPort?<>
|
||||
<Space h="md" />
|
||||
<PortInput
|
||||
fullWidth
|
||||
label="Internal Proxy Port"
|
||||
{...form.getInputProps('internalPort')}
|
||||
/>
|
||||
<Space h="sm" />
|
||||
</>:null}
|
||||
|
||||
<Space h="xl" />
|
||||
|
||||
<Switch
|
||||
label="Auto-Start Service"
|
||||
{...form.getInputProps('autostart', { type: 'checkbox' })}
|
||||
/>
|
||||
|
||||
<Space h="md" />
|
||||
|
||||
<Switch
|
||||
label="Choose internal port"
|
||||
{...form.getInputProps('chosenInternalPort', { type: 'checkbox' })}
|
||||
/>
|
||||
|
||||
<Group align="right" mt="md">
|
||||
<Button loading={submitLoading} type="submit">Add Service</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 AddNewService;
|
||||
@@ -1,101 +0,0 @@
|
||||
import { Button, Group, Space, Notification, Modal, Center, Title } from '@mantine/core';
|
||||
import { useForm } from '@mantine/form';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { ImCross } from "react-icons/im"
|
||||
import { FaLongArrowAltDown } from 'react-icons/fa';
|
||||
import { regexproxy, Service } from '../utils';
|
||||
import { okNotify } from '../../../js/utils';
|
||||
import PortInput from '../../PortInput';
|
||||
|
||||
type InputForm = {
|
||||
internalPort:number,
|
||||
port:number
|
||||
}
|
||||
|
||||
function ChangePortModal({ service, opened, onClose }:{ service:Service, opened:boolean, onClose:()=>void }) {
|
||||
|
||||
const form = useForm({
|
||||
initialValues: {
|
||||
internalPort: service.internal_port,
|
||||
port: service.public_port
|
||||
},
|
||||
validate:{
|
||||
internalPort: (value) => (value>0 && value<65536) ? null : "Invalid internal port",
|
||||
port: (value) => (value>0 && value<65536) ? null : "Invalid public port",
|
||||
}
|
||||
})
|
||||
|
||||
useEffect(()=>{
|
||||
form.setValues({internalPort: service.internal_port, port:service.public_port})
|
||||
},[opened])
|
||||
|
||||
const close = () =>{
|
||||
onClose()
|
||||
form.reset()
|
||||
setError(null)
|
||||
}
|
||||
|
||||
const [submitLoading, setSubmitLoading] = useState(false)
|
||||
const [error, setError] = useState<string|null>(null)
|
||||
|
||||
const submitRequest = (data:InputForm) =>{
|
||||
setSubmitLoading(true)
|
||||
regexproxy.servicechangeport(service.id, data).then( res => {
|
||||
if (!res){
|
||||
setSubmitLoading(false)
|
||||
close();
|
||||
okNotify(`Internal port on ${service.name} service has changed in ${data.internalPort}`, `Successfully changed internal port of service with id ${service.id}`)
|
||||
}else{
|
||||
setSubmitLoading(false)
|
||||
setError("Invalid request! [ "+res+" ]")
|
||||
}
|
||||
}).catch( err => {
|
||||
setSubmitLoading(false)
|
||||
setError("Request Failed! [ "+err+" ]")
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
return <Modal size="xl" title="Change Ports" opened={opened} onClose={close} closeOnClickOutside={false} centered>
|
||||
<form onSubmit={form.onSubmit(submitRequest)}>
|
||||
|
||||
<PortInput
|
||||
fullWidth
|
||||
label="Internal Proxy Port"
|
||||
{...form.getInputProps('internalPort')}
|
||||
/>
|
||||
|
||||
<Space h="xl" />
|
||||
<Center><FaLongArrowAltDown size={50}/></Center>
|
||||
|
||||
<PortInput
|
||||
fullWidth
|
||||
label="Public Service Port"
|
||||
{...form.getInputProps('port')}
|
||||
/>
|
||||
|
||||
<Space h="xl" />
|
||||
|
||||
<Center><Title order={5}>The change of the ports will cause a temporarily shutdown of the service! ⚠️</Title></Center>
|
||||
|
||||
<Space h="md" />
|
||||
|
||||
<Group align="right" mt="md">
|
||||
<Button loading={submitLoading} disabled={
|
||||
service.internal_port === form.values.internalPort && service.public_port === form.values.port
|
||||
} type="submit">Change Port</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 ChangePortModal;
|
||||
@@ -1,68 +0,0 @@
|
||||
import { Button, Group, Space, TextInput, Notification, Modal } from '@mantine/core';
|
||||
import { useForm } from '@mantine/form';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { okNotify } from '../../../js/utils';
|
||||
import { ImCross } from "react-icons/im"
|
||||
import { regexproxy, Service } from '../utils';
|
||||
|
||||
function RenameForm({ opened, onClose, service }:{ opened:boolean, onClose:()=>void, service:Service }) {
|
||||
|
||||
const form = useForm({
|
||||
initialValues: { name:service.name },
|
||||
validate:{ name: (value) => value !== ""? null : "Service name is required" }
|
||||
})
|
||||
|
||||
const close = () =>{
|
||||
onClose()
|
||||
form.reset()
|
||||
setError(null)
|
||||
}
|
||||
|
||||
useEffect(()=> form.setFieldValue("name", service.name),[opened])
|
||||
|
||||
const [submitLoading, setSubmitLoading] = useState(false)
|
||||
const [error, setError] = useState<string|null>(null)
|
||||
|
||||
const submitRequest = ({ name }:{ name:string }) => {
|
||||
setSubmitLoading(true)
|
||||
regexproxy.servicerename(service.id, name).then( res => {
|
||||
if (!res){
|
||||
setSubmitLoading(false)
|
||||
close();
|
||||
okNotify(`Service ${service.name} has been renamed in ${ name }`, `Successfully renamed service on port ${service.public_port}`)
|
||||
}else{
|
||||
setSubmitLoading(false)
|
||||
setError("Error: [ "+res+" ]")
|
||||
}
|
||||
}).catch( err => {
|
||||
setSubmitLoading(false)
|
||||
setError("Request Failed! [ "+err+" ]")
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
||||
return <Modal size="xl" title={`Rename '${service.name}' service on port ${service.public_port}`} opened={opened} onClose={close} closeOnClickOutside={false} centered>
|
||||
<form onSubmit={form.onSubmit(submitRequest)}>
|
||||
<TextInput
|
||||
label="Service Name"
|
||||
placeholder="Awesome Service Name!"
|
||||
{...form.getInputProps('name')}
|
||||
/>
|
||||
<Group align="right" mt="md">
|
||||
<Button loading={submitLoading} type="submit">Rename</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 RenameForm;
|
||||
@@ -1,205 +0,0 @@
|
||||
import { ActionIcon, Badge, Box, Divider, Grid, Menu, Space, Title, Tooltip } from '@mantine/core';
|
||||
import { useState } from 'react';
|
||||
import { FaPause, FaPlay, FaStop } from 'react-icons/fa';
|
||||
import { MdOutlineArrowForwardIos } from "react-icons/md"
|
||||
import YesNoModal from '../../YesNoModal';
|
||||
import { errorNotify, isMediumScreen, 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';
|
||||
import { MenuDropDownWithButton } from '../../MainLayout';
|
||||
|
||||
//"status":"stop"/"wait"/"active"/"pause",
|
||||
function ServiceRow({ service, onClick }:{ service:Service, onClick?:()=>void }) {
|
||||
|
||||
let status_color = "gray";
|
||||
switch(service.status){
|
||||
case "stop": status_color = "red"; break;
|
||||
case "wait": status_color = "yellow"; break;
|
||||
case "active": status_color = "teal"; break;
|
||||
case "pause": status_color = "cyan"; break;
|
||||
}
|
||||
|
||||
const [stopModal, setStopModal] = useState(false);
|
||||
const [buttonLoading, setButtonLoading] = useState(false)
|
||||
const [tooltipStopOpened, setTooltipStopOpened] = useState(false);
|
||||
const [deleteModal, setDeleteModal] = useState(false)
|
||||
const [changePortModal, setChangePortModal] = useState(false)
|
||||
const [choosePortModal, setChoosePortModal] = useState(false)
|
||||
const [renameModal, setRenameModal] = useState(false)
|
||||
|
||||
const isMedium = isMediumScreen()
|
||||
|
||||
const stopService = async () => {
|
||||
setButtonLoading(true)
|
||||
await regexproxy.servicestop(service.id).then(res => {
|
||||
if(!res){
|
||||
okNotify(`Service ${service.id} stopped successfully!`,`The service ${service.name} has been stopped!`)
|
||||
}else{
|
||||
errorNotify(`An error as occurred during the stopping of the service ${service.id}`,`Error: ${res}`)
|
||||
}
|
||||
}).catch(err => {
|
||||
errorNotify(`An error as occurred during the stopping of the service ${service.id}`,`Error: ${err}`)
|
||||
})
|
||||
setButtonLoading(false);
|
||||
}
|
||||
|
||||
const startService = async () => {
|
||||
setButtonLoading(true)
|
||||
await regexproxy.servicestart(service.id).then(res => {
|
||||
if(!res){
|
||||
okNotify(`Service ${service.id} started successfully!`,`The service ${service.name} has been started!`)
|
||||
}else{
|
||||
errorNotify(`An error as occurred during the starting of the service ${service.id}`,`Error: ${res}`)
|
||||
}
|
||||
}).catch(err => {
|
||||
errorNotify(`An error as occurred during the starting of the service ${service.id}`,`Error: ${err}`)
|
||||
})
|
||||
setButtonLoading(false)
|
||||
}
|
||||
|
||||
const pauseService = async () => {
|
||||
setButtonLoading(true)
|
||||
await regexproxy.servicepause(service.id).then(res => {
|
||||
if(!res){
|
||||
okNotify(`Service ${service.id} paused successfully!`,`The service ${service.name} has been paused (Transparent mode)!`)
|
||||
}else{
|
||||
errorNotify(`An error as occurred during the pausing of the service ${service.id}`,`Error: ${res}`)
|
||||
}
|
||||
}).catch(err => {
|
||||
errorNotify(`An error as occurred during the pausing of the service ${service.id}`,`Error: ${err}`)
|
||||
})
|
||||
setButtonLoading(false)
|
||||
|
||||
}
|
||||
|
||||
const deleteService = () => {
|
||||
regexproxy.servicedelete(service.id).then(res => {
|
||||
if (!res){
|
||||
okNotify("Service delete complete!",`The service ${service.id} has been deleted!`)
|
||||
}else
|
||||
errorNotify("An error occurred while deleting a service",`Error: ${res}`)
|
||||
}).catch(err => {
|
||||
errorNotify("An error occurred while deleting a service",`Error: ${err}`)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
const changePort = () => {
|
||||
regexproxy.serviceregenport(service.id).then(res => {
|
||||
if (!res){
|
||||
okNotify("Service port regeneration completed!",`The service ${service.id} has changed the internal port!`)
|
||||
}else
|
||||
errorNotify("An error occurred while changing the internal service port",`Error: ${res}`)
|
||||
}).catch(err => {
|
||||
errorNotify("An error occurred while changing the internal service port",`Error: ${err}`)
|
||||
})
|
||||
}
|
||||
|
||||
return <>
|
||||
<Grid className="firegex__servicerow__row" justify="flex-end" style={{width:"100%"}}>
|
||||
<Grid.Col span={{ md:4, xs: 12 }}>
|
||||
<Box className={isMedium?"center-flex-row":"center-flex"}>
|
||||
<Box className="center-flex"><Title className="firegex__servicerow__name">{service.name}</Title> <Badge size="xl" gradient={{ from: 'indigo', to: 'cyan' }} variant="gradient">:{service.public_port}</Badge></Box>
|
||||
<Badge color={status_color} size="lg" radius="md">{service.internal_port} {"->"} {service.public_port}</Badge>
|
||||
</Box>
|
||||
{!isMedium?<Space h="xl" />:null}
|
||||
</Grid.Col>
|
||||
|
||||
<Grid.Col className="center-flex" span={{ md:8, xs: 12 }}>
|
||||
{!isMedium?<Box className='flex-spacer' />:<><Space w="xl" /><Space w="xl" /></>}
|
||||
<Box className="center-flex-row">
|
||||
<Badge style={{marginBottom:"20px"}} color={status_color} radius="sm" size="lg" variant="filled">Status: <u>{service.status}</u></Badge>
|
||||
<Badge style={{marginBottom:"8px"}}color="violet" radius="sm" size="md" variant="filled">Regex: {service.n_regex}</Badge>
|
||||
<Badge color="yellow" radius="sm" size="md" variant="filled">Connections Blocked: {service.n_packets}</Badge>
|
||||
</Box>
|
||||
{isMedium?<Box className='flex-spacer' />:<><Space w="xl" /><Space w="xl" /></>}
|
||||
<Box className="center-flex">
|
||||
<MenuDropDownWithButton>
|
||||
<Menu.Label><b>Rename service</b></Menu.Label>
|
||||
<Menu.Item leftSection={<BiRename size={18} />} onClick={()=>setRenameModal(true)}>Change service name</Menu.Item>
|
||||
<Divider />
|
||||
<Menu.Label><b>Change ports</b></Menu.Label>
|
||||
<Menu.Item leftSection={<TbNumbers size={18} />} onClick={()=>setChoosePortModal(true)}>Change port</Menu.Item>
|
||||
<Menu.Item leftSection={<BsArrowRepeat size={18} />} onClick={()=>setChangePortModal(true)}>Regen proxy port</Menu.Item>
|
||||
<Divider />
|
||||
<Menu.Label><b>Danger zone</b></Menu.Label>
|
||||
<Menu.Item color="red" leftSection={<BsTrashFill size={18} />} onClick={()=>setDeleteModal(true)}>Delete Service</Menu.Item>
|
||||
</MenuDropDownWithButton>
|
||||
<Space w="md"/>
|
||||
{["pause","wait"].includes(service.status)?
|
||||
|
||||
<Tooltip label="Stop service" zIndex={0} color="orange" opened={tooltipStopOpened}>
|
||||
<ActionIcon color="yellow" loading={buttonLoading}
|
||||
onClick={()=>setStopModal(true)} size="xl" radius="md" variant="filled"
|
||||
disabled={service.status === "stop"}
|
||||
aria-describedby="tooltip-stop-id"
|
||||
onFocus={() => setTooltipStopOpened(false)} onBlur={() => setTooltipStopOpened(false)}
|
||||
onMouseEnter={() => setTooltipStopOpened(true)} onMouseLeave={() => setTooltipStopOpened(false)}>
|
||||
<FaStop size="20px" />
|
||||
</ActionIcon>
|
||||
</Tooltip>:
|
||||
<Tooltip label={service.status === "stop"?"Start in pause mode":"Pause service"} zIndex={0} color={service.status === "stop"?"cyan":"red"}>
|
||||
<ActionIcon color={service.status === "stop"?"cyan":"red"} loading={buttonLoading}
|
||||
onClick={pauseService} size="xl" radius="md" variant="filled">
|
||||
<FaPause size="20px" />
|
||||
</ActionIcon>
|
||||
</Tooltip>
|
||||
}
|
||||
|
||||
<Space w="md"/>
|
||||
<Tooltip label="Start service" zIndex={0} color="teal">
|
||||
<ActionIcon color="teal" size="xl" radius="md" onClick={startService} loading={buttonLoading}
|
||||
variant="filled" disabled={!["stop","pause"].includes(service.status)?true:false}>
|
||||
<FaPlay size="20px" />
|
||||
</ActionIcon>
|
||||
</Tooltip>
|
||||
</Box>
|
||||
<Space w="xl" /><Space w="xl" />
|
||||
{onClick?<Box>
|
||||
<MdOutlineArrowForwardIos onClick={onClick} style={{cursor:"pointer"}} size={45} />
|
||||
<Space w="xl" />
|
||||
</Box>:null}
|
||||
{!isMedium?<><Space w="xl" /><Space w="xl" /></>:null}
|
||||
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
<YesNoModal
|
||||
title='Are you sure to stop this service?'
|
||||
description={`You are going to delete the service '${service.id}', causing the firewall to stop. This will cause the shutdown of your service! ⚠️`}
|
||||
onClose={()=>{setStopModal(false);}}
|
||||
action={stopService}
|
||||
opened={stopModal}
|
||||
/>
|
||||
<Divider size="md" style={{width:"100%"}}/>
|
||||
<YesNoModal
|
||||
title='Are you sure to delete this service?'
|
||||
description={`You are going to delete the service '${service.id}', causing the stopping of the firewall and deleting all the regex associated. This will cause the shutdown of your service! ⚠️`}
|
||||
onClose={()=>setDeleteModal(false) }
|
||||
action={deleteService}
|
||||
opened={deleteModal}
|
||||
/>
|
||||
<YesNoModal
|
||||
title='Are you sure to change the proxy internal port?'
|
||||
description={`You are going to change the proxy port '${service.internal_port}'. This will cause the shutdown of your service temporarily! ⚠️`}
|
||||
onClose={()=>setChangePortModal(false)}
|
||||
action={changePort}
|
||||
opened={changePortModal}
|
||||
/>
|
||||
<ChangePortModal
|
||||
service={service}
|
||||
onClose={()=> setChoosePortModal(false)}
|
||||
opened={choosePortModal}
|
||||
/>
|
||||
<RenameForm
|
||||
onClose={()=>setRenameModal(false)}
|
||||
opened={renameModal}
|
||||
service={service}
|
||||
/>
|
||||
</>
|
||||
}
|
||||
|
||||
export default ServiceRow;
|
||||
@@ -1,97 +0,0 @@
|
||||
import { useQuery } from "@tanstack/react-query"
|
||||
import { RegexAddForm, RegexFilter, ServerResponse } from "../../js/models"
|
||||
import { getapi, postapi } from "../../js/utils"
|
||||
|
||||
export type Service = {
|
||||
id:string,
|
||||
name:string,
|
||||
status:string,
|
||||
public_port:number,
|
||||
internal_port:number,
|
||||
n_packets:number,
|
||||
n_regex:number,
|
||||
}
|
||||
|
||||
export type ServiceAddForm = {
|
||||
name:string,
|
||||
port:number,
|
||||
internalPort?:number
|
||||
}
|
||||
|
||||
export type ServerResponseWithID = {
|
||||
status:string,
|
||||
id:string
|
||||
}
|
||||
|
||||
export type ChangePort = {
|
||||
port?: number,
|
||||
internalPort?: number
|
||||
}
|
||||
|
||||
export const serviceQueryKey = ["regexproxy","services"]
|
||||
|
||||
export const regexproxyServiceQuery = () => useQuery({queryKey:serviceQueryKey, queryFn:regexproxy.services})
|
||||
export const regexproxyServiceRegexesQuery = (service_id:string) => useQuery({
|
||||
queryKey:[...serviceQueryKey,service_id,"regexes"],
|
||||
queryFn:() => regexproxy.serviceregexes(service_id)
|
||||
})
|
||||
|
||||
|
||||
export const regexproxy = {
|
||||
services: async() => {
|
||||
return await getapi("regexproxy/services") as Service[];
|
||||
},
|
||||
serviceinfo: async (service_id:string) => {
|
||||
return await getapi(`regexproxy/service/${service_id}`) as Service;
|
||||
},
|
||||
regexdelete: async (regex_id:number) => {
|
||||
const { status } = await getapi(`regexproxy/regex/${regex_id}/delete`) as ServerResponse;
|
||||
return status === "ok"?undefined:status
|
||||
},
|
||||
regexenable: async (regex_id:number) => {
|
||||
const { status } = await getapi(`regexproxy/regex/${regex_id}/enable`) as ServerResponse;
|
||||
return status === "ok"?undefined:status
|
||||
},
|
||||
regexdisable: async (regex_id:number) => {
|
||||
const { status } = await getapi(`regexproxy/regex/${regex_id}/disable`) as ServerResponse;
|
||||
return status === "ok"?undefined:status
|
||||
},
|
||||
servicestart: async (service_id:string) => {
|
||||
const { status } = await getapi(`regexproxy/service/${service_id}/start`) as ServerResponse;
|
||||
return status === "ok"?undefined:status
|
||||
},
|
||||
servicestop: async (service_id:string) => {
|
||||
const { status } = await getapi(`regexproxy/service/${service_id}/stop`) as ServerResponse;
|
||||
return status === "ok"?undefined:status
|
||||
},
|
||||
servicepause: async (service_id:string) => {
|
||||
const { status } = await getapi(`regexproxy/service/${service_id}/pause`) as ServerResponse;
|
||||
return status === "ok"?undefined:status
|
||||
},
|
||||
serviceregenport: async (service_id:string) => {
|
||||
const { status } = await getapi(`regexproxy/service/${service_id}/regen-port`) as ServerResponse;
|
||||
return status === "ok"?undefined:status
|
||||
},
|
||||
servicechangeport: async (service_id:string, data:ChangePort) => {
|
||||
const { status } = await postapi(`regexproxy/service/${service_id}/change-ports`,data) as ServerResponse;
|
||||
return status === "ok"?undefined:status
|
||||
},
|
||||
servicesadd: async (data:ServiceAddForm) => {
|
||||
return await postapi("regexproxy/services/add",data) as ServerResponseWithID;
|
||||
},
|
||||
servicerename: async (service_id:string, name: string) => {
|
||||
const { status } = await postapi(`regexproxy/service/${service_id}/rename`,{ name }) as ServerResponse;
|
||||
return status === "ok"?undefined:status
|
||||
},
|
||||
servicedelete: async (service_id:string) => {
|
||||
const { status } = await getapi(`regexproxy/service/${service_id}/delete`) as ServerResponse;
|
||||
return status === "ok"?undefined:status
|
||||
},
|
||||
regexesadd: async (data:RegexAddForm) => {
|
||||
const { status } = await postapi("regexproxy/regexes/add",data) as ServerResponse;
|
||||
return status === "ok"?undefined:status
|
||||
},
|
||||
serviceregexes: async (service_id:string) => {
|
||||
return await getapi(`regexproxy/service/${service_id}/regexes`) as RegexFilter[];
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import { RegexFilter } from '../../js/models';
|
||||
import { b64decode, errorNotify, getapiobject, okNotify } from '../../js/utils';
|
||||
import { BsTrashFill } from "react-icons/bs"
|
||||
import YesNoModal from '../YesNoModal';
|
||||
import FilterTypeSelector from '../FilterTypeSelector';
|
||||
import { FaPause, FaPlay } from 'react-icons/fa';
|
||||
import { useClipboard } from '@mantine/hooks';
|
||||
|
||||
@@ -74,12 +73,6 @@ function RegexView({ regexInfo }:{ regexInfo:RegexFilter }) {
|
||||
</Grid.Col>
|
||||
<Grid.Col className='center-flex' span={12}>
|
||||
<Box className='center-flex-row'>
|
||||
<FilterTypeSelector
|
||||
size="md"
|
||||
color="gray"
|
||||
disabled
|
||||
value={regexInfo.is_blacklist?"blacklist":"whitelist"}
|
||||
/>
|
||||
<Space h="md" />
|
||||
<Box className='center-flex'>
|
||||
<Badge size="md" color="cyan" variant="filled">Service: {regexInfo.service_id}</Badge>
|
||||
|
||||
Reference in New Issue
Block a user