public bool TryFindNode(IPAddress address, int listenPort, out RelayNodeDefinition nodeDefintion) { foreach (RelayNodeDefinition node in RelayNodes) { if (node.IPAddress.Equals(address) && node.Port == listenPort) { nodeDefintion = node; return(true); } } nodeDefintion = null; return(false); }
internal RelayNodeDefinition GetNodeFor(IPAddress address, int listenPort) { RelayNodeDefinition nodeDefinition = null; foreach (RelayNodeDefinition node in RelayNodes) { if (node.IPAddress.Equals(address) && node.Port == listenPort) { nodeDefinition = node; break; } } return(nodeDefinition); }
/// <summary> /// Returns a <see cref="RelayNodeDefinition"/> of a node configured to listen /// on a given address and port contained in any cluster for the current environment. /// </summary> /// <param name="address">The <see cref="IPAddress"/> to look for.</param> /// <param name="listenPort">The port that the node is listening on.</param> /// <returns>Returns a definition if found; otherwise, returns null.</returns> public RelayNodeDefinition GetNodeFor(IPAddress address, int listenPort) { RelayNodeDefinition nodeDefinition = null; var defaultSettings = DefaultRelayNodeClusters; RelayNodeClusterDefinition[] clusters = defaultSettings; EnvironmentDefinition env = GetEnvironment(); if (env != null) { clusters = env.RelayNodeClusters; } foreach (RelayNodeClusterDefinition cluster in clusters) { nodeDefinition = cluster.GetNodeFor(address, listenPort); if (nodeDefinition != null) { break; } } return(nodeDefinition); }
/// <summary> /// Determines if there is defined a node configured to listen on a given address and port /// contained in any cluster accross all environments. /// </summary> /// <param name="address">The <see cref="IPAddress"/> to look for.</param> /// <param name="listenPort">The port that the node is listening on.</param> /// <returns>Returns true if the address is contained in this group; otherwise, false.</returns> public bool ContainsNode(IPAddress address, int listenPort) { RelayNodeDefinition node = GetNodeFor(address, listenPort); return(node != null); }