mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
Serialized data version check.
This commit is contained in:
parent
5e096c8ec9
commit
8c96264304
@ -1575,6 +1575,9 @@ class FlowReader:
|
||||
try:
|
||||
while 1:
|
||||
data = tnetstring.load(self.fo)
|
||||
if tuple(data["version"]) != version.IVERSION:
|
||||
v = ".".join(str(i) for i in data["version"])
|
||||
raise FlowReadError("Incompatible serialized data version: %s"%v)
|
||||
off = self.fo.tell()
|
||||
yield Flow._from_state(data)
|
||||
except ValueError:
|
||||
|
@ -1,7 +1,7 @@
|
||||
import Queue, time
|
||||
from cStringIO import StringIO
|
||||
import email.utils
|
||||
from libmproxy import filt, flow, controller, utils
|
||||
from libmproxy import filt, flow, controller, utils, tnetstring
|
||||
import tutils
|
||||
import libpry
|
||||
|
||||
@ -494,6 +494,17 @@ class uSerialize(libpry.AutoTree):
|
||||
f = flow.FlowReadError("foo")
|
||||
assert f.strerror == "foo"
|
||||
|
||||
def test_versioncheck(self):
|
||||
f = tutils.tflow()
|
||||
d = f._get_state()
|
||||
d["version"] = (0, 0)
|
||||
sio = StringIO()
|
||||
tnetstring.dump(d, sio)
|
||||
sio.seek(0)
|
||||
|
||||
r = flow.FlowReader(sio)
|
||||
libpry.raises("version", list, r.stream())
|
||||
|
||||
|
||||
class uFlowMaster(libpry.AutoTree):
|
||||
def test_load_script(self):
|
||||
|
Loading…
Reference in New Issue
Block a user