Skip to content

Commit

Permalink
Add history and type parameters to Shodan.dns.domain_info() method an…
Browse files Browse the repository at this point in the history
…d CLI command
  • Loading branch information
achillean committed Dec 25, 2019
1 parent 9b1fe51 commit c73cf83
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
CHANGELOG
=========

1.21.1
------
* Add ``history`` and ``type`` parameters to ``Shodan.dns.domain_info()`` method and CLI command

1.21.0
------
* New API methods ``api.search_facets()`` and ``api.search_filters()`` to get a list of available facets and filters.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setup(
name='shodan',
version='1.21.0',
version='1.21.1',
description='Python library and command-line utility for Shodan (https://developer.shodan.io)',
long_description=README,
long_description_content_type='text/x-rst',
Expand Down
6 changes: 4 additions & 2 deletions shodan/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,15 @@ def convert(fields, input, format):
@click.argument('domain', metavar='<domain>')
@click.option('--details', '-D', help='Lookup host information for any IPs in the domain results', default=False, is_flag=True)
@click.option('--save', '-S', help='Save the information in the a file named after the domain (append if file exists).', default=False, is_flag=True)
def domain_info(domain, details, save):
@click.option('--history', '-H', help='Include historical DNS data in the results', default=False, is_flag=True)
@click.option('--type', '-T', help='Only returns DNS records of the provided type', default=None)
def domain_info(domain, details, save, history, type):
"""View all available information for a domain"""
key = get_api_key()
api = shodan.Shodan(key)

try:
info = api.dns.domain_info(domain)
info = api.dns.domain_info(domain, history=history, type=type)
except shodan.APIError as e:
raise click.ClickException(e.value)

Expand Down
9 changes: 7 additions & 2 deletions shodan/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,15 @@ class Dns:
def __init__(self, parent):
self.parent = parent

def domain_info(self, domain):
def domain_info(self, domain, history=False, type=None):
"""Grab the DNS information for a domain.
"""
return self.parent._request('/dns/domain/{}'.format(domain), {})
args = {}
if history:
args['history'] = history
if type:
args['type'] = type
return self.parent._request('/dns/domain/{}'.format(domain), args)

class Notifier:

Expand Down

0 comments on commit c73cf83

Please sign in to comment.