diff --git a/PyFunceble/downloader/base.py b/PyFunceble/downloader/base.py index e0af29fe..b2b6a88a 100644 --- a/PyFunceble/downloader/base.py +++ b/PyFunceble/downloader/base.py @@ -56,7 +56,6 @@ import PyFunceble.downloader.exceptions import PyFunceble.exceptions -import PyFunceble.factory import PyFunceble.storage from PyFunceble.helpers.dict import DictHelper from PyFunceble.helpers.download import DownloadHelper @@ -271,6 +270,7 @@ def is_last_download_expired(self) -> bool: return False + def start(self) -> None: """ Starts the download process. diff --git a/PyFunceble/query/dns/nameserver.py b/PyFunceble/query/dns/nameserver.py index bbcfece9..11038d30 100644 --- a/PyFunceble/query/dns/nameserver.py +++ b/PyFunceble/query/dns/nameserver.py @@ -55,9 +55,9 @@ import dns.exception import dns.resolver +from PyFunceble.checker.syntax.ip import IPSyntaxChecker import PyFunceble.facility import PyFunceble.storage -from PyFunceble.checker.syntax.domain import DomainSyntaxChecker from PyFunceble.converter.url2netloc import Url2Netloc @@ -78,13 +78,13 @@ class Nameservers: protocol: Optional[str] = None - domain_syntax_checker: Optional[DomainSyntaxChecker] = None + ip_syntax_checker: Optional[IPSyntaxChecker] = None url2netloc: Url2Netloc = Url2Netloc() def __init__( self, nameserver: Optional[List[str]] = None, protocol: str = "TCP" ) -> None: - self.domain_syntax_checker = DomainSyntaxChecker() + self.ip_syntax_checker = IPSyntaxChecker() self.protocol = protocol if nameserver is not None: @@ -139,7 +139,9 @@ def get_ip_from_nameserver(self, nameserver: str) -> List[str]: result = [] - if self.domain_syntax_checker.set_subject(nameserver).is_valid(): + if self.ip_syntax_checker.set_subject(nameserver).is_valid(): + result.append(nameserver) + else: try: result.extend( [ @@ -159,8 +161,6 @@ def get_ip_from_nameserver(self, nameserver: str) -> List[str]: ) except dns.exception.DNSException: pass - else: - result.append(nameserver) PyFunceble.facility.Logger.debug( "IP from nameserver (%r):\n%r", nameserver, result diff --git a/tests/query/dnss/test_nameserver.py b/tests/query/dnss/test_nameserver.py index f1b9f444..d394758a 100644 --- a/tests/query/dnss/test_nameserver.py +++ b/tests/query/dnss/test_nameserver.py @@ -259,7 +259,7 @@ def test_get_ip_from_nameserver_not_valid_domain(self) -> None: given = "example.funilrys" - expected = ["example.funilrys"] + expected = [] actual = self.nameserver_provider.get_ip_from_nameserver(given) self.assertEqual(expected, actual)