summaryrefslogtreecommitdiff
path: root/src/hydrilla/proxy/addon.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/hydrilla/proxy/addon.py')
-rw-r--r--src/hydrilla/proxy/addon.py20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/hydrilla/proxy/addon.py b/src/hydrilla/proxy/addon.py
index 2185bcb..b8ad819 100644
--- a/src/hydrilla/proxy/addon.py
+++ b/src/hydrilla/proxy/addon.py
@@ -34,6 +34,7 @@ from addon script.
from __future__ import annotations
import sys
+import re
import typing as t
import dataclasses as dc
import traceback as tb
@@ -91,6 +92,10 @@ class FlowHandlingData:
policy: policies.Policy
+magical_mitm_it_url_reg = re.compile(r'^http://mitm.it(/.*)?$')
+dummy_url = parse_url('http://dummy.replacement.url')
+
+
@dc.dataclass
class HaketiloAddon:
"""
@@ -142,11 +147,16 @@ class HaketiloAddon:
handling_data = self.flows_data.get(id(flow))
if handling_data is None:
- try:
- parsed_url = parse_url(flow.request.url)
- policy = self.state.select_policy(parsed_url)
- except HaketiloException as e:
- policy = policies.ErrorBlockPolicy(builtin=True, error=e)
+ parsed_url = dummy_url
+
+ if magical_mitm_it_url_reg.match(flow.request.url):
+ policy = policies.DoNothingPolicy()
+ else:
+ try:
+ parsed_url = parse_url(flow.request.url)
+ policy = self.state.select_policy(parsed_url)
+ except HaketiloException as e:
+ policy = policies.ErrorBlockPolicy(builtin=True, error=e)
handling_data = FlowHandlingData(parsed_url, policy)