public override int GetHashCode() { int hash = 1; if (VersionTag.Length != 0) { hash ^= VersionTag.GetHashCode(); } if (Ips.Length != 0) { hash ^= Ips.GetHashCode(); } if (Ports.Length != 0) { hash ^= Ports.GetHashCode(); } if (ResourceUrl.Length != 0) { hash ^= ResourceUrl.GetHashCode(); } if (VersionUrl.Length != 0) { hash ^= VersionUrl.GetHashCode(); } if (ShowState != false) { hash ^= ShowState.GetHashCode(); } if (SelectServer != false) { hash ^= SelectServer.GetHashCode(); } return(hash); }
public SMSeedOptions() { smRom = new Lazy <byte[]>(() => { using var ips = OpenReadInnerStream(Ips.First()); var rom = File.ReadAllBytes(smFile); FileData.Rom.ApplyIps(rom, ips); return(rom); }); }
private Ips Map(string linea) { Ips ips = new Ips(); char delimiter = ';'; string[] sacaMatrizLab = linea.Split(delimiter); ips.IdIps = sacaMatrizLab[0]; ips.NombreIps = sacaMatrizLab[1]; return(ips); }
public SMZ3SeedOptions() { smz3Rom = new Lazy <byte[]>(() => { using var sm = File.OpenRead(smFile); using var z3 = File.OpenRead(z3File); using var ips = OpenReadInnerStream(Ips.First()); var rom = FileData.Rom.CombineSMZ3Rom(sm, z3); FileData.Rom.ApplyIps(rom, ips); return(rom); }); }
public void GuardarBD(Ips ips) { using (var command = connection.CreateCommand()) { command.CommandText = "Insert Into IPS (IdIPS, NombreIPS)" + " VALUES (@IdIps, @NombreIPS)"; command.Parameters.AddWithValue("@IdIps", ips.IdIps); command.Parameters.AddWithValue("@NombreIPS", ips.NombreIps); command.ExecuteNonQuery(); } }
private Ips DataReaderMapIps(SqlDataReader dataReader) { if (!dataReader.HasRows) { return(null); } Ips Ips = new Ips(); Ips.IdIps = (string)dataReader["IdIps"]; Ips.NombreIps = (string)dataReader["NombreIps"]; return(Ips); }
public string Guardar(Ips Ips) { try { connectionManager.Open(); IpsRepository.GuardarBD(Ips); return($"Se guardaron los datos satisfactoriamente"); } catch (Exception e) { return($"Error de la aplicacion : {e.Message}"); } finally { connectionManager.Close(); } }
/// <summary> /// 是否机器人IP /// </summary> /// <param name="ip"></param> /// <param name="userAgent"></param> /// <returns></returns> public static bool IsRobotIp(string ip, string userAgent) { if (string.IsNullOrWhiteSpace(ip) || string.IsNullOrWhiteSpace(userAgent)) { return(true); } if (RegSpider.IsMatch(userAgent)) { return(false); } if (BlackIpLists.Exists(p => p.Ip.Equals(ip))) { return(true); } var item = new Ips() { Ip = ip, Ticks = DateTime.Now.Ticks }; var overLine = item.Ticks - Seconds * 10000000; Task.Run(() => { lock (IpLists) { IpLists.RemoveAll(p => p.Ticks < overLine); } }); var total = 0; lock (IpLists) { IpLists.Add(item); total = IpLists.Count(p => p.Ip.Equals(ip) && p.Ticks > overLine); } if (total > Seconds) { BlackIpLists.Add(item); return(true); } return(false); }
public List <Ips> ConsultarTodaLaLista(string fileName) { List <Ips> ListaDeIps = new List <Ips>(); FileStream file = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Read); StreamReader reader = new StreamReader(file); string linea = string.Empty; while ((linea = reader.ReadLine()) != null) { Ips ips = Map(linea); ListaDeIps.Add(ips); } reader.Close(); file.Close(); return(ListaDeIps); }
/// <summary> /// Returns true if APIKeyInfo instances are equal /// </summary> /// <param name="input">Instance of APIKeyInfo to be compared</param> /// <returns>Boolean</returns> public bool Equals(APIKeyInfo input) { if (input == null) { return(false); } return (( ApiKey == input.ApiKey || (ApiKey != null && ApiKey.Equals(input.ApiKey)) ) && ( UserId == input.UserId || (UserId != null && UserId.Equals(input.UserId)) ) && ( Ips == input.Ips || Ips != null && Ips.SequenceEqual(input.Ips) ) && ( Note == input.Note || (Note != null && Note.Equals(input.Note)) ) && ( Permissions == input.Permissions || Permissions != null && Permissions.SequenceEqual(input.Permissions) ) && ( CreatedAt == input.CreatedAt || (CreatedAt != null && CreatedAt.Equals(input.CreatedAt)) ) && ( ReadOnly == input.ReadOnly || (ReadOnly != null && ReadOnly.Equals(input.ReadOnly)) )); }
//public void Guardar(Ips ips) //{ // FileStream file = new FileStream(fileName, FileMode.Append); // StreamWriter writer = new StreamWriter(file); // writer.WriteLine($"{ips.IdIps};{ips.NombreIps}"); // writer.Close(); // file.Close(); //} public List <Ips> ConsultarTodosBD() { List <Ips> ListaDeIps = new List <Ips>(); using (var command = connection.CreateCommand()) { command.CommandText = "Select * from IPS"; var dataReader = command.ExecuteReader(); if (dataReader.HasRows) { while (dataReader.Read()) { Ips Ips = DataReaderMapIps(dataReader); ListaDeIps.Add(Ips); } } } return(ListaDeIps); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = 41; if (ApiKey != null) { hashCode = hashCode * 59 + ApiKey.GetHashCode(); } if (UserId != null) { hashCode = hashCode * 59 + UserId.GetHashCode(); } if (Ips != null) { hashCode = hashCode * 59 + Ips.GetHashCode(); } if (Note != null) { hashCode = hashCode * 59 + Note.GetHashCode(); } if (Permissions != null) { hashCode = hashCode * 59 + Permissions.GetHashCode(); } if (CreatedAt != null) { hashCode = hashCode * 59 + CreatedAt.GetHashCode(); } if (ReadOnly != null) { hashCode = hashCode * 59 + ReadOnly.GetHashCode(); } return(hashCode); } }
public BsonDocument ToDocument() { var doc = new BsonDocument(); doc.Add("_id", Domain); if (Ips != null) { doc.Add("Ips", new BsonArray(Ips.Select(x => new BsonValue((int)x)))); } if (OldIps != null) { doc.Add("OldIps", new BsonArray(OldIps.Select(x => new BsonValue((int)x)))); } if (Date != DateTime.MinValue) { doc.Add("Date", Date); } if (Expire != DateTime.MinValue) { doc.Add("Expire", Expire); } if (Ips6 != null) { doc.Add("Ips6", new BsonArray(Ips6.Select(x => new BsonValue(x.ToBytes())))); } if (OldIps6 != null) { doc.Add("OldIps6", new BsonArray(OldIps6.Select(x => new BsonValue(x.ToBytes())))); } if (Date6 != DateTime.MinValue) { doc.Add("Date6", Date6); } if (Expire6 != DateTime.MinValue) { doc.Add("Expire6", Expire6); } return(doc); }
/** * Data: 27/02/2019 * Construtor da classe que configura os principais variáveis da classe; * Return: void */ public Server_StreamClose(int port = 0, string IP = null) { try { PORT = port == 0 ? 80 : port; NomeLocalMaquina = Dns.GetHostName(); //Obtém o nome da máquina local IPsHost = Dns.GetHostEntry(NomeLocalMaquina); //Obtém uma lista de endereços de ips locais TEndPoint = __Autenticacao.Cliente; /*Se não for, explicitamente informado o tipo de Serviço, será utilizado o serviço de Cliente*/ if (IP == null) { IPEscutar = IPsHost.AddressList[2]; //Falta implementar a seleção de qual ip será utilizado quando existir mais IP } else { IPEscutar = IPAddress.Parse(IP); bool Test = false; foreach (IPAddress Ips in IPsHost.AddressList) { if (Ips.Equals(IPEscutar)) { Test = true; } } if (!Test) { throw new Exception("O ip informado não coincide com os IPs desta máquina."); } } } catch (Exception e) { TratadorErros(e, this.GetType().Name);; } }
/** * Data: 27/02/2019 * Construtor da classe que configura os principais variáveis da classe; * Return: void */ public Server_STREAMOpen(int port = 0, string IP = null) { try { TSaida_Error = TipoSaidaErros.ShowWindow; PORT = port == 0 ? 80 : port; NomeLocalMaquina = Dns.GetHostName(); //Obtém o nome da máquina local IPsHost = Dns.GetHostEntry(NomeLocalMaquina); //Obtém uma lista de endereços de ips locais if (IP == null) { IPEscutar = IPsHost.AddressList[1]; //Falta implementar a seleção de qual ip será utilizado quando existir mais IP } else { IPEscutar = IPAddress.Parse(IP); bool Test = false; foreach (IPAddress Ips in IPsHost.AddressList) { if (Ips.Equals(IPEscutar)) { Test = true; } } if (!Test) { throw new Exception("O ip informado não coincide com os IPs desta máquina."); } } } catch (Exception e) { TratadorErros(e, this.GetType().Name); } }
// GET: api/Ips/5 public HttpResponseMessage Get(string id) { string ipTable = string.Empty; string city = string.Empty; string country = string.Empty; string longitude = string.Empty; string latitude = string.Empty; string ip = id.Replace('-', '.'); string Host = "localhost"; string User = "******"; string DBname = "postgres"; string Password = "******"; string Port = "5432"; string connString = String.Format( "Server={0}; User Id={1}; Database={2}; Port={3}; Password={4};", Host, User, DBname, Port, Password); NpgsqlConnection conn = new NpgsqlConnection(connString); Console.WriteLine("Opening connection"); conn.Open(); //NpgsqlCommand com = new NpgsqlCommand("select * from ips order by \"ip\"", conn); NpgsqlCommand com = new NpgsqlCommand("select * from ips where ip='" + ip + "'", conn); NpgsqlDataReader reader; reader = com.ExecuteReader(); while (reader.Read()) { try { ipTable = reader.GetString(1); city = reader.GetString(2); country = reader.GetString(3); longitude = reader.GetString(4); latitude = reader.GetString(5); } catch { } } conn.Close(); Ips item = new Ips(); item.Ip = ipTable; item.City = city; item.Country = country; item.Longitude = longitude; item.Latitude = latitude; return(Request.CreateResponse(HttpStatusCode.OK, item, Configuration.Formatters.JsonFormatter)); }