mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-30 03:14:22 +00:00
24cf8da27e
The primary motivation here (and for all the other moving around) is to present a clean "front of house" to library users, and to migrate primary objects to the top of the module hierarchy.
60 lines
1.2 KiB
Python
60 lines
1.2 KiB
Python
from mitmproxy import controller
|
|
from mitmproxy import http
|
|
from mitmproxy import tcp
|
|
|
|
Events = frozenset([
|
|
"clientconnect",
|
|
"clientdisconnect",
|
|
"serverconnect",
|
|
"serverdisconnect",
|
|
|
|
"tcp_start",
|
|
"tcp_message",
|
|
"tcp_error",
|
|
"tcp_end",
|
|
|
|
"request",
|
|
"requestheaders",
|
|
"response",
|
|
"responseheaders",
|
|
"error",
|
|
|
|
"intercept",
|
|
"resume",
|
|
|
|
"websocket_handshake",
|
|
|
|
"next_layer",
|
|
|
|
"configure",
|
|
"done",
|
|
"log",
|
|
"start",
|
|
"tick",
|
|
])
|
|
|
|
|
|
def event_sequence(f):
|
|
if isinstance(f, http.HTTPFlow):
|
|
if f.request:
|
|
yield "requestheaders", f
|
|
yield "request", f
|
|
if f.response:
|
|
yield "responseheaders", f
|
|
yield "response", f
|
|
if f.error:
|
|
yield "error", f
|
|
elif isinstance(f, tcp.TCPFlow):
|
|
messages = f.messages
|
|
f.messages = []
|
|
f.reply = controller.DummyReply()
|
|
yield "tcp_start", f
|
|
while messages:
|
|
f.messages.append(messages.pop(0))
|
|
yield "tcp_message", f
|
|
if f.error:
|
|
yield "tcp_error", f
|
|
yield "tcp_end", f
|
|
else:
|
|
raise NotImplementedError
|