Skip to content
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

IPv6 support #6

Open
leenaars opened this issue Oct 21, 2015 · 0 comments
Open

IPv6 support #6

leenaars opened this issue Oct 21, 2015 · 0 comments

Comments

@leenaars
Copy link
Contributor

Instead of doing a regex for IP(v4) addresses, you might consider using
native Python functionality such as:

https://docs.python.org/3/library/socket.html#socket.inet_pton
https://docs.python.org/2/library/socket.html#socket.inet_pton

which would be IP version agnostic and would allow a check like:

def check_ipv6(n):
try:
socket.inet_pton(socket.AF_INET6, n)
return True
except socket.error:
return False

Or in v3 only there is the native ipaddress module:

https://docs.python.org/3/library/ipaddress.html

(see https://docs.python.org/3/howto/ipaddress.html#ipaddress-howto)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant