我運行一個代理腳本,在Mitmproxy github上examples建議:Mitmproxy裝載和卸載與Python
from libmproxy import proxy, flow
class MitmProxy(flow.FlowMaster):
def run(self):
try:
flow.FlowMaster.run(self)
except KeyboardInterrupt:
self.shutdown()
def handle_request(self, r):
f = flow.FlowMaster.handle_request(self, r)
if f:
r.reply()
return f
def handle_response(self, r):
f = flow.FlowMaster.handle_response(self, r)
if f:
r.reply()
return f
config = proxy.ProxyConfig(
cacert = os.path.expanduser("~/.ssl/mitmproxy.pem")
)
state = flow.State()
server = proxy.ProxyServer(config, 8083)
m = MitmProxy(server, state)
try:
m.run()
except Exception, e:
print e.message
m.shutdown()
我想要處理不阻塞他人, 的,我需要每個請求/響應使用併發修飾器和腳本
我的問題是:我如何加載和卸載腳本到在此配置中運行的代理?
TNX工作,幫助我很多。我也嘗試從代碼中加載腳本。 m.load_script(腳本的路徑),但它給了我一些錯誤。進一步挖掘後,我發現有人報告它是一個錯誤,而開發人員修復它,這裏是問題的鏈接:[https://github.com/mitmproxy/mitmproxy/issues/267](https://github。 COM/mitmproxy/mitmproxy /問題/ 267) – Urban48