mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-17 14:10:41 +01:00
src/utils/net: Fix our method of determining whether an IPV6 or IP socket is needed.
This commit is contained in:
parent
da762194ff
commit
ef3e002db3
@ -36,13 +36,14 @@ import socket
|
|||||||
|
|
||||||
emailRe = re.compile(r"^(\w&.+-]+!)*[\w&.+-]+@"
|
emailRe = re.compile(r"^(\w&.+-]+!)*[\w&.+-]+@"
|
||||||
r"(([0-9a-z]([0-9a-z-]*[0-9a-z])?\.)[a-z]{2,6}|"
|
r"(([0-9a-z]([0-9a-z-]*[0-9a-z])?\.)[a-z]{2,6}|"
|
||||||
r"([0-9]{1,3}\.){3}[0-9]{1,3})$", re.I)
|
r"([0-9]{1,3}\.){3}[0-9]{1,3})$", re.I)
|
||||||
|
|
||||||
def getSocket(host):
|
def getSocket(host):
|
||||||
"""Returns a socket of the correct AF_INET type (v4 or v6) in order to
|
"""Returns a socket of the correct AF_INET type (v4 or v6) in order to
|
||||||
communicate with host.
|
communicate with host.
|
||||||
"""
|
"""
|
||||||
host = socket.gethostbyname(host)
|
addrinfo = socket.getaddrinfo(host, None)
|
||||||
|
host = addrinfo[0][4][0]
|
||||||
if isIP(host):
|
if isIP(host):
|
||||||
return socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
return socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
elif isIPV6(host):
|
elif isIPV6(host):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user