mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-26 18:18:25 +00:00
Serialized data version check.
This commit is contained in:
parent
5e096c8ec9
commit
8c96264304
@ -1575,6 +1575,9 @@ class FlowReader:
|
|||||||
try:
|
try:
|
||||||
while 1:
|
while 1:
|
||||||
data = tnetstring.load(self.fo)
|
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()
|
off = self.fo.tell()
|
||||||
yield Flow._from_state(data)
|
yield Flow._from_state(data)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import Queue, time
|
import Queue, time
|
||||||
from cStringIO import StringIO
|
from cStringIO import StringIO
|
||||||
import email.utils
|
import email.utils
|
||||||
from libmproxy import filt, flow, controller, utils
|
from libmproxy import filt, flow, controller, utils, tnetstring
|
||||||
import tutils
|
import tutils
|
||||||
import libpry
|
import libpry
|
||||||
|
|
||||||
@ -494,6 +494,17 @@ class uSerialize(libpry.AutoTree):
|
|||||||
f = flow.FlowReadError("foo")
|
f = flow.FlowReadError("foo")
|
||||||
assert f.strerror == "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):
|
class uFlowMaster(libpry.AutoTree):
|
||||||
def test_load_script(self):
|
def test_load_script(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user