aboutsummaryrefslogtreecommitdiff
path: root/src/hydrilla/proxy/policies
diff options
context:
space:
mode:
authorWojtek Kosior <koszko@koszko.org>2022-10-10 15:01:08 +0200
committerWojtek Kosior <koszko@koszko.org>2022-10-10 15:01:08 +0200
commitb880bdc779b800ebde810279d1cf5b9e530000de (patch)
treebdf867969da926b38c021e964d06c0052a6bc28c /src/hydrilla/proxy/policies
parent39ba8a202f4010286b99c3ac34003ffa329153c5 (diff)
downloadhaketilo-hydrilla-b880bdc779b800ebde810279d1cf5b9e530000de.tar.gz
haketilo-hydrilla-b880bdc779b800ebde810279d1cf5b9e530000de.zip
[proxy] make it possible to access http://mitm.it magical domain
Diffstat (limited to 'src/hydrilla/proxy/policies')
-rw-r--r--src/hydrilla/proxy/policies/__init__.py3
-rw-r--r--src/hydrilla/proxy/policies/misc.py (renamed from src/hydrilla/proxy/policies/fallback.py)22
2 files changed, 23 insertions, 2 deletions
diff --git a/src/hydrilla/proxy/policies/__init__.py b/src/hydrilla/proxy/policies/__init__.py
index 062ec56..448420a 100644
--- a/src/hydrilla/proxy/policies/__init__.py
+++ b/src/hydrilla/proxy/policies/__init__.py
@@ -12,6 +12,7 @@ from .payload_resource import PayloadResourcePolicyFactory
from .rule import RuleBlockPolicyFactory, RuleAllowPolicyFactory
-from .fallback import FallbackAllowPolicy, FallbackBlockPolicy, ErrorBlockPolicy
+from .misc import FallbackAllowPolicy, FallbackBlockPolicy, ErrorBlockPolicy, \
+ DoNothingPolicy
from .web_ui import WebUIPolicyFactory
diff --git a/src/hydrilla/proxy/policies/fallback.py b/src/hydrilla/proxy/policies/misc.py
index f5c9b16..bc3b08f 100644
--- a/src/hydrilla/proxy/policies/fallback.py
+++ b/src/hydrilla/proxy/policies/misc.py
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Policies for blocking and allowing JS when no other policies match.
+# Miscellaneous policies.
#
# This file is part of Hydrilla&Haketilo.
#
@@ -39,6 +39,7 @@ import enum
from abc import ABC, abstractmethod
from .. import state
+from .. import http_messages
from . import base
from .rule import AllowPolicy, BlockPolicy
@@ -59,3 +60,22 @@ class ErrorBlockPolicy(BlockPolicy):
error: Exception
builtin: bool = True
+
+class DoNothingPolicy(base.Policy):
+ """
+ A special policy class for handling of the magical mitm.it domain. It causes
+ request and response not to be modified in any way, and also (unlike
+ FallbackAllowPolicy) prevents them from being streamed.
+ """
+ _process_request: t.ClassVar[bool] = True
+ _process_response: t.ClassVar[bool] = True
+ anticache: t.ClassVar[bool] = False
+
+ def consume_request(self, request_info: http_messages.RequestInfo) -> None:
+ return None
+
+ def consume_response(self, response_info: http_messages.ResponseInfo) \
+ -> None:
+ return None
+
+ builtin: bool = True