def isLoopbackURL(url):
"""Checks if the specified URL refers to a loopback address.
:return: True if the URL refers to the loopback interface, otherwise False.
"""
if url is not None:
if url.hostname is not None:
is_loopback = yield deferToThread(
resolves_to_loopback_address, url.hostname)
else:
# Empty URL == localhost.
is_loopback = True
else:
# We need to pass is_loopback in, but it is only checked if url
# is not None. None is the "I don't know and you won't ask"
# state for this boolean.
is_loopback = None
return is_loopback
评论列表
文章目录