aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy
diff options
context:
space:
mode:
Diffstat (limited to 'libmproxy')
-rw-r--r--libmproxy/cmdline.py2
-rw-r--r--libmproxy/console/flowview.py4
-rw-r--r--libmproxy/protocol/__init__.py2
-rw-r--r--libmproxy/proxy/server.py20
4 files changed, 15 insertions, 13 deletions
diff --git a/libmproxy/cmdline.py b/libmproxy/cmdline.py
index 6c0cae9f..bee4aa60 100644
--- a/libmproxy/cmdline.py
+++ b/libmproxy/cmdline.py
@@ -209,7 +209,7 @@ def common_options(parser):
action="store", type = int, dest="port", default=8080,
help = "Proxy service port."
)
- # We could make a mutually exclusive group out of -R, -F, -T, but we don't do because
+ # We could make a mutually exclusive group out of -R, -F, -T, but we don't do that because
# - --upstream-server should be in that group as well, but it's already in a different group.
# - our own error messages are more helpful
parser.add_argument(
diff --git a/libmproxy/console/flowview.py b/libmproxy/console/flowview.py
index f5b5f83f..9b636840 100644
--- a/libmproxy/console/flowview.py
+++ b/libmproxy/console/flowview.py
@@ -2,7 +2,7 @@ import os, sys, copy
import urwid
import common, grideditor, contentview
from .. import utils, flow, controller
-from ..protocol.http import CONTENT_MISSING
+from ..protocol.http import HTTPResponse, CONTENT_MISSING
class SearchError(Exception): pass
@@ -571,7 +571,7 @@ class FlowView(common.WWrap):
conn = self.flow.request
else:
if not self.flow.response:
- self.flow.response = flow.Response(
+ self.flow.response = HTTPResponse(
self.flow.request,
self.flow.request.httpversion,
200, "OK", flow.ODictCaseless(), "", None
diff --git a/libmproxy/protocol/__init__.py b/libmproxy/protocol/__init__.py
index 6200757f..b253fbd5 100644
--- a/libmproxy/protocol/__init__.py
+++ b/libmproxy/protocol/__init__.py
@@ -1,4 +1,4 @@
-from libmproxy.proxy.primitives import AddressPriority
+from ..proxy.primitives import AddressPriority
KILL = 0 # const for killed requests
diff --git a/libmproxy/proxy/server.py b/libmproxy/proxy/server.py
index 554ee551..c77ab2a8 100644
--- a/libmproxy/proxy/server.py
+++ b/libmproxy/proxy/server.py
@@ -1,10 +1,9 @@
import socket
-from .. import version, protocol
-from libmproxy.proxy.primitives import Log
-from .primitives import ProxyServerError
-from .connection import ClientConnection, ServerConnection
-from .primitives import ProxyError, ConnectionTypeChange, AddressPriority
+from OpenSSL import SSL
from netlib import tcp
+from .primitives import ProxyServerError, Log, ProxyError, ConnectionTypeChange, AddressPriority
+from .connection import ClientConnection, ServerConnection
+from .. import version, protocol
class DummyServer:
@@ -23,6 +22,7 @@ class DummyServer:
class ProxyServer(tcp.TCPServer):
allow_reuse_address = True
bound = True
+
def __init__(self, config, port, host='', server_version=version.NAMEVERSION):
"""
Raises ProxyServerError if there's a startup problem.
@@ -51,8 +51,11 @@ class ProxyServer(tcp.TCPServer):
class ConnectionHandler:
def __init__(self, config, client_connection, client_address, server, channel, server_version):
self.config = config
+ """@type: libmproxy.proxy.config.ProxyConfig"""
self.client_conn = ClientConnection(client_connection, client_address, server)
+ """@type: libmproxy.proxy.connection.ClientConnection"""
self.server_conn = None
+ """@type: libmproxy.proxy.connection.ServerConnection"""
self.channel, self.server_version = channel, server_version
self.close = False
@@ -98,7 +101,7 @@ class ConnectionHandler:
def del_server_connection(self):
"""
- Deletes an existing server connection.
+ Deletes (and closes) an existing server connection.
"""
if self.server_conn and self.server_conn.connection:
self.server_conn.finish()
@@ -150,8 +153,7 @@ class ConnectionHandler:
"""
Establishes SSL on the existing connection(s) to the server or the client,
as specified by the parameters. If the target server is on the pass-through list,
- the conntype attribute will be changed and the SSL connection won't be wrapped.
- A protocol handler must raise a ConnTypeChanged exception if it detects that this is happening
+ the conntype attribute will be changed and a ConnTypeChanged exception will be raised.
"""
# TODO: Implement SSL pass-through handling and change conntype
passthrough = [
@@ -160,7 +162,7 @@ class ConnectionHandler:
]
if self.server_conn.address.host in passthrough or self.sni in passthrough:
self.conntype = "tcp"
- return
+ raise ConnectionTypeChange
# Logging
if client or server: