data handler improves, written test for nfproxy, new option on parsing fail
This commit is contained in:
@@ -30,7 +30,27 @@ def filter_with_args(http_request: HttpRequest) -> int:
|
||||
return REJECT
|
||||
`
|
||||
|
||||
const IMPORT_FULL_ACTION_STREAM = `from firegex.nfproxy import FullStreamAction`
|
||||
const IMPORT_FULL_ACTION_STREAM = `from firegex.nfproxy import FullStreamAction
|
||||
|
||||
# Here the definition of FullStreamAction enum
|
||||
class FullStreamAction(Enum):
|
||||
"""Action to be taken by the filter when the stream is full"""
|
||||
FLUSH = 0
|
||||
ACCEPT = 1
|
||||
REJECT = 2
|
||||
DROP = 3
|
||||
`
|
||||
|
||||
const ENUM_IMPORT_AND_DEFINITION = `from firegex.nfproxy import ExceptionAction
|
||||
|
||||
# Here the definition of ExceptionAction enum
|
||||
class ExceptionAction(Enum):
|
||||
"""Action to be taken by the filter when an exception occurs (used in some cases)"""
|
||||
ACCEPT = 0 # Accept the packet that caused the exception
|
||||
DROP = 1 # Drop the connection that caused the exception
|
||||
REJECT = 2 # Reject the connection that caused the exception
|
||||
NOACTION = 3 # Do nothing, the excpetion will be signaled and the stream will be accepted without calling anymore the pyfilters (for the current stream)
|
||||
`
|
||||
|
||||
export const HELP_NFPROXY_SIM = `➤ fgex nfproxy -h
|
||||
|
||||
@@ -241,9 +261,6 @@ export const NFProxyDocs = () => {
|
||||
<List.Item>
|
||||
<strong>method: </strong> The method of the request (read only)
|
||||
</List.Item>
|
||||
<List.Item>
|
||||
<strong>has_begun: </strong> It's true if the request has begun, false if it's not. (read only)
|
||||
</List.Item>
|
||||
<List.Item>
|
||||
<strong>headers_complete: </strong> It's true if the headers are complete, false if they are not. (read only)
|
||||
</List.Item>
|
||||
@@ -303,9 +320,6 @@ export const NFProxyDocs = () => {
|
||||
<List.Item>
|
||||
<strong>status_code: </strong> The status code of the response (read only) (int)
|
||||
</List.Item>
|
||||
<List.Item>
|
||||
<strong>has_begun: </strong> It's true if the response has begun, false if it's not. (read only)
|
||||
</List.Item>
|
||||
<List.Item>
|
||||
<strong>headers_complete: </strong> It's true if the headers are complete, false if they are not. (read only)
|
||||
</List.Item>
|
||||
@@ -357,6 +371,17 @@ export const NFProxyDocs = () => {
|
||||
</List.Item>
|
||||
</List>
|
||||
</Text>
|
||||
<Title order={2} mt="lg" mb="sm">⚠️ Other Options</Title>
|
||||
<Text size="lg" my="xs">
|
||||
Here's other enums that you could need to use:
|
||||
<CodeHighlight code={ENUM_IMPORT_AND_DEFINITION} language="python" my="sm" />
|
||||
Then you can set in the globals these options:
|
||||
<List>
|
||||
<List.Item>
|
||||
<strong>FGEX_INVALID_ENCODING_ACTION: </strong> Sets the action performed when the stream has an invalid encoding (due to a parser crash). The default is ExceptionAction.REJECT.
|
||||
</List.Item>
|
||||
</List>
|
||||
</Text>
|
||||
<Title order={2} mt="lg" mb="sm">🚀 How It Works</Title>
|
||||
<Text mb="sm" size="lg">
|
||||
The proxy is built on a multi-threaded architecture and integrates Python for dynamic filtering:
|
||||
|
||||
@@ -54,12 +54,12 @@ export const nfproxy = {
|
||||
serviceinfo: async (service_id:string) => {
|
||||
return await getapi(`nfproxy/services/${service_id}`) as Service;
|
||||
},
|
||||
pyfilterenable: async (filter_name:string) => {
|
||||
const { status } = await postapi(`nfproxy/pyfilters/${filter_name}/enable`) as ServerResponse;
|
||||
pyfilterenable: async (service_id:string, filter_name:string) => {
|
||||
const { status } = await postapi(`nfproxy/services/${service_id}/pyfilters/${filter_name}/enable`) as ServerResponse;
|
||||
return status === "ok"?undefined:status
|
||||
},
|
||||
pyfilterdisable: async (filter_name:string) => {
|
||||
const { status } = await postapi(`nfproxy/pyfilters/${filter_name}/disable`) as ServerResponse;
|
||||
pyfilterdisable: async (service_id:string, filter_name:string) => {
|
||||
const { status } = await postapi(`nfproxy/services/${service_id}/pyfilters/${filter_name}/disable`) as ServerResponse;
|
||||
return status === "ok"?undefined:status
|
||||
},
|
||||
servicestart: async (service_id:string) => {
|
||||
@@ -89,10 +89,10 @@ export const nfproxy = {
|
||||
return status === "ok"?undefined:status
|
||||
},
|
||||
getpyfilterscode: async (service_id:string) => {
|
||||
return await getapi(`nfproxy/services/${service_id}/pyfilters/code`) as string;
|
||||
return await getapi(`nfproxy/services/${service_id}/code`) as string;
|
||||
},
|
||||
setpyfilterscode: async (service_id:string, code:string) => {
|
||||
const { status } = await putapi(`nfproxy/services/${service_id}/pyfilters/code`,{ code }) as ServerResponse;
|
||||
const { status } = await putapi(`nfproxy/services/${service_id}/code`,{ code }) as ServerResponse;
|
||||
return status === "ok"?undefined:status
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ export default function PyFilterView({ filterInfo }:{ filterInfo:PyFilter }) {
|
||||
const isMedium = isMediumScreen()
|
||||
|
||||
const changeRegexStatus = () => {
|
||||
(filterInfo.active?nfproxy.pyfilterdisable:nfproxy.pyfilterenable)(filterInfo.name).then(res => {
|
||||
(filterInfo.active?nfproxy.pyfilterdisable:nfproxy.pyfilterenable)(filterInfo.service_id, filterInfo.name).then(res => {
|
||||
if(!res){
|
||||
okNotify(`Filter ${filterInfo.name} ${filterInfo.active?"deactivated":"activated"} successfully!`,`Filter '${filterInfo.name}' has been ${filterInfo.active?"deactivated":"activated"}!`)
|
||||
}else{
|
||||
|
||||
@@ -52,6 +52,7 @@ export type RegexAddForm = {
|
||||
|
||||
export type PyFilter = {
|
||||
name:string,
|
||||
service_id:string,
|
||||
blocked_packets:number,
|
||||
edited_packets:number,
|
||||
active:boolean
|
||||
|
||||
Reference in New Issue
Block a user