mirror of
https://git.FreeBSD.org/ports.git
synced 2025-01-13 07:34:50 +00:00
www/mitmproxy: update to 6.0.2 release and unbreak.
PR: 250799 Reported by: p5B2E9A8F@t-online.de Patch by: maintainer, lwhsu, ale
This commit is contained in:
parent
10b183fab0
commit
c7bab0df6c
@ -1,9 +1,8 @@
|
||||
# Created by: Hung-Yi Chen <gaod@hychen.org>
|
||||
|
||||
PORTNAME= mitmproxy
|
||||
PORTVERSION= 4.0.4
|
||||
PORTVERSION= 6.0.2
|
||||
DISTVERSIONPREFIX= v
|
||||
PORTREVISION= 3
|
||||
CATEGORIES= www python
|
||||
|
||||
MAINTAINER= gaod@hychen.org
|
||||
@ -12,35 +11,37 @@ COMMENT= SSL-capable man-in-the-middle proxy
|
||||
LICENSE= MIT
|
||||
LICENSE_FILE= ${WRKSRC}/LICENSE
|
||||
|
||||
BROKEN= incorrect depends: depends on package: py38-hyperframe>=5.1.0<6 - not found
|
||||
|
||||
RUN_DEPENDS= ${PYTHON_PKGNAMEPREFIX}click>=6.2:devel/py-click@${PY_FLAVOR} \
|
||||
${PYTHON_PKGNAMEPREFIX}blinker>=1.4:devel/py-blinker@${PY_FLAVOR} \
|
||||
${PYTHON_PKGNAMEPREFIX}certifi>=2015.11.20.1:security/py-certifi@${PY_FLAVOR} \
|
||||
${PYTHON_PKGNAMEPREFIX}wsproto>=0.11.0:net/py-wsproto@${PY_FLAVOR} \
|
||||
${PYTHON_PKGNAMEPREFIX}ldap3>=2.5:net/py-ldap3@${PY_FLAVOR} \
|
||||
${PYTHON_PKGNAMEPREFIX}passlib>=1.6.5:security/py-passlib@${PY_FLAVOR} \
|
||||
RUN_DEPENDS= ${PYTHON_PKGNAMEPREFIX}asgiref>=3.2.10<3.4:www/py-asgiref@${PY_FLAVOR} \
|
||||
${PYTHON_PKGNAMEPREFIX}blinker>=1.4<1.5:devel/py-blinker@${PY_FLAVOR} \
|
||||
${PYTHON_PKGNAMEPREFIX}brotli>=1.0<1.1:archivers/py-brotli@${PY_FLAVOR} \
|
||||
${PYTHON_PKGNAMEPREFIX}certifi>=2019.9.11:security/py-certifi@${PY_FLAVOR} \
|
||||
${PYTHON_PKGNAMEPREFIX}click>=7.0<8:devel/py-click@${PY_FLAVOR} \
|
||||
${PYTHON_PKGNAMEPREFIX}cryptography>=3.3<3.4:security/py-cryptography@${PY_FLAVOR} \
|
||||
${PYTHON_PKGNAMEPREFIX}Flask>=1.1.1<1.2:www/py-flask@${PY_FLAVOR} \
|
||||
${PYTHON_PKGNAMEPREFIX}h2>=4.0<5:www/py-h2@${PY_FLAVOR} \
|
||||
${PYTHON_PKGNAMEPREFIX}hyperframe>=6.0<7:www/py-hyperframe@${PY_FLAVOR} \
|
||||
${PYTHON_PKGNAMEPREFIX}kaitaistruct>=0.7<0.10:devel/py-kaitaistruct@${PY_FLAVOR} \
|
||||
${PYTHON_PKGNAMEPREFIX}ldap3>=2.8<2.9:net/py-ldap3@${PY_FLAVOR} \
|
||||
${PYTHON_PKGNAMEPREFIX}msgpack>=1.0.0<1.1.0:devel/py-msgpack@${PY_FLAVOR} \
|
||||
${PYTHON_PKGNAMEPREFIX}passlib>=1.6.5<1.8:security/py-passlib@${PY_FLAVOR} \
|
||||
${PYTHON_PKGNAMEPREFIX}protobuf>=3.14,1<3.15,1:devel/py-protobuf@${PY_FLAVOR} \
|
||||
${PYTHON_PKGNAMEPREFIX}pyasn1>=0.3.1<0.5:devel/py-pyasn1@${PY_FLAVOR} \
|
||||
${PYTHON_PKGNAMEPREFIX}openssl>=17.5:security/py-openssl@${PY_FLAVOR} \
|
||||
${PYTHON_PKGNAMEPREFIX}pyparsing>=2.1.3:devel/py-pyparsing@${PY_FLAVOR} \
|
||||
${PYTHON_PKGNAMEPREFIX}ruamel.yaml>=0.13.2:devel/py-ruamel.yaml@${PY_FLAVOR} \
|
||||
${PYTHON_PKGNAMEPREFIX}tornado5>=4.3<5.2:www/py-tornado5@${PY_FLAVOR} \
|
||||
${PYTHON_PKGNAMEPREFIX}urwid>=2.0.1:devel/py-urwid@${PY_FLAVOR} \
|
||||
${PYTHON_PKGNAMEPREFIX}brotli>=0.7.0:archivers/py-brotli@${PY_FLAVOR} \
|
||||
${PYTHON_PKGNAMEPREFIX}sortedcontainers>=1.5.4:devel/py-sortedcontainers@${PY_FLAVOR} \
|
||||
${PYTHON_PKGNAMEPREFIX}pyperclip>=1.6.0:devel/py-pyperclip@${PY_FLAVOR} \
|
||||
${PYTHON_PKGNAMEPREFIX}hyperframe>=5.1.0<6:www/py-hyperframe@${PY_FLAVOR} \
|
||||
${PYTHON_PKGNAMEPREFIX}kaitaistruct>=0.7<0.9:devel/py-kaitaistruct@${PY_FLAVOR} \
|
||||
${PYTHON_PKGNAMEPREFIX}h2>=3.0.1<4:www/py-h2@${PY_FLAVOR} \
|
||||
${PYTHON_PKGNAMEPREFIX}cryptography>=2.1.4:security/py-cryptography@${PY_FLAVOR}
|
||||
${PYTHON_PKGNAMEPREFIX}openssl>=20.0<20.1:security/py-openssl@${PY_FLAVOR} \
|
||||
${PYTHON_PKGNAMEPREFIX}pyparsing>=2.4.2<2.5:devel/py-pyparsing@${PY_FLAVOR} \
|
||||
${PYTHON_PKGNAMEPREFIX}pyperclip>=1.6.0<1.9:devel/py-pyperclip@${PY_FLAVOR} \
|
||||
${PYTHON_PKGNAMEPREFIX}ruamel.yaml>=0.16<0.17:devel/py-ruamel.yaml@${PY_FLAVOR} \
|
||||
${PYTHON_PKGNAMEPREFIX}sortedcontainers>=2.3<2.4:devel/py-sortedcontainers@${PY_FLAVOR} \
|
||||
${PYTHON_PKGNAMEPREFIX}tornado>=4.3<7:www/py-tornado@${PY_FLAVOR} \
|
||||
${PYTHON_PKGNAMEPREFIX}urwid>=2.1.1<2.2:devel/py-urwid@${PY_FLAVOR} \
|
||||
${PYTHON_PKGNAMEPREFIX}wsproto>=1.0.0<1.1.0:net/py-wsproto@${PY_FLAVOR} \
|
||||
${PYTHON_PKGNAMEPREFIX}publicsuffix2>=2.20190812<3:dns/py-publicsuffix2@${PY_FLAVOR} \
|
||||
${PYTHON_PKGNAMEPREFIX}zstandard>=0.11<0.16:archivers/py-zstandard@${PY_FLAVOR} \
|
||||
${PYTHON_PKGNAMEPREFIX}sqlite3>0:databases/py-sqlite3@${PY_FLAVOR}
|
||||
|
||||
USES= python:3.5+
|
||||
USES= python:3.8+
|
||||
USE_PYTHON= distutils autoplist noflavors
|
||||
USE_GITHUB= yes
|
||||
|
||||
NO_ARCH= yes
|
||||
|
||||
post-extract:
|
||||
@${REINPLACE_CMD} -e 's/brotlipy/brotli/' -e 's/, <.*",/",/' ${WRKSRC}/setup.py
|
||||
|
||||
.include <bsd.port.mk>
|
||||
|
@ -1,3 +1,3 @@
|
||||
TIMESTAMP = 1550146900
|
||||
SHA256 (mitmproxy-mitmproxy-v4.0.4_GH0.tar.gz) = d91eaaad06a5e124a76388999b22a4c590ea26149a30aaff73658cd98d0651d5
|
||||
SIZE (mitmproxy-mitmproxy-v4.0.4_GH0.tar.gz) = 27131713
|
||||
TIMESTAMP = 1608910538
|
||||
SHA256 (mitmproxy-mitmproxy-v6.0.2_GH0.tar.gz) = 15b32ce31e707d35de1707afe09e82bbf3d643bdd93968c5512caba80523c606
|
||||
SIZE (mitmproxy-mitmproxy-v6.0.2_GH0.tar.gz) = 27274682
|
||||
|
@ -1,174 +0,0 @@
|
||||
--- mitmproxy/proxy/protocol/websocket.py.orig 2019-02-14 21:03:58 UTC
|
||||
+++ mitmproxy/proxy/protocol/websocket.py
|
||||
@@ -4,8 +4,9 @@ from OpenSSL import SSL
|
||||
|
||||
|
||||
import wsproto
|
||||
-from wsproto import events
|
||||
-from wsproto.connection import ConnectionType, WSConnection
|
||||
+from wsproto import events, WSConnection
|
||||
+from wsproto.connection import ConnectionType
|
||||
+from wsproto.events import AcceptConnection, CloseConnection, Message, Ping, Request
|
||||
from wsproto.extensions import PerMessageDeflate
|
||||
|
||||
from mitmproxy import exceptions
|
||||
@@ -52,51 +53,52 @@ class WebSocketLayer(base.Layer):
|
||||
|
||||
self.connections: dict[object, WSConnection] = {}
|
||||
|
||||
- extensions = []
|
||||
+ client_extensions = []
|
||||
+ server_extensions = []
|
||||
if 'Sec-WebSocket-Extensions' in handshake_flow.response.headers:
|
||||
if PerMessageDeflate.name in handshake_flow.response.headers['Sec-WebSocket-Extensions']:
|
||||
- extensions = [PerMessageDeflate()]
|
||||
- self.connections[self.client_conn] = WSConnection(ConnectionType.SERVER,
|
||||
- extensions=extensions)
|
||||
- self.connections[self.server_conn] = WSConnection(ConnectionType.CLIENT,
|
||||
- host=handshake_flow.request.host,
|
||||
- resource=handshake_flow.request.path,
|
||||
- extensions=extensions)
|
||||
- if extensions:
|
||||
- for conn in self.connections.values():
|
||||
- conn.extensions[0].finalize(conn, handshake_flow.response.headers['Sec-WebSocket-Extensions'])
|
||||
+ client_extensions = [PerMessageDeflate()]
|
||||
+ server_extensions = [PerMessageDeflate()]
|
||||
+ self.connections[self.client_conn] = WSConnection(ConnectionType.SERVER)
|
||||
+ self.connections[self.server_conn] = WSConnection(ConnectionType.CLIENT)
|
||||
|
||||
- data = self.connections[self.server_conn].bytes_to_send()
|
||||
- self.connections[self.client_conn].receive_bytes(data)
|
||||
+ if client_extensions:
|
||||
+ client_extensions[0].finalize(handshake_flow.response.headers['Sec-WebSocket-Extensions'])
|
||||
+ if server_extensions:
|
||||
+ server_extensions[0].finalize(handshake_flow.response.headers['Sec-WebSocket-Extensions'])
|
||||
|
||||
+ request = Request(extensions=client_extensions, host=handshake_flow.request.host, target=handshake_flow.request.path)
|
||||
+ data = self.connections[self.server_conn].send(request)
|
||||
+ self.connections[self.client_conn].receive_data(data)
|
||||
+
|
||||
event = next(self.connections[self.client_conn].events())
|
||||
- assert isinstance(event, events.ConnectionRequested)
|
||||
+ assert isinstance(event, events.Request)
|
||||
|
||||
- self.connections[self.client_conn].accept(event)
|
||||
- self.connections[self.server_conn].receive_bytes(self.connections[self.client_conn].bytes_to_send())
|
||||
- assert isinstance(next(self.connections[self.server_conn].events()), events.ConnectionEstablished)
|
||||
+ data = self.connections[self.client_conn].send(AcceptConnection(extensions=server_extensions))
|
||||
+ self.connections[self.server_conn].receive_data(data)
|
||||
+ assert isinstance(next(self.connections[self.server_conn].events()), events.AcceptConnection)
|
||||
|
||||
def _handle_event(self, event, source_conn, other_conn, is_server):
|
||||
- if isinstance(event, events.DataReceived):
|
||||
- return self._handle_data_received(event, source_conn, other_conn, is_server)
|
||||
- elif isinstance(event, events.PingReceived):
|
||||
- return self._handle_ping_received(event, source_conn, other_conn, is_server)
|
||||
- elif isinstance(event, events.PongReceived):
|
||||
- return self._handle_pong_received(event, source_conn, other_conn, is_server)
|
||||
- elif isinstance(event, events.ConnectionClosed):
|
||||
- return self._handle_connection_closed(event, source_conn, other_conn, is_server)
|
||||
+ if isinstance(event, events.Message):
|
||||
+ return self._handle_message(event, source_conn, other_conn, is_server)
|
||||
+ elif isinstance(event, events.Ping):
|
||||
+ return self._handle_ping(event, source_conn, other_conn, is_server)
|
||||
+ elif isinstance(event, events.Pong):
|
||||
+ return self._handle_pong(event, source_conn, other_conn, is_server)
|
||||
+ elif isinstance(event, events.CloseConnection):
|
||||
+ return self._handle_close_connection(event, source_conn, other_conn, is_server)
|
||||
|
||||
# fail-safe for unhandled events
|
||||
return True # pragma: no cover
|
||||
|
||||
- def _handle_data_received(self, event, source_conn, other_conn, is_server):
|
||||
+ def _handle_message(self, event, source_conn, other_conn, is_server):
|
||||
fb = self.server_frame_buffer if is_server else self.client_frame_buffer
|
||||
fb.append(event.data)
|
||||
|
||||
if event.message_finished:
|
||||
original_chunk_sizes = [len(f) for f in fb]
|
||||
|
||||
- if isinstance(event, events.TextReceived):
|
||||
+ if isinstance(event, events.TextMessage):
|
||||
message_type = wsproto.frame_protocol.Opcode.TEXT
|
||||
payload = ''.join(fb)
|
||||
else:
|
||||
@@ -127,19 +129,20 @@ class WebSocketLayer(base.Layer):
|
||||
yield (payload[i:i + chunk_size], True if i + chunk_size >= len(payload) else False)
|
||||
|
||||
for chunk, final in get_chunk(websocket_message.content):
|
||||
- self.connections[other_conn].send_data(chunk, final)
|
||||
- other_conn.send(self.connections[other_conn].bytes_to_send())
|
||||
+ data = self.connections[other_conn].send(Message(data=chunk, message_finished=final))
|
||||
+ other_conn.send(data)
|
||||
|
||||
if self.flow.stream:
|
||||
- self.connections[other_conn].send_data(event.data, event.message_finished)
|
||||
- other_conn.send(self.connections[other_conn].bytes_to_send())
|
||||
+ data = self.connections[other_conn].send(Message(data=event.data, message_finished=event.message_finished))
|
||||
+ other_conn.send(data)
|
||||
return True
|
||||
|
||||
- def _handle_ping_received(self, event, source_conn, other_conn, is_server):
|
||||
- # PING is automatically answered with a PONG by wsproto
|
||||
- self.connections[other_conn].ping()
|
||||
- other_conn.send(self.connections[other_conn].bytes_to_send())
|
||||
- source_conn.send(self.connections[source_conn].bytes_to_send())
|
||||
+ def _handle_ping(self, event, source_conn, other_conn, is_server):
|
||||
+ # Use event.response to create the approprate Pong response
|
||||
+ data = self.connections[other_conn].send(Ping())
|
||||
+ other_conn.send(data)
|
||||
+ data = self.connections[source_conn].send(event.response())
|
||||
+ source_conn.send(data)
|
||||
self.log(
|
||||
"Ping Received from {}".format("server" if is_server else "client"),
|
||||
"info",
|
||||
@@ -147,7 +150,7 @@ class WebSocketLayer(base.Layer):
|
||||
)
|
||||
return True
|
||||
|
||||
- def _handle_pong_received(self, event, source_conn, other_conn, is_server):
|
||||
+ def _handle_pong(self, event, source_conn, other_conn, is_server):
|
||||
self.log(
|
||||
"Pong Received from {}".format("server" if is_server else "client"),
|
||||
"info",
|
||||
@@ -155,14 +158,15 @@ class WebSocketLayer(base.Layer):
|
||||
)
|
||||
return True
|
||||
|
||||
- def _handle_connection_closed(self, event, source_conn, other_conn, is_server):
|
||||
+ def _handle_close_connection(self, event, source_conn, other_conn, is_server):
|
||||
self.flow.close_sender = "server" if is_server else "client"
|
||||
self.flow.close_code = event.code
|
||||
self.flow.close_reason = event.reason
|
||||
|
||||
- self.connections[other_conn].close(event.code, event.reason)
|
||||
- other_conn.send(self.connections[other_conn].bytes_to_send())
|
||||
- source_conn.send(self.connections[source_conn].bytes_to_send())
|
||||
+ data = self.connections[other_conn].send(CloseConnection(code=event.code, reason=event.reason))
|
||||
+ other_conn.send(data)
|
||||
+ data = self.connections[source_conn].send(event.response())
|
||||
+ source_conn.send(data)
|
||||
|
||||
return False
|
||||
|
||||
@@ -170,8 +174,7 @@ class WebSocketLayer(base.Layer):
|
||||
while True:
|
||||
try:
|
||||
payload = message_queue.get_nowait()
|
||||
- self.connections[endpoint].send_data(payload, final=True)
|
||||
- data = self.connections[endpoint].bytes_to_send()
|
||||
+ data = self.connections[endpoint].send(Message(data=payload, message_finished=True))
|
||||
endpoint.send(data)
|
||||
except queue.Empty:
|
||||
break
|
||||
@@ -197,8 +200,8 @@ class WebSocketLayer(base.Layer):
|
||||
is_server = (source_conn == self.server_conn)
|
||||
|
||||
frame = websockets.Frame.from_file(source_conn.rfile)
|
||||
- self.connections[source_conn].receive_bytes(bytes(frame))
|
||||
- source_conn.send(self.connections[source_conn].bytes_to_send())
|
||||
+ data = self.connections[source_conn].receive_data(bytes(frame))
|
||||
+ source_conn.send(data)
|
||||
|
||||
if close_received:
|
||||
return
|
@ -1,34 +1,11 @@
|
||||
--- setup.py.orig 2019-12-09 13:30:10 UTC
|
||||
--- setup.py.orig 2021-06-30 07:08:47 UTC
|
||||
+++ setup.py
|
||||
@@ -61,24 +61,24 @@ setup(
|
||||
# It is not considered best practice to use install_requires to pin dependencies to specific versions.
|
||||
install_requires=[
|
||||
"blinker>=1.4",
|
||||
- "brotli>=0.7.0,<0.8",
|
||||
+ "brotli>=0.7.0",
|
||||
"certifi>=2015.11.20.1", # no semver here - this should always be on the last release!
|
||||
"click>=6.2",
|
||||
- "cryptography>=2.1.4,<2.4",
|
||||
+ "cryptography>=2.1.4",
|
||||
"h2>=3.0.1,<4",
|
||||
"hyperframe>=5.1.0,<6",
|
||||
"kaitaistruct>=0.7,<0.9",
|
||||
- "ldap3>=2.5,<2.6",
|
||||
+ "ldap3>=2.5",
|
||||
"passlib>=1.6.5",
|
||||
"pyasn1>=0.3.1,<0.5",
|
||||
- "pyOpenSSL>=17.5,<18.1",
|
||||
+ "pyOpenSSL>=17.5",
|
||||
"pyparsing>=2.1.3",
|
||||
"pyperclip>=1.6.0",
|
||||
"ruamel.yaml>=0.13.2",
|
||||
- "sortedcontainers>=1.5.4,<2.1",
|
||||
+ "sortedcontainers>=1.5.4",
|
||||
"tornado>=4.3,<5.2",
|
||||
- "urwid>=2.0.1,<2.1",
|
||||
- "wsproto>=0.11.0,<0.12.0",
|
||||
+ "urwid>=2.0.1",
|
||||
+ "wsproto>=0.13.0",
|
||||
@@ -91,7 +91,7 @@ setup(
|
||||
"urwid>=2.1.1,<2.2",
|
||||
"wsproto>=1.0,<1.1",
|
||||
"publicsuffix2>=2.20190812,<3",
|
||||
- "zstandard>=0.11,<0.15",
|
||||
+ "zstandard>=0.11,<0.16",
|
||||
],
|
||||
extras_require={
|
||||
':sys_platform == "win32"': [
|
||||
|
@ -5,4 +5,4 @@ fly.
|
||||
'mitmdump' is the command-line version of mitmproxy, with the same
|
||||
functionality but without the frills. Think tcpdump for HTTP.
|
||||
|
||||
WWW: https://mitmproxy.org/index.html
|
||||
WWW: https://mitmproxy.org/
|
||||
|
Loading…
Reference in New Issue
Block a user