Skip to content

Commit

Permalink
fixed decision for httpsInterception and improved logging for it
Browse files Browse the repository at this point in the history
  • Loading branch information
JJ-Author committed Oct 20, 2024
1 parent 8f32bb4 commit 3ce4e0c
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions ontologytimemachine/custom_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@


IP = "0.0.0.0"
PORT = "8899"
PORT = "8896"

config = None

Expand All @@ -34,7 +34,7 @@

class OntologyTimeMachinePlugin(HttpProxyBasePlugin):
def __init__(self, *args, **kwargs):
logger.info("Init")
logger.info(f"Init - Object ID: {id(self)}")
super().__init__(*args, **kwargs)
self.config = config
self.current_config = None
Expand Down Expand Up @@ -75,15 +75,21 @@ def before_upstream_connection(self, request: HttpParser) -> HttpParser | None:

def do_intercept(self, _request: HttpParser) -> bool:
wrapped_request = HttpRequestWrapper(_request)
if self.config.httpsInterception in HttpsInterception.ALL:
if self.config.httpsInterception == HttpsInterception.ALL:
logger.info("Intercepting all HTTPS requests")
return True
elif self.config.httpsInterception in HttpsInterception.NONE:
elif self.config.httpsInterception == HttpsInterception.NONE:
logger.info("Intercepting no HTTPS requests")
return False
# elif self.config.httpsInterception == HttpsInterception.BLOCK: #this should actually be not triggered
# return False
elif self.config.httpsInterception in HttpsInterception.ARCHIVO:
elif self.config.httpsInterception == HttpsInterception.BLOCK:
logger.error("Reached code block for interception decision in block mode which should have been blocked before")
#this should actually be not triggered as the CONNECT request should have been blocked before
return False
elif self.config.httpsInterception == HttpsInterception.ARCHIVO:
if is_archivo_ontology_request(wrapped_request):
logger.info("Intercepting HTTPS request since it is an Archivo ontology request")
return True
logger.info("No Interception of HTTPS request since it is NOT an Archivo ontology request")
return False
else:
logger.info(
Expand Down

0 comments on commit 3ce4e0c

Please sign in to comment.