aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2017-08-31 15:22:07 +0200
committerGitHub <noreply@github.com>2017-08-31 15:22:07 +0200
commit7bd930693e809af7c0fc89aa0edb28975f30e44a (patch)
tree94a1363e572d5b2564fab9e3ab784ebfb42975ef
parent9942f782177b83d57da1d579bd930209e99002d3 (diff)
parenta98dd1642cb7a6357f4502882d4e11d48cbf7e1f (diff)
downloadmitmproxy-7bd930693e809af7c0fc89aa0edb28975f30e44a.tar.gz
mitmproxy-7bd930693e809af7c0fc89aa0edb28975f30e44a.tar.bz2
mitmproxy-7bd930693e809af7c0fc89aa0edb28975f30e44a.zip
Merge pull request #2551 from MatthewShao/static-viewer
[web] Add settings.json to Static viewer
-rw-r--r--mitmproxy/tools/web/static_viewer.py6
-rw-r--r--test/mitmproxy/tools/web/test_static_viewer.py6
-rw-r--r--web/src/js/backends/static.js1
3 files changed, 13 insertions, 0 deletions
diff --git a/mitmproxy/tools/web/static_viewer.py b/mitmproxy/tools/web/static_viewer.py
index 416c2539..03156638 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/test/mitmproxy/tools/web/test_static_viewer.py b/test/mitmproxy/tools/web/test_static_viewer.py
index 5b7ddfff..cfe6cd7f 100644
--- a/test/mitmproxy/tools/web/test_static_viewer.py
+++ b/test/mitmproxy/tools/web/test_static_viewer.py
@@ -26,6 +26,12 @@ def test_save_filter_help(tmpdir):
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):
flows = [tflow.tflow(req=True, resp=None), tflow.tflow(req=True, resp=True)]
static_viewer.save_flows(tmpdir, flows)
diff --git a/web/src/js/backends/static.js b/web/src/js/backends/static.js
index d2c8d3fe..1da222ce 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.
}