def is_it_us(self, host, port):
"""
True if the host/port combination corresponds to an address exposed by
this server
"""
if port != self.portNo:
return False
our_ip = self.ipAddress
if our_ip != '0.0.0.0' and our_ip == host:
return True
# We are exposed to all interfaces and `host` might be one of them
# gethostbyname_ex[2] is a list of addresses
for h in socket.gethostbyname_ex(host)[2]:
if h in self.all_ip_addresses:
return True
return False
评论列表
文章目录