aboutsummaryrefslogtreecommitdiffstats
path: root/examples/tcp_message.py
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2016-07-15 23:17:57 -0700
committerMaximilian Hils <git@maximilianhils.com>2016-07-15 23:17:57 -0700
commit3602fd7a36d963311339ab11ed36ff00df860f71 (patch)
tree5834a98b35c02639c876544bc645f205068fac99 /examples/tcp_message.py
parenta3c7c84d49c3e6563e7f37ef60c989f99ed96788 (diff)
parent17305643bc482c0b185eec5c64d506790cd26587 (diff)
downloadmitmproxy-3602fd7a36d963311339ab11ed36ff00df860f71.tar.gz
mitmproxy-3602fd7a36d963311339ab11ed36ff00df860f71.tar.bz2
mitmproxy-3602fd7a36d963311339ab11ed36ff00df860f71.zip
Merge remote-tracking branch 'origin/master' into message-body-encoding
Diffstat (limited to 'examples/tcp_message.py')
-rw-r--r--examples/tcp_message.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/examples/tcp_message.py b/examples/tcp_message.py
index 78500c19..b431c23f 100644
--- a/examples/tcp_message.py
+++ b/examples/tcp_message.py
@@ -11,15 +11,17 @@ mitmdump -T --host --tcp ".*" -q -s examples/tcp_message.py
from netlib import strutils
-def tcp_message(ctx, tcp_msg):
+def tcp_message(tcp_msg):
modified_msg = tcp_msg.message.replace("foo", "bar")
is_modified = False if modified_msg == tcp_msg.message else True
tcp_msg.message = modified_msg
- print("[tcp_message{}] from {} {} to {} {}:\r\n{}".format(
- " (modified)" if is_modified else "",
- "client" if tcp_msg.sender == tcp_msg.client_conn else "server",
- tcp_msg.sender.address,
- "server" if tcp_msg.receiver == tcp_msg.server_conn else "client",
- tcp_msg.receiver.address, strutils.clean_bin(tcp_msg.message)))
+ print(
+ "[tcp_message{}] from {} {} to {} {}:\r\n{}".format(
+ " (modified)" if is_modified else "",
+ "client" if tcp_msg.sender == tcp_msg.client_conn else "server",
+ tcp_msg.sender.address,
+ "server" if tcp_msg.receiver == tcp_msg.server_conn else "client",
+ tcp_msg.receiver.address, strutils.bytes_to_escaped_str(tcp_msg.message))
+ )