GeezerVison is showing github.com — Bug fix to bad coordinate reading on private IPs. by UmanShahzad · Pull Request #11 · ipinfo/python
Conversation
UmanShahzad
commented
Mar 15, 2019
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Closes #10
Fixes an issue where geolocation data isn't available (e.g. for private IPs) and we try to retrieve it by giving an index, without checking if it's valid for the list.
Was able to reproduce the issue in #10 with:
>>> details = handler.getDetails('10.62.100.139')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/mslm/dev/ipinfo/python/ipinfo/handler.py", line 53, in getDetails
lat, lon = coords[0], coords[1]
IndexError: tuple index out of range
After the fix:
>>> details = handler.getDetails('10.62.100.139')
>>> details.all
{'ip': '10.62.100.139', 'bogon': True, 'country_name': None, 'ip_address': IPv4Address('10.62.100.139'), 'latitude': None, 'longitude': None}
>>> details.latitude
>>> details.longitude
>>> details.bogon
True
and for public IPs:
>>> details = handler.getDetails('9.9.9.9')
>>> details.all
{'ip': '9.9.9.9', 'hostname': 'dns.quad9.net', 'city': '', 'region': '', 'country': 'FR', 'loc': '48.8582,2.3387', 'org': 'AS19281 Quad9', 'country_name': 'France', 'ip_address': IPv4Address('9.9.9.9'), 'latitude': '48.8582', 'longitude': '2.3387'}
>>> details.latitude
'48.8582'
>>> details.longitude
'2.3387'
>>> details.loc
'48.8582,2.3387'
>>> details.country
'FR'
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
coderholic
Awaiting requested review from coderholic
jhtimmins
Awaiting requested review from jhtimmins
Uh oh!
There was an error while loading. Please reload this page.
Milestone
No milestone
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|