Do ord() on first two bytes of host in checkIPv6Address()
only in python2
This commit is contained in:
parent
c11186e7be
commit
06643bbbf3
|
@ -202,15 +202,19 @@ def checkIPv6Address(host, hostStandardFormat, private=False):
|
||||||
Returns hostStandardFormat if it is an IPv6 address,
|
Returns hostStandardFormat if it is an IPv6 address,
|
||||||
otherwise returns False
|
otherwise returns False
|
||||||
"""
|
"""
|
||||||
if host == (b'\x00' * 15) + b'\x01':
|
if host == b'\x00' * 15 + b'\x01':
|
||||||
if not private:
|
if not private:
|
||||||
logger.debug('Ignoring loopback address: %s', hostStandardFormat)
|
logger.debug('Ignoring loopback address: %s', hostStandardFormat)
|
||||||
return False
|
return False
|
||||||
if host[0] == b'\xFE' and (ord(host[1]) & 0xc0) == 0x80:
|
try:
|
||||||
|
host = [ord(c) for c in host[:2]]
|
||||||
|
except TypeError: # python3 has ints already
|
||||||
|
pass
|
||||||
|
if host[0] == 0xfe and host[1] & 0xc0 == 0x80:
|
||||||
if not private:
|
if not private:
|
||||||
logger.debug('Ignoring local address: %s', hostStandardFormat)
|
logger.debug('Ignoring local address: %s', hostStandardFormat)
|
||||||
return hostStandardFormat if private else False
|
return hostStandardFormat if private else False
|
||||||
if (ord(host[0]) & 0xfe) == 0xfc:
|
if host[0] & 0xfe == 0xfc:
|
||||||
if not private:
|
if not private:
|
||||||
logger.debug(
|
logger.debug(
|
||||||
'Ignoring unique local address: %s', hostStandardFormat)
|
'Ignoring unique local address: %s', hostStandardFormat)
|
||||||
|
|
Reference in New Issue
Block a user