From 0c6663d0d5335e666598807c2e5d8f105803eac0 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Thu, 9 Mar 2017 13:52:58 +1300 Subject: Enable custom options for addons - Add an options parameter to the start() event. This is to be used by addons on startup to add custom options. - Add a running() event that is called once the proxy is up and running. - With the new paradigm we can't log during master __init__, so add a tiny termstatus addon to print proxy status to terminal once we're running. --- examples/simple/custom_option.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 examples/simple/custom_option.py (limited to 'examples/simple/custom_option.py') diff --git a/examples/simple/custom_option.py b/examples/simple/custom_option.py new file mode 100644 index 00000000..e9c34850 --- /dev/null +++ b/examples/simple/custom_option.py @@ -0,0 +1,10 @@ +from mitmproxy import ctx + + +def start(options): + ctx.log.info("Registering option 'custom'") + options.add_option("custom", str, "default", "A custom option") + + +def configure(options, updated): + ctx.log.info("custom option value: %s" % options.custom) -- cgit v1.2.3 From c24f7d8e12ee2002678adb695be513a7e593e198 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Sun, 12 Mar 2017 11:18:16 +1300 Subject: Optmanager: handle unknown options in value sets --- examples/simple/custom_option.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples/simple/custom_option.py') diff --git a/examples/simple/custom_option.py b/examples/simple/custom_option.py index e9c34850..a8b4e778 100644 --- a/examples/simple/custom_option.py +++ b/examples/simple/custom_option.py @@ -3,7 +3,7 @@ from mitmproxy import ctx def start(options): ctx.log.info("Registering option 'custom'") - options.add_option("custom", str, "default", "A custom option") + options.add_option("custom", bool, False, "A custom option") def configure(options, updated): -- cgit v1.2.3 From b745428b5c4e89753a83fe228cb5478327eeb540 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Tue, 14 Mar 2017 09:22:44 +1300 Subject: Enable custom options in config files We also now ignore unknown options in config files by default, and print a warning if verbosity is incremented. --- examples/simple/custom_option.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'examples/simple/custom_option.py') diff --git a/examples/simple/custom_option.py b/examples/simple/custom_option.py index a8b4e778..324d27e7 100644 --- a/examples/simple/custom_option.py +++ b/examples/simple/custom_option.py @@ -7,4 +7,5 @@ def start(options): def configure(options, updated): - ctx.log.info("custom option value: %s" % options.custom) + if "custom" in updated: + ctx.log.info("custom option value: %s" % options.custom) -- cgit v1.2.3