aboutsummaryrefslogtreecommitdiffstats
path: root/mitmproxy/addons/block.py
diff options
context:
space:
mode:
Diffstat (limited to 'mitmproxy/addons/block.py')
-rw-r--r--mitmproxy/addons/block.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/mitmproxy/addons/block.py b/mitmproxy/addons/block.py
index a484f5c4..91f9f709 100644
--- a/mitmproxy/addons/block.py
+++ b/mitmproxy/addons/block.py
@@ -21,17 +21,19 @@ class Block:
)
def clientconnect(self, layer):
- address = ipaddress.ip_address(layer.client_conn.address[0])
+ astr = layer.client_conn.address[0]
+
+ parts = astr.rsplit("%", 1)
+ address = ipaddress.ip_address(parts[0])
if isinstance(address, ipaddress.IPv6Address):
address = address.ipv4_mapped or address
- ipa = ipaddress.ip_address(address)
- if ipa.is_loopback:
+ if address.is_loopback:
return
- if ctx.options.block_private and ipa.is_private:
- ctx.log.warn("Client connection from %s killed by block_private" % address)
+ 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 ipa.is_global:
- ctx.log.warn("Client connection from %s killed by block_global" % address)
+ if ctx.options.block_global and address.is_global:
+ ctx.log.warn("Client connection from %s killed by block_global" % astr)
layer.reply.kill() \ No newline at end of file