diff options
author | Wojtek Kosior <koszko@koszko.org> | 2022-10-25 11:30:45 +0200 |
---|---|---|
committer | Wojtek Kosior <koszko@koszko.org> | 2022-10-25 11:30:45 +0200 |
commit | 37b3cf9fb2a56cfa980844f527d834916b38cca8 (patch) | |
tree | 288a3b3ddc7e1fe115d568480f44313173183c2d /src/hydrilla/proxy/policies/misc.py | |
parent | 44c09ab27ce8407f4fc5c75df9cdf309df8463eb (diff) | |
download | haketilo-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/misc.py')
-rw-r--r-- | src/hydrilla/proxy/policies/misc.py | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/hydrilla/proxy/policies/misc.py b/src/hydrilla/proxy/policies/misc.py index 350f3dc..0ff4596 100644 --- a/src/hydrilla/proxy/policies/misc.py +++ b/src/hydrilla/proxy/policies/misc.py @@ -29,9 +29,10 @@ ..... """ +import enum +import traceback as tb import dataclasses as dc import typing as t -import enum from abc import ABC, abstractmethod @@ -44,16 +45,39 @@ from .rule import AllowPolicy, BlockPolicy class FallbackAllowPolicy(AllowPolicy): priority = base.PolicyPriority._ONE + def make_info_page(self, http_info: http_messages.FullHTTPInfo) \ + -> t.Optional[str]: + template = base.get_info_template('js_fallback_allowed_info.html.jinja') + return template.render(url=http_info.request_info.url.orig_url) + class FallbackBlockPolicy(BlockPolicy): priority = base.PolicyPriority._ONE + def make_info_page(self, http_info: http_messages.FullHTTPInfo) \ + -> t.Optional[str]: + template = base.get_info_template('js_fallback_blocked_info.html.jinja') + return template.render(url=http_info.request_info.url.orig_url) + @dc.dataclass(frozen=True) class ErrorBlockPolicy(BlockPolicy): - """....""" error: Exception + @property + def traceback(self) -> str: + lines = tb.format_exception(None, self.error, self.error.__traceback__) + return ''.join(lines) + + def make_info_page(self, http_info: http_messages.FullHTTPInfo) \ + -> t.Optional[str]: + template = base.get_info_template('js_error_blocked_info.html.jinja') + return template.render( + url = http_info.request_info.url.orig_url, + settings = self.haketilo_settings, + traceback = self.traceback + ) + class MitmItPagePolicy(base.Policy): """ |