Skip to content

Commit

Permalink
Fix issue when a IP range is given.
Browse files Browse the repository at this point in the history
This patch fixes #127.

Indeed, before this patch, I didn't took into consideration that an IP
range could have been given.

Contributors:
  * @spirillen
  • Loading branch information
funilrys committed Dec 23, 2020
1 parent 34d25d6 commit 5755032
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions PyFunceble/checker/syntax/ipv4.py
Expand Up @@ -152,18 +152,21 @@ def is_reserved(self) -> bool:
"""

if self.is_valid():
address = ipaddress.IPv4Address(self.idna_subject)

return (
address.is_multicast
or address.is_private
or address.is_unspecified
or address.is_reserved
or address.is_loopback
or address.is_link_local
or not address.is_global
or RegexHelper(self._get_regex_reserved_ip()).match(
self.idna_subject, return_match=False
try:
address = ipaddress.IPv4Address(self.idna_subject)

return (
address.is_multicast
or address.is_private
or address.is_unspecified
or address.is_reserved
or address.is_loopback
or address.is_link_local
or not address.is_global
or RegexHelper(self._get_regex_reserved_ip()).match(
self.idna_subject, return_match=False
)
)
)
except ValueError:
pass
return False

0 comments on commit 5755032

Please sign in to comment.