Frontend Changes

This commit is contained in:
DomySh
2022-06-22 01:31:46 +02:00
parent ede11873c5
commit 34d6b18ec0
10 changed files with 69 additions and 65 deletions

View File

@@ -1,13 +1,13 @@
{
"files": {
"main.css": "/static/css/main.c375ae17.css",
"main.js": "/static/js/main.3ae3ab4b.js",
"main.js": "/static/js/main.76d17c5c.js",
"index.html": "/index.html",
"main.c375ae17.css.map": "/static/css/main.c375ae17.css.map",
"main.3ae3ab4b.js.map": "/static/js/main.3ae3ab4b.js.map"
"main.76d17c5c.js.map": "/static/js/main.76d17c5c.js.map"
},
"entrypoints": [
"static/css/main.c375ae17.css",
"static/js/main.3ae3ab4b.js"
"static/js/main.76d17c5c.js"
]
}

View File

@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"><link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"><link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"><link rel="manifest" href="/site.webmanifest"><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#FFFFFFFF"/><meta name="description" content="Firegex by Pwnzer0tt1"/><title>Firegex</title><script defer="defer" src="/static/js/main.3ae3ab4b.js"></script><link href="/static/css/main.c375ae17.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"><link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"><link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"><link rel="manifest" href="/site.webmanifest"><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#FFFFFFFF"/><meta name="description" content="Firegex by Pwnzer0tt1"/><title>Firegex</title><script defer="defer" src="/static/js/main.76d17c5c.js"></script><link href="/static/css/main.c375ae17.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>

File diff suppressed because one or more lines are too long

View File

@@ -2,7 +2,7 @@ import { Button, Group, Space, TextInput, Notification, Switch, NativeSelect, To
import { useForm } from '@mantine/hooks';
import React, { useState } from 'react';
import { RegexAddForm } from '../js/models';
import { addregex, b64encode, fireUpdateRequest, getHumanReadableRegex, okNotify } from '../js/utils';
import { addregex, b64encode, fireUpdateRequest, getBinaryRegex, getHumanReadableRegex, okNotify } from '../js/utils';
import { ImCross } from "react-icons/im"
import FilterTypeSelector from './FilterTypeSelector';
@@ -12,7 +12,6 @@ type RegexAddInfo = {
type:string,
mode:string,
is_case_insensitive:boolean,
regex_exact:boolean,
percentage_encoding:boolean
}
@@ -24,7 +23,6 @@ function AddNewRegex({ opened, onClose, service }:{ opened:boolean, onClose:()=>
type:"blacklist",
mode:"C <-> S",
is_case_insensitive:false,
regex_exact:false,
percentage_encoding:false
},
validationRules:{
@@ -47,12 +45,9 @@ function AddNewRegex({ opened, onClose, service }:{ opened:boolean, onClose:()=>
setSubmitLoading(true)
const filter_mode = ({'C -> S':'C', 'S -> C':'S', 'C <-> S':'B'}[values.mode])
let final_regex = values.regex
let final_regex:string|number[] = values.regex
if (values.percentage_encoding){
final_regex = decodeURIComponent(final_regex)
}
if(!values.regex_exact){
final_regex = ".*"+final_regex+".*"
final_regex = getBinaryRegex(final_regex)
}
const request:RegexAddForm = {
@@ -105,11 +100,6 @@ function AddNewRegex({ opened, onClose, service }:{ opened:boolean, onClose:()=>
{...form.getInputProps('is_case_insensitive', { type: 'checkbox' })}
/>
<Space h="md" />
<Switch
label="Match exactly the regex"
{...form.getInputProps('regex_exact', { type: 'checkbox' })}
/>
<Space h="md" />
<NativeSelect
data={['C -> S', 'S -> C', 'C <-> S']}
label="Choose the source of the packets to filter"

View File

@@ -15,12 +15,6 @@ function RegexView({ regexInfo }:{ regexInfo:RegexFilter }) {
regexInfo.mode === "B"? "S <-> C": "🤔"
let regex_expr = getHumanReadableRegex(regexInfo.regex);
let exact_regex = true;
if (regex_expr.length>=4 && regex_expr.startsWith(".*") && regex_expr.endsWith(".*")){
regex_expr = regex_expr.substring(2,regex_expr.length-2)
exact_regex = false;
}
const [deleteModal, setDeleteModal] = useState(false);
const [tooltipOpened, setTooltipOpened] = useState(false);
@@ -72,9 +66,7 @@ function RegexView({ regexInfo }:{ regexInfo:RegexFilter }) {
<Grid.Col style={{width:"100%"}} span={6}>
<Space h="xs" />
<div className='center-flex-row'>
<Badge size="md" color={exact_regex?"grape":"pink"} variant="filled">Match: {exact_regex?"EXACT":"FIND"}</Badge>
<Space h="xs" />
<Badge size="md" color={regexInfo.is_case_sensitive?"red":"green"} variant="filled">Case: {regexInfo.is_case_sensitive?"SENSIIVE":"INSENSITIVE"}</Badge>
<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" />

View File

@@ -137,7 +137,36 @@ export function getHumanReadableRegex(regexB64:string){
if (unescapedChars.includes(byte)){
res+=byte
}else{
res+="%"+regex[i].toString(16)
let hex_data = regex[i].toString(16)
if (hex_data.length === 1) hex_data = "0"+hex_data
res+="%"+hex_data
}
}
return res
}
const hexChars = "0123456789abcdefABCDEF"
export function getBinaryRegex(regexPercentageEncoded:string):number[]{
const regex = Buffer.from(regexPercentageEncoded)
let res = []
for (let i=0; i < regex.length; i++){
const byte = String.fromCharCode(regex[i]);
if ("%" === byte){
if(i+2 < regex.length){
const byte_1 = String.fromCharCode(regex[i+1]);
const byte_2 = String.fromCharCode(regex[i+2]);
if(hexChars.includes(byte_1) && hexChars.includes(byte_2)){
res.push(parseInt(byte_1+byte_2,16))
i += 2
}else{
res.push(regex[i])
}
}else{
res.push(regex[i])
}
}else{
res.push(regex[i])
}
}
return res
@@ -163,6 +192,6 @@ export function okNotify(title:string, description:string ){
});
}
export function b64encode(data:string){
export function b64encode(data:number[]|string){
return Buffer.from(data).toString('base64')
}