mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-26 03:54:08 +01:00
Fix for isIPV6 on platforms that don't support IPV6.
This commit is contained in:
parent
aa7408c09b
commit
ed7748492f
@ -181,6 +181,20 @@ def isIPV6(s):
|
|||||||
try:
|
try:
|
||||||
return bool(socket.inet_pton(socket.AF_INET6, s))
|
return bool(socket.inet_pton(socket.AF_INET6, s))
|
||||||
except socket.error:
|
except socket.error:
|
||||||
|
try:
|
||||||
|
socket.inet_pton(socket.AF_INET6, '::')
|
||||||
|
except socket.error:
|
||||||
|
# We gotta fake it.
|
||||||
|
if s.count('::') <= 1:
|
||||||
|
L = s.split(':')
|
||||||
|
if len(L) <= 8:
|
||||||
|
for x in L:
|
||||||
|
if x:
|
||||||
|
try:
|
||||||
|
int(x, 16)
|
||||||
|
except ValueError:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def banmask(hostmask):
|
def banmask(hostmask):
|
||||||
|
Loading…
Reference in New Issue
Block a user