""" Usage: mitmproxy -p 443 -s dns_spoofing.py -R http://localhost:8000 """ def request(flow): flow.request.scheme = "http" sni = flow.client_conn.connection.get_servername() if sni == b"ws.audioscrobbler.com": flow.request.port = 3001 else: flow.request.port = 8000