/// <summary> /// The get ip address. /// </summary> /// <param name="user"> /// The user. /// </param> /// <returns> /// The <see cref="IPAddress"/>. /// </returns> private IPAddress GetIpAddress(IUser user) { if (user.Hostname.Contains("/")) { // cloaked. hmm... // gateway, try username var validHexIp = new Regex("^[0-9A-Fa-f]{8}$"); if (validHexIp.IsMatch(user.Username)) { return Decode.GetIpAddressFromHex(user.Username); } // not a gateway cloak. Can't do anything. return null; } // resolve hostname IPAddress[] addresses = new IPAddress[0]; try { addresses = Dns.GetHostEntry(user.Hostname).AddressList; } catch (SocketException) { } return addresses.FirstOrDefault(); }