Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mitmproxy下载后,本地可以直接通过命令打开,但是lyrebird一直启动不了代理 #742

Open
xudongming1998 opened this issue Feb 23, 2023 · 11 comments
Labels
bug Something isn't working

Comments

@xudongming1998
Copy link

日志:
2023-02-23 10:52:09,035 /Users/xudongming/code_res/lyrebird-2.12.0/lyrebird/mitm/proxy_server.py:25
ERROR Start mitmdump failed.
Please check your mitmdump file ~/.lyrebird/bin/mitmdump
2023-02-23 10:52:09,038 /Users/xudongming/code_res/lyrebird-2.12.0/lyrebird/event.py:168

Mac平台,使用download_mitmproxy()方法下载的mitmproxy

@zhaoye
Copy link
Member

zhaoye commented Feb 24, 2023

有几个问题啊:
1
直接使用

~/.lyrebird/bin/mitmdump

是可以启动的吗?

2
download_mitmproxy()方法具体是哪个呢

@xudongming1998

@xudongming1998
Copy link
Author

image

image

image

@xudongming1998
Copy link
Author

您好,这个我启动的时候,前面一直都在请求http://127.0.0.1:9090/api/status,然后每次返回都在报错,最后超时后提示ERROR Start mitmdump failed.

@xudongming1998
Copy link
Author

@zhaoye

@zhaoye
Copy link
Member

zhaoye commented Feb 28, 2023

您好,这个我启动的时候,前面一直都在请求http://127.0.0.1:9090/api/status,然后每次返回都在报错,最后超时后提示ERROR Start mitmdump failed.

是这样的,现在我想排查一下您遇到的是什么问题。
我需要先检查你的mitmdump是不是可用的,所以才会询问是否可以手动启动 ~/.lyrebird/bin/mitmdump

或者如果你不方便执行它的话,可以尝试以下操作:

  1. 删除 ~/.lyrebird/bin/mitmdump
  2. 自已通过brew安装mitmproxy。 brew install mitmproxy
  3. 重新启动lyrebird

@xudongming1998

@EnergyEigenfunction
Copy link

我也遇到了同样的问题,可以手动启动 ~/.lyrebird/bin/mitmdump,但还是报错
ERROR Start mitmdump failed.
Please check your mitmdump file /usr/local/bin/mitmdump
删除后自己安装重启,还是如此

@iwakura-lain
Copy link

iwakura-lain commented Mar 5, 2023

@zhaoye 大佬,我在本地debug了一下,发现是在轮询 /api/status 接口时 ProxyHandler 中命中条件走了 DuplicateRequest 的 handle,导致 retcode 为 901 非 200,wait_for_mitm_start 超过次数后返回 false 报错

is_mitm_start = self.wait_for_mitm_start(config, logger)
if is_mitm_start:
    self.publish_init_status(queue, 'READY')
    logger.log(60, f'HTTP proxy server start on {proxy_port}')
else:
    self.publish_init_status(queue, 'ERROR')
    self.show_mitmdump_start_timeout_help(mitmdump_path, logger)

目前解决方法是将

elif parsed_url.hostname in ['localhost', '127.0.0.1'] and parsed_url.port == application.config["mock.port"] :
    DuplicateRequest().handle(handler_context)
    return

改为

elif parsed_url.hostname in ['localhost', '127.0.0.1'] and parsed_url.port == application.config["mock.port"] and parsed_url.path in ['/api/status']:
    handler_context.is_proxiable = False
    return
elif parsed_url.hostname in ['localhost', '127.0.0.1'] and parsed_url.port == application.config["mock.port"] :
    DuplicateRequest().handle(handler_context)
    return

没有细看框架,不知道这样写是否有什么问题,同时想知道对本地回环做限制是为了什么?

@zhaoye zhaoye added the bug Something isn't working label Apr 3, 2023
@zhaoye
Copy link
Member

zhaoye commented Apr 3, 2023

@zhaoye 大佬,我在本地debug了一下,发现是在轮询 /api/status 接口时 ProxyHandler 中命中条件走了 DuplicateRequest 的 handle,导致 retcode 为 901 非 200,wait_for_mitm_start 超过次数后返回 false 报错

is_mitm_start = self.wait_for_mitm_start(config, logger)
if is_mitm_start:
    self.publish_init_status(queue, 'READY')
    logger.log(60, f'HTTP proxy server start on {proxy_port}')
else:
    self.publish_init_status(queue, 'ERROR')
    self.show_mitmdump_start_timeout_help(mitmdump_path, logger)

目前解决方法是将

elif parsed_url.hostname in ['localhost', '127.0.0.1'] and parsed_url.port == application.config["mock.port"] :
    DuplicateRequest().handle(handler_context)
    return

改为

elif parsed_url.hostname in ['localhost', '127.0.0.1'] and parsed_url.port == application.config["mock.port"] and parsed_url.path in ['/api/status']:
    handler_context.is_proxiable = False
    return
elif parsed_url.hostname in ['localhost', '127.0.0.1'] and parsed_url.port == application.config["mock.port"] :
    DuplicateRequest().handle(handler_context)
    return

没有细看框架,不知道这样写是否有什么问题,同时想知道对本地回环做限制是为了什么?

收到。 十分感谢。我们尽快看一下

@zhaoye
Copy link
Member

zhaoye commented Apr 3, 2023

我也遇到了同样的问题,可以手动启动 ~/.lyrebird/bin/mitmdump,但还是报错 ERROR Start mitmdump failed. Please check your mitmdump file /usr/local/bin/mitmdump 删除后自己安装重启,还是如此

收到。我们尽快排查

@Kingson
Copy link

Kingson commented Jul 25, 2024

image
这个问题还存在

@HeartIsBeat
Copy link

同上,问题还在
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants