问题描述当我尝试使用HttpEvents的方法flow.live.change_upstream_proxy_server(address)切换上游代理时,上游代理保持不变并且不会改变。 重现该行为的步骤:使用上游和脚本启动 Mitm: mitmdump --mode upstream:182.52.74.76:34084 --ssl-insecure -s scripts/watcher.py等待上游代理失败让 watcher.py 更新上游代理当前结果:此时我们假设上游代理现在更改为103.199.84.54:8080,但是当我们更新请求时,我们可以在错误消息中看到代理仍然是相同的(182.52.74.76:34084)而不是103.199.84.54:8080:Watcher.pyfrom mitmproxy import httpfrom mitmproxy import ctximport requestsimport jsonimport typing#***** Some fetching to get new proxy from my API*****def getNewProxy() -> typing.Tuple[str, int]: id = str(getRandID()) params = { 'id': 'eq.' + id, 'select': 'proxy'} response = str(requests.get(url = url, params = params).json()[0]['proxy'])[7:].split(':') proxIP = (response[0], int(response[1])) return (proxIP)class Events: def error(self, flow: http.HTTPFlow): ctx.log.info(str(flow.server_conn.address)) pAddr = getNewProxy() ctx.log.info("Switching upstream proxy to: " + pAddr[0] + ":" + str(pAddr[1])) flow.live.change_upstream_proxy_server(pAddr)addons = [ Events()]系统信息mitmproxy --版本:$ mitmdump --versionMitmproxy: 5.2Python: 3.7.3OpenSSL: OpenSSL 1.1.1g 21 Apr 2020Platform: Linux-4.19.0-9-amd64-x86_64-with-debian-10.4感谢您的帮助,现在真的被这个问题困扰了!
添加回答
举报
0/150
提交
取消