mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-26 18:18:25 +00:00
Merge pull request #2551 from MatthewShao/static-viewer
[web] Add settings.json to Static viewer
This commit is contained in:
commit
7bd930693e
@ -9,6 +9,7 @@ from mitmproxy import contentviews
|
|||||||
from mitmproxy import ctx
|
from mitmproxy import ctx
|
||||||
from mitmproxy import flowfilter
|
from mitmproxy import flowfilter
|
||||||
from mitmproxy import io, flow
|
from mitmproxy import io, flow
|
||||||
|
from mitmproxy import version
|
||||||
from mitmproxy.tools.web.app import flow_to_json
|
from mitmproxy.tools.web.app import flow_to_json
|
||||||
|
|
||||||
web_dir = pathlib.Path(__file__).absolute().parent
|
web_dir = pathlib.Path(__file__).absolute().parent
|
||||||
@ -33,6 +34,11 @@ def save_filter_help(path: pathlib.Path) -> None:
|
|||||||
json.dump(dict(commands=flowfilter.help), f)
|
json.dump(dict(commands=flowfilter.help), f)
|
||||||
|
|
||||||
|
|
||||||
|
def save_settings(path: pathlib.Path) -> None:
|
||||||
|
with open(str(path / 'settings.json'), 'w') as f:
|
||||||
|
json.dump(dict(version=version.VERSION), f)
|
||||||
|
|
||||||
|
|
||||||
def save_flows(path: pathlib.Path, flows: typing.Iterable[flow.Flow]) -> None:
|
def save_flows(path: pathlib.Path, flows: typing.Iterable[flow.Flow]) -> None:
|
||||||
with open(str(path / 'flows.json'), 'w') as f:
|
with open(str(path / 'flows.json'), 'w') as f:
|
||||||
json.dump(
|
json.dump(
|
||||||
|
@ -26,6 +26,12 @@ def test_save_filter_help(tmpdir):
|
|||||||
assert f.read() == json.dumps(dict(commands=flowfilter.help))
|
assert f.read() == json.dumps(dict(commands=flowfilter.help))
|
||||||
|
|
||||||
|
|
||||||
|
def test_save_settings(tmpdir):
|
||||||
|
static_viewer.save_settings(tmpdir)
|
||||||
|
f = tmpdir.join('/settings.json')
|
||||||
|
assert f.check(file=1)
|
||||||
|
|
||||||
|
|
||||||
def test_save_flows(tmpdir):
|
def test_save_flows(tmpdir):
|
||||||
flows = [tflow.tflow(req=True, resp=None), tflow.tflow(req=True, resp=True)]
|
flows = [tflow.tflow(req=True, resp=None), tflow.tflow(req=True, resp=True)]
|
||||||
static_viewer.save_flows(tmpdir, flows)
|
static_viewer.save_flows(tmpdir, flows)
|
||||||
|
@ -12,6 +12,7 @@ export default class StaticBackend {
|
|||||||
|
|
||||||
onOpen() {
|
onOpen() {
|
||||||
this.fetchData("flows")
|
this.fetchData("flows")
|
||||||
|
this.fetchData("settings")
|
||||||
// this.fetchData("events") # TODO: Add events log to static viewer.
|
// this.fetchData("events") # TODO: Add events log to static viewer.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user