Make content view lines limit configurable

This commit is contained in:
Kamil Borzym 2018-10-19 15:58:07 +02:00
parent 57868ef5fa
commit 41cef4e9e3
4 changed files with 12 additions and 5 deletions

View File

@ -24,7 +24,7 @@ from . import (
auto, raw, hex, json, xml_html, wbxml, javascript, css, auto, raw, hex, json, xml_html, wbxml, javascript, css,
urlencoded, multipart, image, query, protobuf urlencoded, multipart, image, query, protobuf
) )
from .base import View, VIEW_CUTOFF, KEY_MAX, format_text, format_dict, TViewResult from .base import View, KEY_MAX, format_text, format_dict, TViewResult
views: List[View] = [] views: List[View] = []
content_types_map: Dict[str, List[View]] = {} content_types_map: Dict[str, List[View]] = {}
@ -160,6 +160,6 @@ add(query.ViewQuery())
add(protobuf.ViewProtobuf()) add(protobuf.ViewProtobuf())
__all__ = [ __all__ = [
"View", "VIEW_CUTOFF", "KEY_MAX", "format_text", "format_dict", "TViewResult", "View", "KEY_MAX", "format_text", "format_dict", "TViewResult",
"get", "add", "remove", "get_content_view", "get_message_content_view", "get", "add", "remove", "get_content_view", "get_message_content_view",
] ]

View File

@ -1,8 +1,6 @@
# Default view cutoff *in lines* # Default view cutoff *in lines*
import typing import typing
VIEW_CUTOFF = 512
KEY_MAX = 30 KEY_MAX = 30
TTextType = typing.Union[str, bytes] # FIXME: This should be either bytes or str ultimately. TTextType = typing.Union[str, bytes] # FIXME: This should be either bytes or str ultimately.

View File

@ -6,6 +6,7 @@ from mitmproxy.net import tls
CONF_DIR = "~/.mitmproxy" CONF_DIR = "~/.mitmproxy"
LISTEN_PORT = 8080 LISTEN_PORT = 8080
CONTENT_VIEW_LINES_CUTOFF = 512
class Options(optmanager.OptManager): class Options(optmanager.OptManager):
@ -161,5 +162,12 @@ class Options(optmanager.OptManager):
communication contents are printed to the log in verbose mode. communication contents are printed to the log in verbose mode.
""" """
) )
self.add_option(
"content_view_lines_cutoff", int, CONTENT_VIEW_LINES_CUTOFF,
"""
Flow content view lines limit. Limit is enabled by default to
speedup flows browsing.
"""
)
self.update(**kwargs) self.update(**kwargs)

View File

@ -6,6 +6,7 @@ from typing import Optional, Union # noqa
import urwid import urwid
from mitmproxy import contentviews from mitmproxy import contentviews
from mitmproxy import ctx
from mitmproxy import http from mitmproxy import http
from mitmproxy.tools.console import common from mitmproxy.tools.console import common
from mitmproxy.tools.console import layoutwidget from mitmproxy.tools.console import layoutwidget
@ -102,7 +103,7 @@ class FlowDetails(tabs.Tabs):
if full == "true": if full == "true":
limit = sys.maxsize limit = sys.maxsize
else: else:
limit = contentviews.VIEW_CUTOFF limit = ctx.options.content_view_lines_cutoff
flow_modify_cache_invalidation = hash(( flow_modify_cache_invalidation = hash((
message.raw_content, message.raw_content,