View | Details | Raw Unified | Return to bug 250799 | Differences between
and this patch

Collapse All | Expand All

(-)www/mitmproxy/Makefile (-20 / +26 lines)
Lines 2-10 Link Here
2
# $FreeBSD$
2
# $FreeBSD$
3
3
4
PORTNAME=	mitmproxy
4
PORTNAME=	mitmproxy
5
PORTVERSION=	4.0.4
5
PORTVERSION=	6.0.2
6
DISTVERSIONPREFIX=	v
6
DISTVERSIONPREFIX=	v
7
PORTREVISION=	2
8
CATEGORIES=	www python
7
CATEGORIES=	www python
9
8
10
MAINTAINER=	gaod@hychen.org
9
MAINTAINER=	gaod@hychen.org
Lines 13-39 Link Here
13
LICENSE=	MIT
12
LICENSE=	MIT
14
LICENSE_FILE=	${WRKSRC}/LICENSE
13
LICENSE_FILE=	${WRKSRC}/LICENSE
15
14
16
RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}click>=6.2:devel/py-click@${PY_FLAVOR} \
15
RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}asgiref>=3.2.10:www/py-asgiref@${PY_FLAVOR} \
17
		${PYTHON_PKGNAMEPREFIX}blinker>=1.4:devel/py-blinker@${PY_FLAVOR} \
16
		${PYTHON_PKGNAMEPREFIX}blinker>=1.4:devel/py-blinker@${PY_FLAVOR} \
18
		${PYTHON_PKGNAMEPREFIX}certifi>=2015.11.20.1:security/py-certifi@${PY_FLAVOR} \
17
		${PYTHON_PKGNAMEPREFIX}brotli>=1.0:archivers/py-brotli@${PY_FLAVOR} \
19
		${PYTHON_PKGNAMEPREFIX}wsproto>=0.11.0:net/py-wsproto@${PY_FLAVOR} \
18
		${PYTHON_PKGNAMEPREFIX}certifi>=2019.9.11:security/py-certifi@${PY_FLAVOR} \
20
		${PYTHON_PKGNAMEPREFIX}ldap3>=2.5:net/py-ldap3@${PY_FLAVOR} \
19
		${PYTHON_PKGNAMEPREFIX}click>=7.0:devel/py-click@${PY_FLAVOR} \
21
		${PYTHON_PKGNAMEPREFIX}passlib>=1.6.5:security/py-passlib@${PY_FLAVOR} \
20
		${PYTHON_PKGNAMEPREFIX}cryptography>=3.3:security/py-cryptography@${PY_FLAVOR} \
21
		${PYTHON_PKGNAMEPREFIX}Flask>=1.1.1:www/py-flask@${PY_FLAVOR} \
22
		${PYTHON_PKGNAMEPREFIX}h2>=4.0<5:www/py-h2@${PY_FLAVOR} \
23
		${PYTHON_PKGNAMEPREFIX}hyperframe>=6.0<7:www/py-hyperframe@${PY_FLAVOR} \
24
		${PYTHON_PKGNAMEPREFIX}kaitaistruct>=0.7<0.10:devel/py-kaitaistruct@${PY_FLAVOR} \
25
		${PYTHON_PKGNAMEPREFIX}ldap3>=2.8<2.9:net/py-ldap3@${PY_FLAVOR} \
26
		${PYTHON_PKGNAMEPREFIX}msgpack>=1.0.0<1.1.0:devel/py-msgpack@${PY_FLAVOR} \
27
		${PYTHON_PKGNAMEPREFIX}openssl>=20.0<20.1:security/py-openssl@${PY_FLAVOR} \
28
		${PYTHON_PKGNAMEPREFIX}passlib>=1.6.5<1.8:security/py-passlib@${PY_FLAVOR} \
29
		${PYTHON_PKGNAMEPREFIX}protobuf>=3.14.0:devel/py-protobuf@${PY_FLAVOR} \
