From 57eb0566759f09165a23bf5d3c581c29ab53033a Mon Sep 17 00:00:00 2001 From: ST47 Date: Mon, 19 Oct 2020 11:51:43 -0400 Subject: [PATCH 01/26] Add 'get_recursive' option for legacy whois to RIPE NCC This patch adds an argument `get_recursive` to `lookup_whois()`. The argument default is True, which causes no change to the behavior. If the user passes `get_recursive=False`, and the IP is allocated to RIPE, this causes the `-r` flag to be included in the query string. The `-r` flag asks RIPE WHOIS servers not to perform recursive queries, such as for related "person" or "role" objects. This helps users avoid IP blacklisting by RIPE. The `-r` flag is only supported by RIPE, so this patch only affects queries to RIPE servers. --- ipwhois/ipwhois.py | 8 ++++++-- ipwhois/net.py | 5 +++-- ipwhois/whois.py | 4 ++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/ipwhois/ipwhois.py b/ipwhois/ipwhois.py index 946c64b..d89471d 100644 --- a/ipwhois/ipwhois.py +++ b/ipwhois/ipwhois.py @@ -68,7 +68,7 @@ def lookup_whois(self, inc_raw=False, retry_count=3, get_referral=False, extra_blacklist=None, ignore_referral_errors=False, field_list=None, extra_org_map=None, inc_nir=True, nir_field_list=None, asn_methods=None, - get_asn_description=True): + get_asn_description=True, get_recursive=True): """ The function for retrieving and parsing whois information for an IP address via port 43 (WHOIS). @@ -113,6 +113,10 @@ def lookup_whois(self, inc_raw=False, retry_count=3, get_referral=False, get_asn_description (:obj:`bool`): Whether to run an additional query when pulling ASN information via dns, in order to get the ASN description. Defaults to True. + get_recursive (:obj:`bool`): Whether to ask the server to perform + recursive queries to get related objects. If False, passes + the '-r' flag to RIPE WHOIS servers. Has no effect for other + RIRs. Defaults to True. Returns: dict: The IP whois lookup results @@ -167,7 +171,7 @@ def lookup_whois(self, inc_raw=False, retry_count=3, get_referral=False, inc_raw=inc_raw, retry_count=retry_count, response=None, get_referral=get_referral, extra_blacklist=extra_blacklist, ignore_referral_errors=ignore_referral_errors, asn_data=asn_data, - field_list=field_list + field_list=field_list, get_recursive=get_recursive, ) # Add the WHOIS information to the return dictionary. diff --git a/ipwhois/net.py b/ipwhois/net.py index c7ce39c..a4d6363 100644 --- a/ipwhois/net.py +++ b/ipwhois/net.py @@ -512,7 +512,7 @@ def get_asn_origin_whois(self, asn_registry='radb', asn=None, ) def get_whois(self, asn_registry='arin', retry_count=3, server=None, - port=43, extra_blacklist=None): + port=43, extra_blacklist=None, get_recursive=True): """ The function for retrieving whois or rwhois information for an IP address via any port. Defaults to port 43/tcp (WHOIS). @@ -562,8 +562,9 @@ def get_whois(self, asn_registry='arin', retry_count=3, server=None, # Prep the query. query = self.address_str + '\r\n' if asn_registry == 'arin': - query = 'n + {0}'.format(query) + if asn_registry == 'ripencc' and get_recursive is False: + query = '-r {0}'.format(query) # Query the whois server, and store the results. conn.send(query.encode()) diff --git a/ipwhois/whois.py b/ipwhois/whois.py index 40c131d..de443d6 100644 --- a/ipwhois/whois.py +++ b/ipwhois/whois.py @@ -550,7 +550,7 @@ def get_nets_other(self, response): def lookup(self, inc_raw=False, retry_count=3, response=None, get_referral=False, extra_blacklist=None, ignore_referral_errors=False, asn_data=None, - field_list=None, is_offline=False): + field_list=None, is_offline=False, get_recursive=True): """ The function for retrieving and parsing whois information for an IP address via port 43/tcp (WHOIS). @@ -635,7 +635,7 @@ def lookup(self, inc_raw=False, retry_count=3, response=None, # Retrieve the whois data. response = self._net.get_whois( asn_registry=asn_data['asn_registry'], retry_count=retry_count, - extra_blacklist=extra_blacklist + extra_blacklist=extra_blacklist, get_recursive=get_recursive ) if get_referral: From 0f4a1dbc6a0f6f24f0ac0f681b1137e2d111b575 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikk=20Margus=20M=C3=B6ll?= Date: Fri, 6 Nov 2020 16:28:22 +0200 Subject: [PATCH 02/26] Avoid deprecated query method of dnspython --- ipwhois/net.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ipwhois/net.py b/ipwhois/net.py index c7ce39c..47468d5 100644 --- a/ipwhois/net.py +++ b/ipwhois/net.py @@ -220,7 +220,7 @@ def get_asn_dns(self): try: log.debug('ASN query for {0}'.format(self.dns_zone)) - data = self.dns_resolver.query(self.dns_zone, 'TXT') + data = self.dns_resolver.resolve(self.dns_zone, 'TXT') return list(data) except (dns.resolver.NXDOMAIN, dns.resolver.NoNameservers, @@ -262,7 +262,7 @@ def get_asn_verbose_dns(self, asn=None): try: log.debug('ASN verbose query for {0}'.format(zone)) - data = self.dns_resolver.query(zone, 'TXT') + data = self.dns_resolver.resolve(zone, 'TXT') return str(data[0]) except (dns.resolver.NXDOMAIN, dns.resolver.NoNameservers, From 0b62db664c0b9a106a9a9508bc2854fd5065cbd7 Mon Sep 17 00:00:00 2001 From: Philip Hane Date: Sun, 15 Nov 2020 11:45:39 -0600 Subject: [PATCH 03/26] 294 fix dnspython deprecated query method --- CHANGES.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 52519b3..9d39869 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,6 +1,11 @@ Changelog ========= +1.3.0 (TBD) +----------- + +- Fixed deprecated query method of dnspython (#294 - monoidic) + 1.2.0 (2020-09-17) ------------------ From d0f39f8fe9bbfdcde19005a78dbb4a7a2e9503e8 Mon Sep 17 00:00:00 2001 From: secynic Date: Sat, 12 Oct 2024 00:19:34 -0500 Subject: [PATCH 04/26] Close sockets --- ipwhois/net.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ipwhois/net.py b/ipwhois/net.py index 47468d5..d47bd9d 100644 --- a/ipwhois/net.py +++ b/ipwhois/net.py @@ -327,6 +327,10 @@ def get_asn_whois(self, retry_count=3): except (socket.timeout, socket.error) as e: # pragma: no cover log.debug('ASN query socket error: {0}'.format(e)) + try: + conn.close() + except Exception: + pass if retry_count > 0: log.debug('ASN query retrying (count: {0})'.format( @@ -486,6 +490,10 @@ def get_asn_origin_whois(self, asn_registry='radb', asn=None, except (socket.timeout, socket.error) as e: log.debug('ASN origin WHOIS query socket error: {0}'.format(e)) + try: + conn.close() + except Exception: + pass if retry_count > 0: log.debug('ASN origin WHOIS query retrying (count: {0})' From d4dc114c1fdab87496bd2de7229125ed465c6d1a Mon Sep 17 00:00:00 2001 From: secynic Date: Sat, 12 Oct 2024 00:19:44 -0500 Subject: [PATCH 05/26] Update dnspython --- ipwhois/docs/requirements.txt | 2 +- requirements/python2.txt | 4 ++-- requirements/python3.txt | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ipwhois/docs/requirements.txt b/ipwhois/docs/requirements.txt index 9a90c11..b7845ba 100644 --- a/ipwhois/docs/requirements.txt +++ b/ipwhois/docs/requirements.txt @@ -1,3 +1,3 @@ sphinx sphinx_rtd_theme -dnspython<=2.0.0 +dnspython diff --git a/requirements/python2.txt b/requirements/python2.txt index 6f6db6b..b7f70e7 100644 --- a/requirements/python2.txt +++ b/requirements/python2.txt @@ -1,2 +1,2 @@ -dnspython<=2.0.0 -ipaddr==2.2.0 +dnspython +ipaddr diff --git a/requirements/python3.txt b/requirements/python3.txt index 337b63d..2f73596 100644 --- a/requirements/python3.txt +++ b/requirements/python3.txt @@ -1 +1 @@ -dnspython<=2.0.0 +dnspython From 13724b37539585883f97f253ad091fa2ed1206ae Mon Sep 17 00:00:00 2001 From: secynic Date: Sat, 12 Oct 2024 00:20:46 -0500 Subject: [PATCH 06/26] Fix assertEquals to assertEqual --- ipwhois/tests/test_asn.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ipwhois/tests/test_asn.py b/ipwhois/tests/test_asn.py index bb73051..10be3d6 100644 --- a/ipwhois/tests/test_asn.py +++ b/ipwhois/tests/test_asn.py @@ -282,7 +282,7 @@ def test__get_nets_radb(self): '\nsource: AFRINIC' '\n\n' ) - self.assertEquals( + self.assertEqual( obj.get_nets_radb(multi_net_response), [{ 'updated': None, From 653041d587dfd4f7741ef10e6874fbf18062414a Mon Sep 17 00:00:00 2001 From: secynic Date: Sat, 12 Oct 2024 00:32:43 -0500 Subject: [PATCH 07/26] Update dnspython --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index ef22a09..8bd277a 100644 --- a/setup.py +++ b/setup.py @@ -67,7 +67,7 @@ PACKAGE_DATA = {'ipwhois': ['data/*.xml', 'data/*.csv']} -INSTALL_REQUIRES = ['dnspython<=2.0.0', 'ipaddr==2.2.0;python_version<"3.3"'] +INSTALL_REQUIRES = ['dnspython', 'ipaddr==2.2.0;python_version<"3.3"'] setup( name=NAME, From 15fe3cfc8a01cd87391380f3e85c6dbbbe00f335 Mon Sep 17 00:00:00 2001 From: secynic Date: Sat, 12 Oct 2024 01:01:33 -0500 Subject: [PATCH 08/26] Switch to defusedxml per KOLANICH #306 --- ipwhois/docs/requirements.txt | 1 + ipwhois/utils.py | 2 +- requirements/python2.txt | 1 + requirements/python3.txt | 1 + setup.py | 3 ++- 5 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ipwhois/docs/requirements.txt b/ipwhois/docs/requirements.txt index b7845ba..67fcda5 100644 --- a/ipwhois/docs/requirements.txt +++ b/ipwhois/docs/requirements.txt @@ -1,3 +1,4 @@ sphinx sphinx_rtd_theme dnspython +defusedxml diff --git a/ipwhois/utils.py b/ipwhois/utils.py index f3c0a76..58fc7e0 100644 --- a/ipwhois/utils.py +++ b/ipwhois/utils.py @@ -23,7 +23,7 @@ # POSSIBILITY OF SUCH DAMAGE. import sys -from xml.dom.minidom import parseString +from defusedxml.minidom import parseString from os import path import re import copy diff --git a/requirements/python2.txt b/requirements/python2.txt index b7f70e7..392f875 100644 --- a/requirements/python2.txt +++ b/requirements/python2.txt @@ -1,2 +1,3 @@ dnspython ipaddr +defusedxml diff --git a/requirements/python3.txt b/requirements/python3.txt index 2f73596..adbd7bc 100644 --- a/requirements/python3.txt +++ b/requirements/python3.txt @@ -1 +1,2 @@ dnspython +defusedxml diff --git a/setup.py b/setup.py index 8bd277a..077818a 100644 --- a/setup.py +++ b/setup.py @@ -67,7 +67,8 @@ PACKAGE_DATA = {'ipwhois': ['data/*.xml', 'data/*.csv']} -INSTALL_REQUIRES = ['dnspython', 'ipaddr==2.2.0;python_version<"3.3"'] +INSTALL_REQUIRES = ['dnspython', 'ipaddr==2.2.0;python_version<"3.3"', + 'defusedxml'] setup( name=NAME, From c0d38bff1e06fc762331be3f35bd0c1a56397592 Mon Sep 17 00:00:00 2001 From: secynic Date: Sat, 12 Oct 2024 01:04:15 -0500 Subject: [PATCH 09/26] Update to https per KOLANICH #307 --- ipwhois/asn.py | 2 +- ipwhois/net.py | 2 +- ipwhois/rdap.py | 22 +++++++++++----------- ipwhois/utils.py | 30 +++++++++++++++--------------- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/ipwhois/asn.py b/ipwhois/asn.py index 71b5675..4796e12 100644 --- a/ipwhois/asn.py +++ b/ipwhois/asn.py @@ -61,7 +61,7 @@ ASN_ORIGIN_HTTP = { 'radb': { - 'url': 'http://www.radb.net/query', + 'url': 'https://www.radb.net/query', 'form_data_asn_field': 'keywords', 'form_data': { 'advanced_query': '1', diff --git a/ipwhois/net.py b/ipwhois/net.py index d47bd9d..593bea0 100644 --- a/ipwhois/net.py +++ b/ipwhois/net.py @@ -69,7 +69,7 @@ log = logging.getLogger(__name__) # POSSIBLY UPDATE TO USE RDAP -ARIN = 'http://whois.arin.net/rest/nets;q={0}?showDetails=true&showARIN=true' +ARIN = 'https://whois.arin.net/rest/nets;q={0}?showDetails=true&showARIN=true' CYMRU_WHOIS = 'whois.cymru.com' diff --git a/ipwhois/rdap.py b/ipwhois/rdap.py index 3a65aef..cb870cd 100644 --- a/ipwhois/rdap.py +++ b/ipwhois/rdap.py @@ -32,28 +32,28 @@ log = logging.getLogger(__name__) -BOOTSTRAP_URL = 'http://rdap.arin.net/bootstrap' +BOOTSTRAP_URL = 'https://rdap.arin.net/bootstrap' RIR_RDAP = { 'arin': { - 'ip_url': 'http://rdap.arin.net/registry/ip/{0}', - 'entity_url': 'http://rdap.arin.net/registry/entity/{0}' + 'ip_url': 'https://rdap.arin.net/registry/ip/{0}', + 'entity_url': 'https://rdap.arin.net/registry/entity/{0}' }, 'ripencc': { - 'ip_url': 'http://rdap.db.ripe.net/ip/{0}', - 'entity_url': 'http://rdap.db.ripe.net/entity/{0}' + 'ip_url': 'https://rdap.db.ripe.net/ip/{0}', + 'entity_url': 'https://rdap.db.ripe.net/entity/{0}' }, 'apnic': { - 'ip_url': 'http://rdap.apnic.net/ip/{0}', - 'entity_url': 'http://rdap.apnic.net/entity/{0}' + 'ip_url': 'https://rdap.apnic.net/ip/{0}', + 'entity_url': 'https://rdap.apnic.net/entity/{0}' }, 'lacnic': { - 'ip_url': 'http://rdap.lacnic.net/rdap/ip/{0}', - 'entity_url': 'http://rdap.lacnic.net/rdap/entity/{0}' + 'ip_url': 'https://rdap.lacnic.net/rdap/ip/{0}', + 'entity_url': 'https://rdap.lacnic.net/rdap/entity/{0}' }, 'afrinic': { - 'ip_url': 'http://rdap.afrinic.net/rdap/ip/{0}', - 'entity_url': 'http://rdap.afrinic.net/rdap/entity/{0}' + 'ip_url': 'https://rdap.afrinic.net/rdap/ip/{0}', + 'entity_url': 'https://rdap.afrinic.net/rdap/entity/{0}' } } diff --git a/ipwhois/utils.py b/ipwhois/utils.py index 58fc7e0..22198bc 100644 --- a/ipwhois/utils.py +++ b/ipwhois/utils.py @@ -61,26 +61,26 @@ IETF_RFC_REFERENCES = { # IPv4 'RFC 1122, Section 3.2.1.3': - 'http://tools.ietf.org/html/rfc1122#section-3.2.1.3', - 'RFC 1918': 'http://tools.ietf.org/html/rfc1918', - 'RFC 3927': 'http://tools.ietf.org/html/rfc3927', - 'RFC 5736': 'http://tools.ietf.org/html/rfc5736', - 'RFC 5737': 'http://tools.ietf.org/html/rfc5737', - 'RFC 3068': 'http://tools.ietf.org/html/rfc3068', - 'RFC 2544': 'http://tools.ietf.org/html/rfc2544', - 'RFC 3171': 'http://tools.ietf.org/html/rfc3171', - 'RFC 919, Section 7': 'http://tools.ietf.org/html/rfc919#section-7', + 'https://tools.ietf.org/html/rfc1122#section-3.2.1.3', + 'RFC 1918': 'https://tools.ietf.org/html/rfc1918', + 'RFC 3927': 'https://tools.ietf.org/html/rfc3927', + 'RFC 5736': 'https://tools.ietf.org/html/rfc5736', + 'RFC 5737': 'https://tools.ietf.org/html/rfc5737', + 'RFC 3068': 'https://tools.ietf.org/html/rfc3068', + 'RFC 2544': 'https://tools.ietf.org/html/rfc2544', + 'RFC 3171': 'https://tools.ietf.org/html/rfc3171', + 'RFC 919, Section 7': 'https://tools.ietf.org/html/rfc919#section-7', # IPv6 - 'RFC 4291, Section 2.7': 'http://tools.ietf.org/html/rfc4291#section-2.7', - 'RFC 4291': 'http://tools.ietf.org/html/rfc4291', + 'RFC 4291, Section 2.7': 'https://tools.ietf.org/html/rfc4291#section-2.7', + 'RFC 4291': 'https://tools.ietf.org/html/rfc4291', 'RFC 4291, Section 2.5.2': - 'http://tools.ietf.org/html/rfc4291#section-2.5.2', + 'https://tools.ietf.org/html/rfc4291#section-2.5.2', 'RFC 4291, Section 2.5.3': - 'http://tools.ietf.org/html/rfc4291#section-2.5.3', + 'https://tools.ietf.org/html/rfc4291#section-2.5.3', 'RFC 4291, Section 2.5.6': - 'http://tools.ietf.org/html/rfc4291#section-2.5.6', + 'https://tools.ietf.org/html/rfc4291#section-2.5.6', 'RFC 4291, Section 2.5.7': - 'http://tools.ietf.org/html/rfc4291#section-2.5.7', + 'https://tools.ietf.org/html/rfc4291#section-2.5.7', 'RFC 4193': 'https://tools.ietf.org/html/rfc4193' } From 168b02da5c7dfcf925006674e46d7d66f5696f22 Mon Sep 17 00:00:00 2001 From: secynic Date: Sat, 12 Oct 2024 01:11:16 -0500 Subject: [PATCH 10/26] Add socket close to whois query to avoid ResourceWarning --- ipwhois/net.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ipwhois/net.py b/ipwhois/net.py index 593bea0..0abfa9b 100644 --- a/ipwhois/net.py +++ b/ipwhois/net.py @@ -619,6 +619,10 @@ def get_whois(self, asn_registry='arin', retry_count=3, server=None, except (socket.timeout, socket.error) as e: log.debug('WHOIS query socket error: {0}'.format(e)) + try: + conn.close() + except Exception: + pass if retry_count > 0: log.debug('WHOIS query retrying (count: {0})'.format( From 020975e92612df8ed07d8b92b350415a61d46ae6 Mon Sep 17 00:00:00 2001 From: secynic Date: Sat, 12 Oct 2024 01:30:31 -0500 Subject: [PATCH 11/26] Temporary hardcode user agent for ASN origin lookup --- ipwhois/asn.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ipwhois/asn.py b/ipwhois/asn.py index 4796e12..bc76b43 100644 --- a/ipwhois/asn.py +++ b/ipwhois/asn.py @@ -816,6 +816,11 @@ def lookup(self, asn=None, inc_raw=False, retry_count=3, response=None, ).format(ASN_ORIGIN_HTTP['radb']['url'], asn), retry_count=retry_count, request_type='GET', + headers={'Accept': 'text/html', + 'User-Agent': + 'Mozilla/5.0 (X11; Ubuntu; ' + 'Linux x86_64; rv:131.0) ' + 'Gecko/20100101 Firefox/131.0'} # form_data=tmp ) is_http = True # pragma: no cover From bd258b18ebd84689299f98ed3b1abaf835cab6f3 Mon Sep 17 00:00:00 2001 From: secynic Date: Sat, 12 Oct 2024 01:42:12 -0500 Subject: [PATCH 12/26] Potential fix for #317 --- ipwhois/asn.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ipwhois/asn.py b/ipwhois/asn.py index bc76b43..b57a775 100644 --- a/ipwhois/asn.py +++ b/ipwhois/asn.py @@ -75,7 +75,7 @@ 'description': r'(descr):[^\S\n]+(?P.+?)\n', 'maintainer': r'(mnt-by):[^\S\n]+(?P.+?)\n', 'updated': r'(changed):[^\S\n]+(?P.+?)\n', - 'source': r'(source):[^\S\n]+(?P.+?)\<', + 'source': r'(source):[^\S\n]+(?P.+?)(\<|\n)', } }, } From 4d7507b014b2dd03dbb753315efea388501db04b Mon Sep 17 00:00:00 2001 From: secynic Date: Sat, 12 Oct 2024 01:53:49 -0500 Subject: [PATCH 13/26] Update arin bootstrap URL #300 --- ipwhois/rdap.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ipwhois/rdap.py b/ipwhois/rdap.py index cb870cd..5779f81 100644 --- a/ipwhois/rdap.py +++ b/ipwhois/rdap.py @@ -32,7 +32,7 @@ log = logging.getLogger(__name__) -BOOTSTRAP_URL = 'https://rdap.arin.net/bootstrap' +BOOTSTRAP_URL = 'https://rdap-bootstrap.arin.net/bootstrap' RIR_RDAP = { 'arin': { From fa241b111f8895029529e3dd6b09313026b7a8da Mon Sep 17 00:00:00 2001 From: secynic Date: Sat, 12 Oct 2024 22:18:16 -0500 Subject: [PATCH 14/26] Add RTD config --- .readthedocs.yaml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .readthedocs.yaml diff --git a/.readthedocs.yaml b/.readthedocs.yaml new file mode 100644 index 0000000..f0b13fc --- /dev/null +++ b/.readthedocs.yaml @@ -0,0 +1,36 @@ +# Read the Docs configuration file for Sphinx projects + +# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details + + +# Required + +version: 2 + + +# Set the OS, Python version and other tools you might need + +build: + + os: ubuntu-22.04 + + tools: + + python: "3.12" + +# Build documentation in the "docs/" directory with Sphinx + +sphinx: + + configuration: ipwhois/docs/source/conf.py + +formats: + + - pdf + - epub + +python: + + install: + + - requirements: docs/requirements.txt \ No newline at end of file From 83179c2bc4c679c428018cf2414004057ac2de60 Mon Sep 17 00:00:00 2001 From: secynic Date: Sat, 12 Oct 2024 22:24:41 -0500 Subject: [PATCH 15/26] Remove reserved IANA 198.97.38.0/24 #315 --- ipwhois/utils.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/ipwhois/utils.py b/ipwhois/utils.py index 22198bc..b609c8c 100644 --- a/ipwhois/utils.py +++ b/ipwhois/utils.py @@ -352,12 +352,6 @@ def ipv4_is_defined(address): return results(True, 'Private-Use Networks', 'RFC 1918') - # New IANA Reserved - # TODO: Someone needs to find the RFC for this - elif query_ip in IPv4Network('198.97.38.0/24'): - - return results(True, 'IANA Reserved', '') - return results(False, '', '') From 5634717c59876508bf60d3f3d75f3f9ef1fee986 Mon Sep 17 00:00:00 2001 From: secynic Date: Sat, 12 Oct 2024 22:51:54 -0500 Subject: [PATCH 16/26] Remove reserved IANA 198.97.38.0/24 #315 --- ipwhois/tests/test_utils.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/ipwhois/tests/test_utils.py b/ipwhois/tests/test_utils.py index 9dc041f..35af2c9 100644 --- a/ipwhois/tests/test_utils.py +++ b/ipwhois/tests/test_utils.py @@ -92,8 +92,6 @@ def test_ipv4_is_defined(self): (True, 'Limited Broadcast', 'RFC 919, Section 7')) self.assertEqual(ipv4_is_defined('192.168.0.1'), (True, 'Private-Use Networks', 'RFC 1918')) - self.assertEqual(ipv4_is_defined('198.97.38.0'), - (True, 'IANA Reserved', '')) def test_ipv6_is_defined(self): if sys.version_info >= (3, 3): From b5aafb207611d3c8701ae7206c4696a2bf096f7c Mon Sep 17 00:00:00 2001 From: secynic Date: Sat, 12 Oct 2024 23:14:37 -0500 Subject: [PATCH 17/26] Cymru fix for local domain ASN search #324 --- ipwhois/net.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ipwhois/net.py b/ipwhois/net.py index 232a9cd..091f802 100644 --- a/ipwhois/net.py +++ b/ipwhois/net.py @@ -73,9 +73,9 @@ CYMRU_WHOIS = 'whois.cymru.com' -IPV4_DNS_ZONE = '{0}.origin.asn.cymru.com' +IPV4_DNS_ZONE = '{0}.origin.asn.cymru.com.' -IPV6_DNS_ZONE = '{0}.origin6.asn.cymru.com' +IPV6_DNS_ZONE = '{0}.origin6.asn.cymru.com.' BLACKLIST = [ 'root.rwhois.net' @@ -221,6 +221,8 @@ def get_asn_dns(self): log.debug('ASN query for {0}'.format(self.dns_zone)) data = self.dns_resolver.resolve(self.dns_zone, 'TXT') + log.debug('ASN query results using {0}: {1}'.format( + self.dns_zone, list(data))) return list(data) except (dns.resolver.NXDOMAIN, dns.resolver.NoNameservers, @@ -257,7 +259,7 @@ def get_asn_verbose_dns(self, asn=None): asn = 'AS{0}'.format(asn) - zone = '{0}.asn.cymru.com'.format(asn) + zone = '{0}.asn.cymru.com.'.format(asn) try: From b3bbc22743c78eb61914028fe77d36d75282ec12 Mon Sep 17 00:00:00 2001 From: secynic Date: Sat, 12 Oct 2024 23:33:09 -0500 Subject: [PATCH 18/26] Docs for local RDAP file processing #248 --- RDAP.rst | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/RDAP.rst b/RDAP.rst index 0f8d0fa..b41ad95 100644 --- a/RDAP.rst +++ b/RDAP.rst @@ -555,6 +555,24 @@ Use a proxy >>>> opener = request.build_opener(handler) >>>> obj = IPWhois('74.125.225.229', proxy_opener = opener) +Use a local file with RDAP data +------------------------------- + +:: + + >>>> from ipwhois.net import Net + >>>> from ipwhois.rdap import RDAP + >>>> data_dir = '/some/dir' + >>>> with io.open(str(data_dir) + '/rdap.json', 'r') as data_file: + >>>> data = json.load(data_file) + >>>> for key, val in data.items(): + >>>> net = Net(key) + >>>> obj = RDAP(net) + >>>> obj.lookup(response=val['response'], + asn_data=val['asn_data'], + depth=0 + ) + Optimizing queries for your network ----------------------------------- From 9ebd1bfc0c85372f5fe41661625e92180cd2902b Mon Sep 17 00:00:00 2001 From: secynic Date: Sat, 12 Oct 2024 23:44:59 -0500 Subject: [PATCH 19/26] Remove travis #328 --- .travis.yml | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 845f994..0000000 --- a/.travis.yml +++ /dev/null @@ -1,23 +0,0 @@ -language: python -os: linux -dist: xenial -python: - - 2.7 - - 3.4 - - 3.5 - - 3.6 - - 3.7 - - 3.8 -install: - - pip install --upgrade setuptools - - pip install --upgrade pip - - if [[ $TRAVIS_PYTHON_VERSION == 2* ]]; then pip install -r requirements/python2.txt; fi - - if [[ $TRAVIS_PYTHON_VERSION == 3* ]]; then pip install -r requirements/python3.txt; fi - - pip install coveralls - - pip install codeclimate-test-reporter - - pip install -e . -script: - - nosetests -v -w ipwhois --include=online --exclude=stress --with-coverage --cover-package=ipwhois -after_success: - - coveralls --rcfile=.coveragerc - - codeclimate-test-reporter From 28aa92aa506fd9f78cb5ffeeef2bdb03a03d612a Mon Sep 17 00:00:00 2001 From: secynic Date: Tue, 15 Oct 2024 00:39:11 -0500 Subject: [PATCH 20/26] v1.3.0 --- CHANGES.rst | 16 ++++++++++++++-- README.rst | 2 -- UPGRADING.rst | 14 ++++++++++++++ ipwhois/__init__.py | 2 +- ipwhois/docs/source/conf.py | 4 ++-- setup.py | 2 +- 6 files changed, 32 insertions(+), 8 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 9d39869..22abee1 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,10 +1,22 @@ Changelog ========= -1.3.0 (TBD) ------------ +1.3.0 (2024-10-15) +------------------ - Fixed deprecated query method of dnspython (#294 - monoidic) +- Upgrade dnspython (#303) +- Added requirement for defusedxml for security (#306) +- Added support for Python up to 3.12 +- Remove reserved IANA 198.97.38.0/24 (#315) +- Fix for ASN queries against RADB for RIPE source (#317) +- Temporary (move to config later) hardcoding of user agent for ASN origin + lookup to avoid 403 +- Updated to HTTPS where applicable (#307) +- Updated ARIN bootstrap URL (#300) +- Close sockets on exception to avoid warnings +- Move tests from assertEquals to assertEqual +- Fix for local domain searches with ASN (#324) 1.2.0 (2020-09-17) ------------------ diff --git a/README.rst b/README.rst index 524bcd7..541764e 100644 --- a/README.rst +++ b/README.rst @@ -2,8 +2,6 @@ ipwhois ======= -.. image:: https://travis-ci.org/secynic/ipwhois.svg?branch=master - :target: https://travis-ci.org/secynic/ipwhois .. image:: https://coveralls.io/repos/github/secynic/ipwhois/badge.svg?branch= master :target: https://coveralls.io/github/secynic/ipwhois?branch=master diff --git a/UPGRADING.rst b/UPGRADING.rst index 300da87..79d92ee 100644 --- a/UPGRADING.rst +++ b/UPGRADING.rst @@ -9,6 +9,20 @@ any changes that may affect user experience when upgrading to a new release. This page is new as of version 1.0.0. Any information on older versions is likely missing or incomplete. +****** +v1.3.0 +****** + +- Upgrade dnspython +- Added requirement for defusedxml for security +- Added support for Python up to 3.12 +- Remove reserved IANA 198.97.38.0/24 +- Fix for ASN queries against RADB for RIPE source +- Temporary (move to config later) hardcoding of user agent for ASN origin + lookup to avoid 403 +- Updated to HTTPS where applicable +- Fix for local domain searches with ASN + ****** v1.2.0 ****** diff --git a/ipwhois/__init__.py b/ipwhois/__init__.py index 2a1402b..57d99e7 100644 --- a/ipwhois/__init__.py +++ b/ipwhois/__init__.py @@ -26,4 +26,4 @@ from .net import Net from .ipwhois import IPWhois -__version__ = '1.2.0' +__version__ = '1.3.0' diff --git a/ipwhois/docs/source/conf.py b/ipwhois/docs/source/conf.py index 1039de6..71e7c6e 100644 --- a/ipwhois/docs/source/conf.py +++ b/ipwhois/docs/source/conf.py @@ -67,9 +67,9 @@ # built documents. # # The short X.Y version. -version = '1.2.0' +version = '1.3.0' # The full version, including alpha/beta/rc tags. -release = '1.2.0' +release = '1.3.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/setup.py b/setup.py index 077818a..5340c18 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ import io NAME = 'ipwhois' -VERSION = '1.2.0' +VERSION = '1.3.0' AUTHOR = 'Philip Hane' AUTHOR_EMAIL = 'secynic@gmail.com' DESCRIPTION = 'Retrieve and parse whois data for IPv4 and IPv6 addresses.' From 50d772f92457f746848d5f6cf8482618b57aa47e Mon Sep 17 00:00:00 2001 From: secynic Date: Tue, 15 Oct 2024 00:40:20 -0500 Subject: [PATCH 21/26] v1.3.0 --- README.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.rst b/README.rst index 541764e..f134097 100644 --- a/README.rst +++ b/README.rst @@ -100,10 +100,12 @@ Python 2.7:: dnspython ipaddr + defusedxml Python 3.4+:: dnspython + defusedxml Installing ========== From 09de769d2aca83fce41f177fe5a05674d6891d56 Mon Sep 17 00:00:00 2001 From: secynic Date: Tue, 15 Oct 2024 00:41:36 -0500 Subject: [PATCH 22/26] v1.3.0 --- setup.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/setup.py b/setup.py index 5340c18..3bb5d18 100644 --- a/setup.py +++ b/setup.py @@ -59,6 +59,10 @@ 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', 'Topic :: Internet', 'Topic :: Software Development', ] From 945ea5dccb1700880ba2fb3c71be5d393cb44ca0 Mon Sep 17 00:00:00 2001 From: secynic Date: Tue, 15 Oct 2024 00:42:14 -0500 Subject: [PATCH 23/26] Remove travis reference --- CONTRIBUTING.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 5808f7f..e151568 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -48,7 +48,7 @@ Feature Requests Testing ======= -You may have noticed that Travis CI tests are taking longer to complete. +You may have noticed that CI tests are taking longer to complete. This is due to the enabling of online lookup tests (network tests in the ipwhois/tests/online directory). From a463693bab83e791a31f66796aeae2a30f82727f Mon Sep 17 00:00:00 2001 From: secynic Date: Tue, 15 Oct 2024 01:13:54 -0500 Subject: [PATCH 24/26] Update examples v1.3.0 --- ASN.rst | 21 +++++++ EXPERIMENTAL.rst | 6 +- NIR.rst | 152 +++++++++++++++++++++++++++++++++++++---------- RDAP.rst | 82 +++++++++++++++++++------ 4 files changed, 208 insertions(+), 53 deletions(-) diff --git a/ASN.rst b/ASN.rst index 23691ed..eb1bf32 100644 --- a/ASN.rst +++ b/ASN.rst @@ -249,12 +249,33 @@ Basic usage "source": "AFRINIC", "updated": "***@isoc.org 20160720" }, + { + "cidr": "196.49.22.0/24", + "description": "KIXP Mombasa Management Network", + "maintainer": "TESPOK-MNT", + "source": "AFRINIC", + "updated": "***@tespok.co.ke 20210510" + }, + { + "cidr": "2001:43f8:c1::/48", + "description": "KIXP Mombasa Management Network", + "maintainer": "TESPOK-MNT", + "source": "AFRINIC", + "updated": "***@tespok.co.ke 20201218" + }, { "cidr": "2001:43f8:7b0::/48", "description": "KIXP Nairobi Management Network", "maintainer": "TESPOK-MNT", "source": "AFRINIC", "updated": "***@isoc.org 20160721" + }, + { + "cidr": "2001:43f8:c40::/48", + "description": "KIXP GRX Management", + "maintainer": "TESPOK-MNT", + "source": "AFRINIC", + "updated": "***@tespok.co.ke 20201218" } ], "query": "AS37578", diff --git a/EXPERIMENTAL.rst b/EXPERIMENTAL.rst index 0c6179f..a7a7743 100644 --- a/EXPERIMENTAL.rst +++ b/EXPERIMENTAL.rst @@ -68,15 +68,15 @@ Basic usage >>>> pprint(results.split('\n')) [ - "Bulk mode; whois.cymru.com [2020-09-15 16:42:29 +0000]", + "Bulk mode; whois.cymru.com [2024-10-15 05:46:42 +0000]", "15169 | 74.125.225.229 | 74.125.225.0/24 | US | arin | 2007-03-13 | GOOGLE, US", "15169 | 2001:4860:4860::8888 | 2001:4860::/32 | US | arin | 2005-03-14 | GOOGLE, US", "2856 | 62.239.237.1 | 62.239.0.0/16 | GB | ripencc | 2001-01-02 | BT-UK-AS BTnet UK Regional network, GB", "2856 | 2a00:2381:ffff::1 | 2a00:2380::/25 | GB | ripencc | 2007-08-29 | BT-UK-AS BTnet UK Regional network, GB", "3786 | 210.107.73.73 | 210.107.0.0/17 | KR | apnic | 1997-08-29 | LGDACOM LG DACOM Corporation, KR", "2497 | 2001:240:10c:1::ca20:9d1d | 2001:240::/32 | JP | apnic | 2000-03-08 | IIJ Internet Initiative Japan Inc., JP", - "19373 | 200.57.141.161 | 200.57.128.0/20 | MX | lacnic | 2000-12-04 | Triara.com, S.A. de C.V., MX", - "NA | 2801:10:c000:: | NA | CO | lacnic | 2013-10-29 | NA", + "19373 | 200.57.141.161 | 200.57.128.0/20 | MX | lacnic | 2000-12-04 | Triara.com S.A. de C.V., MX", + "264653 | 2801:10:c000:: | 2801:10:c000::/48 | CO | lacnic | 2013-10-29 | Universidad Catolica de Oriente, CO", "12091 | 196.11.240.215 | 196.11.240.0/24 | ZA | afrinic | 1994-07-21 | MTNNS-1, ZA", "37578 | 2001:43f8:7b0:: | 2001:43f8:7b0::/48 | KE | afrinic | 2013-03-22 | Tespok, KE", "4730 | 133.1.2.5 | 133.1.0.0/16 | JP | apnic | 1997-03-01 | ODINS Osaka University, JP", diff --git a/NIR.rst b/NIR.rst index e36c8bd..0736083 100644 --- a/NIR.rst +++ b/NIR.rst @@ -178,28 +178,26 @@ show the usage and results. "asn": "4730", "asn_cidr": "133.1.0.0/16", "asn_country_code": "JP", - "asn_date": "", + "asn_date": "1997-03-01", "asn_description": "ODINS Osaka University, JP", "asn_registry": "apnic", "nets": [ { - "address": "Urbannet-Kanda Bldg 4F\n3-6-2 Uchi-Kanda\nChiyoda-ku, Tokyo 101-0047,Japan", + "address": "Uchikanda OS Bldg 4F, 2-12-6 Uchi-Kanda\nChiyoda-ku, Tokyo 101-0047, japan", "cidr": "133.0.0.0/8", "city": None, "country": "JP", "created": None, "description": "Japan Network Information Center", "emails": [ - "hm-changed@apnic.net", - "hostmaster@nic.ad.jp", - "ip-apnic@nic.ad.jp" + "hostmaster@nic.ad.jp" ], - "handle": "JNIC1-AP", + "handle": "AJ382-AP", "name": "JPNIC-NET-JP-ERX", "postal_code": None, "range": "133.0.0.0 - 133.255.255.255", "state": None, - "updated": "20120828" + "updated": None } ], "nir": { @@ -212,23 +210,23 @@ show the usage and results. "division": "Department of Information and Communications Technology Services", "email": "odins-room@odins.osaka-u.ac.jp", "fax": "06-6879-8988", - "name": "Yoshihide, Minami", + "name": "Minami, Yoshihide", "organization": "Osaka University", "phone": "06-6879-8815", - "reply_email": "reg@jpdirect.jp", + "reply_email": "odins-room@odins.osaka-u.ac.jp", "title": "Specialist", - "updated": "2015-08-13T09:08:34" + "updated": "2022-06-30T03:50:03" }, "tech": { "division": "Department of Information and Communications Technology Services", "email": "odins-room@odins.osaka-u.ac.jp", "fax": "06-6879-8988", - "name": "Yoshihide, Minami", + "name": "Minami, Yoshihide", "organization": "Osaka University", "phone": "06-6879-8815", - "reply_email": "reg@jpdirect.jp", + "reply_email": "odins-room@odins.osaka-u.ac.jp", "title": "Specialist", - "updated": "2015-08-13T09:08:34" + "updated": "2022-06-30T03:50:03" } }, "country": "JP", @@ -242,7 +240,7 @@ show the usage and results. ], "postal_code": None, "range": "133.1.0.1 - 133.1.255.255", - "updated": "2015-01-14T02:50:03" + "updated": "2022-07-15T05:50:05" } ], "query": "133.1.2.5", @@ -261,27 +259,34 @@ show the usage and results. "asn": "4730", "asn_cidr": "133.1.0.0/16", "asn_country_code": "JP", - "asn_date": "", + "asn_date": "1997-03-01", "asn_description": "ODINS Osaka University, JP", "asn_registry": "apnic", "entities": [ - "JNIC1-AP" + "JNIC1-AP", + "IRT-JPNIC-JP" ], "network": { "cidr": "133.0.0.0/8", "country": "JP", "end_address": "133.255.255.255", "events": [ + { + "action": "registration", + "actor": None, + "timestamp": "2022-11-01T04:33:10Z" + }, { "action": "last changed", "actor": None, - "timestamp": "2009-10-30T00:51:09Z" + "timestamp": "2022-11-01T04:33:10Z" } ], "handle": "133.0.0.0 - 133.255.255.255", "ip_version": "v4", "links": [ - "http://rdap.apnic.net/ip/133.0.0.0/8" + "https://rdap.apnic.net/ip/133.0.0.0/8", + "https://netox.apnic.net/search/133.0.0.0%2F8?utm_source=rdap&utm_medium=result&utm_campaign=rdap_result" ], "name": "JPNIC-NET-JP-ERX", "notices": [ @@ -296,6 +301,13 @@ show the usage and results. "http://www.apnic.net/db/dbcopyright.html" ], "title": "Terms and Conditions" + }, + { + "description": "If you see inaccuracies in the results, please visit: ", + "links": [ + "https://www.apnic.net/manage-ip/using-whois/abuse-and-spamming/invalid-contact-form" + ], + "title": "Whois Inaccuracy Reporting" } ], "parent_handle": None, @@ -313,7 +325,9 @@ show the usage and results. } ], "start_address": "133.0.0.0", - "status": None, + "status": [ + "active" + ], "type": "ALLOCATED PORTABLE" }, "nir": { @@ -326,23 +340,23 @@ show the usage and results. "division": "Department of Information and Communications Technology Services", "email": "odins-room@odins.osaka-u.ac.jp", "fax": "06-6879-8988", - "name": "Yoshihide, Minami", + "name": "Minami, Yoshihide", "organization": "Osaka University", "phone": "06-6879-8815", - "reply_email": "reg@jpdirect.jp", + "reply_email": "odins-room@odins.osaka-u.ac.jp", "title": "Specialist", - "updated": "2015-08-13T09:08:34" + "updated": "2022-06-30T03:50:03" }, "tech": { "division": "Department of Information and Communications Technology Services", "email": "odins-room@odins.osaka-u.ac.jp", "fax": "06-6879-8988", - "name": "Yoshihide, Minami", + "name": "Minami, Yoshihide", "organization": "Osaka University", "phone": "06-6879-8815", - "reply_email": "reg@jpdirect.jp", + "reply_email": "odins-room@odins.osaka-u.ac.jp", "title": "Specialist", - "updated": "2015-08-13T09:08:34" + "updated": "2022-06-30T03:50:03" } }, "country": "JP", @@ -356,19 +370,84 @@ show the usage and results. ], "postal_code": None, "range": "133.1.0.1 - 133.1.255.255", - "updated": "2015-01-14T02:50:03" + "updated": "2022-07-15T05:50:05" } ], "query": "133.1.2.5", "raw": None }, "objects": { + "IRT-JPNIC-JP": { + "contact": { + "address": [ + { + "type": None, + "value": "Uchikanda OS Bldg 4F, 2-12-6 Uchi-Kanda\nChiyoda-ku, Tokyo 101-0047, japan" + } + ], + "email": [ + { + "type": None, + "value": "hostmaster@nic.ad.jp" + }, + { + "type": None, + "value": "hostmaster@nic.ad.jp" + } + ], + "kind": "group", + "name": "IRT-JPNIC-JP", + "phone": [ + { + "type": "voice", + "value": "+81-3-5297-2311" + }, + { + "type": "fax", + "value": "+81-3-5297-2312" + } + ], + "role": None, + "title": None + }, + "entities": None, + "events": [ + { + "action": "registration", + "actor": None, + "timestamp": "2010-11-08T01:21:46Z" + }, + { + "action": "last changed", + "actor": None, + "timestamp": "2024-09-28T21:13:03Z" + } + ], + "events_actor": None, + "handle": "IRT-JPNIC-JP", + "links": [ + "https://rdap.apnic.net/entity/IRT-JPNIC-JP" + ], + "notices": None, + "raw": None, + "remarks": [ + { + "description": "hostmaster@nic.ad.jp is invalid", + "links": None, + "title": "remarks" + } + ], + "roles": [ + "abuse" + ], + "status": None + }, "JNIC1-AP": { "contact": { "address": [ { "type": None, - "value": "Urbannet-Kanda Bldg 4F\n3-6-2 Uchi-Kanda\nChiyoda-ku, Tokyo 101-0047,Japan" + "value": "Uchikanda OS Bldg 4F, 2-12-6 Uchi-Kanda\nChiyoda-ku, Tokyo 101-0047, Japan" } ], "email": [ @@ -393,18 +472,29 @@ show the usage and results. "title": None }, "entities": None, - "events": None, + "events": [ + { + "action": "registration", + "actor": None, + "timestamp": "2008-09-04T07:54:15Z" + }, + { + "action": "last changed", + "actor": None, + "timestamp": "2022-01-05T03:04:02Z" + } + ], "events_actor": None, "handle": "JNIC1-AP", "links": [ - "http://rdap.apnic.net/entity/JNIC1-AP" + "https://rdap.apnic.net/entity/JNIC1-AP" ], "notices": None, "raw": None, "remarks": None, "roles": [ - "technical", - "administrative" + "administrative", + "technical" ], "status": None } diff --git a/RDAP.rst b/RDAP.rst index b41ad95..75307b8 100644 --- a/RDAP.rst +++ b/RDAP.rst @@ -306,7 +306,7 @@ Basic usage "asn_cidr": "74.125.225.0/24", "asn_country_code": "US", "asn_date": "2007-03-13", - "asn_description": "GOOGLE - Google Inc., US", + "asn_description": "GOOGLE, US", "asn_registry": "arin", "entities": [ "GOGL" @@ -330,7 +330,7 @@ Basic usage "handle": "NET-74-125-0-0-1", "ip_version": "v4", "links": [ - "https://rdap.arin.net/registry/ip/074.125.000.000", + "https://rdap.arin.net/registry/ip/74.125.0.0", "https://whois.arin.net/rest/net/NET-74-125-0-0-1" ], "name": "GOOGLE", @@ -338,17 +338,31 @@ Basic usage { "description": "By using the ARIN RDAP/Whois service, you are agreeing to the RDAP/Whois Terms of Use", "links": [ - "https://www.arin.net/whois_tou.html" + "https://www.arin.net/resources/registry/whois/tou/" ], "title": "Terms of Service" + }, + { + "description": "If you see inaccuracies in the results, please visit: ", + "links": [ + "https://www.arin.net/resources/registry/whois/inaccuracy_reporting/" + ], + "title": "Whois Inaccuracy Reporting" + }, + { + "description": "Copyright 1997-2024, American Registry for Internet Numbers, Ltd.", + "links": None, + "title": "Copyright Notice" } ], "parent_handle": "NET-74-0-0-0-0", "raw": None, "remarks": None, "start_address": "74.125.0.0", - "status": None, - "type": None + "status": [ + "active" + ], + "type": "DIRECT ALLOCATION" }, "nir": None, "objects": { @@ -357,7 +371,7 @@ Basic usage "address": [ { "type": None, - "value": "1600 Amphitheatre Parkway\nMountain View\nCA\n94043\nUNITED STATES" + "value": "1600 Amphitheatre Parkway\nMountain View\nCA\n94043\nUnited States" } ], "email": [ @@ -385,7 +399,7 @@ Basic usage { "action": "last changed", "actor": None, - "timestamp": "2016-11-08T14:12:52-05:00" + "timestamp": "2024-08-01T17:54:23-04:00" }, { "action": "registration", @@ -403,15 +417,27 @@ Basic usage { "description": "By using the ARIN RDAP/Whois service, you are agreeing to the RDAP/Whois Terms of Use", "links": [ - "https://www.arin.net/whois_tou.html" + "https://www.arin.net/resources/registry/whois/tou/" ], "title": "Terms of Service" + }, + { + "description": "If you see inaccuracies in the results, please visit: ", + "links": [ + "https://www.arin.net/resources/registry/whois/inaccuracy_reporting/" + ], + "title": "Whois Inaccuracy Reporting" + }, + { + "description": "Copyright 1997-2024, American Registry for Internet Numbers, Ltd.", + "links": None, + "title": "Copyright Notice" } ], "raw": None, "remarks": [ { - "description": "Please note that the recommended way to file abuse complaints are located in the following links.\r\n\r\nTo report abuse and illegal activity: https://www.google.com/intl/en_US/goodtoknow/online-safety/reporting-abuse/ \r\n\r\nFor legal requests: http://support.google.com/legal \r\n\r\nRegards,\r\nThe Google Team", + "description": "Please note that the recommended way to file abuse complaints are located in the following links.\n\nTo report abuse and illegal activity: https://www.google.com/contact/\n\nFor legal requests: http://support.google.com/legal \n\nRegards,\nThe Google Team", "links": None, "title": "Registration Comments" } @@ -428,12 +454,12 @@ Basic usage "address": [ { "type": None, - "value": "1600 Amphitheatre Parkway\nMountain View\nCA\n94043\nUNITED STATES" + "value": "1600 Amphitheatre Parkway\nMountain View\nCA\n94043\nUnited States" } ], "email": None, "kind": "org", - "name": "Google Inc.", + "name": "Google LLC", "phone": None, "role": None, "title": None @@ -446,7 +472,7 @@ Basic usage { "action": "last changed", "actor": None, - "timestamp": "2017-01-28T08:32:29-05:00" + "timestamp": "2019-10-31T15:45:45-04:00" }, { "action": "registration", @@ -462,7 +488,13 @@ Basic usage ], "notices": None, "raw": None, - "remarks": None, + "remarks": [ + { + "description": "Please note that the recommended way to file abuse complaints are located in the following links. \n\nTo report abuse and illegal activity: https://www.google.com/contact/\n\nFor legal requests: http://support.google.com/legal \n\nRegards, \nThe Google Team", + "links": None, + "title": "Registration Comments" + } + ], "roles": [ "registrant" ], @@ -473,7 +505,7 @@ Basic usage "address": [ { "type": None, - "value": "1600 Amphitheatre Parkway\nMountain View\nCA\n94043\nUNITED STATES" + "value": "1600 Amphitheatre Parkway\nMountain View\nCA\n94043\nUnited States" } ], "email": [ @@ -483,7 +515,7 @@ Basic usage } ], "kind": "group", - "name": "Google Inc", + "name": "Google LLC", "phone": [ { "type": [ @@ -501,7 +533,7 @@ Basic usage { "action": "last changed", "actor": None, - "timestamp": "2017-03-13T07:08:09-04:00" + "timestamp": "2023-11-10T07:01:59-05:00" }, { "action": "registration", @@ -519,16 +551,28 @@ Basic usage { "description": "By using the ARIN RDAP/Whois service, you are agreeing to the RDAP/Whois Terms of Use", "links": [ - "https://www.arin.net/whois_tou.html" + "https://www.arin.net/resources/registry/whois/tou/" ], "title": "Terms of Service" + }, + { + "description": "If you see inaccuracies in the results, please visit: ", + "links": [ + "https://www.arin.net/resources/registry/whois/inaccuracy_reporting/" + ], + "title": "Whois Inaccuracy Reporting" + }, + { + "description": "Copyright 1997-2024, American Registry for Internet Numbers, Ltd.", + "links": None, + "title": "Copyright Notice" } ], "raw": None, "remarks": None, "roles": [ - "administrative", - "technical" + "technical", + "administrative" ], "status": [ "validated" From 1bf8f81c4b0fcf70cfbcdbf4fd40673bddf289ad Mon Sep 17 00:00:00 2001 From: secynic Date: Tue, 15 Oct 2024 01:17:39 -0500 Subject: [PATCH 25/26] Update timeout --- ipwhois/scripts/docs/generate_examples.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ipwhois/scripts/docs/generate_examples.py b/ipwhois/scripts/docs/generate_examples.py index c5a6ea2..daca6ac 100644 --- a/ipwhois/scripts/docs/generate_examples.py +++ b/ipwhois/scripts/docs/generate_examples.py @@ -248,13 +248,13 @@ ' >>>> from ipwhois import IPWhois\n' ' >>>> from pprint import pprint\n\n' ' >>>> obj = IPWhois(\'38.113.198.252\')\n' - ' >>>> results = obj.lookup_whois(get_referral=True)\n' + ' >>>> results = obj.lookup_whois(get_referral=True, timeout=30)\n' ' >>>> pprint(results)\n\n' ' {0}' ), 'queries': { '0': lambda: IPWhois('38.113.198.252', - timeout=15).lookup_whois( + timeout=30).lookup_whois( get_referral=True, retry_count=10 ), } From c184dde2f1a6b3596efe950a7440a689d9d7cc18 Mon Sep 17 00:00:00 2001 From: secynic Date: Tue, 15 Oct 2024 01:17:59 -0500 Subject: [PATCH 26/26] Don't raise error when no rwhois results --- ipwhois/net.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ipwhois/net.py b/ipwhois/net.py index 091f802..a904654 100644 --- a/ipwhois/net.py +++ b/ipwhois/net.py @@ -611,12 +611,17 @@ def get_whois(self, asn_registry='arin', retry_count=3, server=None, 'exceeded, wait and try again (possibly a ' 'temporary block).'.format(self.address_str)) - elif ('error 501' in response or 'error 230' in response - ): # pragma: no cover + elif 'error 501' in response: # pragma: no cover log.debug('WHOIS query error: {0}'.format(response)) raise ValueError + elif 'error 230' in response: # pragma: no cover + + # No results found + log.debug('WHOIS query error: {0}'.format(response)) + pass + return str(response) except (socket.timeout, socket.error) as e: