diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2012-06-26 20:49:34 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2012-06-26 20:49:34 +1200 |
commit | e6cdbefb3b741e0123ef76273566a5aaadc706b8 (patch) | |
tree | 1cfc97521ce9bcbea95ac94a5c9b0555968809b3 /libmproxy/proxy.py | |
parent | ad893ad134cdc03f9152548e39a1dbce896cbee4 (diff) | |
download | mitmproxy-e6cdbefb3b741e0123ef76273566a5aaadc706b8.tar.gz mitmproxy-e6cdbefb3b741e0123ef76273566a5aaadc706b8.tar.bz2 mitmproxy-e6cdbefb3b741e0123ef76273566a5aaadc706b8.zip |
Add transparent mode platform module for Linux.
Diffstat (limited to 'libmproxy/proxy.py')
-rw-r--r-- | libmproxy/proxy.py | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/libmproxy/proxy.py b/libmproxy/proxy.py index 3ab93790..efa1c5e4 100644 --- a/libmproxy/proxy.py +++ b/libmproxy/proxy.py @@ -17,7 +17,7 @@ import shutil, tempfile, threading import optparse, SocketServer from OpenSSL import SSL from netlib import odict, tcp, http, wsgi -import utils, flow, certutils, version +import utils, flow, certutils, version, platform class ProxyError(Exception): @@ -222,7 +222,10 @@ class ProxyHandler(tcp.BaseHandler): self.convert_to_ssl(certfile, self.config.certfile or self.config.cacert) else: scheme = "http" - method, path, httpversion = http.parse_init_http(line) + r = http.parse_init_http(line) + if not r: + raise ProxyError(400, "Bad HTTP request line.") + method, path, httpversion = r headers = http.read_headers(self.rfile) content = http.read_http_body_request( self.rfile, self.wfile, headers, httpversion, self.config.body_size_limit @@ -230,7 +233,10 @@ class ProxyHandler(tcp.BaseHandler): return flow.Request(client_conn, httpversion, host, port, "http", method, path, headers, content) elif self.config.reverse_proxy: scheme, host, port = self.config.reverse_proxy - method, path, httpversion = http.parse_init_http(line) + r = http.parse_init_http(line) + if not r: + raise ProxyError(400, "Bad HTTP request line.") + method, path, httpversion = r headers = http.read_headers(self.rfile) content = http.read_http_body_request( self.rfile, self.wfile, headers, httpversion, self.config.body_size_limit @@ -257,7 +263,10 @@ class ProxyHandler(tcp.BaseHandler): line = self.rfile.readline(line) if self.proxy_connect_state: host, port, httpversion = self.proxy_connect_state - method, path, httpversion = http.parse_init_http(line) + r = http.parse_init_http(line) + if not r: + raise ProxyError(400, "Bad HTTP request line.") + method, path, httpversion = r headers = http.read_headers(self.rfile) content = http.read_http_body_request( self.rfile, self.wfile, headers, httpversion, self.config.body_size_limit @@ -400,7 +409,7 @@ def process_proxy_options(parser, options): if options.transparent_proxy: trans = dict( - resolver = None, + resolver = platform.resolver, sslports = TRANSPARENT_SSL_PORTS ) else: |