aboutsummaryrefslogtreecommitdiffstats
path: root/libpathod
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2014-02-07 10:50:57 +1300
committerAldo Cortesi <aldo@nullcube.com>2014-02-07 10:50:57 +1300
commit0baa296613506f20b362a4d54b6a94ec27e1097b (patch)
tree69c78dfbabf2cd25a8bb0e67439b56c0d5a4df09 /libpathod
parent1572d14cc336215a7cf8d6e20b4ad4a25bfd60ef (diff)
parentb64e1ccf9152d5f7fc7a933e1b77d18185fecb22 (diff)
downloadmitmproxy-0baa296613506f20b362a4d54b6a94ec27e1097b.tar.gz
mitmproxy-0baa296613506f20b362a4d54b6a94ec27e1097b.tar.bz2
mitmproxy-0baa296613506f20b362a4d54b6a94ec27e1097b.zip
Merge branch 'tcp_proxy'
Diffstat (limited to 'libpathod')
-rw-r--r--libpathod/pathoc.py10
-rw-r--r--libpathod/pathod.py10
-rw-r--r--libpathod/test.py2
3 files changed, 11 insertions, 11 deletions
diff --git a/libpathod/pathoc.py b/libpathod/pathoc.py
index 0769b43c..32ae8441 100644
--- a/libpathod/pathoc.py
+++ b/libpathod/pathoc.py
@@ -22,8 +22,8 @@ SSLVERSIONS = {
}
class Pathoc(tcp.TCPClient):
- def __init__(self, host, port, ssl=None, sni=None, sslversion=1, clientcert=None):
- tcp.TCPClient.__init__(self, host, port)
+ def __init__(self, address, ssl=None, sni=None, sslversion=1, clientcert=None):
+ tcp.TCPClient.__init__(self, address)
self.settings = dict(
staticdir = os.getcwd(),
unconstrained_file_access = True,
@@ -68,7 +68,7 @@ class Pathoc(tcp.TCPClient):
language.FileAccessDenied.
"""
r = language.parse_request(self.settings, spec)
- language.serve(r, self.wfile, self.settings, self.host)
+ language.serve(r, self.wfile, self.settings, self.address.host)
self.wfile.flush()
return Response(*http.read_response(self.rfile, r.method, None))
@@ -109,7 +109,7 @@ class Pathoc(tcp.TCPClient):
return
if explain:
- r = r.freeze(self.settings, self.host)
+ r = r.freeze(self.settings, self.address.host)
resp, req = None, None
if showreq:
@@ -117,7 +117,7 @@ class Pathoc(tcp.TCPClient):
if showresp:
self.rfile.start_log()
try:
- req = language.serve(r, self.wfile, self.settings, self.host)
+ req = language.serve(r, self.wfile, self.settings, self.address.host)
self.wfile.flush()
resp = http.read_response(self.rfile, r.method, None)
except http.HttpError, v:
diff --git a/libpathod/pathod.py b/libpathod/pathod.py
index 93f7a8ae..e71701fb 100644
--- a/libpathod/pathod.py
+++ b/libpathod/pathod.py
@@ -21,7 +21,7 @@ class PathodHandler(tcp.BaseHandler):
wbufsize = 0
sni = None
def info(self, s):
- logger.info("%s:%s: %s"%(self.client_address[0], self.client_address[1], str(s)))
+ logger.info("%s:%s: %s"%(self.address.host, self.address.port, str(s)))
def handle_sni(self, connection):
self.sni = connection.get_servername()
@@ -118,7 +118,7 @@ class PathodHandler(tcp.BaseHandler):
headers = headers.lst,
httpversion = httpversion,
sni = self.sni,
- remote_address = self.client_address,
+ remote_address = self.address(),
clientcert = clientcert
)
@@ -155,13 +155,13 @@ class PathodHandler(tcp.BaseHandler):
return False, dict(type = "error", msg="Access denied: web interface disabled")
else:
self.info("app: %s %s"%(method, path))
- cc = wsgi.ClientConn(self.client_address)
+ cc = wsgi.ClientConn(self.address())
req = wsgi.Request(cc, "http", method, path, headers, content)
sn = self.connection.getsockname()
a = wsgi.WSGIAdaptor(
self.server.app,
sn[0],
- self.server.port,
+ self.server.address.port,
version.NAMEVERSION
)
a.serve(req, self.wfile)
@@ -282,7 +282,7 @@ class Pathod(tcp.TCPServer):
staticdir = self.staticdir
)
- def handle_connection(self, request, client_address):
+ def handle_client_connection(self, request, client_address):
h = PathodHandler(request, client_address, self)
try:
h.handle()
diff --git a/libpathod/test.py b/libpathod/test.py
index cc858497..11c62303 100644
--- a/libpathod/test.py
+++ b/libpathod/test.py
@@ -75,5 +75,5 @@ class _PaThread(threading.Thread):
ssl = self.ssl,
**self.daemonargs
)
- self.q.put(self.server.port)
+ self.q.put(self.server.address.port)
self.server.serve_forever()