aboutsummaryrefslogtreecommitdiffstats
path: root/libpathod/pathod.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2013-01-05 17:06:41 +1300
committerAldo Cortesi <aldo@nullcube.com>2013-01-05 17:15:42 +1300
commitc744ef2dcbb95182668ed8897542029c6c6734b9 (patch)
tree143b97667093615c43f25b93dcb4f21b84eea21a /libpathod/pathod.py
parent1e932e704577ff8159f93d424d4b7041dec29eea (diff)
downloadmitmproxy-c744ef2dcbb95182668ed8897542029c6c6734b9.tar.gz
mitmproxy-c744ef2dcbb95182668ed8897542029c6c6734b9.tar.bz2
mitmproxy-c744ef2dcbb95182668ed8897542029c6c6734b9.zip
Proxy mode: drop to SSL if we see an HTTP CONNECT request
Diffstat (limited to 'libpathod/pathod.py')
-rw-r--r--libpathod/pathod.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/libpathod/pathod.py b/libpathod/pathod.py
index 48aa076f..fa5d519c 100644
--- a/libpathod/pathod.py
+++ b/libpathod/pathod.py
@@ -63,14 +63,24 @@ class PathodHandler(tcp.BaseHandler):
m = utils.MemBool()
if m(http.parse_init_connect(line)):
+ headers = http.read_headers(self.rfile)
self.wfile.write(
'HTTP/1.1 200 Connection established\r\n' +
('Proxy-agent: %s\r\n'%version.NAMEVERSION) +
'\r\n'
)
self.wfile.flush()
-
- if m(http.parse_init_proxy(line)):
+ try:
+ self.convert_to_ssl(
+ self.server.ssloptions.certfile,
+ self.server.ssloptions.keyfile,
+ )
+ except tcp.NetLibError, v:
+ s = str(v)
+ self.info(s)
+ return False, dict(type = "error", msg = s)
+ return True, None
+ elif m(http.parse_init_proxy(line)):
method, _, _, _, path, httpversion = m.v
elif m(http.parse_init_http(line)):
method, path, httpversion = m.v