mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-26 10:16:27 +00:00
mitmproxy: fix most flake8 offenses
This commit is contained in:
parent
e4045dc7f8
commit
7971dce223
@ -6,6 +6,7 @@ from .exceptions import Kill
|
||||
|
||||
|
||||
class Master(object):
|
||||
|
||||
"""
|
||||
The master handles mitmproxy's main event loop.
|
||||
"""
|
||||
@ -48,6 +49,7 @@ class Master(object):
|
||||
|
||||
|
||||
class ServerMaster(Master):
|
||||
|
||||
"""
|
||||
The ServerMaster adds server thread support to the master.
|
||||
"""
|
||||
@ -74,6 +76,7 @@ class ServerMaster(Master):
|
||||
|
||||
|
||||
class ServerThread(threading.Thread):
|
||||
|
||||
def __init__(self, server):
|
||||
self.server = server
|
||||
super(ServerThread, self).__init__()
|
||||
@ -85,6 +88,7 @@ class ServerThread(threading.Thread):
|
||||
|
||||
|
||||
class Channel(object):
|
||||
|
||||
"""
|
||||
The only way for the proxy server to communicate with the master
|
||||
is to use the channel it has been given.
|
||||
@ -126,6 +130,7 @@ class Channel(object):
|
||||
|
||||
|
||||
class DummyReply(object):
|
||||
|
||||
"""
|
||||
A reply object that does nothing. Useful when we need an object to seem
|
||||
like it has a channel, and during testing.
|
||||
@ -143,6 +148,7 @@ NO_REPLY = object()
|
||||
|
||||
|
||||
class Reply(object):
|
||||
|
||||
"""
|
||||
Messages sent through a channel are decorated with a "reply" attribute.
|
||||
This object is used to respond to the message through the return
|
||||
|
@ -13,6 +13,7 @@ import sys
|
||||
|
||||
|
||||
class ProxyException(Exception):
|
||||
|
||||
"""
|
||||
Base class for all exceptions thrown by mitmproxy.
|
||||
"""
|
||||
@ -22,6 +23,7 @@ class ProxyException(Exception):
|
||||
|
||||
|
||||
class Kill(ProxyException):
|
||||
|
||||
"""
|
||||
Signal that both client and server connection(s) should be killed immediately.
|
||||
"""
|
||||
@ -37,6 +39,7 @@ class TlsProtocolException(ProtocolException):
|
||||
|
||||
|
||||
class ClientHandshakeException(TlsProtocolException):
|
||||
|
||||
def __init__(self, message, server):
|
||||
super(ClientHandshakeException, self).__init__(message)
|
||||
self.server = server
|
||||
@ -67,6 +70,7 @@ class ReplayException(ProxyException):
|
||||
|
||||
|
||||
class ScriptException(ProxyException):
|
||||
|
||||
@classmethod
|
||||
def from_exception_context(cls, cut_tb=1):
|
||||
"""
|
||||
|
@ -38,6 +38,7 @@ import pyparsing as pp
|
||||
|
||||
|
||||
class _Token(object):
|
||||
|
||||
def dump(self, indent=0, fp=sys.stdout):
|
||||
print("{spacing}{name}{expr}".format(
|
||||
spacing="\t" * indent,
|
||||
|
@ -8,6 +8,7 @@ import re
|
||||
from six.moves.urllib.parse import quote
|
||||
from six.moves.urllib.parse import quote_plus
|
||||
|
||||
|
||||
def curl_command(flow):
|
||||
data = "curl "
|
||||
|
||||
@ -124,7 +125,6 @@ def locust_code(flow):
|
||||
max_wait = 3000
|
||||
""").strip()
|
||||
|
||||
|
||||
components = map(lambda x: quote(x, safe=""), flow.request.path_components)
|
||||
file_name = "_".join(components)
|
||||
name = re.sub('\W|^(?=\d)', '_', file_name)
|
||||
|
@ -10,6 +10,7 @@ from .. import stateobject, utils
|
||||
|
||||
|
||||
class ClientConnection(tcp.BaseHandler, stateobject.StateObject):
|
||||
|
||||
"""
|
||||
A client connection
|
||||
|
||||
@ -21,6 +22,7 @@ class ClientConnection(tcp.BaseHandler, stateobject.StateObject):
|
||||
timestamp_ssl_setup: TLS established timestamp
|
||||
timestamp_end: Connection end timestamp
|
||||
"""
|
||||
|
||||
def __init__(self, client_connection, address, server):
|
||||
# Eventually, this object is restored from state. We don't have a
|
||||
# connection then.
|
||||
@ -101,6 +103,7 @@ class ClientConnection(tcp.BaseHandler, stateobject.StateObject):
|
||||
|
||||
|
||||
class ServerConnection(tcp.TCPClient, stateobject.StateObject):
|
||||
|
||||
"""
|
||||
A server connection
|
||||
|
||||
@ -117,6 +120,7 @@ class ServerConnection(tcp.TCPClient, stateobject.StateObject):
|
||||
timestamp_ssl_setup: TLS established timestamp
|
||||
timestamp_end: Connection end timestamp
|
||||
"""
|
||||
|
||||
def __init__(self, address, source_address=None):
|
||||
tcp.TCPClient.__init__(self, address, source_address)
|
||||
|
||||
|
@ -109,6 +109,7 @@ class HTTPRequest(MessageMixin, Request):
|
||||
|
||||
|
||||
class HTTPResponse(MessageMixin, Response):
|
||||
|
||||
"""
|
||||
A mitmproxy HTTP response.
|
||||
This is a very thin wrapper on top of :py:class:`netlib.http.Response` and
|
||||
|
@ -6,6 +6,7 @@ from .flow import Flow
|
||||
|
||||
|
||||
class TCPMessage(Serializable):
|
||||
|
||||
def __init__(self, from_client, content, timestamp=None):
|
||||
self.content = content
|
||||
self.from_client = from_client
|
||||
@ -33,6 +34,7 @@ class TCPMessage(Serializable):
|
||||
|
||||
|
||||
class TCPFlow(Flow):
|
||||
|
||||
"""
|
||||
A TCPFlow is a simplified representation of a TCP session.
|
||||
"""
|
||||
|
@ -312,6 +312,7 @@ class TlsClientHello(object):
|
||||
|
||||
|
||||
class TlsLayer(Layer):
|
||||
|
||||
"""
|
||||
The TLS layer implements transparent TLS connections.
|
||||
|
||||
|
@ -68,6 +68,7 @@ like so::
|
||||
|
||||
"""
|
||||
import six
|
||||
from collections import deque
|
||||
|
||||
__ver_major__ = 0
|
||||
__ver_minor__ = 2
|
||||
@ -77,9 +78,6 @@ __version__ = "%d.%d.%d%s" % (
|
||||
__ver_major__, __ver_minor__, __ver_patch__, __ver_sub__)
|
||||
|
||||
|
||||
from collections import deque
|
||||
|
||||
|
||||
def dumps(value, encoding=None):
|
||||
"""dumps(object,encoding=None) -> string
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user