def verify_contacts(self, id_obj): """ """ nowip = strng.to_bin(misc.readExternalIP()) tcp_contact = 'tcp://%s:%d' % ( nowip, settings.getTCPPort(), ) if id_obj.getContactIndex(contact=tcp_contact) < 0: if _Debug: lg.out( 4, 'tcp_interface.verify_contacts returning False: tcp contact not found or changed' ) return False if tcp_node.get_internal_port() != settings.getTCPPort(): if _Debug: lg.out( 4, 'tcp_interface.verify_contacts returning False: tcp port has been changed' ) return False if _Debug: lg.out(4, 'tcp_interface.verify_contacts returning True') return True
def isNeedUPNP(self, *args, **kwargs): if not settings.enableUPNP(): return False if driver.is_on('service_tcp_transport'): try: from transport.tcp import tcp_node if int(tcp_node.get_internal_port()) != int(settings.getTCPPort()): return True except: lg.exc() return False return time.time() - self.last_upnp_time > 60 * 60