-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpassthrough_parser.py
36 lines (26 loc) · 1 KB
/
passthrough_parser.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# This parser simply passes the data through and is the default for new parsers
from __future__ import annotations
import typing
# This is the base class for the custom parser class
import base_parser
# import stuff for API calls
from enum_socket_role import ESocketRole
if typing.TYPE_CHECKING:
from proxy import Proxy
from application import Application
from enum import Enum
class Parser(base_parser.Parser):
# Define the parser name here as it should appear in the prompt
def __str__(self) -> str:
return 'PASS'
def parse(self, data: bytes, proxy: Proxy, origin: ESocketRole) -> list[str]:
output = super().parse(data, proxy, origin)
# Pass data through to the target.
if origin == ESocketRole.CLIENT:
proxy.sendToServer(data)
else:
proxy.sendToClient(data)
return output
def __init__(self, application: Application, settings: dict[Enum, typing.Any]):
super().__init__(application, settings)
return