/// <summary> /// Check the new connection <br/> /// If it is equal to the Nonce of local or any remote node, it'll return false, else we'll return true and update the Listener address of the connected remote node. /// </summary> /// <param name="actor">Remote node actor</param> /// <param name="node">Remote node</param> public bool AllowNewConnection(IActorRef actor, RemoteNode node) { if (node.Version.Magic != ProtocolSettings.Default.Magic) { return(false); } if (node.Version.Nonce == Nonce) { return(false); } // filter duplicate connections foreach (var other in RemoteNodes.Values) { if (other != node && other.Remote.Address.Equals(node.Remote.Address) && other.Version?.Nonce == node.Version.Nonce) { return(false); } } if (node.Remote.Port != node.ListenerTcpPort && node.ListenerTcpPort != 0) { ConnectedPeers.TryUpdate(actor, node.Listener, node.Remote); } return(true); }
/// <summary> /// Check the new connection <br/> /// If it is equal to the Nonce of local or any remote node, it'll return false, else we'll return true and update the Listener address of the connected remote node. /// </summary> /// <param name="actor">Remote node actor</param> /// <param name="node">Remote node</param> public bool AllowNewConnection(IActorRef actor, RemoteNode node) { if (node.Version.Magic != system.Settings.Magic) return false; if (node.Version.Nonce == Nonce) return false; // filter duplicate connections foreach (var other in RemoteNodes.Values) if (other != node && other.Remote.Address.Equals(node.Remote.Address) && other.Version?.Nonce == node.Version.Nonce) return false; if (node.Remote.Port != node.ListenerTcpPort && node.ListenerTcpPort != 0) ConnectedPeers.TryUpdate(actor, node.Listener, node.Remote); return true; }