Skip to content

Commit

Permalink
feat: stop manipulating IP address
Browse files Browse the repository at this point in the history
  • Loading branch information
eat-swap committed Nov 17, 2023
1 parent a6f4c3d commit 088c7a5
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions isso/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,7 @@ def anonymize(remote_addr):
and /48 (zero'd).
"""
if not isinstance(remote_addr, str) and isinstance(remote_addr, str):
remote_addr = remote_addr.decode('ascii', 'ignore')
try:
ipv4 = ipaddress.IPv4Address(remote_addr)
return u''.join(ipv4.exploded.rsplit('.', 1)[0]) + '.' + '0'
except ipaddress.AddressValueError:
try:
ipv6 = ipaddress.IPv6Address(remote_addr)
if ipv6.ipv4_mapped is not None:
return anonymize(str(ipv6.ipv4_mapped))
return u'' + ipv6.exploded.rsplit(':', 5)[0] + ':' + ':'.join(['0000'] * 5)
except ipaddress.AddressValueError:
return u'0.0.0.0'
return remote_addr


class Bloomfilter:
Expand Down

0 comments on commit 088c7a5

Please sign in to comment.