From 4719b2e8620c3a480bb24b7589d8fab92fdee115 Mon Sep 17 00:00:00 2001 From: KuetTai Date: Wed, 4 Dec 2024 16:57:06 +0800 Subject: [PATCH] Fix isPrivateIp exception error by using ipaddress lib instead of netaddr --- utils/Tools.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/Tools.py b/utils/Tools.py index a692baa..abb9214 100644 --- a/utils/Tools.py +++ b/utils/Tools.py @@ -6,7 +6,7 @@ from pprint import pprint from utils.Config import Config from typing import Set, Dict, Union -from netaddr import IPAddress +from ipaddress import ip_address as IPAddress from functools import lru_cache from functools import lru_cache from functools import lru_cache @@ -40,7 +40,7 @@ def checkIsPrivateIp(ipaddr): if ip[0] == '0.0.0.0': return False - return IPAddress(ip[0]).is_private() + return IPAddress(ip[0]).is_private except ValueError as e: raise ValueError(f"Invalid IP address format: {ip_addr}") from e