You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using mitmproxy in WireGuard mode for iOS/Android devices. Sometimes, DNS flows are recorded with the request timestamp being later than the response, which causes the console to freeze when these flows are displayed.
Upon encountering this issue, manually rendering the screen using a debugger revealed the following error:
Traceback (most recent call last):
File "c:\Users\x\Documents\code\y\.venv\lib\site-packages\mitmproxy\tools\console\common.py", line 352, in format_duration
99 - 100 * min(math.log2(1 + 1000 * duration) / 12, 0.99)
ValueError: math domain error
The problem seems to be from a negative duration value calculated as f.response.timestamp - f.request.timestamp. I suspect this causes the faux_idle_callback() in urwid/main_loop.py not to be called anymore, stopping the screen rendering.
Although format_duration is invoked from various layers, the issue only occurs with DNS flows in my environment. Adjusting a single line in the format_dns_flow() function within mitmproxy\tools\console\common.py resolved the issue.
- if duration:
+ if duration and duration > 0:
The UI freezing during exceptions made it difficult to pinpoint the problem. It would be helpful if there was a way to output errors to a file.
Problem Description
I'm using mitmproxy in WireGuard mode for iOS/Android devices. Sometimes, DNS flows are recorded with the request timestamp being later than the response, which causes the console to freeze when these flows are displayed.
Upon encountering this issue, manually rendering the screen using a debugger revealed the following error:
The problem seems to be from a negative
duration
value calculated asf.response.timestamp - f.request.timestamp
. I suspect this causes the faux_idle_callback() in urwid/main_loop.py not to be called anymore, stopping the screen rendering.Although format_duration is invoked from various layers, the issue only occurs with DNS flows in my environment. Adjusting a single line in the
format_dns_flow()
function withinmitmproxy\tools\console\common.py
resolved the issue.The UI freezing during exceptions made it difficult to pinpoint the problem. It would be helpful if there was a way to output errors to a file.
Steps to Reproduce:
invalid_timestamp_dns.flow
in mitmproxy.invalid_timestamp_dns.zip
System Info
Mitmproxy: 10.2.2
Python: 3.11.7
OpenSSL: OpenSSL 3.1.4 24 Oct 2023
Platform: Windows-10-10.0.22631-SP0
WireGuard for iOS: 1.0.16 (27)
The text was updated successfully, but these errors were encountered: