mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
commit
02f51d043d
@ -8,9 +8,9 @@ class Onboarding(wsgiapp.WSGIApp):
|
||||
self.enabled = False
|
||||
|
||||
def configure(self, options, updated):
|
||||
self.host = options.app_host
|
||||
self.port = options.app_port
|
||||
self.enabled = options.app
|
||||
self.host = options.onboarding_host
|
||||
self.port = options.onboarding_port
|
||||
self.enabled = options.onboarding
|
||||
|
||||
def request(self, f):
|
||||
if self.enabled:
|
||||
|
@ -298,19 +298,19 @@ class View(collections.Sequence):
|
||||
"Invalid interception filter: %s" % opts.filter
|
||||
)
|
||||
self.set_filter(filt)
|
||||
if "order" in updated:
|
||||
if opts.order is None:
|
||||
if "console_order" in updated:
|
||||
if opts.console_order is None:
|
||||
self.set_order(self.default_order)
|
||||
else:
|
||||
if opts.order not in self.orders:
|
||||
if opts.console_order not in self.orders:
|
||||
raise exceptions.OptionsError(
|
||||
"Unknown flow order: %s" % opts.order
|
||||
"Unknown flow order: %s" % opts.console_order
|
||||
)
|
||||
self.set_order(self.orders[opts.order])
|
||||
if "order_reversed" in updated:
|
||||
self.set_reversed(opts.order_reversed)
|
||||
if "focus_follow" in updated:
|
||||
self.focus_follow = opts.focus_follow
|
||||
self.set_order(self.orders[opts.console_order])
|
||||
if "console_order_reversed" in updated:
|
||||
self.set_reversed(opts.console_order_reversed)
|
||||
if "console_focus_follow" in updated:
|
||||
self.focus_follow = opts.console_focus_follow
|
||||
|
||||
def request(self, f):
|
||||
self.add(f)
|
||||
|
@ -22,96 +22,96 @@ DEFAULT_CLIENT_CIPHERS = "ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA
|
||||
|
||||
class Options(optmanager.OptManager):
|
||||
def __init__(
|
||||
self,
|
||||
*, # all args are keyword-only.
|
||||
# TODO: rename to onboarding_app_*
|
||||
app: bool = True,
|
||||
app_host: str = APP_HOST,
|
||||
app_port: int = APP_PORT,
|
||||
anticache: bool = False,
|
||||
anticomp: bool = False,
|
||||
client_replay: Sequence[str] = [],
|
||||
replay_kill_extra: bool = False,
|
||||
keepserving: bool = True,
|
||||
no_server: bool = False,
|
||||
server_replay_nopop: bool = False,
|
||||
refresh_server_playback: bool = True,
|
||||
rfile: Optional[str] = None,
|
||||
scripts: Sequence[str] = [],
|
||||
showhost: bool = False,
|
||||
replacements: Sequence[Tuple[str, str, str]] = [],
|
||||
server_replay_use_headers: Sequence[str] = [],
|
||||
setheaders: Sequence[Tuple[str, str, str]] = [],
|
||||
server_replay: Sequence[str] = [],
|
||||
stickycookie: Optional[str] = None,
|
||||
stickyauth: Optional[str] = None,
|
||||
stream_large_bodies: Optional[int] = None,
|
||||
verbosity: int = 2,
|
||||
default_contentview: str = "auto",
|
||||
streamfile: Optional[str] = None,
|
||||
streamfile_append: bool = False,
|
||||
server_replay_ignore_content: bool = False,
|
||||
server_replay_ignore_params: Sequence[str] = [],
|
||||
server_replay_ignore_payload_params: Sequence[str] = [],
|
||||
server_replay_ignore_host: bool = False,
|
||||
# Proxy options
|
||||
auth_nonanonymous: bool = False,
|
||||
auth_singleuser: Optional[str] = None,
|
||||
auth_htpasswd: Optional[str] = None,
|
||||
add_upstream_certs_to_client_chain: bool = False,
|
||||
body_size_limit: Optional[int] = None,
|
||||
cadir: str = CA_DIR,
|
||||
certs: Sequence[Tuple[str, str]] = [],
|
||||
ciphers_client: str=DEFAULT_CLIENT_CIPHERS,
|
||||
ciphers_server: Optional[str]=None,
|
||||
clientcerts: Optional[str] = None,
|
||||
http2: bool = True,
|
||||
ignore_hosts: Sequence[str] = [],
|
||||
listen_host: str = "",
|
||||
listen_port: int = LISTEN_PORT,
|
||||
upstream_bind_address: str = "",
|
||||
mode: str = "regular",
|
||||
no_upstream_cert: bool = False,
|
||||
rawtcp: bool = False,
|
||||
websocket: bool = True,
|
||||
spoof_source_address: bool = False,
|
||||
upstream_server: Optional[str] = None,
|
||||
upstream_auth: Optional[str] = None,
|
||||
ssl_version_client: str = "secure",
|
||||
ssl_version_server: str = "secure",
|
||||
ssl_insecure: bool = False,
|
||||
ssl_verify_upstream_trusted_cadir: Optional[str] = None,
|
||||
ssl_verify_upstream_trusted_ca: Optional[str] = None,
|
||||
tcp_hosts: Sequence[str] = [],
|
||||
self,
|
||||
*, # all args are keyword-only.
|
||||
onboarding: bool = True,
|
||||
onboarding_host: str = APP_HOST,
|
||||
onboarding_port: int = APP_PORT,
|
||||
anticache: bool = False,
|
||||
anticomp: bool = False,
|
||||
client_replay: Sequence[str] = [],
|
||||
replay_kill_extra: bool = False,
|
||||
keepserving: bool = True,
|
||||
no_server: bool = False,
|
||||
server_replay_nopop: bool = False,
|
||||
refresh_server_playback: bool = True,
|
||||
rfile: Optional[str] = None,
|
||||
scripts: Sequence[str] = [],
|
||||
showhost: bool = False,
|
||||
replacements: Sequence[Tuple[str, str, str]] = [],
|
||||
server_replay_use_headers: Sequence[str] = [],
|
||||
setheaders: Sequence[Tuple[str, str, str]] = [],
|
||||
server_replay: Sequence[str] = [],
|
||||
stickycookie: Optional[str] = None,
|
||||
stickyauth: Optional[str] = None,
|
||||
stream_large_bodies: Optional[int] = None,
|
||||
verbosity: int = 2,
|
||||
default_contentview: str = "auto",
|
||||
streamfile: Optional[str] = None,
|
||||
streamfile_append: bool = False,
|
||||
server_replay_ignore_content: bool = False,
|
||||
server_replay_ignore_params: Sequence[str] = [],
|
||||
server_replay_ignore_payload_params: Sequence[str] = [],
|
||||
server_replay_ignore_host: bool = False,
|
||||
# Proxy options
|
||||
auth_nonanonymous: bool = False,
|
||||
auth_singleuser: Optional[str] = None,
|
||||
auth_htpasswd: Optional[str] = None,
|
||||
add_upstream_certs_to_client_chain: bool = False,
|
||||
body_size_limit: Optional[int] = None,
|
||||
cadir: str = CA_DIR,
|
||||
certs: Sequence[Tuple[str, str]] = [],
|
||||
ciphers_client: str=DEFAULT_CLIENT_CIPHERS,
|
||||
ciphers_server: Optional[str]=None,
|
||||
clientcerts: Optional[str] = None,
|
||||
http2: bool = True,
|
||||
ignore_hosts: Sequence[str] = [],
|
||||
listen_host: str = "",
|
||||
listen_port: int = LISTEN_PORT,
|
||||
upstream_bind_address: str = "",
|
||||
mode: str = "regular",
|
||||
no_upstream_cert: bool = False,
|
||||
rawtcp: bool = False,
|
||||
websocket: bool = True,
|
||||
spoof_source_address: bool = False,
|
||||
upstream_server: Optional[str] = None,
|
||||
upstream_auth: Optional[str] = None,
|
||||
ssl_version_client: str = "secure",
|
||||
ssl_version_server: str = "secure",
|
||||
ssl_insecure: bool = False,
|
||||
ssl_verify_upstream_trusted_cadir: Optional[str] = None,
|
||||
ssl_verify_upstream_trusted_ca: Optional[str] = None,
|
||||
tcp_hosts: Sequence[str] = [],
|
||||
|
||||
intercept: Optional[str] = None,
|
||||
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,
|
||||
# Console options
|
||||
console_eventlog: bool = False,
|
||||
console_focus_follow: bool = False,
|
||||
console_palette: Optional[str] = "dark",
|
||||
console_palette_transparent: bool = False,
|
||||
console_no_mouse: bool = False,
|
||||
console_order: Optional[str] = None,
|
||||
console_order_reversed: bool = False,
|
||||
|
||||
# Web options
|
||||
open_browser: bool = True,
|
||||
wdebug: bool = False,
|
||||
wport: int = 8081,
|
||||
wiface: str = "127.0.0.1",
|
||||
filter: Optional[str] = None,
|
||||
|
||||
# Dump options
|
||||
filtstr: Optional[str] = None,
|
||||
flow_detail: int = 1
|
||||
# Web options
|
||||
web_open_browser: bool = True,
|
||||
web_debug: bool = False,
|
||||
web_port: int = 8081,
|
||||
web_iface: 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.
|
||||
|
||||
self.app = app
|
||||
self.app_host = app_host
|
||||
self.app_port = app_port
|
||||
self.onboarding = onboarding
|
||||
self.onboarding_host = onboarding_host
|
||||
self.onboarding_port = onboarding_port
|
||||
self.anticache = anticache
|
||||
self.anticomp = anticomp
|
||||
self.client_replay = client_replay
|
||||
@ -172,20 +172,21 @@ class Options(optmanager.OptManager):
|
||||
self.intercept = intercept
|
||||
|
||||
# Console options
|
||||
self.eventlog = eventlog
|
||||
self.focus_follow = focus_follow
|
||||
self.console_eventlog = console_eventlog
|
||||
self.console_focus_follow = console_focus_follow
|
||||
self.console_palette = console_palette
|
||||
self.console_palette_transparent = console_palette_transparent
|
||||
self.console_no_mouse = console_no_mouse
|
||||
self.console_order = console_order
|
||||
self.console_order_reversed = console_order_reversed
|
||||
|
||||
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
|
||||
self.web_open_browser = web_open_browser
|
||||
self.web_debug = web_debug
|
||||
self.web_port = web_port
|
||||
self.web_iface = web_iface
|
||||
|
||||
# Dump options
|
||||
self.filtstr = filtstr
|
||||
|
@ -229,7 +229,10 @@ class OptManager(metaclass=_DefaultsMeta):
|
||||
this object. May raise OptionsError if the config file is invalid.
|
||||
"""
|
||||
data = self._load(text)
|
||||
self.update(**data)
|
||||
try:
|
||||
self.update(**data)
|
||||
except KeyError as v:
|
||||
raise exceptions.OptionsError(v)
|
||||
|
||||
def load_paths(self, *paths):
|
||||
"""
|
||||
@ -242,7 +245,12 @@ class OptManager(metaclass=_DefaultsMeta):
|
||||
if os.path.exists(p) and os.path.isfile(p):
|
||||
with open(p, "r") as f:
|
||||
txt = f.read()
|
||||
self.load(txt)
|
||||
try:
|
||||
self.load(txt)
|
||||
except exceptions.OptionsError as e:
|
||||
raise exceptions.OptionsError(
|
||||
"Error reading %s: %s" % (p, e)
|
||||
)
|
||||
|
||||
def merge(self, opts):
|
||||
"""
|
||||
|
@ -212,9 +212,9 @@ def get_common_options(args):
|
||||
args.verbose = 0
|
||||
|
||||
return dict(
|
||||
app=args.app,
|
||||
app_host=args.app_host,
|
||||
app_port=args.app_port,
|
||||
onboarding=args.onboarding,
|
||||
onboarding_host=args.onboarding_host,
|
||||
onboarding_port=args.onboarding_port,
|
||||
|
||||
anticache=args.anticache,
|
||||
anticomp=args.anticomp,
|
||||
@ -568,13 +568,13 @@ def proxy_ssl_options(parser):
|
||||
def onboarding_app(parser):
|
||||
group = parser.add_argument_group("Onboarding App")
|
||||
group.add_argument(
|
||||
"--noapp",
|
||||
action="store_false", dest="app",
|
||||
"--no-onboarding",
|
||||
action="store_false", dest="onboarding",
|
||||
help="Disable the mitmproxy onboarding app."
|
||||
)
|
||||
group.add_argument(
|
||||
"--app-host",
|
||||
action="store", dest="app_host",
|
||||
"--onboarding-host",
|
||||
action="store", dest="onboarding_host",
|
||||
help="""
|
||||
Domain to serve the onboarding app from. For transparent mode, use
|
||||
an IP when a DNS entry for the app domain is not present. Default:
|
||||
@ -582,9 +582,9 @@ def onboarding_app(parser):
|
||||
""" % options.APP_HOST
|
||||
)
|
||||
group.add_argument(
|
||||
"--app-port",
|
||||
"--onboarding-port",
|
||||
action="store",
|
||||
dest="app_port",
|
||||
dest="onboarding_port",
|
||||
type=int,
|
||||
metavar="80",
|
||||
help="Port to serve the onboarding app from."
|
||||
@ -770,34 +770,34 @@ def mitmproxy():
|
||||
common_options(parser)
|
||||
parser.add_argument(
|
||||
"--palette", type=str,
|
||||
action="store", dest="palette",
|
||||
action="store", dest="console_palette",
|
||||
choices=sorted(palettes.palettes.keys()),
|
||||
help="Select color palette: " + ", ".join(palettes.palettes.keys())
|
||||
)
|
||||
parser.add_argument(
|
||||
"--palette-transparent",
|
||||
action="store_true", dest="palette_transparent",
|
||||
action="store_true", dest="console_palette_transparent",
|
||||
help="Set transparent background for palette."
|
||||
)
|
||||
parser.add_argument(
|
||||
"-e", "--eventlog",
|
||||
action="store_true", dest="eventlog",
|
||||
action="store_true", dest="console_eventlog",
|
||||
help="Show event log."
|
||||
)
|
||||
parser.add_argument(
|
||||
"--follow",
|
||||
action="store_true", dest="focus_follow",
|
||||
action="store_true", dest="console_focus_follow",
|
||||
help="Focus follows new flows."
|
||||
)
|
||||
parser.add_argument(
|
||||
"--order",
|
||||
type=str, dest="order",
|
||||
type=str, dest="console_order",
|
||||
choices=[o[1] for o in view.orders],
|
||||
help="Flow sort order."
|
||||
)
|
||||
parser.add_argument(
|
||||
"--no-mouse",
|
||||
action="store_true", dest="no_mouse",
|
||||
action="store_true", dest="console_no_mouse",
|
||||
help="Disable mouse interaction."
|
||||
)
|
||||
group = parser.add_argument_group(
|
||||
@ -851,24 +851,24 @@ def mitmweb():
|
||||
group = parser.add_argument_group("Mitmweb")
|
||||
group.add_argument(
|
||||
"--no-browser",
|
||||
action="store_false", dest="open_browser",
|
||||
action="store_false", dest="web_open_browser",
|
||||
help="Don't start a browser"
|
||||
)
|
||||
group.add_argument(
|
||||
"--wport",
|
||||
action="store", type=int, dest="wport",
|
||||
"--web-port",
|
||||
action="store", type=int, dest="web_port",
|
||||
metavar="PORT",
|
||||
help="Mitmweb port."
|
||||
)
|
||||
group.add_argument(
|
||||
"--wiface",
|
||||
action="store", dest="wiface",
|
||||
"--web-iface",
|
||||
action="store", dest="web_iface",
|
||||
metavar="IFACE",
|
||||
help="Mitmweb interface."
|
||||
)
|
||||
group.add_argument(
|
||||
"--wdebug",
|
||||
action="store_true", dest="wdebug",
|
||||
"--web-debug",
|
||||
action="store_true", dest="web_debug",
|
||||
help="Turn on mitmweb debugging"
|
||||
)
|
||||
|
||||
|
@ -387,7 +387,7 @@ class FlowListBox(urwid.ListBox):
|
||||
lookup = dict([(i[0], i[1]) for i in view.orders])
|
||||
|
||||
def change_order(k):
|
||||
self.master.options.order = lookup[k]
|
||||
self.master.options.console_order = lookup[k]
|
||||
|
||||
signals.status_prompt_onekey.send(
|
||||
prompt = "Order",
|
||||
@ -398,8 +398,8 @@ class FlowListBox(urwid.ListBox):
|
||||
o = self.master.options
|
||||
o.focus_follow = not o.focus_follow
|
||||
elif key == "v":
|
||||
val = not self.master.options.order_reversed
|
||||
self.master.options.order_reversed = val
|
||||
val = not self.master.options.console_order_reversed
|
||||
self.master.options.console_order_reversed = val
|
||||
elif key == "W":
|
||||
if self.master.options.streamfile:
|
||||
self.master.options.streamfile = None
|
||||
|
@ -106,7 +106,7 @@ class ConsoleMaster(master.Master):
|
||||
self.logbuffer.append(e)
|
||||
if len(self.logbuffer) > EVENTLOG_SIZE:
|
||||
self.logbuffer.pop(0)
|
||||
if self.options.focus_follow:
|
||||
if self.options.console_focus_follow:
|
||||
self.logbuffer.set_focus(len(self.logbuffer) - 1)
|
||||
|
||||
def sig_call_in(self, sender, seconds, callback, args=()):
|
||||
@ -150,7 +150,7 @@ class ConsoleMaster(master.Master):
|
||||
signals.add_log("Script error: %s" % e, "warn")
|
||||
|
||||
def toggle_eventlog(self):
|
||||
self.options.eventlog = not self.options.eventlog
|
||||
self.options.console_eventlog = not self.options.console_eventlog
|
||||
self.view_flowlist()
|
||||
signals.replace_view_state.send(self)
|
||||
|
||||
@ -230,8 +230,8 @@ class ConsoleMaster(master.Master):
|
||||
|
||||
def set_palette(self, options, updated):
|
||||
self.ui.register_palette(
|
||||
palettes.palettes[options.palette].palette(
|
||||
options.palette_transparent
|
||||
palettes.palettes[options.console_palette].palette(
|
||||
options.console_palette_transparent
|
||||
)
|
||||
)
|
||||
self.ui.clear()
|
||||
@ -253,7 +253,7 @@ class ConsoleMaster(master.Master):
|
||||
self.loop = urwid.MainLoop(
|
||||
urwid.SolidFill("x"),
|
||||
screen = self.ui,
|
||||
handle_mouse = not self.options.no_mouse,
|
||||
handle_mouse = not self.options.console_no_mouse,
|
||||
)
|
||||
self.ab = statusbar.ActionBar()
|
||||
|
||||
@ -347,7 +347,7 @@ class ConsoleMaster(master.Master):
|
||||
if self.ui.started:
|
||||
self.ui.clear()
|
||||
|
||||
if self.options.eventlog:
|
||||
if self.options.console_eventlog:
|
||||
body = flowlist.BodyPile(self)
|
||||
else:
|
||||
body = flowlist.FlowListBox(self)
|
||||
|
@ -75,7 +75,7 @@ class Options(urwid.WidgetWrap):
|
||||
select.Option(
|
||||
"Palette",
|
||||
"P",
|
||||
checker("palette", master.options),
|
||||
checker("console_palette", master.options),
|
||||
self.palette
|
||||
),
|
||||
select.Option(
|
||||
|
@ -42,7 +42,7 @@ class PalettePicker(urwid.WidgetWrap):
|
||||
return select.Option(
|
||||
i,
|
||||
None,
|
||||
lambda: self.master.options.palette == name,
|
||||
lambda: self.master.options.console_palette == name,
|
||||
lambda: setattr(self.master.options, "palette", name)
|
||||
)
|
||||
|
||||
@ -58,7 +58,7 @@ class PalettePicker(urwid.WidgetWrap):
|
||||
select.Option(
|
||||
"Transparent",
|
||||
"T",
|
||||
lambda: master.options.palette_transparent,
|
||||
lambda: master.options.console_palette_transparent,
|
||||
master.options.toggler("palette_transparent")
|
||||
)
|
||||
]
|
||||
|
@ -204,10 +204,10 @@ class StatusBar(urwid.WidgetWrap):
|
||||
r.append("[")
|
||||
r.append(("heading_key", "M"))
|
||||
r.append(":%s]" % self.master.options.default_contentview)
|
||||
if self.master.options.order:
|
||||
if self.master.options.console_order:
|
||||
r.append("[")
|
||||
r.append(("heading_key", "o"))
|
||||
r.append(":%s]" % self.master.options.order)
|
||||
r.append(":%s]" % self.master.options.console_order)
|
||||
|
||||
opts = []
|
||||
if self.master.options.anticache:
|
||||
@ -222,7 +222,7 @@ class StatusBar(urwid.WidgetWrap):
|
||||
opts.append("killextra")
|
||||
if self.master.options.no_upstream_cert:
|
||||
opts.append("no-upstream-cert")
|
||||
if self.master.options.focus_follow:
|
||||
if self.master.options.console_focus_follow:
|
||||
opts.append("following")
|
||||
if self.master.options.stream_large_bodies:
|
||||
opts.append(
|
||||
@ -258,7 +258,7 @@ class StatusBar(urwid.WidgetWrap):
|
||||
else:
|
||||
offset = self.master.view.focus.index + 1
|
||||
|
||||
if self.master.options.order_reversed:
|
||||
if self.master.options.console_order_reversed:
|
||||
arrow = common.SYMBOL_UP
|
||||
else:
|
||||
arrow = common.SYMBOL_DOWN
|
||||
|
@ -70,14 +70,15 @@ def mitmproxy(args=None): # pragma: no cover
|
||||
console_options.merge(cmdline.get_common_options(args))
|
||||
console_options.merge(
|
||||
dict(
|
||||
palette = args.palette,
|
||||
palette_transparent = args.palette_transparent,
|
||||
eventlog = args.eventlog,
|
||||
focus_follow = args.focus_follow,
|
||||
intercept = args.intercept,
|
||||
console_palette = args.console_palette,
|
||||
console_palette_transparent = args.console_palette_transparent,
|
||||
console_eventlog = args.console_eventlog,
|
||||
console_focus_follow = args.console_focus_follow,
|
||||
console_no_mouse = args.console_no_mouse,
|
||||
console_order = args.console_order,
|
||||
|
||||
filter = args.filter,
|
||||
no_mouse = args.no_mouse,
|
||||
order = args.order,
|
||||
intercept = args.intercept,
|
||||
)
|
||||
)
|
||||
|
||||
@ -149,10 +150,10 @@ def mitmweb(args=None): # pragma: no cover
|
||||
web_options.merge(
|
||||
dict(
|
||||
intercept = args.intercept,
|
||||
open_browser = args.open_browser,
|
||||
wdebug = args.wdebug,
|
||||
wiface = args.wiface,
|
||||
wport = args.wport,
|
||||
web_open_browser = args.web_open_browser,
|
||||
web_debug = args.web_debug,
|
||||
web_iface = args.web_iface,
|
||||
web_port = args.web_port,
|
||||
)
|
||||
)
|
||||
server = process_options(parser, web_options, args)
|
||||
|
@ -38,7 +38,7 @@ class WebMaster(master.Master):
|
||||
if with_termlog:
|
||||
self.addons.add(termlog.TermLog())
|
||||
self.app = app.Application(
|
||||
self, self.options.wdebug
|
||||
self, self.options.web_debug
|
||||
)
|
||||
# This line is just for type hinting
|
||||
self.options = self.options # type: Options
|
||||
@ -103,7 +103,7 @@ class WebMaster(master.Master):
|
||||
iol = tornado.ioloop.IOLoop.instance()
|
||||
|
||||
http_server = tornado.httpserver.HTTPServer(self.app)
|
||||
http_server.listen(self.options.wport, self.options.wiface)
|
||||
http_server.listen(self.options.web_port, self.options.web_iface)
|
||||
|
||||
iol.add_callback(self.start)
|
||||
tornado.ioloop.PeriodicCallback(lambda: self.tick(timeout=0), 5).start()
|
||||
@ -113,13 +113,13 @@ class WebMaster(master.Master):
|
||||
"info"
|
||||
)
|
||||
|
||||
web_url = "http://{}:{}/".format(self.options.wiface, self.options.wport)
|
||||
web_url = "http://{}:{}/".format(self.options.web_iface, self.options.web_port)
|
||||
self.add_log(
|
||||
"Web server listening at {}".format(web_url),
|
||||
"info"
|
||||
)
|
||||
|
||||
if self.options.open_browser:
|
||||
if self.options.web_open_browser:
|
||||
success = open_browser(web_url)
|
||||
if not success:
|
||||
self.add_log(
|
||||
|
@ -19,15 +19,15 @@ class Options(options.Options):
|
||||
self,
|
||||
*,
|
||||
filter=None,
|
||||
order=None,
|
||||
order_reversed=False,
|
||||
focus_follow=False,
|
||||
console_order=None,
|
||||
console_order_reversed=False,
|
||||
console_focus_follow=False,
|
||||
**kwargs
|
||||
):
|
||||
self.filter = filter
|
||||
self.order = order
|
||||
self.order_reversed = order_reversed
|
||||
self.focus_follow = focus_follow
|
||||
self.console_order = console_order
|
||||
self.console_order_reversed = console_order_reversed
|
||||
self.console_focus_follow = console_focus_follow
|
||||
super().__init__(**kwargs)
|
||||
|
||||
|
||||
@ -42,7 +42,7 @@ def test_order_refresh():
|
||||
|
||||
tf = tflow.tflow(resp=True)
|
||||
with taddons.context(options=Options()) as tctx:
|
||||
tctx.configure(v, order="time")
|
||||
tctx.configure(v, console_order="time")
|
||||
v.add(tf)
|
||||
tf.request.timestamp_start = 1
|
||||
assert not sargs
|
||||
@ -148,12 +148,12 @@ def test_order():
|
||||
v.request(tft(method="put", start=4))
|
||||
assert [i.request.timestamp_start for i in v] == [1, 2, 3, 4]
|
||||
|
||||
tctx.configure(v, order="method")
|
||||
tctx.configure(v, console_order="method")
|
||||
assert [i.request.method for i in v] == ["GET", "GET", "PUT", "PUT"]
|
||||
v.set_reversed(True)
|
||||
assert [i.request.method for i in v] == ["PUT", "PUT", "GET", "GET"]
|
||||
|
||||
tctx.configure(v, order="time")
|
||||
tctx.configure(v, console_order="time")
|
||||
assert [i.request.timestamp_start for i in v] == [4, 3, 2, 1]
|
||||
|
||||
v.set_reversed(False)
|
||||
@ -271,7 +271,7 @@ def test_signals():
|
||||
def test_focus_follow():
|
||||
v = view.View()
|
||||
with taddons.context(options=Options()) as tctx:
|
||||
tctx.configure(v, focus_follow=True, filter="~m get")
|
||||
tctx.configure(v, console_focus_follow=True, filter="~m get")
|
||||
|
||||
v.add(tft(start=5))
|
||||
assert v.focus.index == 0
|
||||
@ -384,12 +384,12 @@ def test_configure():
|
||||
tctx.configure(v, filter="~q")
|
||||
tutils.raises("invalid interception filter", tctx.configure, v, filter="~~")
|
||||
|
||||
tctx.configure(v, order="method")
|
||||
tutils.raises("unknown flow order", tctx.configure, v, order="no")
|
||||
tctx.configure(v, console_order="method")
|
||||
tutils.raises("unknown flow order", tctx.configure, v, console_order="no")
|
||||
|
||||
tctx.configure(v, order_reversed=True)
|
||||
tctx.configure(v, console_order_reversed=True)
|
||||
|
||||
tctx.configure(v, order=None)
|
||||
tctx.configure(v, console_order=None)
|
||||
|
||||
tctx.configure(v, focus_follow=True)
|
||||
tctx.configure(v, console_focus_follow=True)
|
||||
assert v.focus_follow
|
||||
|
Loading…
Reference in New Issue
Block a user