code: def validate_node(self, node_ip, node_port=None, same_nodes=1):
          self.debug_print("Validating: " + node_ip)
  
          # Is this a valid IP?
          if not is_ip_valid(node_ip) or node_ip == "0.0.0.0":
              self.debug_print("Invalid node ip in validate node")
              return 0
  
          # Is this a valid port?
          if node_port != 0 and node_port is not None:
              if not is_valid_port(node_port):
                  self.debug_print("Invalid node port in validate port")
                  return 0
  
          
          if not self.enable_duplicate_ip_cons:
              # Don't connect to ourself.
              if (node_ip == "127.0.0.1" or
                      node_ip == get_lan_ip(self.interface) or
                      node_ip == self.wan_ip):
                  self.debug_print("Cannot connect to ourself.")
                  return 0
  
              # No, really: don't connect to ourself.
              if node_ip == self.passive_bind and node_port == self.passive_port:
                  self.debug_print("Error connecting to same listen server.")
                  return 0
  
              # Don't connect to same nodes.
              if same_nodes:
                  for node in self.outbound + self.inbound:
                      try:
                          addr, port = node["con"].s.getpeername()
                          if node_ip == addr:
                              self.debug_print("Already connected to this node.")
                              return 0
                      except Exception as e:
                          print(e)
                          return 0
  
          return 1
docs: Don't accept connections from self to passive server
          or connections to already connected nodes.