1
1
import asyncio
2
- import pathlib
3
2
import threading
4
3
import warnings
5
4
@@ -21,7 +20,7 @@ def __init__(self, on_running):
21
20
self .running = on_running
22
21
self .flows = []
23
22
24
- def websocket_start (self , flow ):
23
+ def tcp_start (self , flow ):
25
24
self .flows .append (flow )
26
25
27
26
def get_flows (self ):
@@ -48,7 +47,13 @@ async def run_proxy(cls):
48
47
cls .proxy_loop = loop = asyncio .get_event_loop ()
49
48
cls .proxy_stop = stop = loop .create_future ()
50
49
51
- cls .proxy_options = options = Options (mode = [cls .proxy_mode ])
50
+ cls .proxy_options = options = Options (
51
+ mode = [cls .proxy_mode ],
52
+ # Don't intercept connections, but record them.
53
+ ignore_hosts = ["^localhost:" , "^127.0.0.1:" , "^::1:" ],
54
+ # This option requires mitmproxy 11.0.0, which requires Python 3.11.
55
+ show_ignored_hosts = True ,
56
+ )
52
57
cls .proxy_master = master = Master (options )
53
58
master .addons .add (
54
59
core .Core (),
@@ -58,12 +63,6 @@ async def run_proxy(cls):
58
63
tlsconfig .TlsConfig (),
59
64
RecordFlows (on_running = cls .proxy_ready .set ),
60
65
)
61
- options .update (
62
- # Use test certificate for TLS between client and proxy.
63
- certs = [str (pathlib .Path (__file__ ).with_name ("test_localhost.pem" ))],
64
- # Disable TLS verification between proxy and upstream.
65
- ssl_insecure = True ,
66
- )
67
66
68
67
task = loop .create_task (cls .proxy_master .run ())
69
68
await stop
0 commit comments