Mitmproxy使用python加载和卸载脚本

Mitmproxy使用python加载和卸载脚本,python,concurrency,proxy,mitmproxy,libmproxy,Python,Concurrency,Proxy,Mitmproxy,Libmproxy,我正在运行Mitmproxy github中建议的代理: 我希望在不阻塞其他请求/响应的情况下处理每个请求/响应, 为此,我需要使用并发装饰器和脚本 我的问题是:如何将脚本加载和卸载到此配置中运行的代理?您可以使用并发模式加载脚本。 这里有一个关于这种用法的例子 我更喜欢在流级别实现mitmproxy逻辑。 您可以使用此代码 def handle_response(self, r): reply = f.response.reply f.response.reply =

我正在运行Mitmproxy github中建议的代理:

我希望在不阻塞其他请求/响应的情况下处理每个请求/响应, 为此,我需要使用并发装饰器和脚本


我的问题是:如何将脚本加载和卸载到此配置中运行的代理?

您可以使用并发模式加载脚本。
这里有一个关于这种用法的例子

我更喜欢在流级别实现mitmproxy逻辑。
您可以使用此代码

def handle_response(self, r):
    reply = f.response.reply
        f.response.reply = controller.DummyReply()
        if hasattr(reply, "q"):
            f.response.reply.q = reply.q
        def run(): 
            pass
        threading.Thread(target=run)

您基本上必须复制handle_concurrent_reply在中的工作方式


tnx,这对我很有帮助。我还尝试通过执行以下操作从代码中加载脚本。m、 加载脚本(脚本的路径),但它给了我一些错误。在进一步挖掘之后,我发现有人报告它是一个bug,开发人员修复了它,下面是问题的链接:
def handle_response(self, r):
    reply = f.response.reply
        f.response.reply = controller.DummyReply()
        if hasattr(reply, "q"):
            f.response.reply.q = reply.q
        def run(): 
            pass
        threading.Thread(target=run)
f = flow.FlowMaster.handle_request(self,r)
if f:
        def run():
           request.reply() #if you forget this you'll end up in a loop and never reply
threading.Thread(target=run).start()  #this will start run