-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improved IP address fetch & display #87
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You would want to make the lines L#117 and L#121, the part of the ipaddress
function so as to avoid repeating the same parts of code. Also, please make use of a try-except block in the function to address the cases when the server providing those addresses is unreachable.
(Don't worry about the specificity of the exception. Just catch one and let the user know that the addresses could not be fetched.)
def ipaddress(v): | ||
url = "https://api64.ipify.org" | ||
if v == 4: | ||
url = "https://api.ipify.org" | ||
elif v == 6: | ||
url = "https://api6.ipify.org" | ||
response = urllib3.PoolManager().request('GET', url) | ||
return response.data.decode('UTF-8') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work done with fetching distinct addresses.
@@ -1,4 +1,4 @@ | |||
import asyncio, websockets, sys, click, time, os | |||
import asyncio, websockets, sys, click, urllib3, time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
urllib3
is a not-so elegant module but lightweight - something which is perfect for our usecase. Thanks for replacing requests
in favour of this module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just make changes listed on #87 (review).
Just pushed a new, even simpler and faster implementation |
Added a simple & better method to fetch and display public IP address in the server verbose
Closes #23