mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-30 03:14:22 +00:00
mark unused variables and arguments
This commit is contained in:
parent
40436ffb1f
commit
69e71097f7
@ -1,5 +1,8 @@
|
|||||||
max-line-length: 120
|
max-line-length: 120
|
||||||
pylint:
|
pylint:
|
||||||
|
options:
|
||||||
|
dummy-variables-rgx: _$|.+_$|dummy_.+
|
||||||
|
|
||||||
disable:
|
disable:
|
||||||
- missing-docstring
|
- missing-docstring
|
||||||
- protected-access
|
- protected-access
|
||||||
|
@ -333,7 +333,7 @@ class CertStore(object):
|
|||||||
|
|
||||||
return entry.cert, entry.privatekey, entry.chain_file
|
return entry.cert, entry.privatekey, entry.chain_file
|
||||||
|
|
||||||
def gen_pkey(self, cert):
|
def gen_pkey(self, cert_):
|
||||||
# FIXME: We should do something with cert here?
|
# FIXME: We should do something with cert here?
|
||||||
from . import certffi
|
from . import certffi
|
||||||
certffi.set_flags(self.default_privatekey, 1)
|
certffi.set_flags(self.default_privatekey, 1)
|
||||||
|
@ -116,7 +116,8 @@ class Frame(object):
|
|||||||
self.length = len(self.payload_bytes())
|
self.length = len(self.payload_bytes())
|
||||||
|
|
||||||
return "\n".join([
|
return "\n".join([
|
||||||
"%s: %s | length: %d | flags: %#x | stream_id: %d" % (direction, self.__class__.__name__, self.length, self.flags, self.stream_id),
|
"%s: %s | length: %d | flags: %#x | stream_id: %d" % (
|
||||||
|
direction, self.__class__.__name__, self.length, self.flags, self.stream_id),
|
||||||
self.payload_human_readable(),
|
self.payload_human_readable(),
|
||||||
"===============================================================",
|
"===============================================================",
|
||||||
])
|
])
|
||||||
|
@ -59,8 +59,8 @@ class HTTP2Protocol(object):
|
|||||||
while True:
|
while True:
|
||||||
frm = self.read_frame(hide)
|
frm = self.read_frame(hide)
|
||||||
if isinstance(frm, frame.SettingsFrame):
|
if isinstance(frm, frame.SettingsFrame):
|
||||||
assert settings_ack_frame.flags & frame.Frame.FLAG_ACK
|
assert frm.flags & frame.Frame.FLAG_ACK
|
||||||
assert len(settings_ack_frame.settings) == 0
|
assert len(frm.settings) == 0
|
||||||
break
|
break
|
||||||
|
|
||||||
def perform_server_connection_preface(self, force=False):
|
def perform_server_connection_preface(self, force=False):
|
||||||
@ -118,11 +118,10 @@ class HTTP2Protocol(object):
|
|||||||
old_value = '-'
|
old_value = '-'
|
||||||
self.http2_settings[setting] = value
|
self.http2_settings[setting] = value
|
||||||
|
|
||||||
self.send_frame(
|
frm = frame.SettingsFrame(
|
||||||
frame.SettingsFrame(
|
|
||||||
state=self,
|
state=self,
|
||||||
flags=frame.Frame.FLAG_ACK),
|
flags=frame.Frame.FLAG_ACK)
|
||||||
hide)
|
self.send_frame(frm, hide)
|
||||||
|
|
||||||
# be liberal in what we expect from the other end
|
# be liberal in what we expect from the other end
|
||||||
# to be more strict use: self._read_settings_ack(hide)
|
# to be more strict use: self._read_settings_ack(hide)
|
||||||
@ -188,7 +187,7 @@ class HTTP2Protocol(object):
|
|||||||
self._create_body(body, stream_id)))
|
self._create_body(body, stream_id)))
|
||||||
|
|
||||||
def read_response(self):
|
def read_response(self):
|
||||||
stream_id, headers, body = self._receive_transmission()
|
stream_id_, headers, body = self._receive_transmission()
|
||||||
return headers[':status'], headers, body
|
return headers[':status'], headers, body
|
||||||
|
|
||||||
def read_request(self):
|
def read_request(self):
|
||||||
|
@ -12,12 +12,13 @@ class NullProxyAuth(object):
|
|||||||
def __init__(self, password_manager):
|
def __init__(self, password_manager):
|
||||||
self.password_manager = password_manager
|
self.password_manager = password_manager
|
||||||
|
|
||||||
def clean(self, headers):
|
def clean(self, headers_):
|
||||||
"""
|
"""
|
||||||
Clean up authentication headers, so they're not passed upstream.
|
Clean up authentication headers, so they're not passed upstream.
|
||||||
"""
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
def authenticate(self, headers):
|
def authenticate(self, headers_):
|
||||||
"""
|
"""
|
||||||
Tests that the user is allowed to use the proxy
|
Tests that the user is allowed to use the proxy
|
||||||
"""
|
"""
|
||||||
@ -62,7 +63,7 @@ class BasicProxyAuth(NullProxyAuth):
|
|||||||
|
|
||||||
class PassMan(object):
|
class PassMan(object):
|
||||||
|
|
||||||
def test(self, username, password_token):
|
def test(self, username_, password_token_):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
@ -72,7 +73,7 @@ class PassManNonAnon(PassMan):
|
|||||||
Ensure the user specifies a username, accept any password.
|
Ensure the user specifies a username, accept any password.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def test(self, username, password_token):
|
def test(self, username, password_token_):
|
||||||
if username:
|
if username:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
@ -87,7 +87,7 @@ def _read_value(s, start, delims):
|
|||||||
return _read_until(s, start, delims)
|
return _read_until(s, start, delims)
|
||||||
|
|
||||||
|
|
||||||
def _read_pairs(s, off=0, specials=()):
|
def _read_pairs(s, off=0):
|
||||||
"""
|
"""
|
||||||
Read pairs of lhs=rhs values.
|
Read pairs of lhs=rhs values.
|
||||||
|
|
||||||
@ -151,10 +151,7 @@ def _parse_set_cookie_pairs(s):
|
|||||||
For Set-Cookie, we support multiple cookies as described in RFC2109.
|
For Set-Cookie, we support multiple cookies as described in RFC2109.
|
||||||
This function therefore returns a list of lists.
|
This function therefore returns a list of lists.
|
||||||
"""
|
"""
|
||||||
pairs, off = _read_pairs(
|
pairs, off_ = _read_pairs(s)
|
||||||
s,
|
|
||||||
specials=("expires", "path")
|
|
||||||
)
|
|
||||||
return pairs
|
return pairs
|
||||||
|
|
||||||
|
|
||||||
@ -185,7 +182,7 @@ def parse_cookie_header(line):
|
|||||||
Parse a Cookie header value.
|
Parse a Cookie header value.
|
||||||
Returns a (possibly empty) ODict object.
|
Returns a (possibly empty) ODict object.
|
||||||
"""
|
"""
|
||||||
pairs, off = _read_pairs(line)
|
pairs, off_ = _read_pairs(line)
|
||||||
return odict.ODict(pairs)
|
return odict.ODict(pairs)
|
||||||
|
|
||||||
|
|
||||||
|
@ -403,7 +403,7 @@ class _Connection(object):
|
|||||||
|
|
||||||
# Verify Options (NONE/PEER/PEER|FAIL_IF_... and trusted CAs)
|
# Verify Options (NONE/PEER/PEER|FAIL_IF_... and trusted CAs)
|
||||||
if verify_options is not None and verify_options is not SSL.VERIFY_NONE:
|
if verify_options is not None and verify_options is not SSL.VERIFY_NONE:
|
||||||
def verify_cert(conn, cert, errno, err_depth, is_cert_verified):
|
def verify_cert(conn_, cert_, errno, err_depth, is_cert_verified):
|
||||||
if is_cert_verified:
|
if is_cert_verified:
|
||||||
return True
|
return True
|
||||||
raise NetLibError(
|
raise NetLibError(
|
||||||
@ -439,7 +439,7 @@ class _Connection(object):
|
|||||||
context.set_alpn_protos(alpn_protos)
|
context.set_alpn_protos(alpn_protos)
|
||||||
elif alpn_select is not None:
|
elif alpn_select is not None:
|
||||||
# select application layer protocol
|
# select application layer protocol
|
||||||
def alpn_select_callback(conn, options):
|
def alpn_select_callback(conn_, options):
|
||||||
if alpn_select in options:
|
if alpn_select in options:
|
||||||
return bytes(alpn_select)
|
return bytes(alpn_select)
|
||||||
else: # pragma no cover
|
else: # pragma no cover
|
||||||
@ -601,7 +601,7 @@ class BaseHandler(_Connection):
|
|||||||
context.set_tlsext_servername_callback(handle_sni)
|
context.set_tlsext_servername_callback(handle_sni)
|
||||||
|
|
||||||
if request_client_cert:
|
if request_client_cert:
|
||||||
def save_cert(conn, cert, errno, depth, preverify_ok):
|
def save_cert(conn_, cert, errno_, depth_, preverify_ok_):
|
||||||
self.clientcert = certutils.SSLCert(cert)
|
self.clientcert = certutils.SSLCert(cert)
|
||||||
# Return true to prevent cert verification error
|
# Return true to prevent cert verification error
|
||||||
return True
|
return True
|
||||||
@ -676,7 +676,7 @@ class TCPServer(object):
|
|||||||
try:
|
try:
|
||||||
while not self.__shutdown_request:
|
while not self.__shutdown_request:
|
||||||
try:
|
try:
|
||||||
r, w, e = select.select(
|
r, w_, e_ = select.select(
|
||||||
[self.socket], [], [], poll_interval)
|
[self.socket], [], [], poll_interval)
|
||||||
except select.error as ex: # pragma: no cover
|
except select.error as ex: # pragma: no cover
|
||||||
if ex[0] == EINTR:
|
if ex[0] == EINTR:
|
||||||
@ -708,7 +708,7 @@ class TCPServer(object):
|
|||||||
self.socket.close()
|
self.socket.close()
|
||||||
self.handle_shutdown()
|
self.handle_shutdown()
|
||||||
|
|
||||||
def handle_error(self, connection, client_address, fp=sys.stderr):
|
def handle_error(self, connection_, client_address, fp=sys.stderr):
|
||||||
"""
|
"""
|
||||||
Called when handle_client_connection raises an exception.
|
Called when handle_client_connection raises an exception.
|
||||||
"""
|
"""
|
||||||
|
@ -35,7 +35,7 @@ def date_time_string():
|
|||||||
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
|
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
|
||||||
]
|
]
|
||||||
now = time.time()
|
now = time.time()
|
||||||
year, month, day, hh, mm, ss, wd, y, z = time.gmtime(now)
|
year, month, day, hh, mm, ss, wd, y_, z_ = time.gmtime(now)
|
||||||
s = "%s, %02d %3s %4d %02d:%02d:%02d GMT" % (
|
s = "%s, %02d %3s %4d %02d:%02d:%02d GMT" % (
|
||||||
WEEKS[wd],
|
WEEKS[wd],
|
||||||
day, MONTHS[month], year,
|
day, MONTHS[month], year,
|
||||||
|
Loading…
Reference in New Issue
Block a user