holePunchAddrs function

List<MultiAddr> holePunchAddrs(
  1. List<MultiAddr> addrs
)

Keeps the addresses a peer on another network can dial: no relay addresses, and no private or loopback addresses. As in go-libp2p, a hole punch uses public addresses only. A private address is reachable only on its own network, where the peers do not need a hole punch, and a dial to it from another network waits for the full dial timeout.

Implementation

List<MultiAddr> holePunchAddrs(List<MultiAddr> addrs) {
  return addrs.where((addr) => !isRelayAddress(addr) && addr.isPublic()).toList();
}