mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-26 18:18:25 +00:00
Merge remote-tracking branch 'tekii/master'
This commit is contained in:
commit
19555bb39a
@ -418,14 +418,14 @@ def common_options(parser):
|
|||||||
group = parser.add_argument_group("Client Replay")
|
group = parser.add_argument_group("Client Replay")
|
||||||
group.add_argument(
|
group.add_argument(
|
||||||
"-c", "--client-replay",
|
"-c", "--client-replay",
|
||||||
action="store", dest="client_replay", default=None, metavar="PATH",
|
action="append", dest="client_replay", default=None, metavar="PATH",
|
||||||
help="Replay client requests from a saved file."
|
help="Replay client requests from a saved file."
|
||||||
)
|
)
|
||||||
|
|
||||||
group = parser.add_argument_group("Server Replay")
|
group = parser.add_argument_group("Server Replay")
|
||||||
group.add_argument(
|
group.add_argument(
|
||||||
"-S", "--server-replay",
|
"-S", "--server-replay",
|
||||||
action="store", dest="server_replay", default=None, metavar="PATH",
|
action="append", dest="server_replay", default=None, metavar="PATH",
|
||||||
help="Replay server responses from a saved file."
|
help="Replay server responses from a saved file."
|
||||||
)
|
)
|
||||||
group.add_argument(
|
group.add_argument(
|
||||||
|
@ -498,11 +498,13 @@ class ConsoleMaster(flow.FlowMaster):
|
|||||||
self.eventlog = not self.eventlog
|
self.eventlog = not self.eventlog
|
||||||
self.view_flowlist()
|
self.view_flowlist()
|
||||||
|
|
||||||
def _readflow(self, path):
|
def _readflow(self, paths):
|
||||||
path = os.path.expanduser(path)
|
|
||||||
try:
|
try:
|
||||||
f = file(path, "rb")
|
flows = []
|
||||||
flows = list(flow.FlowReader(f).stream())
|
for path in paths:
|
||||||
|
path = os.path.expanduser(path)
|
||||||
|
with file(path, "rb") as f:
|
||||||
|
flows.extend(list(flow.FlowReader(f).stream()))
|
||||||
except (IOError, flow.FlowReadError), v:
|
except (IOError, flow.FlowReadError), v:
|
||||||
return True, v.strerror
|
return True, v.strerror
|
||||||
return False, flows
|
return False, flows
|
||||||
|
@ -143,11 +143,13 @@ class DumpMaster(flow.FlowMaster):
|
|||||||
if self.o.app:
|
if self.o.app:
|
||||||
self.start_app(self.o.app_host, self.o.app_port)
|
self.start_app(self.o.app_host, self.o.app_port)
|
||||||
|
|
||||||
def _readflow(self, path):
|
def _readflow(self, paths):
|
||||||
path = os.path.expanduser(path)
|
|
||||||
try:
|
try:
|
||||||
f = file(path, "rb")
|
flows = []
|
||||||
flows = list(flow.FlowReader(f).stream())
|
for path in paths:
|
||||||
|
path = os.path.expanduser(path)
|
||||||
|
with file(path, "rb") as f:
|
||||||
|
flows.extend(list(flow.FlowReader(f).stream()))
|
||||||
except (IOError, flow.FlowReadError), v:
|
except (IOError, flow.FlowReadError), v:
|
||||||
raise DumpError(v.strerror)
|
raise DumpError(v.strerror)
|
||||||
return flows
|
return flows
|
||||||
|
@ -82,17 +82,17 @@ class TestDumpMaster:
|
|||||||
p = os.path.join(t, "rep")
|
p = os.path.join(t, "rep")
|
||||||
self._flowfile(p)
|
self._flowfile(p)
|
||||||
|
|
||||||
o = dump.Options(server_replay=p, kill=True)
|
o = dump.Options(server_replay=[p], kill=True)
|
||||||
m = dump.DumpMaster(None, o, outfile=cs)
|
m = dump.DumpMaster(None, o, outfile=cs)
|
||||||
|
|
||||||
self._cycle(m, "content")
|
self._cycle(m, "content")
|
||||||
self._cycle(m, "content")
|
self._cycle(m, "content")
|
||||||
|
|
||||||
o = dump.Options(server_replay=p, kill=False)
|
o = dump.Options(server_replay=[p], kill=False)
|
||||||
m = dump.DumpMaster(None, o, outfile=cs)
|
m = dump.DumpMaster(None, o, outfile=cs)
|
||||||
self._cycle(m, "nonexistent")
|
self._cycle(m, "nonexistent")
|
||||||
|
|
||||||
o = dump.Options(client_replay=p, kill=False)
|
o = dump.Options(client_replay=[p], kill=False)
|
||||||
m = dump.DumpMaster(None, o, outfile=cs)
|
m = dump.DumpMaster(None, o, outfile=cs)
|
||||||
|
|
||||||
def test_read(self):
|
def test_read(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user