Skip to content

Commit

Permalink
fix is_private_ip()
Browse files Browse the repository at this point in the history
  • Loading branch information
AlyaGomaa committed Dec 11, 2024
1 parent c1f5016 commit e529c70
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions slips_files/common/slips_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,14 +397,13 @@ def is_port_in_use(self, port: int) -> bool:
def is_private_ip(
self, ip: Union[ipaddress.IPv4Address, ipaddress.IPv6Address, str]
) -> bool:
if self.detect_ioc_type(ip) != "ip":
return False

ip_classes = {ipaddress.IPv4Address, ipaddress.IPv6Address}
for class_ in ip_classes:
if isinstance(ip, class_):
return ip and ip.is_private

if self.detect_ioc_type(ip) != "ip":
return False
# convert the given str ip to obj
ip_obj = ipaddress.ip_address(ip)
return ip_obj.is_private
Expand Down

0 comments on commit e529c70

Please sign in to comment.