diff --git a/CLI.rst b/CLI.rst index d4954ac..3af9e1c 100644 --- a/CLI.rst +++ b/CLI.rst @@ -9,15 +9,102 @@ environment Scripts directory. It currently has full ipwhois.py functionality. The others (net.py, rdap.py, utils.py, whois.py) will be included in a future release. -Input +Usage ===== -TODO +ipwhois_cli.py [-h] --addr IP [--whois] [--hr] [--show_name] [--colorize] + [--timeout TIMEOUT] [--proxy_http "PROXY_HTTP"] + [--proxy_https "PROXY_HTTPS"] [--disallow_permutations] + [--inc_raw] [--retry_count RETRY_COUNT] + [--asn_alts "ASN_ALTS"] [--extra_org_map "ASN_ALTS"] + [--depth COLOR_DEPTH] + [--excluded_entities "EXCLUDED_ENTITIES"] [--bootstrap] + [--rate_limit_timeout RATE_LIMIT_TIMEOUT] + [--get_referral] [--extra_blacklist "EXTRA_BLACKLIST"] + [--ignore_referral_errors] [--field_list "FIELD_LIST"] -Output -====== +ipwhois CLI interface -TODO +optional arguments: + -h, --help show this help message and exit + --whois Retrieve whois data via legacy Whois (port 43) instead + of RDAP (default). + +Output options: + --hr If set, returns results with human readable key + translations. + --show_name If this and --hr are set, the key name is shown in + parentheses after its short value + --colorize If set, colorizes the output using ANSI. Should work + in most platform consoles. + +IPWhois settings: + --timeout TIMEOUT The default timeout for socket connections in seconds. + --proxy_http PROXY_HTTP + The proxy HTTP address passed to request.ProxyHandler. + User auth can be passed like + "http://user:pass@192.168.0.1:80" + --proxy_https PROXY_HTTPS + The proxy HTTPS address passed to + request.ProxyHandler. User auth can be passed like + "https://user:pass@192.168.0.1:443" + --disallow_permutations + Disable additional methods if DNS lookups to Cymru + fail. This is the opposite of the ipwhois + allow_permutations, in order to enable + allow_permutations by default in the CLI. + +Common settings (RDAP & Legacy Whois): + --inc_raw Include the raw whois results in the output. + --retry_count RETRY_COUNT + The number of times to retry in case socket errors, + timeouts, connection resets, etc. are encountered. + --asn_alts ASN_ALTS + A comma delimited list of additional lookup types to + attempt if the ASN dns lookup fails. Allow + permutations must be enabled. Defaults to all: + "whois,http" + --extra_org_map ASN_ALTS + 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' + +RDAP settings: + --depth COLOR_DEPTH If not --whois, how many levels deep to run RDAP + queries when additional referenced objects are found. + --excluded_entities EXCLUDED_ENTITIES + If not --whois, a comma delimited list of entity + handles to not perform lookups. + --bootstrap If not --whois, 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. + --rate_limit_timeout RATE_LIMIT_TIMEOUT + If not --whois, the number of seconds to wait before + retrying when a rate limit notice is returned via + rdap+json. + +Legacy Whois settings: + --get_referral If --whois, retrieve referral whois information, if + available. + --extra_blacklist EXTRA_BLACKLIST + If --whois, A list of blacklisted whois servers in + addition to the global BLACKLIST. + --ignore_referral_errors + If --whois, ignore and continue when an exception is + encountered on referral whois lookups. + --field_list FIELD_LIST + If --whois, a list of fields to parse: ['name', + 'handle', 'description', 'country', 'state', 'city', + 'address', 'postal_code', 'emails', 'created', + 'updated'] + +Input (Required): + --addr IP An IPv4 or IPv6 address as a string. Usage Examples ============== @@ -25,4 +112,7 @@ Usage Examples Basic usage ----------- -TODO +:: + + ipwhois_cli.py --addr 74.125.225.229 --hr --show_name --colorize --depth 1 + diff --git a/README.rst b/README.rst index 4b097ff..7a427d7 100644 --- a/README.rst +++ b/README.rst @@ -100,6 +100,35 @@ ipwhois needs some outbound firewall ports opened from your host/server. API === +IPWhois (main class) +-------------------- + +ipwhois.IPWhois is the base class for wrapping RDAP and Legacy Whois lookups. +Instantiate this object, then call one of the lookup functions: + +`RDAP (HTTP) - IPWhois.lookup_rdap() <#rdap-http>`_ +OR +`Legacy Whois - IPWhois.lookup_whois() <#legacy-whois>`_ + +Input +^^^^^ + ++--------------------+--------+-----------------------------------------------+ +| **Key** |**Type**| **Description** | ++--------------------+--------+-----------------------------------------------+ +| address | String | An IPv4 or IPv6 address as a string, integer, | +| | | IPv4Address, or IPv6Address. | ++--------------------+--------+-----------------------------------------------+ +| timeout | Int | The default timeout for socket connections | +| | | in seconds. | ++--------------------+--------+-----------------------------------------------+ +| proxy_opener | Object | The urllib.request.OpenerDirector request for | +| | | proxy support or None. | ++--------------------+--------+-----------------------------------------------+ +| allow_permutations | Bool | Allow net.Net() to use additional methods if | +| | | DNS lookups to Cymru fail. | ++--------------------+--------+-----------------------------------------------+ + RDAP (HTTP) ----------- diff --git a/UTILS.rst b/UTILS.rst index 40d34e6..b7009c3 100644 --- a/UTILS.rst +++ b/UTILS.rst @@ -17,6 +17,19 @@ Use Legacy XML File:: >>>> from ipwhois.utils import get_countries >>>> countries = get_countries(is_legacy_xml=True) +Human Readable Fields +===================== + +Human readable translations are available for all result fields (RDAP and +Legacy Whois). Translations are currently limited to the short name (_short), +the name (_name), and the description (_description). + +See the ipwhois CLI (ipwhois_cli.py) for an example. I plan to better document +this functionality in a future release. + +Import the human readable translation dictionaries:: + + >>>> from ipwhois.hr import (HR_ASN, HR_RDAP_COMMON, HR_RDAP, HR_WHOIS) Usage Examples ============== diff --git a/WHOIS.rst b/WHOIS.rst index 54ac387..e6c0ffe 100644 --- a/WHOIS.rst +++ b/WHOIS.rst @@ -6,7 +6,7 @@ IPWhois.lookup() is deprecated as of v0.12.0 and will be removed. Legacy whois lookups were moved to IPWhois.lookup_whois(). Parsing is currently limited to the keys in the output -`below <#results-dictionary>`_.. +`below <#results-dictionary>`_. This is assuming that those fields are present (for both whois and rwhois). Some IPs have parent networks listed. The parser attempts to recognize this, @@ -73,7 +73,34 @@ Results Dictionary The output dictionary from IPWhois.lookup_whois(). -TODO ++------------------+--------+-------------------------------------------------+ +| **Key** |**Type**| **Description** | ++------------------+--------+-------------------------------------------------+ +| query | String | The IP address input | ++------------------+--------+-------------------------------------------------+ +| asn | String | Globally unique identifier used for routing | +| | | information exchange with Autonomous Systems. | ++------------------+--------+-------------------------------------------------+ +| asn_cidr | String | Network routing block assigned to an ASN. | ++------------------+--------+-------------------------------------------------+ +| asn_country_code | String | ASN assigned country code in ISO 3166-1 format. | ++------------------+--------+-------------------------------------------------+ +| asn_date | String | ASN allocation date in ISO 8601 format. | ++------------------+--------+-------------------------------------------------+ +| asn_registry | String | ASN assigned regional internet registry. | ++------------------+--------+-------------------------------------------------+ +| nets | List | List of network dictionaries. | +| | | See `Network Dictionary <#network-dictionary>`_.| ++------------------+--------+-------------------------------------------------+ +| raw | String | Raw whois results if inc_raw is True. | ++------------------+--------+-------------------------------------------------+ +| referral | Dict | Referral whois information if get_referral | +| | | is True and the server isn't blacklisted. See | +| | | `Referral Dictionary <#referral-dictionary>`_. | ++------------------+--------+-------------------------------------------------+ +| raw_referral | String | Raw referral whois results if the inc_raw | +| | | parameter is True. | ++------------------+--------+-------------------------------------------------+ Network Dictionary ^^^^^^^^^^^^^^^^^^ @@ -81,7 +108,74 @@ Network Dictionary The dictionary mapped to the nets key in the `Results Dictionary <#results-dictionary>`_. -TODO ++-------------+--------+------------------------------------------------------+ +| **Key** |**Type**| **Description** | ++-------------+--------+------------------------------------------------------+ +| cidr | String | Network routing block an IP address belongs to. | ++-------------+--------+------------------------------------------------------+ +| range | String | Network range an IP address belongs to. | ++-------------+--------+------------------------------------------------------+ +| name | String | The identifier assigned to the network registration | +| | | for an IP address. | ++-------------+--------+------------------------------------------------------+ +| handle | String | Unique identifier for a registered network. | ++-------------+--------+------------------------------------------------------+ +| description | String | Description for a registered network. | ++-------------+--------+------------------------------------------------------+ +| country | String | Country code registered with the RIR in | +| | | ISO 3166-1 format. | ++-------------+--------+------------------------------------------------------+ +| state | String | State for a registered network (if applicable). | ++-------------+--------+------------------------------------------------------+ +| city | String | City for a registered network (if applicable). | ++-------------+--------+------------------------------------------------------+ +| address | String | The mailing address for a registered network. | ++-------------+--------+------------------------------------------------------+ +| postal_code | String | The postal code for a registered network. | ++-------------+--------+------------------------------------------------------+ +| emails | String | The email addresses listed for a registered network, | +| | | separated by '\n\' | ++-------------+--------+------------------------------------------------------+ +| created | String | Network registration date in ISO 8601 format. | ++-------------+--------+------------------------------------------------------+ +| updated | String | Network registration updated date in ISO 8601 format.| ++-------------+--------+------------------------------------------------------+ + +Referral Dictionary +^^^^^^^^^^^^^^^^^^^ + +The dictionary mapped to the referral key in the +`Results Dictionary <#results-dictionary>`_. + ++-------------+--------+------------------------------------------------------+ +| **Key** |**Type**| **Description** | ++-------------+--------+------------------------------------------------------+ +| cidr | String | Network routing block an IP address belongs to. | ++-------------+--------+------------------------------------------------------+ +| range | String | Network range an IP address belongs to. | ++-------------+--------+------------------------------------------------------+ +| name | String | The identifier assigned to the network registration | +| | | for an IP address. | ++-------------+--------+------------------------------------------------------+ +| description | String | Description for a registered network. | ++-------------+--------+------------------------------------------------------+ +| country | String | Country code registered in ISO 3166-1 format. | ++-------------+--------+------------------------------------------------------+ +| state | String | State for a registered network (if applicable). | ++-------------+--------+------------------------------------------------------+ +| city | String | City for a registered network (if applicable). | ++-------------+--------+------------------------------------------------------+ +| address | String | The mailing address for a registered network. | ++-------------+--------+------------------------------------------------------+ +| postal_code | String | The postal code for a registered network. | ++-------------+--------+------------------------------------------------------+ +| emails | String | The email addresses listed for a registered network, | +| | | separated by \'\n\'. | ++-------------+--------+------------------------------------------------------+ +| created | String | Network registration date in ISO 8601 format. | ++-------------+--------+------------------------------------------------------+ +| updated | String | Network registration updated date in ISO 8601 format.| ++-------------+--------+------------------------------------------------------+ Usage Examples ============== diff --git a/ipwhois/ipwhois.py b/ipwhois/ipwhois.py index eef4828..cdeb58e 100644 --- a/ipwhois/ipwhois.py +++ b/ipwhois/ipwhois.py @@ -120,9 +120,7 @@ def lookup_whois(self, inc_raw=False, retry_count=3, get_referral=False, :raw: Raw whois results if the inc_raw parameter is True. (String) :referral: Dictionary of referral whois information if get_referral is True and the server isn't blacklisted. Consists of fields - listed in the ipwhois.whois.RWHOIS dictionary. Additional - referral server informaion is added in the server and port - keys. (Dictionary) + listed in the ipwhois.whois.RWHOIS dictionary. :raw_referral: Raw referral whois results if the inc_raw parameter is True. (String) """ diff --git a/ipwhois/net.py b/ipwhois/net.py index 7a073e0..3a8abdf 100644 --- a/ipwhois/net.py +++ b/ipwhois/net.py @@ -828,7 +828,10 @@ def lookup_asn(self, retry_count=3, asn_alts=None, extra_org_map=None): log.debug('ASN WHOIS lookup failed, trying ASN via HTTP') try: - asn_data = self.get_asn_http(retry_count) + asn_data = self.get_asn_http( + retry_count=retry_count, + extra_org_map=extra_org_map + ) except ASNRegistryError: diff --git a/ipwhois/scripts/ipwhois_cli.py b/ipwhois/scripts/ipwhois_cli.py index 2f4e815..a71842f 100644 --- a/ipwhois/scripts/ipwhois_cli.py +++ b/ipwhois/scripts/ipwhois_cli.py @@ -25,6 +25,7 @@ # CLI python script interface for ipwhois lookups and utilities. import argparse +import json from os import path from ipwhois import IPWhois from ipwhois.hr import (HR_ASN, HR_RDAP, HR_RDAP_COMMON, HR_WHOIS) @@ -118,7 +119,7 @@ '--proxy_http', type=str, nargs=1, - default=[None], + default='', metavar='"PROXY_HTTP"', help='The proxy HTTP address passed to request.ProxyHandler. User auth' 'can be passed like "http://user:pass@192.168.0.1:80"', @@ -128,16 +129,19 @@ '--proxy_https', type=str, nargs=1, - default=[None], + default='', metavar='"PROXY_HTTPS"', help='The proxy HTTPS address passed to request.ProxyHandler. User auth' 'can be passed like "https://user:pass@192.168.0.1:443"', required=False ) group.add_argument( - '--allow_permutations', + '--disallow_permutations', action='store_true', - help='Use additional methods if DNS lookups to Cymru fail.' + help='Disable additional methods if DNS lookups to Cymru fail. This is the' + ' opposite of the ipwhois allow_permutations, in order to enable ' + 'allow_permutations by default in the CLI.', + default=False ) # Common (RDAP & Legacy Whois) @@ -159,12 +163,25 @@ '--asn_alts', type=str, nargs=1, - default=[None], + default='whois,http', metavar='"ASN_ALTS"', help='A comma delimited list of additional lookup types to attempt if the ' 'ASN dns lookup fails. Allow permutations must be enabled. ' 'Defaults to all: "whois,http"' ) +group.add_argument( + '--extra_org_map', + type=json.loads, + nargs=1, + default='{"DNIC": "arin"}', + metavar='"ASN_ALTS"', + help='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\'' +) # RDAP group = parser.add_argument_group('RDAP settings') @@ -180,7 +197,7 @@ '--excluded_entities', type=str, nargs=1, - default=[None], + default=None, metavar='"EXCLUDED_ENTITIES"', help='If not --whois, a comma delimited list of entity handles to not ' 'perform lookups.' @@ -212,7 +229,7 @@ '--extra_blacklist', type=str, nargs=1, - default=[None], + default='', metavar='"EXTRA_BLACKLIST"', help='If --whois, A list of blacklisted whois servers in addition to the ' 'global BLACKLIST.' @@ -227,7 +244,7 @@ '--field_list', type=str, nargs=1, - default=[None], + default='', metavar='"FIELD_LIST"', help='If --whois, a list of fields to parse: ' '[\'name\', \'handle\', \'description\', \'country\', \'state\', ' @@ -255,6 +272,20 @@ def generate_output(line='0', short=None, name=None, value=None, is_parent=False, colorize=True): + """ + The function for formatting CLI output results. + + Args: + line: The line number (0-4). Determines indentation. + short: The abbreviated name for a field. See hr.py for values. + name: The name for a field. See hr.py for values. + value: The field data. + is_parent: Set to True if the field value has sub-items (dicts/lists). + colorize: Colorize the console output with ANSI colors. + + Returns: + String: The generated output string. + """ # TODO: so ugly output = '{0}{1}{2}{3}{4}{5}{6}{7}\n'.format( @@ -276,6 +307,20 @@ def generate_output(line='0', short=None, name=None, value=None, class IPWhoisCLI: + """ + The CLI wrapper class for outputting formatted IPWhois results. + + Args: + addr: An IPv4 or IPv6 address as a string, integer, IPv4Address, or + IPv6Address. + timeout: The default timeout for socket connections in seconds. + proxy_http: The urllib.request.ProxyHandler dictionary for proxy + HTTP support or None. + proxy_https: The urllib.request.ProxyHandler dictionary for proxy + HTTPS support or None. + allow_permutations: allow net.Net() to use additional methods if DNS + lookups to Cymru fail. + """ def __init__( self, @@ -320,6 +365,15 @@ def __init__( allow_permutations=self.allow_permutations) def generate_output_header(self, query_type='RDAP'): + """ + The function for generating the CLI output header. + + Args: + query_type: The IPWhois query type. + + Returns: + String: The generated output string. + """ output = '\n{0}{1}{2} query for {3}:{4}\n\n'.format( ANSI['ul'], @@ -332,6 +386,17 @@ def generate_output_header(self, query_type='RDAP'): return output def generate_output_newline(self, line='0', colorize=True): + """ + The function for generating a CLI output new line. + + Args: + line: The line number (0-4). Determines indentation. + colorize: Colorize the console output with ANSI colors. + + Returns: + String: The generated output string. + """ + return generate_output( line=line, is_parent=True, @@ -340,6 +405,19 @@ def generate_output_newline(self, line='0', colorize=True): def generate_output_asn(self, json_data=None, hr=True, show_name=False, colorize=True): + """ + The function for generating CLI output ASN results. + + Args: + json_data: The data dictionary to process. + hr: Enable human readable key translations. + show_name: Show human readable name (default is to only show + short). + colorize: Colorize the console output with ANSI colors. + + Returns: + String: The generated output string. + """ if json_data is None: json_data = {} @@ -368,6 +446,19 @@ def generate_output_asn(self, json_data=None, hr=True, show_name=False, def generate_output_entities(self, json_data=None, hr=True, show_name=False, colorize=True): + """ + The function for generating CLI output RDAP entity results. + + Args: + json_data: The data dictionary to process. + hr: Enable human readable key translations. + show_name: Show human readable name (default is to only show + short). + colorize: Colorize the console output with ANSI colors. + + Returns: + String: The generated output string. + """ output = '' short = HR_RDAP['entities']['_short'] if hr else 'entities' @@ -398,6 +489,22 @@ def generate_output_entities(self, json_data=None, hr=True, def generate_output_events(self, source, key, val, line='2', hr=True, show_name=False, colorize=True): + """ + The function for generating CLI output RDAP events results. + + Args: + source: The parent key (network or objects). + key: The event key (events or events_actor). + val: The event dictionary. + line: The line number (0-4). Determines indentation. + hr: Enable human readable key translations. + show_name: Show human readable name (default is to only show + short). + colorize: Colorize the console output with ANSI colors. + + Returns: + String: The generated output string. + """ output = generate_output( line=line, @@ -473,6 +580,22 @@ def generate_output_events(self, source, key, val, line='2', hr=True, def generate_output_list(self, source, key, val, line='2', hr=True, show_name=False, colorize=True): + """ + The function for generating CLI output RDAP list results. + + Args: + source: The parent key (network or objects). + key: The event key (events or events_actor). + val: The event dictionary. + line: The line number (0-4). Determines indentation. + hr: Enable human readable key translations. + show_name: Show human readable name (default is to only show + short). + colorize: Colorize the console output with ANSI colors. + + Returns: + String: The generated output string. + """ output = generate_output( line=line, @@ -497,6 +620,22 @@ def generate_output_list(self, source, key, val, line='2', hr=True, def generate_output_notices(self, source, key, val, line='1', hr=True, show_name=False, colorize=True): + """ + The function for generating CLI output RDAP notices results. + + Args: + source: The parent key (network or objects). + key: The event key (events or events_actor). + val: The event dictionary. + line: The line number (0-4). Determines indentation. + hr: Enable human readable key translations. + show_name: Show human readable name (default is to only show + short). + colorize: Colorize the console output with ANSI colors. + + Returns: + String: The generated output string. + """ output = generate_output( line=line, @@ -563,6 +702,19 @@ def generate_output_notices(self, source, key, val, line='1', hr=True, def generate_output_network(self, json_data=None, hr=True, show_name=False, colorize=True): + """ + The function for generating CLI output RDAP network results. + + Args: + json_data: The data dictionary to process. + hr: Enable human readable key translations. + show_name: Show human readable name (default is to only show + short). + colorize: Colorize the console output with ANSI colors. + + Returns: + String: The generated output string. + """ if json_data is None: json_data = {} @@ -628,6 +780,19 @@ def generate_output_network(self, json_data=None, hr=True, show_name=False, def generate_output_objects(self, json_data=None, hr=True, show_name=False, colorize=True): + """ + The function for generating CLI output RDAP object results. + + Args: + json_data: The data dictionary to process. + hr: Enable human readable key translations. + show_name: Show human readable name (default is to only show + short). + colorize: Colorize the console output with ANSI colors. + + Returns: + String: The generated output string. + """ if json_data is None: json_data = {} @@ -790,6 +955,20 @@ def generate_output_objects(self, json_data=None, hr=True, show_name=False, return output def lookup_rdap(self, hr=True, show_name=False, colorize=True, **kwargs): + """ + The function for wrapping IPWhois.lookup_rdap() and generating + formatted CLI output. + + Args: + hr: Enable human readable key translations. + show_name: Show human readable name (default is to only show + short). + colorize: Colorize the console output with ANSI colors. + kwargs: Arguments to pass to IPWhois.lookup_rdap(). + + Returns: + String: The generated output string. + """ # Perform the RDAP lookup ret = self.obj.lookup_rdap(**kwargs) @@ -825,6 +1004,19 @@ def lookup_rdap(self, hr=True, show_name=False, colorize=True, **kwargs): def generate_output_whois_nets(self, json_data=None, hr=True, show_name=False, colorize=True): + """ + The function for generating CLI output Legacy Whois networks results. + + Args: + json_data: The data dictionary to process. + hr: Enable human readable key translations. + show_name: Show human readable name (default is to only show + short). + colorize: Colorize the console output with ANSI colors. + + Returns: + String: The generated output string. + """ if json_data is None: json_data = {} @@ -891,6 +1083,19 @@ def generate_output_whois_nets(self, json_data=None, hr=True, def generate_output_whois_referral(self, json_data=None, hr=True, show_name=False, colorize=True): + """ + The function for generating CLI output Legacy Whois referral results. + + Args: + json_data: The data dictionary to process. + hr: Enable human readable key translations. + show_name: Show human readable name (default is to only show + short). + colorize: Colorize the console output with ANSI colors. + + Returns: + String: The generated output string. + """ if json_data is None: json_data = {} @@ -943,6 +1148,20 @@ def generate_output_whois_referral(self, json_data=None, hr=True, return output def lookup_whois(self, hr=True, show_name=False, colorize=True, **kwargs): + """ + The function for wrapping IPWhois.lookup_whois() and generating + formatted CLI output. + + Args: + hr: Enable human readable key translations. + show_name: Show human readable name (default is to only show + short). + colorize: Colorize the console output with ANSI colors. + kwargs: Arguments to pass to IPWhois.lookup_whois(). + + Returns: + String: The generated output string. + """ # Perform the RDAP lookup ret = self.obj.lookup_whois(**kwargs) @@ -973,11 +1192,13 @@ def lookup_whois(self, hr=True, show_name=False, colorize=True, **kwargs): if args.addr: results = IPWhoisCLI( - args.addr[0], - args.timeout, - args.proxy_http[0], - args.proxy_https[0], - args.allow_permutations + addr=args.addr[0], + timeout=args.timeout, + proxy_http=args.proxy_http if ( + args.proxy_http and len(args.proxy_http) > 0) else None, + proxy_https=args.proxy_https if ( + args.proxy_https and len(args.proxy_https) > 0) else None, + allow_permutations=(not args.disallow_permutations) ) if args.whois: @@ -989,10 +1210,17 @@ def lookup_whois(self, hr=True, show_name=False, colorize=True, **kwargs): inc_raw=args.inc_raw, retry_count=args.retry_count, get_referral=args.get_referral, - extra_blacklist=args.extra_blacklist[0], + extra_blacklist=args.extra_blacklist.split(',') if ( + args.extra_blacklist and + len(args.extra_blacklist) > 0) else None, ignore_referral_errors=args.ignore_referral_errors, - field_list=args.field_list[0], - asn_alts=args.asn_alts[0] + field_list=args.field_list.split(',') if ( + args.field_list and + len(args.field_list) > 0) else None, + asn_alts=args.asn_alts.split(',') if ( + args.asn_alts and + len(args.asn_alts) > 0) else None, + extra_org_map=args.extra_org_map )) else: @@ -1004,8 +1232,13 @@ def lookup_whois(self, hr=True, show_name=False, colorize=True, **kwargs): inc_raw=args.inc_raw, retry_count=args.retry_count, depth=args.depth, - excluded_entities=args.excluded_entities[0], + excluded_entities=args.excluded_entities.split(',') if ( + args.excluded_entities and + len(args.excluded_entities) > 0) else None, bootstrap=args.bootstrap, rate_limit_timeout=args.rate_limit_timeout, - asn_alts=args.asn_alts[0] + asn_alts=args.asn_alts.split(',') if ( + args.asn_alts and + len(args.asn_alts) > 0) else None, + extra_org_map=args.extra_org_map )) diff --git a/ipwhois/whois.py b/ipwhois/whois.py index 5d7e09d..4043dd6 100644 --- a/ipwhois/whois.py +++ b/ipwhois/whois.py @@ -521,8 +521,7 @@ def lookup(self, inc_raw=False, retry_count=3, response=None, :raw: Raw whois results if the inc_raw parameter is True. (String) :referral: Dictionary of referral whois information if get_referral is True and the server isn't blacklisted. Consists of fields - listed in the RWHOIS dictionary. Additional referral server - informaion is added in the server and port keys. (Dictionary) + listed in the RWHOIS dictionary. :raw_referral: Raw referral whois results if the inc_raw parameter is True. (String) """