From d0a355889944ed3aed47548bb54577f9a0d6f34d Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 3 Aug 2016 13:57:56 -0700 Subject: [PATCH] maybe help with #126 once we get a decrypt fail for a given request.url.path, cache that path and skip attempts to decrypt requests against that url --- SWProxy.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/SWProxy.py b/SWProxy.py index 52f4c81..4a94766 100755 --- a/SWProxy.py +++ b/SWProxy.py @@ -34,6 +34,7 @@ def handle(self, client): class SWProxyCallback(object): def __init__(self): self.request = None + self.failed_urls = set() def onRequest(self, proxy, host, port, request): try: @@ -47,6 +48,11 @@ def onResponse(self, proxy, response): # we have not obtained a valid request yet return + if request.url.path in self.failed_urls: + # we've tried unsuccessfully before to decrypt a request for this url + # lets improve efficiency by skipping the decrypt we know will fail + return + try: req_plain, req_json = self._parse_request(self.request) resp_plain, resp_json = self._parse_response(response) @@ -62,6 +68,7 @@ def onResponse(self, proxy, response): logger.exception('Exception while executing plugin : {}'.format(e)) except Exception as e: + self.failed_urls.add(request.url.path) # add this url to a set of urls known to fail logger.debug('unknown exception: {}'.format(e)) def onDone(self, proxy):