aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Kriechbaumer <thomas@kriechbaumer.name>2016-11-13 21:26:50 +0100
committerThomas Kriechbaumer <thomas@kriechbaumer.name>2016-11-23 10:18:45 +0100
commit4beb693c9c990e613bb76462f7f24555630cc934 (patch)
tree2234053b6d44b3a91bf7c980c1b2f5cadb2bf1db
parentaaa4ccc28461cd69d0bfb5d0a4eed59c86b88ea1 (diff)
downloadmitmproxy-4beb693c9c990e613bb76462f7f24555630cc934.tar.gz
mitmproxy-4beb693c9c990e613bb76462f7f24555630cc934.tar.bz2
mitmproxy-4beb693c9c990e613bb76462f7f24555630cc934.zip
websocket: change cmdline option
-rw-r--r--mitmproxy/options.py4
-rw-r--r--mitmproxy/proxy/protocol/http.py4
-rw-r--r--mitmproxy/tools/cmdline.py17
-rw-r--r--test/mitmproxy/protocol/test_websocket.py2
4 files changed, 14 insertions, 13 deletions
diff --git a/mitmproxy/options.py b/mitmproxy/options.py
index 6f41bf85..8a9385da 100644
--- a/mitmproxy/options.py
+++ b/mitmproxy/options.py
@@ -73,7 +73,7 @@ class Options(optmanager.OptManager):
mode: str = "regular",
no_upstream_cert: bool = False,
rawtcp: bool = False,
- websockets: bool = False,
+ websocket: bool = True,
spoof_source_address: bool = False,
upstream_server: Optional[str] = None,
upstream_auth: Optional[str] = None,
@@ -136,7 +136,7 @@ class Options(optmanager.OptManager):
self.mode = mode
self.no_upstream_cert = no_upstream_cert
self.rawtcp = rawtcp
- self.websockets = websockets
+ self.websocket = websocket
self.spoof_source_address = spoof_source_address
self.upstream_server = upstream_server
self.upstream_auth = upstream_auth
diff --git a/mitmproxy/proxy/protocol/http.py b/mitmproxy/proxy/protocol/http.py
index 2da4ddbf..89e53d00 100644
--- a/mitmproxy/proxy/protocol/http.py
+++ b/mitmproxy/proxy/protocol/http.py
@@ -398,13 +398,13 @@ class HttpLayer(base.Layer):
websockets.check_handshake(f.request.headers) and
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(
"Client requested WebSocket connection, but the protocol is disabled.",
"info"
)
- if is_websocket and self.config.options.websockets:
+ if is_websocket and self.config.options.websocket:
layer = WebSocketLayer(self, f)
else:
layer = self.ctx.next_layer(self)
diff --git a/mitmproxy/tools/cmdline.py b/mitmproxy/tools/cmdline.py
index 1ad521b5..d5a43f28 100644
--- a/mitmproxy/tools/cmdline.py
+++ b/mitmproxy/tools/cmdline.py
@@ -256,7 +256,7 @@ def get_common_options(args):
no_upstream_cert = args.no_upstream_cert,
spoof_source_address = args.spoof_source_address,
rawtcp = args.rawtcp,
- websockets = args.websockets,
+ websocket = args.websocket,
upstream_server = upstream_server,
upstream_auth = args.upstream_auth,
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.
"""
)
+ group.add_argument(
+ "--no-websocket",
+ action="store_false", dest="websocket",
+ help="Explicitly disable WebSocket support."
+ )
+
parser.add_argument(
"--upstream-auth",
action="store", dest="upstream_auth", default=None,
@@ -468,6 +474,7 @@ def proxy_options(parser):
requests. Format: username:password
"""
)
+
rawtcp = group.add_mutually_exclusive_group()
rawtcp.add_argument("--raw-tcp", action="store_true", dest="rawtcp")
rawtcp.add_argument("--no-raw-tcp", action="store_false", dest="rawtcp",
@@ -475,13 +482,7 @@ def proxy_options(parser):
"Disabled by default. "
"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(
"--spoof-source-address",
action="store_true", dest="spoof_source_address",
diff --git a/test/mitmproxy/protocol/test_websocket.py b/test/mitmproxy/protocol/test_websocket.py
index 93997045..c5db9341 100644
--- a/test/mitmproxy/protocol/test_websocket.py
+++ b/test/mitmproxy/protocol/test_websocket.py
@@ -64,7 +64,7 @@ class _WebSocketTestBase:
listen_port=0,
no_upstream_cert=False,
ssl_insecure=True,
- websockets=True,
+ websocket=True,
)
opts.cadir = os.path.join(tempfile.gettempdir(), "mitmproxy")
return opts