mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2025-02-07 10:40:09 +00:00
websocket: change cmdline option
This commit is contained in:
parent
aaa4ccc284
commit
4beb693c9c
@ -73,7 +73,7 @@ class Options(optmanager.OptManager):
|
|||||||
mode: str = "regular",
|
mode: str = "regular",
|
||||||
no_upstream_cert: bool = False,
|
no_upstream_cert: bool = False,
|
||||||
rawtcp: bool = False,
|
rawtcp: bool = False,
|
||||||
websockets: bool = False,
|
websocket: bool = True,
|
||||||
spoof_source_address: bool = False,
|
spoof_source_address: bool = False,
|
||||||
upstream_server: Optional[str] = None,
|
upstream_server: Optional[str] = None,
|
||||||
upstream_auth: Optional[str] = None,
|
upstream_auth: Optional[str] = None,
|
||||||
@ -136,7 +136,7 @@ class Options(optmanager.OptManager):
|
|||||||
self.mode = mode
|
self.mode = mode
|
||||||
self.no_upstream_cert = no_upstream_cert
|
self.no_upstream_cert = no_upstream_cert
|
||||||
self.rawtcp = rawtcp
|
self.rawtcp = rawtcp
|
||||||
self.websockets = websockets
|
self.websocket = websocket
|
||||||
self.spoof_source_address = spoof_source_address
|
self.spoof_source_address = spoof_source_address
|
||||||
self.upstream_server = upstream_server
|
self.upstream_server = upstream_server
|
||||||
self.upstream_auth = upstream_auth
|
self.upstream_auth = upstream_auth
|
||||||
|
@ -398,13 +398,13 @@ class HttpLayer(base.Layer):
|
|||||||
websockets.check_handshake(f.request.headers) and
|
websockets.check_handshake(f.request.headers) and
|
||||||
websockets.check_handshake(f.response.headers)
|
websockets.check_handshake(f.response.headers)
|
||||||
)
|
)
|
||||||
if is_websocket and not self.config.options.websockets:
|
if is_websocket and not self.config.options.websocket:
|
||||||
self.log(
|
self.log(
|
||||||
"Client requested WebSocket connection, but the protocol is disabled.",
|
"Client requested WebSocket connection, but the protocol is disabled.",
|
||||||
"info"
|
"info"
|
||||||
)
|
)
|
||||||
|
|
||||||
if is_websocket and self.config.options.websockets:
|
if is_websocket and self.config.options.websocket:
|
||||||
layer = WebSocketLayer(self, f)
|
layer = WebSocketLayer(self, f)
|
||||||
else:
|
else:
|
||||||
layer = self.ctx.next_layer(self)
|
layer = self.ctx.next_layer(self)
|
||||||
|
@ -256,7 +256,7 @@ def get_common_options(args):
|
|||||||
no_upstream_cert = args.no_upstream_cert,
|
no_upstream_cert = args.no_upstream_cert,
|
||||||
spoof_source_address = args.spoof_source_address,
|
spoof_source_address = args.spoof_source_address,
|
||||||
rawtcp = args.rawtcp,
|
rawtcp = args.rawtcp,
|
||||||
websockets = args.websockets,
|
websocket = args.websocket,
|
||||||
upstream_server = upstream_server,
|
upstream_server = upstream_server,
|
||||||
upstream_auth = args.upstream_auth,
|
upstream_auth = args.upstream_auth,
|
||||||
ssl_version_client = args.ssl_version_client,
|
ssl_version_client = args.ssl_version_client,
|
||||||
@ -459,6 +459,12 @@ def proxy_options(parser):
|
|||||||
If your OpenSSL version supports ALPN, HTTP/2 is enabled by default.
|
If your OpenSSL version supports ALPN, HTTP/2 is enabled by default.
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
group.add_argument(
|
||||||
|
"--no-websocket",
|
||||||
|
action="store_false", dest="websocket",
|
||||||
|
help="Explicitly disable WebSocket support."
|
||||||
|
)
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--upstream-auth",
|
"--upstream-auth",
|
||||||
action="store", dest="upstream_auth", default=None,
|
action="store", dest="upstream_auth", default=None,
|
||||||
@ -468,6 +474,7 @@ def proxy_options(parser):
|
|||||||
requests. Format: username:password
|
requests. Format: username:password
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
rawtcp = group.add_mutually_exclusive_group()
|
rawtcp = group.add_mutually_exclusive_group()
|
||||||
rawtcp.add_argument("--raw-tcp", action="store_true", dest="rawtcp")
|
rawtcp.add_argument("--raw-tcp", action="store_true", dest="rawtcp")
|
||||||
rawtcp.add_argument("--no-raw-tcp", action="store_false", dest="rawtcp",
|
rawtcp.add_argument("--no-raw-tcp", action="store_false", dest="rawtcp",
|
||||||
@ -475,13 +482,7 @@ def proxy_options(parser):
|
|||||||
"Disabled by default. "
|
"Disabled by default. "
|
||||||
"Default value will change in a future version."
|
"Default value will change in a future version."
|
||||||
)
|
)
|
||||||
websockets = group.add_mutually_exclusive_group()
|
|
||||||
websockets.add_argument("--websockets", action="store_true", dest="websockets")
|
|
||||||
websockets.add_argument("--no-websockets", action="store_false", dest="websockets",
|
|
||||||
help="Explicitly enable/disable experimental WebSocket support. "
|
|
||||||
"Disabled by default as messages are only printed to the event log and not retained. "
|
|
||||||
"Default value will change in a future version."
|
|
||||||
)
|
|
||||||
group.add_argument(
|
group.add_argument(
|
||||||
"--spoof-source-address",
|
"--spoof-source-address",
|
||||||
action="store_true", dest="spoof_source_address",
|
action="store_true", dest="spoof_source_address",
|
||||||
|
@ -64,7 +64,7 @@ class _WebSocketTestBase:
|
|||||||
listen_port=0,
|
listen_port=0,
|
||||||
no_upstream_cert=False,
|
no_upstream_cert=False,
|
||||||
ssl_insecure=True,
|
ssl_insecure=True,
|
||||||
websockets=True,
|
websocket=True,
|
||||||
)
|
)
|
||||||
opts.cadir = os.path.join(tempfile.gettempdir(), "mitmproxy")
|
opts.cadir = os.path.join(tempfile.gettempdir(), "mitmproxy")
|
||||||
return opts
|
return opts
|
||||||
|
Loading…
Reference in New Issue
Block a user