Hola,
hay algo que no entiendo.
Estaba haciendo un programa que filtra ips y vi un comportamiento algo raro en StartsWith.
Yo hice este metodo:
public static bool Check(IPAddress ipaddr)
{
foreach (String ip in bad_ranges)
if (ipaddr.ToString().StartsWith(ip))
{
return true;
}
bool result = false;
return result;
}
Y aqui la lista de ips y de comienzos de ips que debe ser filtrada:
private static String[] bad_ranges
= new String[] {
"46.16",
"64.55.",
"69.22.",
"69.162.",
"69.167.",
"128.241.",
"140.174.",
"204.2.",
"206.14.",
"209.107.",
"199.255.",
"31.210.102.38",
"46.4.62.16",
"67.221.255.12",
"74.82.218.250",
"77.245.78.10",
"79.168.9.111",
"83.142.226.101",
"85.195.76.6",
"89.217.238.",
"95.141.",
"95.142.",
"95.143.",
"95.215.",
"109.74.3.24",
"124.248.202.119",
"174.36.47.170",
"176.227.194.146",
"188.227.180.2",
"209.239.120.120",
"216.185.105.34",
"108.61.74.99",
"79.141.165.21",
"24.99.89.166",
"199.58.84.",
"50.116.5.",
"23.92.22.",
"64.62.201.",
"162.210.196.",
"192.96.203.",
"199.58.84."
};
Y bueno. Al ingresar esta ip: 46.105.121.37 me la filtra el programa.
Pero porque?
Si en la lista no agregue esa ip ni una ip que empieze con 46.105.
StartsWith tiene otra significacion a parte de empezar por los caracteres dados?
Gracias y saludos