mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-29 19:08:44 +00:00
Remove less commonly used command-line options
We now have --set, so only options that really deserve it get a dedicated flag. I'm inclined to strip this back even more. Feel free to argue that YOUR favourite option deserves special treatment here.
This commit is contained in:
parent
ac3b0d69cc
commit
10db254791
@ -367,16 +367,15 @@ class OptManager:
|
|||||||
f = optname.replace("_", "-")
|
f = optname.replace("_", "-")
|
||||||
if o.typespec == bool:
|
if o.typespec == bool:
|
||||||
g = parser.add_mutually_exclusive_group(required=False)
|
g = parser.add_mutually_exclusive_group(required=False)
|
||||||
g.add_argument(
|
|
||||||
"--%s" % f,
|
|
||||||
action="store_true",
|
|
||||||
dest=optname,
|
|
||||||
help=o.help
|
|
||||||
)
|
|
||||||
g.add_argument(
|
g.add_argument(
|
||||||
"--no-%s" % f,
|
"--no-%s" % f,
|
||||||
action="store_false",
|
action="store_false",
|
||||||
dest=optname,
|
dest=optname,
|
||||||
|
)
|
||||||
|
g.add_argument(
|
||||||
|
"--%s" % f,
|
||||||
|
action="store_true",
|
||||||
|
dest=optname,
|
||||||
help=o.help
|
help=o.help
|
||||||
)
|
)
|
||||||
parser.set_defaults(**{optname: None})
|
parser.set_defaults(**{optname: None})
|
||||||
|
@ -57,7 +57,6 @@ def common_options(parser, opts):
|
|||||||
# Basic options
|
# Basic options
|
||||||
opts.make_parser(parser, "mode")
|
opts.make_parser(parser, "mode")
|
||||||
opts.make_parser(parser, "anticache")
|
opts.make_parser(parser, "anticache")
|
||||||
opts.make_parser(parser, "cadir")
|
|
||||||
opts.make_parser(parser, "showhost")
|
opts.make_parser(parser, "showhost")
|
||||||
opts.make_parser(parser, "rfile")
|
opts.make_parser(parser, "rfile")
|
||||||
opts.make_parser(parser, "scripts", metavar="SCRIPT")
|
opts.make_parser(parser, "scripts", metavar="SCRIPT")
|
||||||
@ -65,49 +64,21 @@ def common_options(parser, opts):
|
|||||||
opts.make_parser(parser, "stickyauth", metavar="FILTER")
|
opts.make_parser(parser, "stickyauth", metavar="FILTER")
|
||||||
opts.make_parser(parser, "streamfile")
|
opts.make_parser(parser, "streamfile")
|
||||||
opts.make_parser(parser, "anticomp")
|
opts.make_parser(parser, "anticomp")
|
||||||
opts.make_parser(parser, "body_size_limit", metavar="SIZE")
|
|
||||||
opts.make_parser(parser, "stream_large_bodies")
|
|
||||||
|
|
||||||
# Proxy options
|
# Proxy options
|
||||||
group = parser.add_argument_group("Proxy Options")
|
group = parser.add_argument_group("Proxy Options")
|
||||||
opts.make_parser(group, "listen_host")
|
opts.make_parser(group, "listen_host", metavar="HOST")
|
||||||
opts.make_parser(group, "ignore_hosts", metavar="HOST")
|
opts.make_parser(group, "ignore_hosts", metavar="HOST")
|
||||||
opts.make_parser(group, "tcp_hosts", metavar="HOST")
|
opts.make_parser(group, "tcp_hosts", metavar="HOST")
|
||||||
opts.make_parser(group, "no_server")
|
opts.make_parser(group, "no_server")
|
||||||
opts.make_parser(group, "listen_port", metavar="PORT")
|
opts.make_parser(group, "listen_port", metavar="PORT")
|
||||||
|
|
||||||
http2 = group.add_mutually_exclusive_group()
|
|
||||||
opts.make_parser(http2, "http2")
|
|
||||||
opts.make_parser(http2, "http2_priority")
|
|
||||||
|
|
||||||
websocket = group.add_mutually_exclusive_group()
|
|
||||||
opts.make_parser(websocket, "websocket")
|
|
||||||
|
|
||||||
opts.make_parser(group, "upstream_auth", metavar="USER:PASS")
|
opts.make_parser(group, "upstream_auth", metavar="USER:PASS")
|
||||||
opts.make_parser(group, "rawtcp")
|
opts.make_parser(group, "rawtcp")
|
||||||
opts.make_parser(group, "spoof_source_address")
|
|
||||||
opts.make_parser(group, "upstream_bind_address", metavar="ADDR")
|
|
||||||
opts.make_parser(group, "keep_host_header")
|
|
||||||
|
|
||||||
# Proxy SSL options
|
# Proxy SSL options
|
||||||
group = parser.add_argument_group("SSL")
|
group = parser.add_argument_group("SSL")
|
||||||
opts.make_parser(group, "certs", metavar="SPEC")
|
opts.make_parser(group, "certs", metavar="SPEC")
|
||||||
opts.make_parser(group, "ciphers_server", metavar="CIPHERS")
|
|
||||||
opts.make_parser(group, "ciphers_client", metavar="CIPHERS")
|
|
||||||
opts.make_parser(group, "client_certs")
|
|
||||||
opts.make_parser(group, "upstream_cert")
|
|
||||||
opts.make_parser(group, "add_upstream_certs_to_client_chain")
|
|
||||||
opts.make_parser(group, "ssl_insecure")
|
opts.make_parser(group, "ssl_insecure")
|
||||||
opts.make_parser(group, "ssl_verify_upstream_trusted_cadir", metavar="PATH")
|
|
||||||
opts.make_parser(group, "ssl_verify_upstream_trusted_ca", metavar="PATH")
|
|
||||||
opts.make_parser(group, "ssl_version_client", metavar="VERSION")
|
|
||||||
opts.make_parser(group, "ssl_version_server", metavar="VERSION")
|
|
||||||
|
|
||||||
# Onboarding app
|
|
||||||
group = parser.add_argument_group("Onboarding App")
|
|
||||||
opts.make_parser(group, "onboarding")
|
|
||||||
opts.make_parser(group, "onboarding_host", metavar="HOST")
|
|
||||||
opts.make_parser(group, "onboarding_port", metavar="PORT")
|
|
||||||
|
|
||||||
# Client replay
|
# Client replay
|
||||||
group = parser.add_argument_group("Client Replay")
|
group = parser.add_argument_group("Client Replay")
|
||||||
@ -117,16 +88,8 @@ def common_options(parser, opts):
|
|||||||
group = parser.add_argument_group("Server Replay")
|
group = parser.add_argument_group("Server Replay")
|
||||||
opts.make_parser(group, "server_replay", metavar="PATH")
|
opts.make_parser(group, "server_replay", metavar="PATH")
|
||||||
opts.make_parser(group, "replay_kill_extra")
|
opts.make_parser(group, "replay_kill_extra")
|
||||||
opts.make_parser(group, "server_replay_use_headers", metavar="HEADER")
|
|
||||||
opts.make_parser(group, "refresh_server_playback")
|
|
||||||
opts.make_parser(group, "server_replay_nopop")
|
opts.make_parser(group, "server_replay_nopop")
|
||||||
|
|
||||||
payload = group.add_mutually_exclusive_group()
|
|
||||||
opts.make_parser(payload, "server_replay_ignore_content")
|
|
||||||
opts.make_parser(payload, "server_replay_ignore_payload_params")
|
|
||||||
opts.make_parser(payload, "server_replay_ignore_params")
|
|
||||||
opts.make_parser(payload, "server_replay_ignore_host")
|
|
||||||
|
|
||||||
# Replacements
|
# Replacements
|
||||||
group = parser.add_argument_group(
|
group = parser.add_argument_group(
|
||||||
"Replacements",
|
"Replacements",
|
||||||
@ -167,12 +130,7 @@ def mitmproxy(opts):
|
|||||||
parser = argparse.ArgumentParser(usage="%(prog)s [options]")
|
parser = argparse.ArgumentParser(usage="%(prog)s [options]")
|
||||||
common_options(parser, opts)
|
common_options(parser, opts)
|
||||||
|
|
||||||
opts.make_parser(parser, "console_palette")
|
|
||||||
opts.make_parser(parser, "console_palette_transparent")
|
|
||||||
opts.make_parser(parser, "console_eventlog")
|
opts.make_parser(parser, "console_eventlog")
|
||||||
opts.make_parser(parser, "console_focus_follow")
|
|
||||||
opts.make_parser(parser, "console_order")
|
|
||||||
opts.make_parser(parser, "console_mouse")
|
|
||||||
group = parser.add_argument_group(
|
group = parser.add_argument_group(
|
||||||
"Filters",
|
"Filters",
|
||||||
"See help in mitmproxy for filter expression syntax."
|
"See help in mitmproxy for filter expression syntax."
|
||||||
@ -186,7 +144,6 @@ def mitmdump(opts):
|
|||||||
parser = argparse.ArgumentParser(usage="%(prog)s [options] [filter]")
|
parser = argparse.ArgumentParser(usage="%(prog)s [options] [filter]")
|
||||||
|
|
||||||
common_options(parser, opts)
|
common_options(parser, opts)
|
||||||
opts.make_parser(parser, "keepserving")
|
|
||||||
opts.make_parser(parser, "flow_detail", metavar = "LEVEL")
|
opts.make_parser(parser, "flow_detail", metavar = "LEVEL")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'filter_args',
|
'filter_args',
|
||||||
@ -206,7 +163,6 @@ def mitmweb(opts):
|
|||||||
opts.make_parser(group, "web_open_browser")
|
opts.make_parser(group, "web_open_browser")
|
||||||
opts.make_parser(group, "web_port", metavar="PORT")
|
opts.make_parser(group, "web_port", metavar="PORT")
|
||||||
opts.make_parser(group, "web_iface", metavar="INTERFACE")
|
opts.make_parser(group, "web_iface", metavar="INTERFACE")
|
||||||
opts.make_parser(group, "web_debug")
|
|
||||||
|
|
||||||
common_options(parser, opts)
|
common_options(parser, opts)
|
||||||
group = parser.add_argument_group(
|
group = parser.add_argument_group(
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import os
|
|
||||||
import argparse
|
import argparse
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
from OpenSSL import SSL
|
from OpenSSL import SSL
|
||||||
@ -46,19 +45,6 @@ class TestProcessProxyOptions:
|
|||||||
def test_simple(self):
|
def test_simple(self):
|
||||||
assert self.p()
|
assert self.p()
|
||||||
|
|
||||||
def test_cadir(self):
|
|
||||||
with tutils.tmpdir() as cadir:
|
|
||||||
self.assert_noerr("--cadir", cadir)
|
|
||||||
|
|
||||||
def test_client_certs(self):
|
|
||||||
with tutils.tmpdir() as cadir:
|
|
||||||
self.assert_noerr("--client-certs", cadir)
|
|
||||||
self.assert_noerr(
|
|
||||||
"--client-certs",
|
|
||||||
os.path.join(tutils.test_data.path("mitmproxy/data/clientcert"), "client.pem"))
|
|
||||||
with pytest.raises(Exception, match="path does not exist"):
|
|
||||||
self.p("--client-certs", "nonexistent")
|
|
||||||
|
|
||||||
def test_certs(self):
|
def test_certs(self):
|
||||||
self.assert_noerr(
|
self.assert_noerr(
|
||||||
"--cert",
|
"--cert",
|
||||||
@ -70,16 +56,6 @@ class TestProcessProxyOptions:
|
|||||||
p = self.assert_noerr("--ssl-insecure")
|
p = self.assert_noerr("--ssl-insecure")
|
||||||
assert p.openssl_verification_mode_server == SSL.VERIFY_NONE
|
assert p.openssl_verification_mode_server == SSL.VERIFY_NONE
|
||||||
|
|
||||||
def test_upstream_trusted_cadir(self):
|
|
||||||
expected_dir = "/path/to/a/ca/dir"
|
|
||||||
p = self.assert_noerr("--ssl-verify-upstream-trusted-cadir", expected_dir)
|
|
||||||
assert p.options.ssl_verify_upstream_trusted_cadir == expected_dir
|
|
||||||
|
|
||||||
def test_upstream_trusted_ca(self):
|
|
||||||
expected_file = "/path/to/a/cert/file"
|
|
||||||
p = self.assert_noerr("--ssl-verify-upstream-trusted-ca", expected_file)
|
|
||||||
assert p.options.ssl_verify_upstream_trusted_ca == expected_file
|
|
||||||
|
|
||||||
|
|
||||||
class TestProxyServer:
|
class TestProxyServer:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user