public void AddNode(EndPoint nodeEP) { switch (nodeEP.AddressFamily) { case AddressFamily.InterNetwork: if (!NetUtilities.IsPrivateIPv4((nodeEP as IPEndPoint).Address)) { _ipv4InternetDhtNode.AddNode(nodeEP); } break; case AddressFamily.InterNetworkV6: if (NetUtilities.IsPublicIPv6((nodeEP as IPEndPoint).Address)) { _ipv6InternetDhtNode.AddNode(nodeEP); } break; case AddressFamily.Unspecified: _torInternetDhtNode?.AddNode(nodeEP); break; } }
private bool AllowNewConnection(IPEndPoint existingIP, IPEndPoint newIP) { if (existingIP.AddressFamily != newIP.AddressFamily) { if (existingIP.AddressFamily == AddressFamily.InterNetwork) { return(false); } } if (existingIP.AddressFamily == AddressFamily.InterNetwork) { if (NetUtilities.IsPrivateIPv4(existingIP.Address)) { return(false); } } return(true); }