Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup #4363

Merged
merged 5 commits into from
Dec 21, 2020
Merged

Cleanup #4363

Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 1 addition & 21 deletions mitmproxy/addons/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def load(self, loader):
"""
)

def client_connected(self, client): # pragma: no cover
def client_connected(self, client):
parts = client.peername[0].rsplit("%", 1)
address = ipaddress.ip_address(parts[0])
if isinstance(address, ipaddress.IPv6Address):
Expand All @@ -36,23 +36,3 @@ def client_connected(self, client): # pragma: no cover
if ctx.options.block_global and address.is_global:
ctx.log.warn(f"Client connection from {client.peername[0]} killed by block_global option.")
client.error = "Connection killed by block_global."

# FIXME: Remove old proxy core hook below and remove no cover statements.

def clientconnect(self, layer): # pragma: no cover
astr = layer.client_conn.peername[0]

parts = astr.rsplit("%", 1)
address = ipaddress.ip_address(parts[0])
if isinstance(address, ipaddress.IPv6Address):
address = address.ipv4_mapped or address

if address.is_loopback:
return

if ctx.options.block_private and address.is_private:
ctx.log.warn("Client connection from %s killed by block_private" % astr)
layer.reply.kill()
if ctx.options.block_global and address.is_global:
ctx.log.warn("Client connection from %s killed by block_global" % astr)
layer.reply.kill()
4 changes: 3 additions & 1 deletion mitmproxy/addons/proxyauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,15 @@ def configure(self, updated):
auto_bind=True)
self.ldapconn = conn
self.ldapserver = server
else:
elif ":" in ctx.options.proxyauth:
parts = ctx.options.proxyauth.split(':')
if len(parts) != 2:
raise exceptions.OptionsError(
"Invalid single-user auth specification."
)
self.singleuser = parts
else:
raise exceptions.OptionsError("Invalid proxyauth specification.")
if self.enabled():
if ctx.options.mode == "transparent":
raise exceptions.OptionsError(
Expand Down