ManInTheMiddleAmongUs/handler.py

23 lines
582 B
Python

import binascii
import itertools
from colordiff import Color, Diff
d_c = Diff(Color.GREEN, Color.RED)
d_s = Diff(Color.BLUE, Color.YELLOW)
def handle(tag: str, data: str):
if tag == "stdin":
print(f"[stdin] {data}")
if data.startswith("0c") or data.startswith("0a"):
if tag == "server":
print(f"{Color.YELLOW}{data}{Color.RESET}")
elif tag == "client":
print(f"{Color.RED}{data}{Color.RESET}")
else:
if tag == "server":
d_s.consume(data)
elif tag == "client":
d_c.consume(data)