1 Star 0 Fork 13

吴磊磊/python-mitmproxy

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
fix-build-fail-with-python3.7.patch 3.29 KB
一键复制 编辑 原始数据 按行查看 历史
mdche 提交于 2021-09-30 17:31 . fix run in python3.7 environment
diff -Nur mitmproxy-7.0.0/mitmproxy/contentviews/__init__.py mitmproxy-7.0.0-1/mitmproxy/contentviews/__init__.py
--- mitmproxy-7.0.0/mitmproxy/contentviews/__init__.py 2021-07-16 16:24:38.000000000 +0800
+++ mitmproxy-7.0.0-1/mitmproxy/contentviews/__init__.py 2021-08-04 15:27:39.221691053 +0800
@@ -99,8 +99,10 @@
http_message = None
if isinstance(message, http.Message):
http_message = message
- if ctype := message.headers.get("content-type"):
- if ct := http.parse_content_type(ctype):
+ ctype_tmp = message.headers.get("content-type")
+ if ctype == ctype_tmp:
+ ct_tmp = http.parse_content_type(ctype)
+ if ct == ct_tmp:
content_type = f"{ct[0]}/{ct[1]}"
description, lines, error = get_content_view(
diff -Nur mitmproxy-7.0.0/mitmproxy/net/tls.py mitmproxy-7.0.0-1/mitmproxy/net/tls.py
--- mitmproxy-7.0.0/mitmproxy/net/tls.py 2021-07-16 16:24:38.000000000 +0800
+++ mitmproxy-7.0.0-1/mitmproxy/net/tls.py 2021-08-04 15:32:53.086778204 +0800
@@ -106,7 +106,7 @@
ok += SSL._lib.SSL_CTX_set_max_proto_version(context._context, max_version.value) # type: ignore
if ok != 2:
raise RuntimeError(
- f"Error setting TLS versions ({min_version=}, {max_version=}). "
+ f"Error setting TLS versions ({min_version}, {max_version}). "
"The version you specified may be unavailable in your libssl."
)
@@ -177,7 +177,7 @@
try:
context.load_verify_locations(ca_pemfile, ca_path)
except SSL.Error as e:
- raise RuntimeError(f"Cannot load trusted certificates ({ca_pemfile=}, {ca_path=}).") from e
+ raise RuntimeError(f"Cannot load trusted certificates ({ca_pemfile}, {ca_path}).") from e
# Client Certs
if client_cert:
diff -Nur mitmproxy-7.0.0/mitmproxy/proxy/layers/http/__init__.py mitmproxy-7.0.0-1/mitmproxy/proxy/layers/http/__init__.py
--- mitmproxy-7.0.0/mitmproxy/proxy/layers/http/__init__.py 2021-07-16 16:24:38.000000000 +0800
+++ mitmproxy-7.0.0-1/mitmproxy/proxy/layers/http/__init__.py 2021-08-04 15:30:16.424239006 +0800
@@ -148,8 +148,8 @@
else:
self.flow = event.replay_flow
self.flow.request = event.request
-
- if err := validate_request(self.mode, self.flow.request):
+ err_tmp = validate_request(self.mode, self.flow.request)
+ if err == err_tmp:
self.flow.response = http.Response.make(502, str(err))
self.client_state = self.state_errored
return (yield from self.send_response())
diff -Nur mitmproxy-7.0.0/mitmproxy/proxy/server.py mitmproxy-7.0.0-1/mitmproxy/proxy/server.py
--- mitmproxy-7.0.0/mitmproxy/proxy/server.py 2021-07-16 16:24:38.000000000 +0800
+++ mitmproxy-7.0.0-1/mitmproxy/proxy/server.py 2021-08-04 15:31:48.925738277 +0800
@@ -142,7 +142,8 @@
server=command.connection
)
await self.handle_hook(server_hooks.ServerConnectHook(hook_data))
- if err := command.connection.error:
+ err_tmp = command.connection.error
+ if err == err_tmp:
self.log(f"server connection to {human.format_address(command.connection.address)} killed before connect: {err}")
self.server_event(events.OpenConnectionCompleted(command, f"Connection killed: {err}"))
return
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wu-leilei/python-mitmproxy.git
git@gitee.com:wu-leilei/python-mitmproxy.git
wu-leilei
python-mitmproxy
python-mitmproxy
master

搜索帮助