2015-08-03 16:06:31 +00:00
|
|
|
"""
|
|
|
|
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.
|
|
|
|
"""
|
|
|
|
from __future__ import division, absolute_import, print_function, unicode_literals
|
2015-05-31 01:12:01 +00:00
|
|
|
import sys
|
|
|
|
import inspect
|
|
|
|
import os.path
|
|
|
|
import OpenSSL
|
|
|
|
from . import version
|
|
|
|
|
|
|
|
PYOPENSSL_MIN_VERSION = (0, 15)
|
|
|
|
|
|
|
|
|
2015-08-03 16:06:31 +00:00
|
|
|
def check_mitmproxy_version(mitmproxy_version, fp=sys.stderr):
|
2015-05-31 01:12:01 +00:00
|
|
|
# We don't introduce backward-incompatible changes in patch versions. Only
|
|
|
|
# consider major and minor version.
|
|
|
|
if version.IVERSION[:2] != mitmproxy_version[:2]:
|
|
|
|
print(
|
|
|
|
"You are using mitmproxy %s with netlib %s. "
|
|
|
|
"Most likely, that won't work - please upgrade!" % (
|
|
|
|
mitmproxy_version, version.VERSION
|
|
|
|
),
|
|
|
|
file=fp
|
|
|
|
)
|
|
|
|
sys.exit(1)
|
2015-08-03 16:06:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
def check_pyopenssl_version(min_version=PYOPENSSL_MIN_VERSION, fp=sys.stderr):
|
2015-07-25 11:30:25 +00:00
|
|
|
v = tuple(int(x) for x in OpenSSL.__version__.split(".")[:2])
|
2015-08-03 16:06:31 +00:00
|
|
|
if v < min_version:
|
2015-05-31 01:12:01 +00:00
|
|
|
print(
|
|
|
|
"You are using an outdated version of pyOpenSSL:"
|
2015-06-24 22:37:01 +00:00
|
|
|
" mitmproxy requires pyOpenSSL %s or greater." %
|
2015-08-03 16:06:31 +00:00
|
|
|
str(min_version),
|
2015-05-31 01:12:01 +00:00
|
|
|
file=fp
|
|
|
|
)
|
|
|
|
# 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=fp
|
|
|
|
)
|
|
|
|
sys.exit(1)
|