aboutsummaryrefslogtreecommitdiff
path: root/src/hydrilla/proxy/policies/rule.py
diff options
context:
space:
mode:
authorWojtek Kosior <koszko@koszko.org>2022-10-25 11:30:45 +0200
committerWojtek Kosior <koszko@koszko.org>2022-10-25 11:30:45 +0200
commit37b3cf9fb2a56cfa980844f527d834916b38cca8 (patch)
tree288a3b3ddc7e1fe115d568480f44313173183c2d /src/hydrilla/proxy/policies/rule.py
parent44c09ab27ce8407f4fc5c75df9cdf309df8463eb (diff)
downloadhaketilo-hydrilla-37b3cf9fb2a56cfa980844f527d834916b38cca8.tar.gz
haketilo-hydrilla-37b3cf9fb2a56cfa980844f527d834916b38cca8.zip
[proxy] make Haketilo popup functional
* Ad hoc payload creation was additionally fixed in this commit. * Addition on newly created script blocking/allowing rules to pattern tree was additionally fixed in this commit. It is no longer necessary to restart Haketilo for new rules to come into effect.
Diffstat (limited to 'src/hydrilla/proxy/policies/rule.py')
-rw-r--r--src/hydrilla/proxy/policies/rule.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/hydrilla/proxy/policies/rule.py b/src/hydrilla/proxy/policies/rule.py
index 8c5e69b..1f39295 100644
--- a/src/hydrilla/proxy/policies/rule.py
+++ b/src/hydrilla/proxy/policies/rule.py
@@ -67,11 +67,25 @@ class BlockPolicy(base.Policy):
class RuleAllowPolicy(AllowPolicy):
pattern: ParsedPattern
+ def make_info_page(self, http_info: http_messages.FullHTTPInfo) \
+ -> t.Optional[str]:
+ return base.get_info_template('js_rule_allowed_info.html.jinja').render(
+ url = http_info.request_info.url.orig_url,
+ pattern = self.pattern.orig_url
+ )
+
@dc.dataclass(frozen=True)
class RuleBlockPolicy(BlockPolicy):
pattern: ParsedPattern
+ def make_info_page(self, http_info: http_messages.FullHTTPInfo) \
+ -> t.Optional[str]:
+ return base.get_info_template('js_rule_blocked_info.html.jinja').render(
+ url = http_info.request_info.url.orig_url,
+ pattern = self.pattern.orig_url
+ )
+
@dc.dataclass(frozen=True, unsafe_hash=True) # type: ignore[misc]
class RulePolicyFactory(base.PolicyFactory):