skipDial method

  1. @override
bool skipDial(
  1. MultiAddr addr
)
override

Implementation

@override
bool skipDial(MultiAddr addr) {
  // skip relay addresses
  if (addr.hasProtocol('p2p-circuit')) { // Check for circuit relay protocol
    return true;
  }

  if (allowSelfDials) {
    return false;
  }

  // skip private network (unroutable) addresses
  if (!addr.isPublic()) {
    return true;
  }

  final candidateIP = addr.toIP();
  if (candidateIP == null) {
    return true; // Not an IP address
  }

  // Skip dialing addresses we believe are the local node's
  for (final localAddr in host.addrs) {
    final localIP = localAddr.toIP();
    if (localIP != null && localIP.address == candidateIP.address) {
      return true;
    }
  }
  return false;
}