Skip to content

Commit

Permalink
Merge pull request #160 from secynic/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
secynic authored Feb 3, 2017
2 parents 6bdd234 + 76a360e commit cd93e8b
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ install:
- pip install coveralls
- python setup.py -q install
script:
- nosetests -v -w ipwhois --include=online --with-coverage --cover-package=ipwhois
- nosetests -v -w ipwhois --include=online --exclude=stress --with-coverage --cover-package=ipwhois
after_success:
- coveralls --rcfile=.coveragerc
5 changes: 3 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Changelog
=========

0.15.0 (TBD)
------------
0.15.0 (2017-02-02)
-------------------

- Python 3.3+ dnspython3 requirement changed to dnspython (#155)
- Added ASN origin lookup support (#149)
Expand All @@ -19,6 +19,7 @@ Changelog
- Documentation updates
- Code style tweaks
- Updated tests and version info for Python 3.6
- Added basic stress tests (#144)
- Minor tweaks to existing tests

0.14.0 (2016-08-29)
Expand Down
10 changes: 5 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ for IPv4 and IPv6 addresses.

.. attention::

NIR (National Internet Registry) lookups are now enabled by default.
This is currently only performed for JPNIC and KRNIC addresses.
NIR (National Internet Registry) lookups are enabled by default as of
v0.14.0. This is currently only performed for JPNIC and KRNIC addresses.
To disable, set inc_nir=False in your IPWhois.lookup_*() query.

.. attention::

The 'nets' -> 'emails' key in IPWhois.lookup_whois() has been changed from
a '\\n' separated string to a list.
The 'nets' -> 'emails' key in IPWhois.lookup_whois() was changed from
a '\\n' separated string to a list in v0.14.0.

.. important::

Expand Down Expand Up @@ -63,7 +63,7 @@ Features
* Referral whois support for legacy whois protocol
* Recursive network parsing for IPs with parent/children networks listed
* National Internet Registry support for JPNIC and KRNIC
* Supports ASN origin queries
* Supports IP to ASN and ASN origin queries
* Python 2.6+ and 3.3+ supported
* Useful set of utilities
* BSD license
Expand Down
34 changes: 34 additions & 0 deletions ipwhois/hr.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,40 @@
}
}

HR_ASN_ORIGIN = {
'nets': {
'_short': 'Network',
'_name': 'ASN Network',
'_description': 'A network associated with an Autonomous System Number'
' (ASN)',
'cidr': {
'_short': 'CIDR',
'_name': 'Classless Inter-Domain Routing Block',
'_description': 'The network routing block.'
},
'description': {
'_short': 'Description',
'_name': 'Description',
'_description': 'Description for the registered network.'
},
'maintainer': {
'_short': 'Maintainer',
'_name': 'Maintainer',
'_description': 'The entity that maintains the network.'
},
'updated': {
'_short': 'Updated',
'_name': 'Updated Timestamp',
'_description': 'Network registration updated information.'
},
'source': {
'_short': 'Source',
'_name': 'ASN Network Information Source',
'_description': 'The source of the network information.'
}
}
}

HR_RDAP_COMMON = {
'entities': {
'_short': 'Entities',
Expand Down
20 changes: 0 additions & 20 deletions ipwhois/tests/online/test_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,26 +126,6 @@ def test_get_http_json(self):
self.assertRaises(HTTPLookupError, result.get_http_json, **dict(
url=url, retry_count=0))

# Uncommenting below will result in a flood of up to 20 requests
# to test rate limiting.
'''
url = RIR_RDAP['lacnic']['ip_url'].format('200.57.141.161')
result = Net('200.57.141.161')
count = 20
while count > 0:
count -= 1
try:
self.assertRaises(HTTPRateLimitError, result.get_http_json,
**dict(url=url, retry_count=0))
break
except AssertionError as e:
if count == 0:
raise e
else:
pass
'''

def test_get_host(self):
ips = [
'74.125.225.229', # ARIN
Expand Down
Empty file.
43 changes: 43 additions & 0 deletions ipwhois/tests/stress/test_net.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import logging
from ipwhois.tests import TestCommon
from ipwhois.exceptions import (HTTPLookupError, HTTPRateLimitError)
from ipwhois.net import Net

LOG_FORMAT = ('[%(asctime)s] [%(levelname)s] [%(filename)s:%(lineno)s] '
'[%(funcName)s()] %(message)s')
logging.basicConfig(level=logging.DEBUG, format=LOG_FORMAT)
log = logging.getLogger(__name__)


class TestNet(TestCommon):

def test_get_http_json(self):
from ipwhois.rdap import RIR_RDAP

# Test for HTTPRateLimitError for up to 20 requests. Exits when raised.
url = RIR_RDAP['lacnic']['ip_url'].format('200.57.141.161')
result = Net('200.57.141.161')
count = 20
http_lookup_errors = 0
while count > 0:
log.debug('Attempts left: {0}'.format(str(count)))
count -= 1
try:
self.assertRaises(HTTPRateLimitError, result.get_http_json,
**dict(url=url, retry_count=0))
break

except AssertionError as e:
if count == 0:
raise e
else:
pass

except HTTPLookupError as e:
http_lookup_errors += 1
if http_lookup_errors == 5:
raise Exception('HTTPLookupError has been raised 5 times. '
'Likely cause is socket connection '
'timeouts. Quitting test to avoid an '
'endless loop.')
continue

0 comments on commit cd93e8b

Please sign in to comment.