From a15d591a4e2fd304830e4e6651b20970db530e26 Mon Sep 17 00:00:00 2001 From: Nikita Stupin <18281368+nikitastupin@users.noreply.github.com> Date: Fri, 29 May 2020 20:34:30 +0300 Subject: [PATCH] Remove unrelated focus options for TCP flow details --- mitmproxy/tools/console/consoleaddons.py | 41 ++++++++++++++---------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/mitmproxy/tools/console/consoleaddons.py b/mitmproxy/tools/console/consoleaddons.py index 7c1cbc09e..6e74613c3 100644 --- a/mitmproxy/tools/console/consoleaddons.py +++ b/mitmproxy/tools/console/consoleaddons.py @@ -383,23 +383,30 @@ class ConsoleAddon: """ Possible components for console.edit.focus. """ - return [ - "cookies", - "urlencoded form", - "multipart form", - "path", - "method", - "query", - "reason", - "request-headers", - "response-headers", - "request-body", - "response-body", - "status_code", - "set-cookies", - "url", - "tcp-message" - ] + flow = self.master.view.focus.flow + focus_options = [] + + if type(flow) == tcp.TCPFlow: + focus_options = ["tcp-message"] + elif type(flow) == http.HTTPFlow: + focus_options = [ + "cookies", + "urlencoded form", + "multipart form", + "path", + "method", + "query", + "reason", + "request-headers", + "response-headers", + "request-body", + "response-body", + "status_code", + "set-cookies", + "url", + ] + + return focus_options @command.command("console.edit.focus") @command.argument("flow_part", type=mitmproxy.types.Choice("console.edit.focus.options"))