net: Support for IPv6, correctly validate IP addresses

Since socket.gethostbyname_ex() doesn't support IPv6, switch to using
socket.getaddrinfo()

Additionally validate IP addresses using inet_pton() instead of simply
counting dots in the string. Counting dots fails if the domain name
contains 3 dots (www6.mail.bakulin.de) and doesn't work with IPv6.

Unfortunately we cannot use ipaddress module because it's available
only in Python 3.
Merge pull request #1 from kibab/kibab-public

add: net: Support for IPv6, correctly validate IP addresses