Amalgamate all the Options objects
This commit is contained in:
parent
d742d4fb8c
commit
a617e3b5f7
|
@ -82,7 +82,29 @@ class Options(optmanager.OptManager):
|
|||
ssl_insecure: bool = False,
|
||||
ssl_verify_upstream_trusted_cadir: Optional[str] = None,
|
||||
ssl_verify_upstream_trusted_ca: Optional[str] = None,
|
||||
tcp_hosts: Sequence[str] = []
|
||||
tcp_hosts: Sequence[str] = [],
|
||||
|
||||
intercept: Optional[str] = None,
|
||||
|
||||
# Console options
|
||||
eventlog: bool = False,
|
||||
focus_follow: bool = False,
|
||||
filter: Optional[str] = None,
|
||||
palette: Optional[str] = "dark",
|
||||
palette_transparent: bool = False,
|
||||
no_mouse: bool = False,
|
||||
order: Optional[str] = None,
|
||||
order_reversed: bool = False,
|
||||
|
||||
# Web options
|
||||
open_browser: bool = True,
|
||||
wdebug: bool = False,
|
||||
wport: int = 8081,
|
||||
wiface: str = "127.0.0.1",
|
||||
|
||||
# Dump options
|
||||
filtstr: Optional[str] = None,
|
||||
flow_detail: int = 1
|
||||
) -> None:
|
||||
# We could replace all assignments with clever metaprogramming,
|
||||
# but type hints are a much more valueable asset.
|
||||
|
@ -146,4 +168,27 @@ class Options(optmanager.OptManager):
|
|||
self.ssl_verify_upstream_trusted_cadir = ssl_verify_upstream_trusted_cadir
|
||||
self.ssl_verify_upstream_trusted_ca = ssl_verify_upstream_trusted_ca
|
||||
self.tcp_hosts = tcp_hosts
|
||||
|
||||
self.intercept = intercept
|
||||
|
||||
# Console options
|
||||
self.eventlog = eventlog
|
||||
self.focus_follow = focus_follow
|
||||
self.filter = filter
|
||||
self.palette = palette
|
||||
self.palette_transparent = palette_transparent
|
||||
self.no_mouse = no_mouse
|
||||
self.order = order
|
||||
self.order_reversed = order_reversed
|
||||
|
||||
# Web options
|
||||
self.open_browser = open_browser
|
||||
self.wdebug = wdebug
|
||||
self.wport = wport
|
||||
self.wiface = wiface
|
||||
|
||||
# Dump options
|
||||
self.filtstr = filtstr
|
||||
self.flow_detail = flow_detail
|
||||
|
||||
super().__init__()
|
||||
|
|
|
@ -11,7 +11,6 @@ import tempfile
|
|||
import traceback
|
||||
|
||||
import urwid
|
||||
from typing import Optional
|
||||
|
||||
from mitmproxy import addons
|
||||
from mitmproxy import controller
|
||||
|
@ -39,33 +38,6 @@ from mitmproxy.net import tcp
|
|||
EVENTLOG_SIZE = 500
|
||||
|
||||
|
||||
class Options(mitmproxy.options.Options):
|
||||
def __init__(
|
||||
self,
|
||||
*, # all args are keyword-only.
|
||||
eventlog: bool = False,
|
||||
focus_follow: bool = False,
|
||||
intercept: Optional[str] = None,
|
||||
filter: Optional[str] = None,
|
||||
palette: Optional[str] = palettes.DEFAULT,
|
||||
palette_transparent: bool = False,
|
||||
no_mouse: bool = False,
|
||||
order: Optional[str] = None,
|
||||
order_reversed: bool = False,
|
||||
**kwargs
|
||||
):
|
||||
self.eventlog = eventlog
|
||||
self.focus_follow = focus_follow
|
||||
self.intercept = intercept
|
||||
self.filter = filter
|
||||
self.palette = palette
|
||||
self.palette_transparent = palette_transparent
|
||||
self.no_mouse = no_mouse
|
||||
self.order = order
|
||||
self.order_reversed = order_reversed
|
||||
super().__init__(**kwargs)
|
||||
|
||||
|
||||
class ConsoleMaster(master.Master):
|
||||
palette = []
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import signal # noqa
|
|||
|
||||
from mitmproxy.tools import cmdline # noqa
|
||||
from mitmproxy import exceptions # noqa
|
||||
from mitmproxy import options # noqa
|
||||
from mitmproxy.proxy import config # noqa
|
||||
from mitmproxy.proxy import server # noqa
|
||||
from mitmproxy.utils import version_check # noqa
|
||||
|
@ -71,7 +72,7 @@ def mitmproxy(args=None): # pragma: no cover
|
|||
args = parser.parse_args(args)
|
||||
|
||||
try:
|
||||
console_options = console.master.Options()
|
||||
console_options = options.Options()
|
||||
console_options.load_paths(args.conf)
|
||||
console_options.update(**notnone(cmdline.get_common_options(args)))
|
||||
console_options.update(
|
||||
|
@ -110,7 +111,7 @@ def mitmdump(args=None): # pragma: no cover
|
|||
|
||||
master = None
|
||||
try:
|
||||
dump_options = dump.Options()
|
||||
dump_options = options.Options()
|
||||
dump_options.load_paths(args.conf)
|
||||
dump_options.update(**notnone(cmdline.get_common_options(args)))
|
||||
dump_options.update(
|
||||
|
@ -149,7 +150,7 @@ def mitmweb(args=None): # pragma: no cover
|
|||
args = parser.parse_args(args)
|
||||
|
||||
try:
|
||||
web_options = web.master.Options()
|
||||
web_options = options.Options()
|
||||
web_options.load_paths(args.conf)
|
||||
web_options.update(**notnone(cmdline.get_common_options(args)))
|
||||
web_options.update(
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import webbrowser
|
||||
from typing import Optional
|
||||
|
||||
import tornado.httpserver
|
||||
import tornado.ioloop
|
||||
|
@ -7,7 +6,6 @@ from mitmproxy import addons
|
|||
from mitmproxy import exceptions
|
||||
from mitmproxy import log
|
||||
from mitmproxy import master
|
||||
from mitmproxy import options
|
||||
from mitmproxy.addons import eventstore
|
||||
from mitmproxy.addons import intercept
|
||||
from mitmproxy.addons import termlog
|
||||
|
@ -15,25 +13,6 @@ from mitmproxy.addons import view
|
|||
from mitmproxy.tools.web import app
|
||||
|
||||
|
||||
class Options(options.Options):
|
||||
def __init__(
|
||||
self,
|
||||
*, # all args are keyword-only.
|
||||
intercept: Optional[str] = None,
|
||||
open_browser: bool = True,
|
||||
wdebug: bool = False,
|
||||
wport: int = 8081,
|
||||
wiface: str = "127.0.0.1",
|
||||
**kwargs
|
||||
) -> None:
|
||||
self.intercept = intercept
|
||||
self.open_browser = open_browser
|
||||
self.wdebug = wdebug
|
||||
self.wport = wport
|
||||
self.wiface = wiface
|
||||
super().__init__(**kwargs)
|
||||
|
||||
|
||||
class WebMaster(master.Master):
|
||||
def __init__(self, options, server):
|
||||
super().__init__(options, server)
|
||||
|
|
|
@ -2,6 +2,7 @@ from mitmproxy.test import tflow
|
|||
import mitmproxy.test.tutils
|
||||
from mitmproxy.tools import console
|
||||
from mitmproxy import proxy
|
||||
from mitmproxy import options
|
||||
from mitmproxy.tools.console import common
|
||||
|
||||
from .. import mastertest
|
||||
|
@ -20,14 +21,14 @@ def test_format_keyvals():
|
|||
|
||||
|
||||
def test_options():
|
||||
assert console.master.Options(replay_kill_extra=True)
|
||||
assert options.Options(replay_kill_extra=True)
|
||||
|
||||
|
||||
class TestMaster(mastertest.MasterTest):
|
||||
def mkmaster(self, **options):
|
||||
if "verbosity" not in options:
|
||||
options["verbosity"] = 0
|
||||
o = console.master.Options(**options)
|
||||
def mkmaster(self, **opts):
|
||||
if "verbosity" not in opts:
|
||||
opts["verbosity"] = 0
|
||||
o = options.Options(**opts)
|
||||
return console.master.ConsoleMaster(o, proxy.DummyServer())
|
||||
|
||||
def test_basic(self):
|
||||
|
|
|
@ -4,6 +4,7 @@ import mock
|
|||
import tornado.testing
|
||||
from mitmproxy import exceptions
|
||||
from mitmproxy import proxy
|
||||
from mitmproxy import options
|
||||
from mitmproxy.test import tflow
|
||||
from mitmproxy.tools.web import app
|
||||
from mitmproxy.tools.web import master as webmaster
|
||||
|
@ -17,7 +18,7 @@ def json(resp: httpclient.HTTPResponse):
|
|||
|
||||
class TestApp(tornado.testing.AsyncHTTPTestCase):
|
||||
def get_app(self):
|
||||
o = webmaster.Options()
|
||||
o = options.Options()
|
||||
m = webmaster.WebMaster(o, proxy.DummyServer())
|
||||
f = tflow.tflow(resp=True)
|
||||
f.id = "42"
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
from mitmproxy.tools.web import master
|
||||
from mitmproxy import proxy
|
||||
from mitmproxy import options
|
||||
from . import mastertest
|
||||
|
||||
|
||||
class TestWebMaster(mastertest.MasterTest):
|
||||
def mkmaster(self, **options):
|
||||
o = master.Options(**options)
|
||||
def mkmaster(self, **opts):
|
||||
o = options.Options(**opts)
|
||||
return master.WebMaster(o, proxy.DummyServer(o))
|
||||
|
||||
def test_basic(self):
|
||||
|
|
Loading…
Reference in New Issue