nfqueue to hyperscan and stream match, removed proxyregex
This commit is contained in:
Binary file not shown.
@@ -5,25 +5,25 @@
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@hello-pangea/dnd": "^16.6.0",
|
||||
"@mantine/core": "^7.13.2",
|
||||
"@mantine/form": "^7.13.2",
|
||||
"@mantine/hooks": "^7.13.2",
|
||||
"@mantine/modals": "^7.13.2",
|
||||
"@mantine/notifications": "^7.13.2",
|
||||
"@mantine/core": "^7.16.2",
|
||||
"@mantine/form": "^7.16.2",
|
||||
"@mantine/hooks": "^7.16.2",
|
||||
"@mantine/modals": "^7.16.2",
|
||||
"@mantine/notifications": "^7.16.2",
|
||||
"@tanstack/react-query": "^4.36.1",
|
||||
"@types/jest": "^27.5.2",
|
||||
"@types/node": "^20.16.11",
|
||||
"@types/react": "^18.3.11",
|
||||
"@types/react-dom": "^18.3.1",
|
||||
"@types/node": "^20.17.16",
|
||||
"@types/react": "^18.3.18",
|
||||
"@types/react-dom": "^18.3.5",
|
||||
"buffer": "^6.0.3",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"react-icons": "^5.3.0",
|
||||
"react-router-dom": "^6.27.0",
|
||||
"socket.io-client": "^4.8.0",
|
||||
"react-icons": "^5.4.0",
|
||||
"react-router-dom": "^6.29.0",
|
||||
"socket.io-client": "^4.8.1",
|
||||
"typescript": "^4.9.5",
|
||||
"web-vitals": "^2.1.4",
|
||||
"zustand": "^5.0.0-rc.2"
|
||||
"zustand": "^5.0.3"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
@@ -50,8 +50,8 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tanstack/react-query-devtools": "^4.36.1",
|
||||
"@vitejs/plugin-react": "^4.3.2",
|
||||
"vite": "^4.5.5",
|
||||
"@vitejs/plugin-react": "^4.3.4",
|
||||
"vite": "^4.5.9",
|
||||
"vite-plugin-svgr": "^3.3.0",
|
||||
"vite-tsconfig-paths": "^4.3.2"
|
||||
}
|
||||
|
||||
@@ -8,9 +8,7 @@ import { PasswordSend, ServerStatusResponse } from './js/models';
|
||||
import { DEV_IP_BACKEND, errorNotify, getstatus, HomeRedirector, IS_DEV, login, setpassword } from './js/utils';
|
||||
import NFRegex from './pages/NFRegex';
|
||||
import io from 'socket.io-client';
|
||||
import RegexProxy from './pages/RegexProxy';
|
||||
import ServiceDetailsNFRegex from './pages/NFRegex/ServiceDetails';
|
||||
import ServiceDetailsProxyRegex from './pages/RegexProxy/ServiceDetails';
|
||||
import PortHijack from './pages/PortHijack';
|
||||
import { Firewall } from './pages/Firewall';
|
||||
import { useQueryClient } from '@tanstack/react-query';
|
||||
@@ -150,9 +148,6 @@ function App() {
|
||||
<Route path="nfregex" element={<NFRegex><Outlet /></NFRegex>} >
|
||||
<Route path=":srv" element={<ServiceDetailsNFRegex />} />
|
||||
</Route>
|
||||
<Route path="regexproxy" element={<RegexProxy><Outlet /></RegexProxy>} >
|
||||
<Route path=":srv" element={<ServiceDetailsProxyRegex />} />
|
||||
</Route>
|
||||
<Route path="firewall" element={<Firewall />} />
|
||||
<Route path="porthijack" element={<PortHijack />} />
|
||||
<Route path="*" element={<HomeRedirector />} />
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -47,7 +47,6 @@ export type RegexAddForm = {
|
||||
service_id:string,
|
||||
regex:string,
|
||||
is_case_sensitive:boolean,
|
||||
is_blacklist:boolean,
|
||||
mode:string, // C->S S->C BOTH,
|
||||
active: boolean
|
||||
}
|
||||
@@ -3,7 +3,6 @@ import { ImCross } from "react-icons/im";
|
||||
import { TiTick } from "react-icons/ti"
|
||||
import { Navigate } from "react-router-dom";
|
||||
import { nfregex } from "../components/NFRegex/utils";
|
||||
import { regexproxy } from "../components/RegexProxy/utils";
|
||||
import { ChangePassword, IpInterface, LoginResponse, PasswordSend, ServerResponse, ServerResponseToken, ServerStatusResponse } from "./models";
|
||||
import { Buffer } from "buffer"
|
||||
import { QueryClient, useQuery } from "@tanstack/react-query";
|
||||
@@ -111,8 +110,6 @@ export function getapiobject(){
|
||||
switch(getMainPath()){
|
||||
case "nfregex":
|
||||
return nfregex
|
||||
case "regexproxy":
|
||||
return regexproxy
|
||||
}
|
||||
throw new Error('No api for this tool!');
|
||||
}
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
import { ActionIcon, Box, Grid, LoadingOverlay, Space, Title, Tooltip } from '@mantine/core';
|
||||
import { useState } from 'react';
|
||||
import { Navigate, useParams } from 'react-router-dom';
|
||||
import { BsPlusLg } from "react-icons/bs";
|
||||
import { regexproxyServiceQuery, regexproxyServiceRegexesQuery } from '../../components/RegexProxy/utils';
|
||||
import ServiceRow from '../../components/RegexProxy/ServiceRow';
|
||||
import AddNewRegex from '../../components/AddNewRegex';
|
||||
import RegexView from '../../components/RegexView';
|
||||
|
||||
function ServiceDetailsProxyRegex() {
|
||||
|
||||
const {srv} = useParams()
|
||||
const [open, setOpen] = useState(false)
|
||||
const services = regexproxyServiceQuery()
|
||||
const serviceInfo = services.data?.find(s => s.id == srv)
|
||||
const [tooltipAddRegexOpened, setTooltipAddRegexOpened] = useState(false)
|
||||
const regexesList = regexproxyServiceRegexesQuery(srv??"")
|
||||
|
||||
if (!srv || !serviceInfo || regexesList.isError) return <Navigate to="/" replace />
|
||||
|
||||
return <Box>
|
||||
<LoadingOverlay visible={regexesList.isLoading} />
|
||||
<ServiceRow service={serviceInfo} />
|
||||
{(!regexesList.data || regexesList.data.length == 0)?<>
|
||||
<Space h="xl" />
|
||||
<Title className='center-flex' style={{textAlign:"center"}} order={3}>No regex found for this service! Add one by clicking the "+" buttons</Title>
|
||||
<Space h="xl" /> <Space h="xl" />
|
||||
<Box className='center-flex'>
|
||||
<Tooltip label="Add a new regex" zIndex={0} color="blue" opened={tooltipAddRegexOpened}>
|
||||
<ActionIcon color="blue" onClick={()=>setOpen(true)} size="xl" radius="md" variant="filled"
|
||||
aria-describedby="tooltip-AddRegex-id"
|
||||
onFocus={() => setTooltipAddRegexOpened(false)} onBlur={() => setTooltipAddRegexOpened(false)}
|
||||
onMouseEnter={() => setTooltipAddRegexOpened(true)} onMouseLeave={() => setTooltipAddRegexOpened(false)}><BsPlusLg size="20px" /></ActionIcon>
|
||||
</Tooltip>
|
||||
</Box>
|
||||
</>:
|
||||
<Grid>
|
||||
{regexesList.data.map( (regexInfo) => <Grid.Col key={regexInfo.id} span={{ lg:6, xs: 12 }}><RegexView regexInfo={regexInfo} /></Grid.Col>)}
|
||||
</Grid>
|
||||
}
|
||||
|
||||
{srv?<AddNewRegex opened={open} onClose={() => {setOpen(false)}} service={srv} />:null}
|
||||
|
||||
|
||||
</Box>
|
||||
}
|
||||
|
||||
export default ServiceDetailsProxyRegex;
|
||||
@@ -1,91 +0,0 @@
|
||||
import { ActionIcon, Badge, Box, LoadingOverlay, Space, Title, Tooltip } from '@mantine/core';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { BsPlusLg } from "react-icons/bs";
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
import ServiceRow from '../../components/RegexProxy/ServiceRow';
|
||||
import { regexproxyServiceQuery } from '../../components/RegexProxy/utils';
|
||||
import { errorNotify, getErrorMessage } from '../../js/utils';
|
||||
import AddNewService from '../../components/RegexProxy/AddNewService';
|
||||
import AddNewRegex from '../../components/AddNewRegex';
|
||||
import { useQueryClient } from '@tanstack/react-query';
|
||||
import { TbReload } from 'react-icons/tb';
|
||||
|
||||
|
||||
function RegexProxy({ children }: { children: any }) {
|
||||
|
||||
const navigator = useNavigate()
|
||||
const [open, setOpen] = useState(false);
|
||||
const {srv} = useParams()
|
||||
const [tooltipAddServOpened, setTooltipAddServOpened] = useState(false);
|
||||
const [tooltipAddOpened, setTooltipAddOpened] = useState(false);
|
||||
const queryClient = useQueryClient()
|
||||
const [tooltipRefreshOpened, setTooltipRefreshOpened] = useState(false);
|
||||
|
||||
const services = regexproxyServiceQuery()
|
||||
|
||||
useEffect(()=> {
|
||||
if(services.isError){
|
||||
errorNotify("RegexProxy Update failed!", getErrorMessage(services.error))
|
||||
}
|
||||
},[services.isError])
|
||||
|
||||
const closeModal = () => {setOpen(false);}
|
||||
|
||||
return <>
|
||||
<Space h="sm" />
|
||||
<Box className='center-flex'>
|
||||
<Title order={4}>TCP Proxy Regex Filter (IPv4 Only)</Title>
|
||||
<Box className='flex-spacer' />
|
||||
<Badge size="sm" color="green" variant="filled">Services: {services.isLoading?0:services.data?.length}</Badge>
|
||||
<Space w="xs" />
|
||||
<Badge size="sm" color="yellow" variant="filled">Filtered Connections: {services.isLoading?0:services.data?.reduce((acc, s)=> acc+=s.n_packets, 0)}</Badge>
|
||||
<Space w="xs" />
|
||||
<Badge size="sm" color="violet" variant="filled">Regexes: {services.isLoading?0:services.data?.reduce((acc, s)=> acc+=s.n_regex, 0)}</Badge>
|
||||
<Space w="xs" />
|
||||
{ srv?
|
||||
<Tooltip label="Add a new regex" position='bottom' color="blue" opened={tooltipAddOpened}>
|
||||
<ActionIcon color="blue" onClick={()=>setOpen(true)} size="lg" radius="md" variant="filled"
|
||||
onFocus={() => setTooltipAddOpened(false)} onBlur={() => setTooltipAddOpened(false)}
|
||||
onMouseEnter={() => setTooltipAddOpened(true)} onMouseLeave={() => setTooltipAddOpened(false)}><BsPlusLg size={18} /></ActionIcon>
|
||||
</Tooltip>
|
||||
: <Tooltip label="Add a new service" position='bottom' color="blue" opened={tooltipAddOpened}>
|
||||
<ActionIcon color="blue" onClick={()=>setOpen(true)} size="lg" radius="md" variant="filled"
|
||||
onFocus={() => setTooltipAddOpened(false)} onBlur={() => setTooltipAddOpened(false)}
|
||||
onMouseEnter={() => setTooltipAddOpened(true)} onMouseLeave={() => setTooltipAddOpened(false)}><BsPlusLg size={18} /></ActionIcon>
|
||||
</Tooltip>
|
||||
}
|
||||
<Space w="xs" />
|
||||
<Tooltip label="Refresh" position='bottom' color="indigo" opened={tooltipRefreshOpened}>
|
||||
<ActionIcon color="indigo" onClick={()=>queryClient.invalidateQueries(["regexproxy"])} size="lg" radius="md" variant="filled"
|
||||
loading={services.isFetching}
|
||||
onFocus={() => setTooltipRefreshOpened(false)} onBlur={() => setTooltipRefreshOpened(false)}
|
||||
onMouseEnter={() => setTooltipRefreshOpened(true)} onMouseLeave={() => setTooltipRefreshOpened(false)}><TbReload size={18} /></ActionIcon>
|
||||
</Tooltip>
|
||||
</Box>
|
||||
<Box className="center-flex-row">
|
||||
{srv?null:<>
|
||||
<LoadingOverlay visible={services.isLoading} />
|
||||
{(services.data && services.data?.length > 0)?services.data.map( srv => <ServiceRow service={srv} key={srv.id} onClick={()=>{
|
||||
navigator("/regexproxy/"+srv.id)
|
||||
}} />):<><Space h="xl"/> <Title className='center-flex' style={{textAlign:"center"}} order={3}>No services found! Add one clicking the "+" buttons</Title>
|
||||
<Space h="xl" /> <Space h="xl" />
|
||||
<Box className='center-flex'>
|
||||
<Tooltip label="Add a new service" color="blue" opened={tooltipAddServOpened}>
|
||||
<ActionIcon color="blue" onClick={()=>setOpen(true)} size="xl" radius="md" variant="filled"
|
||||
onFocus={() => setTooltipAddServOpened(false)} onBlur={() => setTooltipAddServOpened(false)}
|
||||
onMouseEnter={() => setTooltipAddServOpened(true)} onMouseLeave={() => setTooltipAddServOpened(false)}><BsPlusLg size="20px" /></ActionIcon>
|
||||
</Tooltip>
|
||||
</Box>
|
||||
</>}
|
||||
<AddNewService opened={open} onClose={closeModal} />
|
||||
</>}
|
||||
</Box>
|
||||
{srv?children:null}
|
||||
{srv?
|
||||
<AddNewRegex opened={open} onClose={closeModal} service={srv} />:
|
||||
<AddNewService opened={open} onClose={closeModal} />
|
||||
}
|
||||
</>
|
||||
}
|
||||
|
||||
export default RegexProxy;
|
||||
Reference in New Issue
Block a user