From 73b7da1a0360f50e660e1983ec02dd5225bde3a3 Mon Sep 17 00:00:00 2001 From: Vincent Haupert Date: Sat, 30 Jul 2016 12:42:33 +0200 Subject: [PATCH 1/2] Fix platform import on Linux using python3 Using python3, sys.platform returns "linux" instead of "linux2" using python2. This patch accepts "linux" as well as "linux2". --- mitmproxy/platform/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mitmproxy/platform/__init__.py b/mitmproxy/platform/__init__.py index e1ff7c474..2e3501315 100644 --- a/mitmproxy/platform/__init__.py +++ b/mitmproxy/platform/__init__.py @@ -1,8 +1,9 @@ import sys +import re resolver = None -if sys.platform == "linux2": +if re.match(r"linux(?:2)?", sys.platform): from . import linux resolver = linux.Resolver elif sys.platform == "darwin": From 07f77f086673a065d2f0f34a85b8e9ab6b06b06a Mon Sep 17 00:00:00 2001 From: Vincent Haupert Date: Sat, 30 Jul 2016 12:49:00 +0200 Subject: [PATCH 2/2] Substitute tilde with user's home. When downloding the mitmproxy certificate using mitm.it, '~' currently is not expanded causing a FileNotFoundException. This patch uses expanduser() to replace the initial tilde with the user's home. --- mitmproxy/onboarding/app.py | 1 + 1 file changed, 1 insertion(+) diff --git a/mitmproxy/onboarding/app.py b/mitmproxy/onboarding/app.py index e26efae8a..491ddbfe9 100644 --- a/mitmproxy/onboarding/app.py +++ b/mitmproxy/onboarding/app.py @@ -48,6 +48,7 @@ class PEM(tornado.web.RequestHandler): def get(self): p = os.path.join(self.request.master.options.cadir, self.filename) + p = os.path.expanduser(p) self.set_header("Content-Type", "application/x-x509-ca-cert") self.set_header( "Content-Disposition",