protected virtual bool RegistTrustIP(ClientManager clmngr) { if (clmngr == null) { return(false); } string ipAddr = ((IPEndPoint)clmngr.Socket.RemoteEndPoint).Address.ToString(); long remoteIP = IPUtility.GetIPIntValue(ipAddr); try { if (remoteIP == _LocalhostIP) { return(false); } if (_Config.TrustRemoteIP != null && _Config.TrustRemoteIP.Count > 0) { foreach (long ip in _Config.TrustRemoteIP) { if (ip == remoteIP) { clmngr.IsTrustIP = true; break; } } } } catch { } return(clmngr.IsTrustIP); }
protected int ParseTrustIPString(string value) { if (string.IsNullOrEmpty(value)) return 0; if (TrustRemoteIP != null) { TrustRemoteIP.Clear(); TrustRemoteIP = null; } try { string[] ips = value.Split(new char[] { ';', ',' }); if (ips != null && ips.Length > 0) { TrustRemoteIP = new HashSet<long>(); foreach (string ipAddr in ips) { long ip = IPUtility.GetIPIntValue(ipAddr); TrustRemoteIP.Add(ip); } } } catch { } return TrustRemoteIP != null ? TrustRemoteIP.Count : 0; }