aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.travis.yml2
-rw-r--r--examples/libpathod_pathoc.py2
-rw-r--r--libpathod/pathoc.py10
-rw-r--r--libpathod/pathod.py10
-rw-r--r--libpathod/test.py2
-rwxr-xr-xpathoc3
-rw-r--r--test/test_pathoc.py15
-rw-r--r--test/test_pathod.py4
-rw-r--r--test/tutils.py2
9 files changed, 23 insertions, 27 deletions
diff --git a/.travis.yml b/.travis.yml
index 2cc19030..80f989b9 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -3,7 +3,7 @@ python:
- "2.7"
# command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors
install:
- - "pip install --upgrade git+https://github.com/mitmproxy/netlib.git"
+ - "pip install --upgrade git+https://github.com/mitmproxy/netlib.git@tcp_proxy"
- "pip install -r requirements.txt --use-mirrors"
- "pip install -r test/requirements.txt --use-mirrors"
# command to run tests, e.g. python setup.py test
diff --git a/examples/libpathod_pathoc.py b/examples/libpathod_pathoc.py
index ca53b08f..cf94151b 100644
--- a/examples/libpathod_pathoc.py
+++ b/examples/libpathod_pathoc.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
from libpathod import pathoc
-p = pathoc.Pathoc("google.com", 80)
+p = pathoc.Pathoc(("google.com", 80))
p.connect()
print p.request("get:/")
print p.request("get:/foo")
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()
diff --git a/pathoc b/pathoc
index de8ae948..c553f68c 100755
--- a/pathoc
+++ b/pathoc
@@ -129,8 +129,7 @@ if __name__ == "__main__":
try:
for i in range(args.repeat):
p = pathoc.Pathoc(
- args.host,
- port,
+ (args.host, port),
ssl=args.ssl,
sni=args.sni,
sslversion=args.sslversion,
diff --git a/test/test_pathoc.py b/test/test_pathoc.py
index 7493b2e7..d96a1728 100644
--- a/test/test_pathoc.py
+++ b/test/test_pathoc.py
@@ -27,8 +27,7 @@ class _TestDaemon:
def test_info(self):
c = pathoc.Pathoc(
- "127.0.0.1",
- self.d.port,
+ ("127.0.0.1", self.d.port),
ssl = self.ssl
)
c.connect()
@@ -41,8 +40,7 @@ class TestDaemonSSL(_TestDaemon):
ssloptions = pathod.SSLOptions(request_client_cert=True)
def test_sni(self):
c = pathoc.Pathoc(
- "127.0.0.1",
- self.d.port,
+ ("127.0.0.1", self.d.port),
ssl = True,
sni = "foobar.com"
)
@@ -54,8 +52,7 @@ class TestDaemonSSL(_TestDaemon):
def test_clientcert(self):
c = pathoc.Pathoc(
- "127.0.0.1",
- self.d.port,
+ ("127.0.0.1", self.d.port),
ssl = True,
clientcert = tutils.test_data.path("data/clientcert/client.pem")
)
@@ -69,7 +66,7 @@ class TestDaemonSSL(_TestDaemon):
class TestDaemon(_TestDaemon):
ssl = False
def tval(self, requests, showreq=False, showresp=False, explain=False, hexdump=False, timeout=None, ignorecodes=None, ignoretimeout=None):
- c = pathoc.Pathoc("127.0.0.1", self.d.port)
+ c = pathoc.Pathoc(("127.0.0.1", self.d.port))
c.connect()
if timeout:
c.settimeout(timeout)
@@ -88,7 +85,7 @@ class TestDaemon(_TestDaemon):
return s.getvalue()
def test_ssl_error(self):
- c = pathoc.Pathoc("127.0.0.1", self.d.port, ssl = True)
+ c = pathoc.Pathoc(("127.0.0.1", self.d.port), ssl = True)
tutils.raises("ssl handshake", c.connect)
def test_ignorecodes(self):
@@ -135,7 +132,7 @@ class TestDaemon(_TestDaemon):
def test_connect_fail(self):
to = ("foobar", 80)
- c = pathoc.Pathoc("127.0.0.1", self.d.port)
+ c = pathoc.Pathoc(("127.0.0.1", self.d.port))
c.rfile, c.wfile = cStringIO.StringIO(), cStringIO.StringIO()
tutils.raises("connect failed", c.http_connect, to)
c.rfile = cStringIO.StringIO(
diff --git a/test/test_pathod.py b/test/test_pathod.py
index 9cd90e94..9ab6d66d 100644
--- a/test/test_pathod.py
+++ b/test/test_pathod.py
@@ -120,7 +120,7 @@ class CommonTests(tutils.DaemonTests):
assert rsp.status_code == 202
def test_invalid_first_line(self):
- c = tcp.TCPClient("localhost", self.d.port)
+ c = tcp.TCPClient(("localhost", self.d.port))
c.connect()
if self.ssl:
c.convert_to_ssl()
@@ -169,7 +169,7 @@ class TestDaemon(CommonTests):
class TestDaemonSSL(CommonTests):
ssl = True
def test_ssl_conn_failure(self):
- c = tcp.TCPClient("localhost", self.d.port)
+ c = tcp.TCPClient(("localhost", self.d.port))
c.rbufsize = 0
c.wbufsize = 0
c.connect()
diff --git a/test/tutils.py b/test/tutils.py
index 59649053..1baf16e2 100644
--- a/test/tutils.py
+++ b/test/tutils.py
@@ -50,7 +50,7 @@ class DaemonTests:
def pathoc(self, spec, timeout=None, connect_to=None, ssl=None):
if ssl is None:
ssl = self.ssl
- c = pathoc.Pathoc("localhost", self.d.port, ssl=ssl)
+ c = pathoc.Pathoc(("localhost", self.d.port), ssl=ssl)
c.connect(connect_to)
if timeout:
c.settimeout(timeout)