diff options
author | Maximilian Hils <git@maximilianhils.com> | 2020-04-08 20:21:12 +0200 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2020-04-08 20:21:12 +0200 |
commit | 9d5305301a8e073cbb64bb6574e66bb34373935a (patch) | |
tree | 7f30b0412a9974751846c757d44889694d00dc7b /examples/simple | |
parent | 40925181e9d64c727f75e89acf0205bb4b87bb3a (diff) | |
parent | 4d6886a0f4ebbf6bc66b74fa548ff724ba2ad660 (diff) | |
download | mitmproxy-9d5305301a8e073cbb64bb6574e66bb34373935a.tar.gz mitmproxy-9d5305301a8e073cbb64bb6574e66bb34373935a.tar.bz2 mitmproxy-9d5305301a8e073cbb64bb6574e66bb34373935a.zip |
Merge remote-tracking branch 'origin/master' into fix-ci
Diffstat (limited to 'examples/simple')
-rw-r--r-- | examples/simple/websocket_messages.py | 11 | ||||
-rw-r--r-- | examples/simple/wsgi_flask_app.py | 6 |
2 files changed, 12 insertions, 5 deletions
diff --git a/examples/simple/websocket_messages.py b/examples/simple/websocket_messages.py index 719e7b10..071ea21f 100644 --- a/examples/simple/websocket_messages.py +++ b/examples/simple/websocket_messages.py @@ -6,8 +6,15 @@ def websocket_message(flow): # get the latest message message = flow.messages[-1] - # simply print the content of the message - ctx.log.info(message.content) + # was the message sent from the client or server? + if message.from_client: + ctx.log.info("Client sent a message: {}".format(message.content)) + else: + ctx.log.info("Server sent a message: {}".format(message.content)) # manipulate the message content message.content = re.sub(r'^Hello', 'HAPPY', message.content) + + if 'FOOBAR' in message.content: + # kill the message and not send it to the other endpoint + message.kill() diff --git a/examples/simple/wsgi_flask_app.py b/examples/simple/wsgi_flask_app.py index 4be38000..bbde6913 100644 --- a/examples/simple/wsgi_flask_app.py +++ b/examples/simple/wsgi_flask_app.py @@ -14,12 +14,12 @@ def hello_world() -> str: return 'Hello World!' -def load(l): +addons = [ # Host app at the magic domain "proxapp.local" on port 80. Requests to this # domain and port combination will now be routed to the WSGI app instance. - return wsgiapp.WSGIApp(app, "proxapp.local", 80) - + wsgiapp.WSGIApp(app, "proxapp.local", 80) # SSL works too, but the magic domain needs to be resolvable from the mitmproxy machine due to mitmproxy's design. # mitmproxy will connect to said domain and use serve its certificate (unless --no-upstream-cert is set) # but won't send any data. # mitmproxy.ctx.master.apps.add(app, "example.com", 443) +] |