mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 08:11:00 +00:00
add simplified connection constructor
This commit is contained in:
parent
679c97ec3e
commit
b8b37fdad6
@ -8,7 +8,6 @@ from .. import stateobject, utils
|
||||
|
||||
|
||||
class ClientConnection(tcp.BaseHandler, stateobject.StateObject):
|
||||
|
||||
def __init__(self, client_connection, address, server):
|
||||
# Eventually, this object is restored from state. We don't have a
|
||||
# connection then.
|
||||
@ -65,6 +64,17 @@ class ClientConnection(tcp.BaseHandler, stateobject.StateObject):
|
||||
f.set_state(state)
|
||||
return f
|
||||
|
||||
@classmethod
|
||||
def make_dummy(cls, address):
|
||||
return cls.from_state(dict(
|
||||
address=dict(address=address, use_ipv6=False),
|
||||
clientcert=None,
|
||||
ssl_established=False,
|
||||
timestamp_start=None,
|
||||
timestamp_end=None,
|
||||
timestamp_ssl_setup=None
|
||||
))
|
||||
|
||||
def convert_to_ssl(self, *args, **kwargs):
|
||||
super(ClientConnection, self).convert_to_ssl(*args, **kwargs)
|
||||
self.timestamp_ssl_setup = utils.timestamp()
|
||||
@ -75,7 +85,6 @@ class ClientConnection(tcp.BaseHandler, stateobject.StateObject):
|
||||
|
||||
|
||||
class ServerConnection(tcp.TCPClient, stateobject.StateObject):
|
||||
|
||||
def __init__(self, address, source_address=None):
|
||||
tcp.TCPClient.__init__(self, address, source_address)
|
||||
|
||||
@ -123,6 +132,21 @@ class ServerConnection(tcp.TCPClient, stateobject.StateObject):
|
||||
f.set_state(state)
|
||||
return f
|
||||
|
||||
@classmethod
|
||||
def make_dummy(cls, address):
|
||||
return cls.from_state(dict(
|
||||
address=dict(address=address, use_ipv6=False),
|
||||
cert=None,
|
||||
sni=None,
|
||||
source_address=dict(address=('', 0), use_ipv6=False),
|
||||
ssl_established=False,
|
||||
timestamp_start=None,
|
||||
timestamp_tcp_setup=None,
|
||||
timestamp_ssl_setup=None,
|
||||
timestamp_end=None,
|
||||
via=None
|
||||
))
|
||||
|
||||
def copy(self):
|
||||
return copy.copy(self)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user