From 4f20005caf8c133c60c329b0d1c1a8d67f8519e6 Mon Sep 17 00:00:00 2001 From: secynic Date: Sun, 30 Jul 2017 18:45:50 -0500 Subject: [PATCH 1/8] experimental usage examples (#134) --- EXPERIMENTAL.rst | 69 +++++++++++++++++++++++ ipwhois/scripts/docs/generate_examples.py | 69 +++++++++++++++++++++++ 2 files changed, 138 insertions(+) diff --git a/EXPERIMENTAL.rst b/EXPERIMENTAL.rst index 1ecf138..4255ca5 100644 --- a/EXPERIMENTAL.rst +++ b/EXPERIMENTAL.rst @@ -58,6 +58,32 @@ Basic usage .. GET_BULK_ASN_WHOIS_OUTPUT_BASIC START +:: + + >>>> from ipwhois.experimental import get_bulk_asn_whois + >>>> from pprint import pprint + + >>>> ip_list = ['74.125.225.229', '2001:4860:4860::8888', '62.239.237.1', '2a00:2381:ffff::1', '210.107.73.73', '2001:240:10c:1::ca20:9d1d', '200.57.141.161', '2801:10:c000::', '196.11.240.215', '2001:43f8:7b0::', '133.1.2.5', '115.1.2.3'] + >>>> results = get_bulk_asn_whois(addresses=ip_list) + >>>> pprint(results.split('\n')) + + [ + "Bulk mode; whois.cymru.com [2017-07-30 23:02:21 +0000]", + "15169 | 74.125.225.229 | 74.125.225.0/24 | US | arin | 2007-03-13 | GOOGLE - Google Inc., US", + "15169 | 2001:4860:4860::8888 | 2001:4860::/32 | US | arin | 2005-03-14 | GOOGLE - Google Inc., 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 | | 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", + "12091 | 196.11.240.215 | 196.11.240.0/24 | ZA | afrinic | | 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 | | ODINS Osaka University, JP", + "4134 | 115.1.2.3 | 115.0.0.0/14 | KR | apnic | 2008-07-01 | CHINANET-BACKBONE No.31,Jin-rong Street, CN", + "" + } + .. GET_BULK_ASN_WHOIS_OUTPUT_BASIC END Bulk RDAP Lookups @@ -180,4 +206,47 @@ Basic usage .. BULK_LOOKUP_RDAP_OUTPUT_BASIC START +:: + + >>>> from ipwhois.experimental import bulk_lookup_rdap + >>>> from pprint import pprint + + >>>> ip_list = ['74.125.225.229', '2001:4860:4860::8888', '62.239.237.1', '2a00:2381:ffff::1', '210.107.73.73', '2001:240:10c:1::ca20:9d1d', '200.57.141.161', '2801:10:c000::', '196.11.240.215', '2001:43f8:7b0::', '133.1.2.5', '115.1.2.3'] + >>>> results, stats = bulk_lookup_rdap(addresses=ip_list) + >>>> pprint(stats) + + { + "afrinic": { + "failed": [], + "rate_limited": [], + "total": 2 + }, + "apnic": { + "failed": [ + "115.1.2.3" + ], + "rate_limited": [], + "total": 4 + }, + "arin": { + "failed": [], + "rate_limited": [], + "total": 2 + }, + "ip_input_total": 12, + "ip_lookup_total": 12, + "ip_unique_total": 12, + "lacnic": { + "failed": [], + "rate_limited": [], + "total": 2 + }, + "ripencc": { + "failed": [], + "rate_limited": [], + "total": 2 + }, + "unallocated_addresses": [] + } + .. BULK_LOOKUP_RDAP_OUTPUT_BASIC END diff --git a/ipwhois/scripts/docs/generate_examples.py b/ipwhois/scripts/docs/generate_examples.py index 8b696b0..e34222d 100644 --- a/ipwhois/scripts/docs/generate_examples.py +++ b/ipwhois/scripts/docs/generate_examples.py @@ -29,6 +29,7 @@ import logging import re from ipwhois import IPWhois +from ipwhois.experimental import (get_bulk_asn_whois, bulk_lookup_rdap) from ipwhois.net import Net from ipwhois.asn import (ASNOrigin, IPASN) from ipwhois.utils import unique_everseen @@ -113,6 +114,74 @@ } } }, + 'EXPERIMENTAL.rst': { + 'GET_BULK_ASN_WHOIS_OUTPUT_BASIC': { + 'content': ( + '::\n\n' + ' >>>> from ipwhois.experimental import get_bulk_asn_whois' + '\n' + ' >>>> from pprint import pprint\n\n' + ' >>>> ip_list = [\'74.125.225.229\', ' + '\'2001:4860:4860::8888\', \'62.239.237.1\', ' + '\'2a00:2381:ffff::1\', \'210.107.73.73\', ' + '\'2001:240:10c:1::ca20:9d1d\', \'200.57.141.161\', ' + '\'2801:10:c000::\', \'196.11.240.215\', \'2001:43f8:7b0::\', ' + '\'133.1.2.5\', \'115.1.2.3\']\n' + ' >>>> results = get_bulk_asn_whois(addresses=ip_list)\n' + ' >>>> pprint(results.split(\'\\\\n\'))\n\n' + ' {0}' + ), + 'queries': { + '0': lambda: get_bulk_asn_whois([ + '74.125.225.229', # ARIN + '2001:4860:4860::8888', + '62.239.237.1', # RIPE + '2a00:2381:ffff::1', + '210.107.73.73', # APNIC + '2001:240:10c:1::ca20:9d1d', + '200.57.141.161', # LACNIC + '2801:10:c000::', + '196.11.240.215', # AFRINIC + '2001:43f8:7b0::', + '133.1.2.5', # JPNIC + '115.1.2.3' # KRNIC + ]).split('\n'), + } + }, + 'BULK_LOOKUP_RDAP_OUTPUT_BASIC': { + 'content': ( + '::\n\n' + ' >>>> from ipwhois.experimental import bulk_lookup_rdap\n' + ' >>>> from pprint import pprint\n\n' + ' >>>> ip_list = [\'74.125.225.229\', ' + '\'2001:4860:4860::8888\', \'62.239.237.1\', ' + '\'2a00:2381:ffff::1\', \'210.107.73.73\', ' + '\'2001:240:10c:1::ca20:9d1d\', \'200.57.141.161\', ' + '\'2801:10:c000::\', \'196.11.240.215\', \'2001:43f8:7b0::\', ' + '\'133.1.2.5\', \'115.1.2.3\']\n' + ' >>>> results, stats = bulk_lookup_rdap(addresses=ip_list)' + '\n' + ' >>>> pprint(stats)\n\n' + ' {0}' + ), + 'queries': { + '0': lambda: bulk_lookup_rdap(addresses=[ + '74.125.225.229', # ARIN + '2001:4860:4860::8888', + '62.239.237.1', # RIPE + '2a00:2381:ffff::1', + '210.107.73.73', # APNIC + '2001:240:10c:1::ca20:9d1d', + '200.57.141.161', # LACNIC + '2801:10:c000::', + '196.11.240.215', # AFRINIC + '2001:43f8:7b0::', + '133.1.2.5', # JPNIC + '115.1.2.3' # KRNIC + ])[1], + } + } + }, 'NIR.rst': { 'OUTPUT_BASIC': { 'content': ( From f81dd200c753af952894d4fa396eef638037f46e Mon Sep 17 00:00:00 2001 From: secynic Date: Sun, 30 Jul 2017 18:47:03 -0500 Subject: [PATCH 2/8] usage examples --- NIR.rst | 4 ++-- WHOIS.rst | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/NIR.rst b/NIR.rst index bf3c70e..5f030fc 100644 --- a/NIR.rst +++ b/NIR.rst @@ -402,8 +402,8 @@ show the usage and results. "raw": None, "remarks": None, "roles": [ - "administrative", - "technical" + "technical", + "administrative" ], "status": None } diff --git a/WHOIS.rst b/WHOIS.rst index ffcd1da..d2a5722 100644 --- a/WHOIS.rst +++ b/WHOIS.rst @@ -282,9 +282,9 @@ Multiple networks listed and referral whois "created": "1991-04-16", "description": "PSINet, Inc.", "emails": [ + "ipalloc@cogentco.com", "abuse@cogentco.com", - "noc@cogentco.com", - "ipalloc@cogentco.com" + "noc@cogentco.com" ], "handle": "NET-38-0-0-0-1", "name": "COGENT-A", @@ -301,9 +301,9 @@ Multiple networks listed and referral whois "created": "2003-08-20", "description": "PSINet, Inc.", "emails": [ + "ipalloc@cogentco.com", "abuse@cogentco.com", - "noc@cogentco.com", - "ipalloc@cogentco.com" + "noc@cogentco.com" ], "handle": "NET-38-112-0-0-1", "name": "COGENT-NB-0002", From 298da630b630db77c29b30d2901891c9172320c3 Mon Sep 17 00:00:00 2001 From: secynic Date: Sun, 30 Jul 2017 18:51:21 -0500 Subject: [PATCH 3/8] version bump (1.0.0) --- ipwhois/__init__.py | 2 +- ipwhois/docs/source/conf.py | 4 ++-- setup.cfg | 2 ++ setup.py | 20 ++++++++------------ 4 files changed, 13 insertions(+), 15 deletions(-) create mode 100644 setup.cfg diff --git a/ipwhois/__init__.py b/ipwhois/__init__.py index 4ffd843..ad0ea34 100644 --- a/ipwhois/__init__.py +++ b/ipwhois/__init__.py @@ -26,4 +26,4 @@ from .net import Net from .ipwhois import IPWhois -__version__ = '0.15.1' +__version__ = '1.0.0' diff --git a/ipwhois/docs/source/conf.py b/ipwhois/docs/source/conf.py index 27b495d..2b6c290 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 = '0.15.1' +version = '1.0.0' # The full version, including alpha/beta/rc tags. -release = '0.15.1' +release = '1.0.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..3480374 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,2 @@ +[bdist_wheel] +universal=1 \ No newline at end of file diff --git a/setup.py b/setup.py index 64aabdf..4e61331 100644 --- a/setup.py +++ b/setup.py @@ -1,15 +1,14 @@ # Filename: setup.py -from distutils.core import setup -import sys +from setuptools import setup import io NAME = 'ipwhois' -VERSION = '0.15.1' +VERSION = '1.0.0' AUTHOR = 'Philip Hane' AUTHOR_EMAIL = 'secynic@gmail.com' DESCRIPTION = 'Retrieve and parse whois data for IPv4 and IPv6 addresses.' -KEYWORDS = [ +KEYWORDS = ' '.join([ 'Python', 'WHOIS', 'RWhois', @@ -32,20 +31,20 @@ 'RIR', 'Regional Internet Registry' 'NIR', - 'National Intgernet Registry', + 'National Internet Registry', 'ASN origin', 'Origin' -] +]) README = io.open(file='README.rst', mode='r', encoding='utf-8').read() CHANGES = io.open(file='CHANGES.rst', mode='r', encoding='utf-8').read() LONG_DESCRIPTION = '\n\n'.join([README, CHANGES]) -LICENSE = io.open(file='LICENSE.txt', mode='r', encoding='utf-8').read() +LICENSE = 'BSD' URL = 'https://github.com/secynic/ipwhois' DOWNLOAD_URL = 'https://github.com/secynic/ipwhois/tarball/master' CLASSIFIERS = [ - 'Development Status :: 4 - Beta', + 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', 'Intended Audience :: Information Technology', 'Intended Audience :: Science/Research', @@ -68,10 +67,7 @@ PACKAGE_DATA = {'ipwhois': ['data/*.xml', 'data/*.csv']} -INSTALL_REQUIRES = ['dnspython'] - -if sys.version_info < (3, 3,): - INSTALL_REQUIRES.append('ipaddr') +INSTALL_REQUIRES = ['dnspython', 'ipaddr;python_version<"3.3"'] setup( name=NAME, From 278bf1246a8fdd815f98ee2266aab5e4a6b7e230 Mon Sep 17 00:00:00 2001 From: secynic Date: Sun, 30 Jul 2017 19:50:16 -0500 Subject: [PATCH 4/8] 1.0.0 docs update --- ASN.rst | 110 +++++++++++++++++------------- EXPERIMENTAL.rst | 28 ++++---- NIR.rst | 65 +++++++++--------- RDAP.rst | 171 +++++++++++++++++++++++++---------------------- README.rst | 12 ++-- WHOIS.rst | 147 +++++++++++++++++++++++----------------- 6 files changed, 291 insertions(+), 242 deletions(-) diff --git a/ASN.rst b/ASN.rst index 8dca575..f2ef8f1 100644 --- a/ASN.rst +++ b/ASN.rst @@ -15,37 +15,41 @@ Arguments supported by IPASN.lookup(). +------------------------+--------+-------------------------------------------+ | **Key** |**Type**| **Description** | +------------------------+--------+-------------------------------------------+ -| inc_raw | Bool | Boolean for whether to include the raw | -| | | whois results in the returned dictionary. | +| inc_raw | bool | Whether to include the raw whois results | +| | | in the returned dictionary. Defaults to | +| | | False. | +------------------------+--------+-------------------------------------------+ -| retry_count | Int | The number of times to retry in case | +| retry_count | int | The number of times to retry in case | | | | socket errors, timeouts, connection | | | | resets, etc. are encountered. | +| | | Defaults to 3. | +------------------------+--------+-------------------------------------------+ -| asn_alts | List | List of additional lookup types to | -| | | attempt if the ASN dns lookup fails. | -| | | Allow permutations must be enabled. | -| | | Defaults to all ['whois', 'http']. | -| | | *WARNING* deprecated in favor of new | -| | | argument asn_methods. | +| asn_alts | list | Additional lookup types to attempt if the | +| | | ASN dns lookup fails. Allow permutations | +| | | must be enabled. If None, defaults to all | +| | | ['whois', 'http']. *WARNING* deprecated | +| | | in favor of new argument asn_methods. | +------------------------+--------+-------------------------------------------+ -| asn_methods | List | List of ASN lookup types to attempt, in | -| | | order. Defaults to all | -| | | ['dns', 'whois', 'http']. | +| extra_org_map | dict | Dictionary mapping org handles to RIRs. | +| | | This is for limited cases where ARIN | +| | | REST (ASN fallback HTTP lookup) does not | +| | | show an RIR as the org handle e.g., DNIC | +| | | (which is now built in ORG_MAP) | +| | | e.g., {'DNIC': 'arin'} | +| | | Valid RIR values are (note the | +| | | case-sensitive - this is meant to match | +| | | the REST result): 'ARIN', 'RIPE', | +| | | 'apnic', 'lacnic', 'afrinic' | +| | | Defaults to None. | +------------------------+--------+-------------------------------------------+ -| extra_org_map | List | Dictionary mapping org handles to RIRs. | -| | | This is for limited cases where ARIN REST | -| | | (ASN fallback HTTP lookup) does not show | -| | | an RIR as the org handle e.g., DNIC | -| | | (which is now the built in ORG_MAP) e.g., | -| | | {'DNIC': 'arin'}. Valid RIR values are | -| | | (note the case-sensitive - this is meant | -| | | to match the REST result): 'ARIN', | -| | | 'RIPE', 'apnic', 'lacnic', 'afrinic' | +| asn_methods | list | ASN lookup types to attempt, in order. If | +| | | None, defaults to all ['dns', 'whois', | +| | | 'http']. | +------------------------+--------+-------------------------------------------+ -| get_asn_description | Bool | Boolean for whether to run an additional | -| | | query when pulling ASN information via | -| | | dns, in order to get the ASN description. | +| get_asn_description | bool | Whether to run an additional query when | +| | | pulling ASN information via dns, in order | +| | | to get the ASN description. Defaults to | +| | | True. | +------------------------+--------+-------------------------------------------+ .. _ip-asn-output: @@ -63,19 +67,19 @@ The output dictionary from IPASN.lookup(). +------------------+--------+-------------------------------------------------+ | **Key** |**Type**| **Description** | +------------------+--------+-------------------------------------------------+ -| asn | String | The Autonomous System Number | +| asn | str | The Autonomous System Number | +------------------+--------+-------------------------------------------------+ -| asn_date | String | The ASN Allocation date | +| asn_date | str | The ASN Allocation date | +------------------+--------+-------------------------------------------------+ -| asn_registry | String | The assigned ASN registry | +| asn_registry | str | The assigned ASN registry | +------------------+--------+-------------------------------------------------+ -| asn_cidr | String | The assigned ASN CIDR | +| asn_cidr | str | The assigned ASN CIDR | +------------------+--------+-------------------------------------------------+ -| asn_country_code | String | The assigned ASN country code | +| asn_country_code | str | The assigned ASN country code | +------------------+--------+-------------------------------------------------+ -| asn_description | String | The ASN description | +| asn_description | str | The ASN description | +------------------+--------+-------------------------------------------------+ -| raw | String | Raw ASN results if inc_raw is True. | +| raw | str | Raw ASN results if inc_raw is True. | +------------------+--------+-------------------------------------------------+ .. _ip-asn-usage-examples: @@ -134,23 +138,33 @@ Arguments supported by ASNOrigin.lookup(). +------------------------+--------+-------------------------------------------+ | **Key** |**Type**| **Description** | +------------------------+--------+-------------------------------------------+ -| asn | String | The autonomous system number (ASN) to | +| asn | str | The autonomous system number (ASN) to | | | | lookup. May be in format '1234'/'AS1234' | +------------------------+--------+-------------------------------------------+ -| inc_raw | Bool | Boolean for whether to include the raw | -| | | whois results in the returned dictionary. | +| inc_raw | bool | Whether to include the raw whois results | +| | | in the returned dictionary. Defaults to | +| | | False. | +------------------------+--------+-------------------------------------------+ -| retry_count | Int | The number of times to retry in case | +| retry_count | int | The number of times to retry in case | | | | socket errors, timeouts, connection | | | | resets, etc. are encountered. | +| | | Defaults to 3. | +------------------------+--------+-------------------------------------------+ -| field_list | List | If provided, a list of fields to parse: | +| response | str | Optional response object, this bypasses | +| | | the Whois lookup. Defaults to None. | ++------------------------+--------+-------------------------------------------+ +| field_list | list | If provided, fields to parse: | | | | ['description', 'maintainer', 'updated', | -| | | 'source'] | +| | | 'source']. If None, defaults to all. | ++------------------------+--------+-------------------------------------------+ +| asn_alts | list | Additional lookup types to attempt if the | +| | | ASN dns lookup fails. Allow permutations | +| | | must be enabled. If None, defaults to all | +| | | ['http']. *WARNING* deprecated | +| | | in favor of new argument asn_methods. | +------------------------+--------+-------------------------------------------+ -| asn_alts | List | List of additional lookup types to | -| | | attempt if the ASN whois lookup fails. | -| | | Defaults to all ['http']. | +| asn_methods | list | ASN lookup types to attempt, in order. If | +| | | None, defaults to all ['whois', 'http']. | +------------------------+--------+-------------------------------------------+ .. _asn-origin-output: @@ -168,12 +182,12 @@ The output dictionary from ASNOrigin.lookup(). +------------------+--------+-------------------------------------------------+ | **Key** |**Type**| **Description** | +------------------+--------+-------------------------------------------------+ -| query | String | The ASN input | +| query | str | The ASN input | +------------------+--------+-------------------------------------------------+ -| nets | List | List of network dictionaries. | +| nets | list | List of network dictionaries. | | | | See :ref:`asn-origin-network-dictionary`. | +------------------+--------+-------------------------------------------------+ -| raw | String | Raw ASN origin whois results if inc_raw is True.| +| raw | str | Raw ASN origin whois results if inc_raw is True.| +------------------+--------+-------------------------------------------------+ .. _asn-origin-network-dictionary: @@ -187,15 +201,15 @@ The dictionary mapped to the nets key in the +-------------+--------+------------------------------------------------------+ | **Key** |**Type**| **Description** | +-------------+--------+------------------------------------------------------+ -| cidr | String | Network routing block an IP address belongs to. | +| cidr | str | Network routing block an IP address belongs to. | +-------------+--------+------------------------------------------------------+ -| description | String | Description for a registered network. | +| description | str | Description for a registered network. | +-------------+--------+------------------------------------------------------+ -| maintainer | String | The entity that maintains this network. | +| maintainer | str | The entity that maintains this network. | +-------------+--------+------------------------------------------------------+ -| updated | String | Network registration updated information. | +| updated | str | Network registration updated information. | +-------------+--------+------------------------------------------------------+ -| source | String | The source of this network information. | +| source | str | The source of this network information. | +-------------+--------+------------------------------------------------------+ .. _asn-origin-usage-examples: diff --git a/EXPERIMENTAL.rst b/EXPERIMENTAL.rst index 4255ca5..d95f635 100644 --- a/EXPERIMENTAL.rst +++ b/EXPERIMENTAL.rst @@ -30,13 +30,13 @@ Arguments supported: +--------------------+--------+-----------------------------------------------+ | **Key** |**Type**| **Description** | +--------------------+--------+-----------------------------------------------+ -| addresses | List | List of IP address strings to lookup. | +| addresses | list | List of IP address strings to lookup. | +--------------------+--------+-----------------------------------------------+ -| retry_count | Int | The number of times to retry in case socket | +| retry_count | int | The number of times to retry in case socket | | | | errors, timeouts, connection resets, etc. are | | | | encountered. Defaults to 3. | +--------------------+--------+-----------------------------------------------+ -| timeout | Int | The default timeout for socket connections in | +| timeout | int | The default timeout for socket connections in | | | | seconds. Defaults to 120. | +--------------------+--------+-----------------------------------------------+ @@ -108,33 +108,33 @@ Arguments supported: +--------------------+--------+-----------------------------------------------+ | **Key** |**Type**| **Description** | +--------------------+--------+-----------------------------------------------+ -| addresses | List | List of IP address strings to lookup. | +| addresses | list | List of IP address strings to lookup. | +--------------------+--------+-----------------------------------------------+ -| inc_raw | Bool | Whether to include the raw whois results in | +| inc_raw | bool | Whether to include the raw whois results in | | | | the returned dictionary. Defaults to False. | +--------------------+--------+-----------------------------------------------+ -| retry_count | Int | The number of times to retry in case socket | +| retry_count | int | The number of times to retry in case socket | | | | errors, timeouts, connection resets, etc. are | | | | encountered. Defaults to 3. | +--------------------+--------+-----------------------------------------------+ -| depth | Int | How many levels deep to run queries when | +| depth | int | How many levels deep to run queries when | | | | additional referenced objects are found. | | | | Defaults to 0. | +--------------------+--------+-----------------------------------------------+ -| excluded_entities | List | Entity handles to not perform lookups. | +| excluded_entities | list | Entity handles to not perform lookups. | | | | Defaults to None. | +--------------------+--------+-----------------------------------------------+ -| rate_limit_timeout | Int | The number of seconds to wait before retrying | +| rate_limit_timeout | int | The number of seconds to wait before retrying | | | | when a rate limit notice isreturned via | | | | rdap+json. Defaults to 60. | +--------------------+--------+-----------------------------------------------+ -| socket_timeout | Int | The default timeout for socket connections in | +| socket_timeout | int | The default timeout for socket connections in | | | | seconds. Defaults to 10. | +--------------------+--------+-----------------------------------------------+ -| asn_timeout | Int | The default timeout for bulk ASN lookups in | +| asn_timeout | int | The default timeout for bulk ASN lookups in | | | | seconds. Defaults to 240. | +--------------------+--------+-----------------------------------------------+ -| proxy_openers | List | List of urllib.request.OpenerDirector proxy | +| proxy_openers | list | List of urllib.request.OpenerDirector proxy | | | | openers for single/rotating proxy support. | | | | Defaults to None. | +--------------------+--------+-----------------------------------------------+ @@ -149,12 +149,12 @@ The output namedtuple from ipwhois.experimental.bulk_lookup_rdap(). +------------------+--------+-------------------------------------------------+ | **Key** |**Type**| **Description** | +------------------+--------+-------------------------------------------------+ -| results | Dict | IP address keys with the values as dictionaries | +| results | dict | IP address keys with the values as dictionaries | | | | returned by `IPWhois.lookup_rdap() | | | | `_ | +------------------+--------+-------------------------------------------------+ -| stats | Dict | Stats for the lookup containing the keys | +| stats | dict | Stats for the lookup containing the keys | | | | identified in :ref:`bulk_lookup_rdap-stats` | +------------------+--------+-------------------------------------------------+ diff --git a/NIR.rst b/NIR.rst index 5f030fc..e36c8bd 100644 --- a/NIR.rst +++ b/NIR.rst @@ -34,25 +34,26 @@ arguments for that function call: +-------------+--------+------------------------------------------------------+ | **Key** |**Type**| **Description** | +-------------+--------+------------------------------------------------------+ -| nir | String | The NIR to query ('jpnic' or 'krnic'). | +| nir | str | The NIR to query ('jpnic' or 'krnic'). | +-------------+--------+------------------------------------------------------+ -| inc_raw | Bool | Boolean for whether to include the raw NIR whois | -| | | results in the returned dictionary. | +| inc_raw | bool | Whether to include the raw whois results in | +| | | the returned dictionary. Defaults to False. | +-------------+--------+------------------------------------------------------+ -| retry_count | Int | The number of times to retry in case socket errors, | +| retry_count | int | The number of times to retry in case socket errors, | | | | timeouts, connection resets, etc. are encountered. | +| | | Defaults to 3. | +-------------+--------+------------------------------------------------------+ -| response | String | Optional response object, this bypasses the NIR | +| response | str | Optional response object, this bypasses the NIR | | | | lookup. | +-------------+--------+------------------------------------------------------+ -| field_list | List | If provided, a list of fields to parse: | +| field_list | list | If provided, a list of fields to parse: | | | | ['name', 'handle', 'country', 'address', | | | | 'postal_code', 'nameservers', 'created', | -| | | 'updated', 'contacts'] | +| | | 'updated', 'contacts']. If None, defaults to all. | +-------------+--------+------------------------------------------------------+ -| is_offline | Bool | Boolean for whether to perform lookups offline. | +| is_offline | bool | Whether to perform lookups offline. | | | | If True, response and asn_data must be provided. | -| | | Primarily used for testing. | +| | | Primarily used for testing. Defaults to False. | +-------------+--------+------------------------------------------------------+ .. _nir-output: @@ -74,12 +75,12 @@ IPWhois.lookup_whois() results. +------------------+--------+-------------------------------------------------+ | **Key** |**Type**| **Description** | +------------------+--------+-------------------------------------------------+ -| query | String | The IP address input | +| query | str | The IP address input | +------------------+--------+-------------------------------------------------+ -| nets | List | List of network dictionaries. | +| nets | list | List of network dictionaries. | | | | See :ref:`nir-network-dictionary`. | +------------------+--------+-------------------------------------------------+ -| raw | String | Raw NIR whois results if inc_raw is True. | +| raw | str | Raw NIR whois results if inc_raw is True. | +------------------+--------+-------------------------------------------------+ .. _nir-network-dictionary: @@ -93,29 +94,29 @@ The dictionary mapped to the nets key in the +-------------+--------+------------------------------------------------------+ | **Key** |**Type**| **Description** | +-------------+--------+------------------------------------------------------+ -| cidr | String | Network routing block an IP address belongs to. | +| cidr | str | Network routing block an IP address belongs to. | +-------------+--------+------------------------------------------------------+ -| range | String | Network range an IP address belongs to. | +| range | str | Network range an IP address belongs to. | +-------------+--------+------------------------------------------------------+ -| name | String | The identifier assigned to the network registration | +| name | str | The identifier assigned to the network registration | | | | for an IP address. | +-------------+--------+------------------------------------------------------+ -| handle | String | Unique identifier for a registered network. | +| handle | str | Unique identifier for a registered network. | +-------------+--------+------------------------------------------------------+ -| country | String | Country code registered with the NIR in ISO 3166-1 | +| country | str | Country code registered with the NIR in ISO 3166-1 | | | | format. | +-------------+--------+------------------------------------------------------+ -| address | String | The mailing address for a registered network. | +| address | str | The mailing address for a registered network. | +-------------+--------+------------------------------------------------------+ -| postal_code | String | The postal code for a registered network. | +| postal_code | str | The postal code for a registered network. | +-------------+--------+------------------------------------------------------+ -| nameservers | List | The nameservers listed for a registered network. | +| nameservers | list | The nameservers listed for a registered network. | +-------------+--------+------------------------------------------------------+ -| created | String | Network registration date in ISO 8601 format. | +| created | str | Network registration date in ISO 8601 format. | +-------------+--------+------------------------------------------------------+ -| updated | String | Network registration updated date in ISO 8601 format.| +| updated | str | Network registration updated date in ISO 8601 format.| +-------------+--------+------------------------------------------------------+ -| contacts | Dict | Dictionary with keys: admin, tech. Values map to | +| contacts | dict | Dictionary with keys: admin, tech. Values map to | | | | contact dictionaries if found. See | | | | :ref:`nir-contact-dictionary`. | +-------------+--------+------------------------------------------------------+ @@ -132,23 +133,23 @@ The contact information dictionary registered to a NIR network object. This is +--------------+--------+-----------------------------------------------------+ | **Key** |**Type**| **Description** | +--------------+--------+-----------------------------------------------------+ -| name | String | The contact's name. | +| name | str | The contact's name. | +--------------+--------+-----------------------------------------------------+ -| organization | String | The contact's organization. | +| organization | str | The contact's organization. | +--------------+--------+-----------------------------------------------------+ -| division | String | The contact's division of the organization. | +| division | str | The contact's division of the organization. | +--------------+--------+-----------------------------------------------------+ -| email | String | Contact email address. | +| email | str | Contact email address. | +--------------+--------+-----------------------------------------------------+ -| reply_email | String | Contact reply email address. | +| reply_email | str | Contact reply email address. | +--------------+--------+-----------------------------------------------------+ -| updated | String | Updated date in ISO 8601 format. | +| updated | str | Updated date in ISO 8601 format. | +--------------+--------+-----------------------------------------------------+ -| phone | String | Contact phone number. | +| phone | str | Contact phone number. | +--------------+--------+-----------------------------------------------------+ -| fax | String | Contact fax number. | +| fax | str | Contact fax number. | +--------------+--------+-----------------------------------------------------+ -| title | String | The contact's position or job title. | +| title | str | The contact's position or job title. | +--------------+--------+-----------------------------------------------------+ .. _nir-usage-examples: diff --git a/RDAP.rst b/RDAP.rst index bcf3658..f216b3a 100644 --- a/RDAP.rst +++ b/RDAP.rst @@ -18,39 +18,37 @@ Arguments supported by IPWhois.lookup_rdap(). +--------------------+--------+-----------------------------------------------+ | **Key** |**Type**| **Description** | +--------------------+--------+-----------------------------------------------+ -| inc_raw | Bool | Boolean for whether to include the raw whois | -| | | results in the returned dictionary. | +| inc_raw | bool | Whether to include the raw whois results in | +| | | the returned dictionary. Defaults to False. | +--------------------+--------+-----------------------------------------------+ -| retry_count | Int | The number of times to retry in case socket | +| retry_count | int | The number of times to retry in case socket | | | | errors, timeouts, connection resets, etc. are | -| | | encountered. | +| | | encountered. Defaults to 3. | +--------------------+--------+-----------------------------------------------+ -| depth | Int | How many levels deep to run queries when | +| depth | int | How many levels deep to run queries when | | | | additional referenced objects are found. | +| | | Defaults to 0. | +--------------------+--------+-----------------------------------------------+ -| excluded_entities | List | A list of entity handles to not perform | -| | | lookups. | +| excluded_entities | list | Entity handles to not perform lookups. | +| | | Defaults to None. | +--------------------+--------+-----------------------------------------------+ -| bootstrap | Bool | If True, performs lookups via ARIN bootstrap | +| bootstrap | bool | If True, performs lookups via ARIN bootstrap | | | | rather than lookups based on ASN data. ASN | | | | lookups are not performed and no output for | -| | | any of the asn* fields is provided. | +| | | any of the asn* fields is provided. Defaults | +| | | to False. | +--------------------+--------+-----------------------------------------------+ -| rate_limit_timeout | Int | The number of seconds to wait before retrying | -| | | when a rate limit notice isreturned via | -| | | rdap+json. | +| rate_limit_timeout | int | The number of seconds to wait before retrying | +| | | when a rate limit notice is returned via | +| | | rdap+json. Defaults to 120. | +--------------------+--------+-----------------------------------------------+ -| asn_alts | List | List of additional lookup types to attempt if | -| | | the ASN dns lookup fails. Allow permutations | -| | | must be enabled. Defaults to all | +| asn_alts | list | Additional lookup types to attempt if the ASN | +| | | dns lookup fails. Allow permutations must be | +| | | enabled. If None, defaults to all | | | | ['whois', 'http']. *WARNING* deprecated in | | | | favor of new argument asn_methods. | +--------------------+--------+-----------------------------------------------+ -| asn_methods | List | List of ASN lookup types to attempt, in | -| | | order. Defaults to all | -| | | ['dns', 'whois', 'http']. | -+--------------------+--------+-----------------------------------------------+ -| extra_org_map | Dict | Dictionary mapping org handles to RIRs. | +| extra_org_map | dict | Dictionary mapping org handles to RIRs. | | | | This is for limited cases where ARIN REST | | | | (ASN fallback HTTP lookup) does not show an | | | | RIR as the org handle e.g., DNIC (which | @@ -59,10 +57,27 @@ Arguments supported by IPWhois.lookup_rdap(). | | | values are (note the case-sensitive - this is | | | | meant to match the REST result): | | | | 'ARIN', 'RIPE', 'apnic', 'lacnic', 'afrinic' | +| | | Defaults to None. | ++--------------------+--------+-----------------------------------------------+ +| inc_nir | bool | Whether to retrieve NIR (National Internet | +| | | Registry) information, if registry is JPNIC | +| | | (Japan) or KRNIC (Korea). If True, extra | +| | | network requests will be required. If False, | +| | | the information returned for JP or KR IPs is | +| | | severely restricted. Defaults to True. | ++--------------------+--------+-----------------------------------------------+ +| nir_field_list | list | If provided and inc_nir, a list of | +| | | fields to parse: ['name', 'handle', 'country',| +| | | 'address', 'postal_code', 'nameservers', | +| | | 'created', 'updated', 'contacts'] | +| | | If None, defaults to all. | ++--------------------+--------+-----------------------------------------------+ +| asn_methods | list | ASN lookup types to attempt, in order. If | +| | | None, defaults to all ['dns', 'whois', 'http']| +--------------------+--------+-----------------------------------------------+ -| get_asn_description| Bool | Boolean for whether to run an additional | -| | | query when pulling ASN information via | -| | | dns, in order to get the ASN description. | +| get_asn_description| bool | Whether to run an additional query when | +| | | pulling ASN information via dns, in order to | +| | | get the ASN description. Defaults to True. | +--------------------+--------+-----------------------------------------------+ .. _rdap-output: @@ -81,37 +96,42 @@ and dictionaries, detailed below this section. +------------------+--------+-------------------------------------------------+ | **Key** |**Type**| **Description** | +------------------+--------+-------------------------------------------------+ -| query | String | The IP address input | +| query | str | The IP address | +------------------+--------+-------------------------------------------------+ -| asn | String | Globally unique identifier used for routing | +| asn | str | Globally unique identifier used for routing | | | | information exchange with Autonomous Systems. | +------------------+--------+-------------------------------------------------+ -| asn_cidr | String | Network routing block assigned to an ASN. | +| asn_cidr | str | Network routing block assigned to an ASN. | +------------------+--------+-------------------------------------------------+ -| asn_country_code | String | ASN assigned country code in ISO 3166-1 format. | +| asn_country_code | str | ASN assigned country code in ISO 3166-1 format. | +------------------+--------+-------------------------------------------------+ -| asn_date | String | ASN allocation date in ISO 8601 format. | +| asn_date | str | ASN allocation date in ISO 8601 format. | +------------------+--------+-------------------------------------------------+ -| asn_registry | String | ASN assigned regional internet registry. | +| asn_registry | str | ASN assigned regional internet registry. | +------------------+--------+-------------------------------------------------+ -| asn_description | String | The ASN description | +| asn_description | str | The ASN description | +------------------+--------+-------------------------------------------------+ -| network | Dict | The assigned network for an IP address. May be | +| network | dict | The assigned network for an IP address. May be | | | | a parent or child network. See | | | | :ref:`rdap-network-dictionary`. | +------------------+--------+-------------------------------------------------+ -| entities | List | List of object names referenced by an RIR | +| entities | list | list of object names referenced by an RIR | | | | network. Map these to the objects dict keys. | +------------------+--------+-------------------------------------------------+ -| objects | Dict | The objects (entities) referenced by an RIR | +| objects | dict | The objects (entities) referenced by an RIR | | | | network or by other entities (depending on | | | | depth parameter). Keys are the object names | | | | with values as | | | | :ref:`rdap-objects-dictionary`. | +------------------+--------+-------------------------------------------------+ -| raw | Dict | The raw results dictionary (JSON) if | +| raw | dict | The raw results dictionary (JSON) if | | | | inc_raw is True. | +------------------+--------+-------------------------------------------------+ +| nir | dict | The National Internet Registry results if | +| | | inc_nir is True. See `NIR result `_ | ++------------------+--------+-------------------------------------------------+ .. _rdap-network-dictionary: @@ -124,39 +144,39 @@ The dictionary mapped to the network key in the objects list within +---------------+--------+----------------------------------------------------+ | **Key** |**Type**| **Description** | +---------------+--------+----------------------------------------------------+ -| cidr | String | Network routing block an IP address belongs to. | +| cidr | str | Network routing block an IP address belongs to. | +---------------+--------+----------------------------------------------------+ -| country | String | Country code registered with the RIR in | +| country | str | Country code registered with the RIR in | | | | ISO 3166-1 format. | +---------------+--------+----------------------------------------------------+ -| end_address | String | The last IP address in a network block. | +| end_address | str | The last IP address in a network block. | +---------------+--------+----------------------------------------------------+ -| events | List | List of event dictionaries. See | +| events | list | List of event dictionaries. See | | | | :ref:`rdap-events-dictionary`. | +---------------+--------+----------------------------------------------------+ -| handle | String | Unique identifier for a registered object. | +| handle | str | Unique identifier for a registered object. | +---------------+--------+----------------------------------------------------+ -| ip_version | String | IP protocol version (v4 or v6) of an IP address. | +| ip_version | str | IP protocol version (v4 or v6) of an IP address. | +---------------+--------+----------------------------------------------------+ -| links | List | HTTP/HTTPS links provided for an RIR object. | +| links | list | HTTP/HTTPS links provided for an RIR object. | +---------------+--------+----------------------------------------------------+ -| name | String | The identifier assigned to the network | +| name | str | The identifier assigned to the network | | | | registration for an IP address. | +---------------+--------+----------------------------------------------------+ -| notices | List | List of notice dictionaries. See | +| notices | list | List of notice dictionaries. See | | | | :ref:`rdap-notices-dictionary`. | +---------------+--------+----------------------------------------------------+ -| parent_handle | String | Unique identifier for the parent network of a | +| parent_handle | str | Unique identifier for the parent network of a | | | | registered network. | +---------------+--------+----------------------------------------------------+ -| remarks | List | List of remark (notice) dictionaries. See | +| remarks | list | List of remark (notice) dictionaries. See | | | | :ref:`rdap-notices-dictionary`. | +---------------+--------+----------------------------------------------------+ -| start_address | String | The first IP address in a network block. | +| start_address | str | The first IP address in a network block. | +---------------+--------+----------------------------------------------------+ -| status | List | List indicating the state of a registered object. | +| status | list | List indicating the state of a registered object. | +---------------+--------+----------------------------------------------------+ -| type | String | The RIR classification of a registered network. | +| type | str | The RIR classification of a registered network. | +---------------+--------+----------------------------------------------------+ .. _rdap-objects-dictionary: @@ -170,32 +190,32 @@ The dictionary mapped to the object (entity) key in the objects list within +--------------+--------+-----------------------------------------------------+ | **Key** |**Type**| **Description** | +--------------+--------+-----------------------------------------------------+ -| contact | Dict | Contact information registered with an RIR object. | +| contact | dict | Contact information registered with an RIR object. | | | | See | | | | :ref:`rdap-objects-contact-dictionary`. | +--------------+--------+-----------------------------------------------------+ -| entities | List | List of object names referenced by an RIR object. | +| entities | list | List of object names referenced by an RIR object. | | | | Map these to other objects dictionary keys. | +--------------+--------+-----------------------------------------------------+ -| events | List | List of event dictionaries. See | +| events | list | List of event dictionaries. See | | | | :ref:`rdap-events-dictionary`. | +--------------+--------+-----------------------------------------------------+ -| events_actor | List | List of event (no actor) dictionaries. See | +| events_actor | list | List of event (no actor) dictionaries. See | | | | :ref:`rdap-events-dictionary`. | +--------------+--------+-----------------------------------------------------+ -| handle | String | Unique identifier for a registered object. | +| handle | str | Unique identifier for a registered object. | +--------------+--------+-----------------------------------------------------+ -| links | List | List of HTTP/HTTPS links provided for an RIR object.| +| links | list | List of HTTP/HTTPS links provided for an RIR object.| +--------------+--------+-----------------------------------------------------+ -| notices | List | List of notice dictionaries. See | +| notices | list | List of notice dictionaries. See | | | | :ref:`rdap-notices-dictionary`. | +--------------+--------+-----------------------------------------------------+ -| remarks | List | List of remark (notice) dictionaries. See | +| remarks | list | List of remark (notice) dictionaries. See | | | | :ref:`rdap-notices-dictionary`. | +--------------+--------+-----------------------------------------------------+ -| roles | List | List of roles assigned to a registered object. | +| roles | list | List of roles assigned to a registered object. | +--------------+--------+-----------------------------------------------------+ -| status | List | List indicating the state of a registered object. | +| status | list | List indicating the state of a registered object. | +--------------+--------+-----------------------------------------------------+ .. _rdap-objects-contact-dictionary: @@ -209,22 +229,22 @@ contact key contained in :ref:`rdap-objects-dictionary`. +---------+--------+----------------------------------------------------------+ | **Key** |**Type**| **Description** | +---------+--------+----------------------------------------------------------+ -| address | List | List of contact postal address dictionaries. Contains key| +| address | list | List of contact postal address dictionaries. Contains key| | | | type and value. | +---------+--------+----------------------------------------------------------+ -| email | List | List of contact email address dictionaries. Contains key | +| email | list | List of contact email address dictionaries. Contains key | | | | type and value. | +---------+--------+----------------------------------------------------------+ -| kind | String | The contact information kind (individual, group, org). | +| kind | str | The contact information kind (individual, group, org). | +---------+--------+----------------------------------------------------------+ -| name | String | The contact name. | +| name | str | The contact name. | +---------+--------+----------------------------------------------------------+ -| phone | List | List of contact phone number dictionaries. Contains key | +| phone | list | List of contact phone number dictionaries. Contains key | | | | type and value. | +---------+--------+----------------------------------------------------------+ -| role | String | The contact's role. | +| role | str | The contact's role. | +---------+--------+----------------------------------------------------------+ -| title | String | The contact's position or job title. | +| title | str | The contact's position or job title. | +---------+--------+----------------------------------------------------------+ .. _rdap-events-dictionary: @@ -239,11 +259,11 @@ Contained in events and events_actor (no actor). +-----------+--------+-------------------------------------------------+ | **Key** |**Type**| **Description** | +-----------+--------+-------------------------------------------------+ -| action | String | The reason for an event. | +| action | str | The reason for an event. | +-----------+--------+-------------------------------------------------+ -| timestamp | String | The date an event occured in ISO 8601 format. | +| timestamp | str | The date an event occured in ISO 8601 format. | +-----------+--------+-------------------------------------------------+ -| actor | String | The identifier for an event initiator (if any). | +| actor | str | The identifier for an event initiator (if any). | +-----------+--------+-------------------------------------------------+ .. _rdap-notices-dictionary: @@ -257,11 +277,11 @@ Common to lists in :ref:`rdap-network-dictionary` and +-------------+--------+-------------------------------------------------+ | **Key** |**Type**| **Description** | +-------------+--------+-------------------------------------------------+ -| title | String | The title/header for a notice. | +| title | str | The title/header for a notice. | +-------------+--------+-------------------------------------------------+ -| description | String | The description/body of a notice. | +| description | str | The description/body of a notice. | +-------------+--------+-------------------------------------------------+ -| links | List | List of HTTP/HTTPS links provided for a notice. | +| links | list | list of HTTP/HTTPS links provided for a notice. | +-------------+--------+-------------------------------------------------+ .. _rdap-usage-examples: @@ -569,15 +589,6 @@ rate limit error (HTTPRateLimitError) is raised, the lookup will wait for rate_limit_timeout seconds before retrying. A combination of adjusting retry_count and rate_limit_timeout is needed to optimize bulk queries. -When performing bulk IP lookups, the goal should be to acquire as much data, as -fast as possible. If you have multiple IP lookups, in a row, that belong to the -same RIR (generally LACNIC), the chance to hit rate limiting errors increases -(also depending on bootstrap, depth, network speeds). - -One option to increase bulk query performance is to disable retries and store -the errored IPs in a list for the next round of lookups (loop your bulk queries -until all IPs resolve). Disable retries by setting retry_count=0 - rate_limit_timeout ^^^^^^^^^^^^^^^^^^ diff --git a/README.rst b/README.rst index 9ffdf51..2173c3d 100644 --- a/README.rst +++ b/README.rst @@ -168,19 +168,19 @@ Input +--------------------+--------+-----------------------------------------------+ | **Key** |**Type**| **Description** | +--------------------+--------+-----------------------------------------------+ -| address | String | An IPv4 or IPv6 address as a string, integer, | +| address | str | An IPv4 or IPv6 address as a string, integer, | | | | IPv4Address, or IPv6Address. | +--------------------+--------+-----------------------------------------------+ -| timeout | Int | The default timeout for socket connections | -| | | in seconds. | +| timeout | int | The default timeout for socket connections | +| | | in seconds. Defaults to 5. | +--------------------+--------+-----------------------------------------------+ -| proxy_opener | Object | The urllib.request.OpenerDirector request for | +| proxy_opener | object | The urllib.request.OpenerDirector request for | | | | proxy support or None. | +--------------------+--------+-----------------------------------------------+ -| allow_permutations | Bool | Allow net.Net() to use additional methods if | +| allow_permutations | bool | Allow net.Net() to use additional methods if | | | | DNS lookups to Cymru fail. *WARNING* | | | | deprecated in favor of new argument | -| | | asn_methods. | +| | | asn_methods. Defaults to True. | +--------------------+--------+-----------------------------------------------+ RDAP (HTTP) diff --git a/WHOIS.rst b/WHOIS.rst index d2a5722..bb7a9b0 100644 --- a/WHOIS.rst +++ b/WHOIS.rst @@ -27,41 +27,39 @@ Arguments supported by IPWhois.lookup_whois(). +------------------------+--------+-------------------------------------------+ | **Key** |**Type**| **Description** | +------------------------+--------+-------------------------------------------+ -| inc_raw | Bool | Boolean for whether to include the raw | -| | | whois results in the returned dictionary. | +| inc_raw | bool | Whether to include the raw whois results | +| | | in the returned dictionary. Defaults to | +| | | False. | +------------------------+--------+-------------------------------------------+ -| retry_count | Int | The number of times to retry in case | +| retry_count | int | The number of times to retry in case | | | | socket errors, timeouts, connection | | | | resets, etc. are encountered. | +| | | Defaults to 3. | +------------------------+--------+-------------------------------------------+ -| get_referral | Bool | Boolean for whether to retrieve | -| | | referral whois information, if available. | +| get_referral | bool | Whether to retrieve referral whois | +| | | information, if available. Defaults to | +| | | False. | +------------------------+--------+-------------------------------------------+ -| extra_blacklist | List | A list of blacklisted whois servers in | -| | | addition to the global BLACKLIST. | +| extra_blacklist | list | Blacklisted whois servers in addition to | +| | | the global BLACKLIST. Defaults to None. | +------------------------+--------+-------------------------------------------+ -| ignore_referral_errors | Bool | Boolean for whether to ignore and | -| | | continue when an exception is encountered | -| | | on referral whois lookups. | +| ignore_referral_errors | bool | Whether to ignore and continue when an | +| | | exception is encountered on referral whois| +| | | lookups. Defaults to False. | +------------------------+--------+-------------------------------------------+ -| field_list | List | If provided, a list of fields to parse: | +| field_list | list | If provided, a list of fields to parse: | | | | ['name', 'handle', 'description', | | | | 'country', 'state', 'city', 'address', | | | | 'postal_code', 'emails', 'created', | -| | | 'updated'] | +| | | 'updated']. If None, defaults to all. | +------------------------+--------+-------------------------------------------+ -| asn_alts | List | List of additional lookup types to | -| | | attempt if the ASN dns lookup fails. | -| | | Allow permutations must be enabled. | -| | | Defaults to all ['whois', 'http']. | -| | | *WARNING* deprecated in favor of new | -| | | argument asn_methods. | +| asn_alts | list | Additional lookup types to attempt if the | +| | | ASN dns lookup fails. Allow permutations | +| | | must be enabled. If None, defaults to all | +| | | ['whois', 'http']. *WARNING* deprecated | +| | | in favor of new argument asn_methods. | +------------------------+--------+-------------------------------------------+ -| asn_methods | List | List of ASN lookup types to attempt, in | -| | | order. Defaults to all | -| | | ['dns', 'whois', 'http']. | -+------------------------+--------+-------------------------------------------+ -| extra_org_map | Dict | Dictionary mapping org handles to RIRs. | +| extra_org_map | dict | Dictionary mapping org handles to RIRs. | | | | This is for limited cases where ARIN | | | | REST (ASN fallback HTTP lookup) does not | | | | show an RIR as the org handle e.g., DNIC | @@ -71,10 +69,30 @@ Arguments supported by IPWhois.lookup_whois(). | | | case-sensitive - this is meant to match | | | | the REST result): 'ARIN', 'RIPE', | | | | 'apnic', 'lacnic', 'afrinic' | +| | | Defaults to None. | ++------------------------+--------+-------------------------------------------+ +| inc_nir | bool | Whether to retrieve NIR (National Internet| +| | | Registry) information, if registry is | +| | | JPNIC (Japan) or KRNIC (Korea). If True, | +| | | extra network requests will be required. | +| | | If False, the information returned for JP | +| | | or KR IPs is severely restricted. | +| | | Defaults to True. | ++------------------------+--------+-------------------------------------------+ +| nir_field_list | list | If provided and inc_nir, a list of fields | +| | | to parse: ['name', 'handle', 'country', | +| | | 'address', 'postal_code', 'nameservers', | +| | | 'created', 'updated', 'contacts'] | +| | | If None, defaults to all. | +------------------------+--------+-------------------------------------------+ -| get_asn_description | Bool | Boolean for whether to run an additional | -| | | query when pulling ASN information via | -| | | dns, in order to get the ASN description. | +| asn_methods | list | ASN lookup types to attempt, in order. If | +| | | None, defaults to all ['dns', 'whois', | +| | | 'http']. | ++------------------------+--------+-------------------------------------------+ +| get_asn_description | bool | Whether to run an additional query when | +| | | pulling ASN information via dns, in order | +| | | to get the ASN description. Defaults to | +| | | True. | +------------------------+--------+-------------------------------------------+ .. _whois-output: @@ -92,33 +110,38 @@ The output dictionary from IPWhois.lookup_whois(). +------------------+--------+-------------------------------------------------+ | **Key** |**Type**| **Description** | +------------------+--------+-------------------------------------------------+ -| query | String | The IP address input | +| query | str | The IP address input | +------------------+--------+-------------------------------------------------+ -| asn | String | Globally unique identifier used for routing | +| asn | str | Globally unique identifier used for routing | | | | information exchange with Autonomous Systems. | +------------------+--------+-------------------------------------------------+ -| asn_cidr | String | Network routing block assigned to an ASN. | +| asn_cidr | str | Network routing block assigned to an ASN. | +------------------+--------+-------------------------------------------------+ -| asn_country_code | String | ASN assigned country code in ISO 3166-1 format. | +| asn_country_code | str | ASN assigned country code in ISO 3166-1 format. | +------------------+--------+-------------------------------------------------+ -| asn_date | String | ASN allocation date in ISO 8601 format. | +| asn_date | str | ASN allocation date in ISO 8601 format. | +------------------+--------+-------------------------------------------------+ -| asn_registry | String | ASN assigned regional internet registry. | +| asn_registry | str | ASN assigned regional internet registry. | +------------------+--------+-------------------------------------------------+ -| asn_description | String | The ASN description | +| asn_description | str | The ASN description | +------------------+--------+-------------------------------------------------+ -| nets | List | List of network dictionaries. | +| nets | list | List of network dictionaries. | | | | See :ref:`whois-network-dictionary`. | +------------------+--------+-------------------------------------------------+ -| raw | String | Raw whois results if inc_raw is True. | +| raw | str | Raw whois results if inc_raw is True. | +------------------+--------+-------------------------------------------------+ -| referral | Dict | Referral whois information if get_referral | +| referral | dict | Referral whois information if get_referral | | | | is True and the server isn't blacklisted. See | | | | :ref:`whois-referral-dictionary`. | +------------------+--------+-------------------------------------------------+ -| raw_referral | String | Raw referral whois results if the inc_raw | +| raw_referral | str | Raw referral whois results if the inc_raw | | | | parameter is True. | +------------------+--------+-------------------------------------------------+ +| nir | dict | The National Internet Registry results if | +| | | inc_nir is True. See `NIR result `_ | ++------------------+--------+-------------------------------------------------+ .. _whois-network-dictionary: @@ -131,33 +154,33 @@ The dictionary mapped to the nets key in the +-------------+--------+------------------------------------------------------+ | **Key** |**Type**| **Description** | +-------------+--------+------------------------------------------------------+ -| cidr | String | Network routing block an IP address belongs to. | +| cidr | str | Network routing block an IP address belongs to. | +-------------+--------+------------------------------------------------------+ -| range | String | Network range an IP address belongs to. | +| range | str | Network range an IP address belongs to. | +-------------+--------+------------------------------------------------------+ -| name | String | The identifier assigned to the network registration | +| name | str | The identifier assigned to the network registration | | | | for an IP address. | +-------------+--------+------------------------------------------------------+ -| handle | String | Unique identifier for a registered network. | +| handle | str | Unique identifier for a registered network. | +-------------+--------+------------------------------------------------------+ -| description | String | Description for a registered network. | +| description | str | Description for a registered network. | +-------------+--------+------------------------------------------------------+ -| country | String | Country code registered with the RIR in | +| country | str | Country code registered with the RIR in | | | | ISO 3166-1 format. | +-------------+--------+------------------------------------------------------+ -| state | String | State for a registered network (if applicable). | +| state | str | State for a registered network (if applicable). | +-------------+--------+------------------------------------------------------+ -| city | String | City for a registered network (if applicable). | +| city | str | City for a registered network (if applicable). | +-------------+--------+------------------------------------------------------+ -| address | String | The mailing address for a registered network. | +| address | str | The mailing address for a registered network. | +-------------+--------+------------------------------------------------------+ -| postal_code | String | The postal code for a registered network. | +| postal_code | str | The postal code for a registered network. | +-------------+--------+------------------------------------------------------+ -| emails | List | The email addresses listed for a registered network. | +| emails | list | The email addresses listed for a registered network. | +-------------+--------+------------------------------------------------------+ -| created | String | Network registration date in ISO 8601 format. | +| created | str | Network registration date in ISO 8601 format. | +-------------+--------+------------------------------------------------------+ -| updated | String | Network registration updated date in ISO 8601 format.| +| updated | str | Network registration updated date in ISO 8601 format.| +-------------+--------+------------------------------------------------------+ .. _whois-referral-dictionary: @@ -171,30 +194,30 @@ The dictionary mapped to the referral key in the +-------------+--------+------------------------------------------------------+ | **Key** |**Type**| **Description** | +-------------+--------+------------------------------------------------------+ -| cidr | String | Network routing block an IP address belongs to. | +| cidr | str | Network routing block an IP address belongs to. | +-------------+--------+------------------------------------------------------+ -| range | String | Network range an IP address belongs to. | +| range | str | Network range an IP address belongs to. | +-------------+--------+------------------------------------------------------+ -| name | String | The identifier assigned to the network registration | +| name | str | The identifier assigned to the network registration | | | | for an IP address. | +-------------+--------+------------------------------------------------------+ -| description | String | Description for a registered network. | +| description | str | Description for a registered network. | +-------------+--------+------------------------------------------------------+ -| country | String | Country code registered in ISO 3166-1 format. | +| country | str | Country code registered in ISO 3166-1 format. | +-------------+--------+------------------------------------------------------+ -| state | String | State for a registered network (if applicable). | +| state | str | State for a registered network (if applicable). | +-------------+--------+------------------------------------------------------+ -| city | String | City for a registered network (if applicable). | +| city | str | City for a registered network (if applicable). | +-------------+--------+------------------------------------------------------+ -| address | String | The mailing address for a registered network. | +| address | str | The mailing address for a registered network. | +-------------+--------+------------------------------------------------------+ -| postal_code | String | The postal code for a registered network. | +| postal_code | str | The postal code for a registered network. | +-------------+--------+------------------------------------------------------+ -| emails | List | The email addresses listed for a registered network. | +| emails | list | The email addresses listed for a registered network. | +-------------+--------+------------------------------------------------------+ -| created | String | Network registration date in ISO 8601 format. | +| created | str | Network registration date in ISO 8601 format. | +-------------+--------+------------------------------------------------------+ -| updated | String | Network registration updated date in ISO 8601 format.| +| updated | str | Network registration updated date in ISO 8601 format.| +-------------+--------+------------------------------------------------------+ .. _whois-usage-examples: From a8103c9a6f8b936f1448b7034b52cb553796b668 Mon Sep 17 00:00:00 2001 From: secynic Date: Sun, 30 Jul 2017 19:59:25 -0500 Subject: [PATCH 5/8] 1.0.0 --- CHANGES.rst | 4 ++-- README.rst | 5 +---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index b0ef4eb..1048f8c 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,8 +1,8 @@ Changelog ========= -1.0.0 (TBD) ------------ +1.0.0 (2017-07-30) +------------------ - Deprecated asn_alts, allow_permutations in favor of new asn_methods (#158) - Added new exception ASNOriginLookupError (#158) diff --git a/README.rst b/README.rst index 2173c3d..a11268e 100644 --- a/README.rst +++ b/README.rst @@ -82,7 +82,7 @@ https://github.com/secynic/ipwhois Pypi ---- -https://pypi.python.org/pypi/ipwhois +https://pypi.org/project/ipwhois Changes ------- @@ -199,9 +199,6 @@ https://ipwhois.readthedocs.io/en/latest/RDAP.html Legacy Whois ------------ -IPWhois.lookup() is deprecated as of v0.12.0 and will be removed. Legacy whois -lookups were moved to IPWhois.lookup_whois(). - Legacy Whois documentation: https://ipwhois.readthedocs.io/en/latest/WHOIS.html From c26c9a0666a2aca81c8124d7e22ee68c9bce05d3 Mon Sep 17 00:00:00 2001 From: secynic Date: Sun, 30 Jul 2017 20:03:00 -0500 Subject: [PATCH 6/8] setuptools fix --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index efda78f..a5a07c0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ install: - if [[ $TRAVIS_PYTHON_VERSION == 3.6* ]]; then pip install -r requirements/python3.txt; fi - pip install coveralls - pip install codeclimate-test-reporter - - python setup.py -q install + - pip install -e . script: - nosetests -v -w ipwhois --include=online --exclude=stress --with-coverage --cover-package=ipwhois after_success: From 2e8facca2396150a835c49017f5a2a0ce1104bf5 Mon Sep 17 00:00:00 2001 From: secynic Date: Sun, 30 Jul 2017 20:07:12 -0500 Subject: [PATCH 7/8] setuptools fix 2 --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index a5a07c0..e4df1aa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,8 @@ python: - 3.5 - 3.6 install: + - pip install setuptools + - pip install --upgrade pip - if [[ $TRAVIS_PYTHON_VERSION == 2* ]]; then pip install -r requirements/python2.txt; fi - if [[ $TRAVIS_PYTHON_VERSION == 3.3* ]]; then pip install -r requirements/python3.txt; fi - if [[ $TRAVIS_PYTHON_VERSION == 3.4* ]]; then pip install -r requirements/python3.txt; fi From eb288aff6bca6e8f6fc8986bdafaf1871a806c8b Mon Sep 17 00:00:00 2001 From: secynic Date: Sun, 30 Jul 2017 20:14:04 -0500 Subject: [PATCH 8/8] setuptools fix 3 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e4df1aa..74836f2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ python: - 3.5 - 3.6 install: - - pip install setuptools + - 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.3* ]]; then pip install -r requirements/python3.txt; fi