mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-29 11:03:13 +00:00
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.
This commit is contained in:
parent
a05a70d816
commit
13ee54da86
@ -2,52 +2,12 @@ from __future__ import print_function, absolute_import
|
|||||||
import os
|
import os
|
||||||
import signal
|
import signal
|
||||||
import sys
|
import sys
|
||||||
import netlib.version
|
import netlib.version, netlib.version_check
|
||||||
from . import version, cmdline
|
from . import version, cmdline
|
||||||
from .proxy import process_proxy_options, ProxyServerError
|
from .proxy import process_proxy_options, ProxyServerError
|
||||||
from .proxy.server import DummyServer, ProxyServer
|
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():
|
def assert_utf8_env():
|
||||||
spec = ""
|
spec = ""
|
||||||
for i in ["LANG", "LC_CTYPE", "LC_ALL"]:
|
for i in ["LANG", "LC_CTYPE", "LC_ALL"]:
|
||||||
@ -78,7 +38,7 @@ def get_server(dummy_server, options):
|
|||||||
def mitmproxy(args=None): # pragma: nocover
|
def mitmproxy(args=None): # pragma: nocover
|
||||||
from . import console
|
from . import console
|
||||||
|
|
||||||
check_versions()
|
netlib.version_check.version_check(version.IVERSION)
|
||||||
assert_utf8_env()
|
assert_utf8_env()
|
||||||
|
|
||||||
parser = cmdline.mitmproxy()
|
parser = cmdline.mitmproxy()
|
||||||
@ -106,7 +66,7 @@ def mitmproxy(args=None): # pragma: nocover
|
|||||||
def mitmdump(args=None): # pragma: nocover
|
def mitmdump(args=None): # pragma: nocover
|
||||||
from . import dump
|
from . import dump
|
||||||
|
|
||||||
check_versions()
|
netlib.version_check.version_check(version.IVERSION)
|
||||||
|
|
||||||
parser = cmdline.mitmdump()
|
parser = cmdline.mitmdump()
|
||||||
options = parser.parse_args(args)
|
options = parser.parse_args(args)
|
||||||
@ -140,7 +100,7 @@ def mitmdump(args=None): # pragma: nocover
|
|||||||
def mitmweb(args=None): # pragma: nocover
|
def mitmweb(args=None): # pragma: nocover
|
||||||
from . import web
|
from . import web
|
||||||
|
|
||||||
check_versions()
|
netlib.version_check.version_check(version.IVERSION)
|
||||||
parser = cmdline.mitmweb()
|
parser = cmdline.mitmweb()
|
||||||
|
|
||||||
options = parser.parse_args(args)
|
options = parser.parse_args(args)
|
||||||
|
1
setup.py
1
setup.py
@ -18,7 +18,6 @@ if os.name != "nt":
|
|||||||
deps = {
|
deps = {
|
||||||
"netlib>=%s, <%s" % (version.MINORVERSION, version.NEXT_MINORVERSION),
|
"netlib>=%s, <%s" % (version.MINORVERSION, version.NEXT_MINORVERSION),
|
||||||
"pyasn1>0.1.2",
|
"pyasn1>0.1.2",
|
||||||
"pyOpenSSL>=0.14",
|
|
||||||
"tornado>=4.0.2",
|
"tornado>=4.0.2",
|
||||||
"configargparse>=0.9.3",
|
"configargparse>=0.9.3",
|
||||||
"pyperclip>=1.5.8",
|
"pyperclip>=1.5.8",
|
||||||
|
Loading…
Reference in New Issue
Block a user