Repository navigation
Closed
Labels
kind/triageUnclassified issues
Description
Problem Description
Hi there Mitmproxy community.
Ever since I upgraded to mitmproxy 8.0.0 from 7.0.4, I'm unable to record network properly. Not only do I see the file size is much smaller that it should, but trying to open the file results in an exception.
Unaware if this issue has been resolved in the latest release of mitmproxy. I know the connections.py file has had issues since the major upgrade , but I'm unable to update to 8.1.0 because I have a dependency on python 3.8.
Steps to reproduce the behavior:
- Record a file in upstream mode
Ex:mitmdump -k -v --mode upstream:proxy.net:3000 --listen-host $IP -p $PORT -w recording.bin - Open the recording
Ex:mitmdump -k -n -r
This results in the following traceback
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/mitmproxy/addons/readfile.py", line 71, in doread
await self.load_flows_from_path(ctx.options.rfile)
File "/usr/local/lib/python3.8/site-packages/mitmproxy/addons/readfile.py", line 94, in load_flows_from_path
return await super().load_flows_from_path(path)
File "/usr/local/lib/python3.8/site-packages/mitmproxy/addons/readfile.py", line 63, in load_flows_from_path
return await self.load_flows(f)
File "/usr/local/lib/python3.8/site-packages/mitmproxy/addons/readfile.py", line 45, in load_flows
for flow in freader.stream():
File "/usr/local/lib/python3.8/site-packages/mitmproxy/io/io.py", line 48, in stream
yield FLOW_TYPES[mdata["type"]].from_state(mdata)
File "/usr/local/lib/python3.8/site-packages/mitmproxy/flow.py", line 165, in from_state
f.set_state(state)
File "/usr/local/lib/python3.8/site-packages/mitmproxy/flow.py", line 160, in set_state
super().set_state(state)
File "/usr/local/lib/python3.8/site-packages/mitmproxy/stateobject.py", line 47, in set_state
setattr(self, attr, make_object(cls, val))
File "/usr/local/lib/python3.8/site-packages/mitmproxy/stateobject.py", line 94, in make_object
return _process(typeinfo, val, True)
File "/usr/local/lib/python3.8/site-packages/mitmproxy/stateobject.py", line 56, in _process
return typeinfo.from_state(val)
File "/usr/local/lib/python3.8/site-packages/mitmproxy/connection.py", line 331, in from_state
server.set_state(state)
File "/usr/local/lib/python3.8/site-packages/mitmproxy/connection.py", line 353, in set_state
self.via = state["via2"]
File "/usr/local/lib/python3.8/site-packages/mitmproxy/connection.py", line 299, in __setattr__
raise RuntimeError(f"Cannot change server.{name} on open connection.")
RuntimeError: Cannot change server.via on open connection.
System Information
Paste the output of "mitmproxy --version" here.
mitmproxy --version
Mitmproxy: 8.0.0
Python: 3.8.11
OpenSSL: OpenSSL 1.1.1n 15 Mar 2022
Platform: Linux
Metadata
Metadata
Assignees
Labels
kind/triageUnclassified issues
Activity
nicovama commentedon Aug 16, 2022
@mhils Could you guide me? I'd like to contribute to a solution but I don't fully understand what is causing the recording to be corrupted (Which causes the -r replay to throw the RunTimeError.)
When I record something (-w) on mitmproxy==8.0.0 Upstream mode and replay it on 7.0.4 (-n -r), The error message is
"File Corrupted"Prinzhorn commentedon Aug 17, 2022
https://github.com/mitmproxy/mitmproxy/search?q=Cannot+change+server.via+on+open+connection.&type=issues
I'm pretty confident this is a duplicate of #5241 and they seem to work on a solution
Prinzhorn commentedon Aug 17, 2022
This is expected behavior as the recordings are not backwards compatible (not necessarily between mitmproxy versions, but when the format changes). It should say something like "please update mitmproxy" when opening with 7.0.4, right?
mhils commentedon Aug 17, 2022
Related to #5241, but different trigger. Let's keep it open. :)
@nicovama: In short, the dumpfile is not corrupt, but upon reading we inadvertedly trigger this check which is supposed to catch bugs in addons modifying live flows:
mitmproxy/mitmproxy/connection.py
Lines 360 to 361 in 1560892
nicovama commentedon Aug 17, 2022
Thank you @mhils.
Another unexpected change is that the dump file size changed drastically. In 7.0.4 it was around 5MB, while the same in 8.0.0 was only 1MB.
I'm going to try to look for a solution.
Thank you
nicovama commentedon Aug 17, 2022
Thanks for the reply and I guess that makes sense. That is not the error message I see. It just says "File corrupted"
don't persist connection state, fix mitmproxy#5524