Moving to mitmproxy 3 as a module


I’m using mitmporxy module in my project just like in example from mitmproxy 2.x. So in short it was like this (in my case I start a thread and I communicate with another process and send some XML files that I need to check):

class MyMaster(master.Master):
    def run(self):
        except KeyboardInterrupt:
    def response(self, f):

opts = options.Options(cadir="~/.mitmproxy/")
config = ProxyConfig(opts)
server = ProxyServer(config)
m = MyMaster(opts, server)

For the version 3 there is no example and reading the docs and checking the source won’t give me a clue how to put response function.

Do anyone have such for v3 prepared or some ideas?


subclassing master.Master is deprecated for quite a while now. :wink: You should be able to achieve your task by writing a mitmproxy addon, see here:

ok… But I need to make it as a class in the same file (so I can provide parameters - multiprocess queue). I have tried but until now - without luck :frowning:

I’m getting only the running and done events to happen. How to make it properly to get the response event working ?