30
		${PYTHON_PKGNAMEPREFIX}publicsuffix2>=2.20190812<3:dns/py-publicsuffix2@${PY_FLAVOR} \
22
		${PYTHON_PKGNAMEPREFIX}pyasn1>=0.3.1<0.5:devel/py-pyasn1@${PY_FLAVOR} \
31
		${PYTHON_PKGNAMEPREFIX}pyasn1>=0.3.1<0.5:devel/py-pyasn1@${PY_FLAVOR} \
23
		${PYTHON_PKGNAMEPREFIX}openssl>=17.5:security/py-openssl@${PY_FLAVOR} \
32
		${PYTHON_PKGNAMEPREFIX}pyparsing>=2.4.2<2.5:devel/py-pyparsing@${PY_FLAVOR} \
24
		${PYTHON_PKGNAMEPREFIX}pyparsing>=2.1.3:devel/py-pyparsing@${PY_FLAVOR} \
33
		${PYTHON_PKGNAMEPREFIX}pyperclip>=1.6.0<1.9:devel/py-pyperclip@${PY_FLAVOR} \
25
		${PYTHON_PKGNAMEPREFIX}ruamel.yaml>=0.13.2:devel/py-ruamel.yaml@${PY_FLAVOR} \
34
		${PYTHON_PKGNAMEPREFIX}ruamel.yaml>=0.16<0.17:devel/py-ruamel.yaml@${PY_FLAVOR} \
26
		${PYTHON_PKGNAMEPREFIX}tornado>=4.3<5.2:www/py-tornado@${PY_FLAVOR} \
35
		${PYTHON_PKGNAMEPREFIX}sortedcontainers>=2.3<2.4:devel/py-sortedcontainers@${PY_FLAVOR} \
27
		${PYTHON_PKGNAMEPREFIX}urwid>=2.0.1:devel/py-urwid@${PY_FLAVOR} \
36
		${PYTHON_PKGNAMEPREFIX}sqlite3>0:databases/py-sqlite3@${PY_FLAVOR} \
28
		${PYTHON_PKGNAMEPREFIX}brotli>=0.7.0:archivers/py-brotli@${PY_FLAVOR} \
37
		${PYTHON_PKGNAMEPREFIX}tornado>=4.3<7:www/py-tornado@${PY_FLAVOR} \
29
		${PYTHON_PKGNAMEPREFIX}sortedcontainers>=1.5.4:devel/py-sortedcontainers@${PY_FLAVOR} \
38
		${PYTHON_PKGNAMEPREFIX}urwid>=2.1.1<2.2:devel/py-urwid@${PY_FLAVOR} \
30
		${PYTHON_PKGNAMEPREFIX}pyperclip>=1.6.0:devel/py-pyperclip@${PY_FLAVOR} \
39
		${PYTHON_PKGNAMEPREFIX}wsproto>=1.0.0<1.1.0:net/py-wsproto@${PY_FLAVOR} \
31
		${PYTHON_PKGNAMEPREFIX}hyperframe>=5.1.0<6:www/py-hyperframe@${PY_FLAVOR} \
40
		${PYTHON_PKGNAMEPREFIX}zstandard>=0.11<0.15:archivers/py-zstandard@${PY_FLAVOR} 
32
		${PYTHON_PKGNAMEPREFIX}kaitaistruct>=0.7<0.9:devel/py-kaitaistruct@${PY_FLAVOR} \
33
		${PYTHON_PKGNAMEPREFIX}h2>=3.0.1<4:www/py-h2@${PY_FLAVOR} \
34
		${PYTHON_PKGNAMEPREFIX}cryptography>=2.1.4:security/py-cryptography@${PY_FLAVOR}
