aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorAmmonite <pierre@ambox.fr>2017-01-22 14:59:46 +0100
committerAmmonite <pierre@ambox.fr>2017-01-22 14:59:46 +0100
commite8fc4af4c62cc6daddea182b01ca0fd093b159c7 (patch)
tree0550889d8d44a9d0f77b346d9931be6eda62b43d /examples
parent93172460aa1d2f69aff1498ff399a286aedc6fc0 (diff)
downloadmitmproxy-e8fc4af4c62cc6daddea182b01ca0fd093b159c7.tar.gz
mitmproxy-e8fc4af4c62cc6daddea182b01ca0fd093b159c7.tar.bz2
mitmproxy-e8fc4af4c62cc6daddea182b01ca0fd093b159c7.zip
Follow PEP-8 and add comment
Diffstat (limited to 'examples')
-rw-r--r--examples/complex/dns_spoofing.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/examples/complex/dns_spoofing.py b/examples/complex/dns_spoofing.py
index eae4860b..c93930f3 100644
--- a/examples/complex/dns_spoofing.py
+++ b/examples/complex/dns_spoofing.py
@@ -30,10 +30,14 @@ parse_host_header = re.compile(r"^(?P<host>[^:]+|\[.+\])(?::(?P<port>\d+))?$")
class Rerouter:
def __init__(self):
- self.hostHeader = None
+ self.host_header = None
def requestheaders(self, flow):
- self.hostHeader = flow.request.headers.get('host')
+ """
+ The original host header is retrieved early
+ before flow.request is replaced by mitmproxy new outgoing request
+ """
+ self.host_header = flow.request.headers.get('host')
def request(self, flow):
if flow.client_conn.ssl_established:
@@ -45,14 +49,13 @@ class Rerouter:
sni = None
port = 80
- host_header = self.hostHeader
- m = parse_host_header.match(host_header)
+ m = parse_host_header.match(self.host_header)
if m:
host_header = m.group("host").strip("[]")
if m.group("port"):
port = int(m.group("port"))
- flow.request.host = sni or host_header
+ flow.request.host = sni or self.host_header
flow.request.port = port