Skip to content

Commit

Permalink
improved proxypy startup logic and flags
Browse files Browse the repository at this point in the history
  • Loading branch information
JJ-Author committed Oct 21, 2024
1 parent f8bd6b4 commit 5177a89
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
16 changes: 9 additions & 7 deletions ontologytimemachine/custom_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def queue_response(self, response):
sys.argv = [sys.argv[0]]

# check it https interception is enabled
if config.httpsInterception != HttpsInterception.NONE:
if config.httpsInterception != (HttpsInterception.NONE or HttpsInterception.BLOCK):
sys.argv += [
"--ca-key-file",
"ca-key.pem",
Expand All @@ -190,12 +190,14 @@ def queue_response(self, response):
]

sys.argv += [
"--hostname",
IP,
"--port",
PORT,
"--plugins",
__name__ + ".OntologyTimeMachinePlugin",
"--hostname", IP,
"--port", PORT,
'--insecure-tls-interception', # without it the proxy would not let through a response using an invalid upstream certificate in interception mode
# since there currently is a bug in proxypy when a connect request uses an IP address instead of a domain name
# the proxy would not be able to work corectly in transparent mode using 3proxy setup since it tries to match
# the IP address as hostname with the certificate instead of the domain name in the SNI field
"--log-level", config.logLevel.name,
"--plugins", __name__ + ".OntologyTimeMachinePlugin",
]

logger.info("Starting OntologyTimeMachineProxy server...")
Expand Down
1 change: 1 addition & 0 deletions ontologytimemachine/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class LogLevel(EnumValuePrint):
INFO = "info"
WARNING = "warning"
ERROR = "error"
CRITICAL = "critical"


class OntoFormat(EnumValuePrint):
Expand Down
1 change: 1 addition & 0 deletions ontologytimemachine/utils/proxy_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ def request_ontology(url, headers, disableRemovingRedirects=False, timeout=5):
def proxy_logic(wrapped_request, config):
logger.info("Proxy has to intervene")

response = mock_response_500 #default if we somehow forget to set the response
set_onto_format_headers(wrapped_request, config)

headers = wrapped_request.get_request_headers()
Expand Down

0 comments on commit 5177a89

Please sign in to comment.