35
41
36
USES=		python:3.5+
42
USES=		python:3.8+
37
USE_PYTHON=	distutils autoplist noflavors
43
USE_PYTHON=	distutils autoplist noflavors
38
USE_GITHUB=	yes
44
USE_GITHUB=	yes
39
45
(-)www/mitmproxy/distinfo (-3 / +3 lines)
Lines 1-3 Link Here
1
TIMESTAMP = 1550146900
1
TIMESTAMP = 1608910538
2
SHA256 (mitmproxy-mitmproxy-v4.0.4_GH0.tar.gz) = d91eaaad06a5e124a76388999b22a4c590ea26149a30aaff73658cd98d0651d5
2
SHA256 (mitmproxy-mitmproxy-v6.0.2_GH0.tar.gz) = 15b32ce31e707d35de1707afe09e82bbf3d643bdd93968c5512caba80523c606
3
SIZE (mitmproxy-mitmproxy-v4.0.4_GH0.tar.gz) = 27131713
3
SIZE (mitmproxy-mitmproxy-v6.0.2_GH0.tar.gz) = 27274682
(-)www/mitmproxy/files/patch-mitmproxy_proxy_protocol_websocket.py (-174 lines)
Lines 1-174 Link Here
1
--- mitmproxy/proxy/protocol/websocket.py.orig	2019-02-14 21:03:58 UTC
2
+++ mitmproxy/proxy/protocol/websocket.py
3
@@ -4,8 +4,9 @@ from OpenSSL import SSL
4
 
5
 
6
 import wsproto
7
-from wsproto import events
8
-from wsproto.connection import ConnectionType, WSConnection
9
+from wsproto import events, WSConnection
10
+from wsproto.connection import ConnectionType
11
+from wsproto.events import AcceptConnection, CloseConnection, Message, Ping, Request
12
 from wsproto.extensions import PerMessageDeflate
13
 
14
 from mitmproxy import exceptions
15
@@ -52,51 +53,52 @@ class WebSocketLayer(base.Layer):
16
 
17
         self.connections: dict[object, WSConnection] = {}
18
 
19
-        extensions = []
20
+        client_extensions = []
21
+        server_extensions = []
22
         if 'Sec-WebSocket-Extensions' in handshake_flow.response.headers:
23
             if PerMessageDeflate.name in handshake_flow.response.headers['Sec-WebSocket-Extensions']:
24
-                extensions = [PerMessageDeflate()]
25
-        self.connections[self.client_conn] = WSConnection(ConnectionType.SERVER,
26
-                                                          extensions=extensions)
27
-        self.connections[self.server_conn] = WSConnection(ConnectionType.CLIENT,
28
-                                                          host=handshake_flow.request.host,
29
-                                                          resource=handshake_flow.request.path,
30
-                                                          extensions=extensions)
31
-        if extensions:
32
-            for conn in self.connections.values():
33
-                conn.extensions[0].finalize(conn, handshake_flow.response.headers['Sec-WebSocket-Extensions'])
34
+                client_extensions = [PerMessageDeflate()]
35
+                server_extensions = [PerMessageDeflate()]
36
+        self.connections[self.client_conn] = WSConnection(ConnectionType.SERVER)
37
+        self.connections[self.server_conn] = WSConnection(ConnectionType.CLIENT)
38
 
39
-        data = self.connections[self.server_conn].bytes_to_send()
40
-        self.connections[self.client_conn].receive_bytes(data)
41
+        if client_extensions:
42
+            client_extensions[0].finalize(handshake_flow.response.headers['Sec-WebSocket-Extensions'])
43
+        if server_extensions:
44
+            server_extensions[0].finalize(handshake_flow.response.headers['Sec-WebSocket-Extensions'])
45
 
46
+        request = Request(extensions=client_extensions, host=handshake_flow.request.host, target=handshake_flow.request.path)
47
+        data = self.connections[self.server_conn].send(request)
48
+        self.connections[self.client_conn].receive_data(data)
49
+
50
         event = next(self.connections[self.client_conn].events())
51
-        assert isinstance(event, events.ConnectionRequested)
52
+        assert isinstance(event, events.Request)
53
 
