From 0647d622a4edeb3ce258736031ccb8052eadc271 Mon Sep 17 00:00:00 2001 From: Matthew Shao Date: Wed, 30 Aug 2017 21:13:51 +0800 Subject: [PATCH] [web] Add settings.json to static viewer, so it can display version. --- mitmproxy/tools/web/static_viewer.py | 6 ++++++ web/src/js/backends/static.js | 1 + 2 files changed, 7 insertions(+) diff --git a/mitmproxy/tools/web/static_viewer.py b/mitmproxy/tools/web/static_viewer.py index 416c2539e..03156638f 100644 --- a/mitmproxy/tools/web/static_viewer.py +++ b/mitmproxy/tools/web/static_viewer.py @@ -9,6 +9,7 @@ from mitmproxy import contentviews from mitmproxy import ctx from mitmproxy import flowfilter from mitmproxy import io, flow +from mitmproxy import version from mitmproxy.tools.web.app import flow_to_json 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) +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: with open(str(path / 'flows.json'), 'w') as f: json.dump( diff --git a/web/src/js/backends/static.js b/web/src/js/backends/static.js index d2c8d3fe3..1da222ce7 100644 --- a/web/src/js/backends/static.js +++ b/web/src/js/backends/static.js @@ -12,6 +12,7 @@ export default class StaticBackend { onOpen() { this.fetchData("flows") + this.fetchData("settings") // this.fetchData("events") # TODO: Add events log to static viewer. }