From 13ee54da86319e4a028279c4dce0967d8a786067 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Sun, 31 May 2015 13:13:12 +1200 Subject: [PATCH] Remove dependency on PyOpenSSL, move version check into netlib. There are a few more functions in the code that accesses PyOpenSSL directly that should probably also be moved to netlib. Later. --- libmproxy/main.py | 48 ++++------------------------------------------- setup.py | 1 - 2 files changed, 4 insertions(+), 45 deletions(-) diff --git a/libmproxy/main.py b/libmproxy/main.py index 73e6c62b0..98413c7af 100644 --- a/libmproxy/main.py +++ b/libmproxy/main.py @@ -2,52 +2,12 @@ from __future__ import print_function, absolute_import import os import signal import sys -import netlib.version +import netlib.version, netlib.version_check from . import version, cmdline from .proxy import process_proxy_options, ProxyServerError from .proxy.server import DummyServer, ProxyServer -# This file is not included in coverage analysis or tests - anything that can be -# tested should live elsewhere. - -def check_versions(): - """ - Having installed a wrong version of pyOpenSSL or netlib is unfortunately a - very common source of error. Check before every start that both versions are - somewhat okay. - """ - # We don't introduce backward-incompatible changes in patch versions. Only - # consider major and minor version. - if netlib.version.IVERSION[:2] != version.IVERSION[:2]: - print( - "Warning: You are using mitmdump %s with netlib %s. " - "Most likely, that won't work - please upgrade!" % ( - version.VERSION, netlib.version.VERSION - ), - file=sys.stderr - ) - import OpenSSL - import inspect - v = tuple([int(x) for x in OpenSSL.__version__.split(".")][:2]) - if v < (0, 14): - print( - "You are using an outdated version of pyOpenSSL:" - " mitmproxy requires pyOpenSSL 0.14 or greater.", - file=sys.stderr - ) - # Some users apparently have multiple versions of pyOpenSSL installed. - # Report which one we got. - pyopenssl_path = os.path.dirname(inspect.getfile(OpenSSL)) - print( - "Your pyOpenSSL %s installation is located at %s" % ( - OpenSSL.__version__, pyopenssl_path - ), - file=sys.stderr - ) - sys.exit(1) - - def assert_utf8_env(): spec = "" for i in ["LANG", "LC_CTYPE", "LC_ALL"]: @@ -78,7 +38,7 @@ def get_server(dummy_server, options): def mitmproxy(args=None): # pragma: nocover from . import console - check_versions() + netlib.version_check.version_check(version.IVERSION) assert_utf8_env() parser = cmdline.mitmproxy() @@ -106,7 +66,7 @@ def mitmproxy(args=None): # pragma: nocover def mitmdump(args=None): # pragma: nocover from . import dump - check_versions() + netlib.version_check.version_check(version.IVERSION) parser = cmdline.mitmdump() options = parser.parse_args(args) @@ -140,7 +100,7 @@ def mitmdump(args=None): # pragma: nocover def mitmweb(args=None): # pragma: nocover from . import web - check_versions() + netlib.version_check.version_check(version.IVERSION) parser = cmdline.mitmweb() options = parser.parse_args(args) diff --git a/setup.py b/setup.py index 4fa646285..1a502b974 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,6 @@ if os.name != "nt": deps = { "netlib>=%s, <%s" % (version.MINORVERSION, version.NEXT_MINORVERSION), "pyasn1>0.1.2", - "pyOpenSSL>=0.14", "tornado>=4.0.2", "configargparse>=0.9.3", "pyperclip>=1.5.8",