54
-        self.connections[self.client_conn].accept(event)
55
-        self.connections[self.server_conn].receive_bytes(self.connections[self.client_conn].bytes_to_send())
56
-        assert isinstance(next(self.connections[self.server_conn].events()), events.ConnectionEstablished)
57
+        data = self.connections[self.client_conn].send(AcceptConnection(extensions=server_extensions))
58
+        self.connections[self.server_conn].receive_data(data)
59
+        assert isinstance(next(self.connections[self.server_conn].events()), events.AcceptConnection)
60
 
61
     def _handle_event(self, event, source_conn, other_conn, is_server):
62
-        if isinstance(event, events.DataReceived):
63
-            return self._handle_data_received(event, source_conn, other_conn, is_server)
64
-        elif isinstance(event, events.PingReceived):
65
-            return self._handle_ping_received(event, source_conn, other_conn, is_server)
66
-        elif isinstance(event, events.PongReceived):
67
-            return self._handle_pong_received(event, source_conn, other_conn, is_server)
68
-        elif isinstance(event, events.ConnectionClosed):
69
-            return self._handle_connection_closed(event, source_conn, other_conn, is_server)
70
+        if isinstance(event, events.Message):
71
+            return self._handle_message(event, source_conn, other_conn, is_server)
72
+        elif isinstance(event, events.Ping):
73
+            return self._handle_ping(event, source_conn, other_conn, is_server)
74
+        elif isinstance(event, events.Pong):
75
+            return self._handle_pong(event, source_conn, other_conn, is_server)
76
+        elif isinstance(event, events.CloseConnection):
77
+            return self._handle_close_connection(event, source_conn, other_conn, is_server)
78
 
79
         # fail-safe for unhandled events
80
         return True  # pragma: no cover
81
 
82
-    def _handle_data_received(self, event, source_conn, other_conn, is_server):
83
+    def _handle_message(self, event, source_conn, other_conn, is_server):
84
         fb = self.server_frame_buffer if is_server else self.client_frame_buffer
85
         fb.append(event.data)
86
 
87
         if event.message_finished:
88
             original_chunk_sizes = [len(f) for f in fb]
89
 
90
-            if isinstance(event, events.TextReceived):
91
+            if isinstance(event, events.TextMessage):
92
                 message_type = wsproto.frame_protocol.Opcode.TEXT
93
                 payload = ''.join(fb)
94
             else:
95
@@ -127,19 +129,20 @@ class WebSocketLayer(base.Layer):
96
                             yield (payload[i:i + chunk_size], True if i + chunk_size >= len(payload) else False)
97
 
98
                 for chunk, final in get_chunk(websocket_message.content):
99
-                    self.connections[other_conn].send_data(chunk, final)
100
-                    other_conn.send(self.connections[other_conn].bytes_to_send())
101
+                    data = self.connections[other_conn].send(Message(data=chunk, message_finished=final))
102
+                    other_conn.send(data)
103
 
104
         if self.flow.stream:
105
-            self.connections[other_conn].send_data(event.data, event.message_finished)
106
-            other_conn.send(self.connections[other_conn].bytes_to_send())
107
+            data = self.connections[other_conn].send(Message(data=event.data, message_finished=event.message_finished))
108
+            other_conn.send(data)
109
         return True
110
 
111
-    def _handle_ping_received(self, event, source_conn, other_conn, is_server):
112
-        # PING is automatically answered with a PONG by wsproto
113
-        self.connections[other_conn].ping()
114
-        other_conn.send(self.connections[other_conn].bytes_to_send())
115
-        source_conn.send(self.connections[source_conn].bytes_to_send())
116
+    def _handle_ping(self, event, source_conn, other_conn, is_server):
117
+        # Use event.response to create the approprate Pong response
118
+        data = self.connections[other_conn].send(Ping())
119
+        other_conn.send(data)
120
+        data = self.connections[source_conn].send(event.response())
121
+        source_conn.send(data)
122
         self.log(
123
             "Ping Received from {}".format("server" if is_server else "client"),
124
             "info",
125
@@ -147,7 +150,7 @@ class WebSocketLayer(base.Layer):
126
         )
127
         return True
128
 
129
-    def _handle_pong_received(self, event, source_conn, other_conn, is_server):
130
+    def _handle_pong(self, event, source_conn, other_conn, is_server):
131
         self.log(
132
             "Pong Received from {}".format("server" if is_server else "client"),
133
             "info",
134
@@ -155,14 +158,15 @@ class WebSocketLayer(base.Layer):
135
         )
136
         return True
137
 
138
-    def _handle_connection_closed(self, event, source_conn, other_conn, is_server):
139
+    def _handle_close_connection(self, event, source_conn, other_conn, is_server):
140
         self.flow.close_sender = "server" if is_server else "client"
141
         self.flow.close_code = event.code
142
         self.flow.close_reason = event.reason
143
 
144
-        self.connections[other_conn].close(event.code, event.reason)
145
-        other_conn.send(self.connections[other_conn].bytes_to_send())
146
-        source_conn.send(self.connections[source_conn].bytes_to_send())
147
+        data = self.connections[other_conn].send(CloseConnection(code=event.code, reason=event.reason))
148
+        other_conn.send(data)
149
+        data = self.connections[source_conn].send(event.response())
150
+        source_conn.send(data)
151
 
152
         return False
153
 
154
@@ -170,8 +174,7 @@ class WebSocketLayer(base.Layer):
155
         while True:
156
             try:
157
                 payload = message_queue.get_nowait()
158
-                self.connections[endpoint].send_data(payload, final=True)
159
-                data = self.connections[endpoint].bytes_to_send()
160
+                data = self.connections[endpoint].send(Message(data=payload, message_finished=True))
161
                 endpoint.send(data)
162
             except queue.Empty:
163
                 break
164
@@ -197,8 +200,8 @@ class WebSocketLayer(base.Layer):
165
                     is_server = (source_conn == self.server_conn)
166
 
167
                     frame = websockets.Frame.from_file(source_conn.rfile)
168
-                    self.connections[source_conn].receive_bytes(bytes(frame))
169
-                    source_conn.send(self.connections[source_conn].bytes_to_send())
170
+                    data = self.connections[source_conn].receive_data(bytes(frame))
171
+                    source_conn.send(data)
172
 
173
                     if close_received:
174
                         return
(-)www/mitmproxy/files/patch-setup.py (-34 lines)
Lines 1-34 Link Here
1
--- setup.py.orig	2019-12-09 13:30:10 UTC
2
+++ setup.py
3
@@ -61,24 +61,24 @@ setup(
4
     # It is not considered best practice to use install_requires to pin dependencies to specific versions.
5
     install_requires=[
6
         "blinker>=1.4",
7
-        "brotli>=0.7.0,<0.8",
8
+        "brotli>=0.7.0",
9
         "certifi>=2015.11.20.1",  # no semver here - this should always be on the last release!
10
         "click>=6.2",
11
-        "cryptography>=2.1.4,<2.4",
12
+        "cryptography>=2.1.4",
13
         "h2>=3.0.1,<4",
14
         "hyperframe>=5.1.0,<6",
15
         "kaitaistruct>=0.7,<0.9",
16
-        "ldap3>=2.5,<2.6",
17
+        "ldap3>=2.5",
18
         "passlib>=1.6.5",
19
         "pyasn1>=0.3.1,<0.5",
20
-        "pyOpenSSL>=17.5,<18.1",
21
+        "pyOpenSSL>=17.5",
22
         "pyparsing>=2.1.3",
23
         "pyperclip>=1.6.0",
24
         "ruamel.yaml>=0.13.2",
25
-        "sortedcontainers>=1.5.4,<2.1",
26
+        "sortedcontainers>=1.5.4",
27
         "tornado>=4.3,<5.2",
28
-        "urwid>=2.0.1,<2.1",
29
-        "wsproto>=0.11.0,<0.12.0",
30
+        "urwid>=2.0.1",
31
+        "wsproto>=0.13.0",
32
     ],
33
     extras_require={
34
         ':sys_platform == "win32"': [

Return to bug 250799