add back support for ip filter files to client_test. add some logging when tracker IPs are filtered
This commit is contained in:
@@ -891,32 +891,22 @@ int main(int argc, char* argv[])
|
|||||||
case 'H': start_dht = false; --i; break;
|
case 'H': start_dht = false; --i; break;
|
||||||
case 'x':
|
case 'x':
|
||||||
{
|
{
|
||||||
/*
|
FILE* filter = fopen(arg, "r");
|
||||||
std::ifstream in(arg);
|
if (filter)
|
||||||
ip_filter filter;
|
{
|
||||||
while (in.good())
|
ip_filter fil;
|
||||||
|
unsigned int a,b,c,d,e,f,g,h, flags;
|
||||||
|
while (fscanf(filter, "%u.%u.%u.%u - %u.%u.%u.%u %u\n", &a, &b, &c, &d, &e, &f, &g, &h, &flags) == 9)
|
||||||
{
|
{
|
||||||
char line[300];
|
|
||||||
in.getline(line, 300);
|
|
||||||
int len = in.gcount();
|
|
||||||
if (len <= 0) continue;
|
|
||||||
if (line[0] == '#') continue;
|
|
||||||
int a, b, c, d;
|
|
||||||
char dummy;
|
|
||||||
std::stringstream ln(line);
|
|
||||||
ln >> a >> dummy >> b >> dummy >> c >> dummy >> d >> dummy;
|
|
||||||
address_v4 start((a << 24) + (b << 16) + (c << 8) + d);
|
address_v4 start((a << 24) + (b << 16) + (c << 8) + d);
|
||||||
ln >> a >> dummy >> b >> dummy >> c >> dummy >> d;
|
address_v4 last((e << 24) + (f << 16) + (g << 8) + h);
|
||||||
address_v4 last((a << 24) + (b << 16) + (c << 8) + d);
|
|
||||||
int flags;
|
|
||||||
ln >> flags;
|
|
||||||
if (flags <= 127) flags = ip_filter::blocked;
|
if (flags <= 127) flags = ip_filter::blocked;
|
||||||
else flags = 0;
|
else flags = 0;
|
||||||
if (ln.fail()) break;
|
fil.add_rule(start, last, flags);
|
||||||
filter.add_rule(start, last, flags);
|
}
|
||||||
|
ses.set_ip_filter(fil);
|
||||||
|
fclose(filter);
|
||||||
}
|
}
|
||||||
ses.set_ip_filter(filter);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'c': ses.set_max_connections(atoi(arg)); break;
|
case 'c': ses.set_max_connections(atoi(arg)); break;
|
||||||
|
@@ -246,6 +246,13 @@ namespace libtorrent
|
|||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
||||||
|
boost::shared_ptr<request_callback> cb = requester();
|
||||||
|
if (cb)
|
||||||
|
{
|
||||||
|
cb->debug_log("*** TRACKER_FILTER");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (endpoints.empty())
|
if (endpoints.empty())
|
||||||
fail(error_code(errors::banned_by_ip_filter));
|
fail(error_code(errors::banned_by_ip_filter));
|
||||||
}
|
}
|
||||||
|
@@ -147,7 +147,12 @@ namespace libtorrent
|
|||||||
i != m_endpoints.end();)
|
i != m_endpoints.end();)
|
||||||
{
|
{
|
||||||
if (m_ses.m_ip_filter.access(i->address()) == ip_filter::blocked)
|
if (m_ses.m_ip_filter.access(i->address()) == ip_filter::blocked)
|
||||||
|
{
|
||||||
|
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
||||||
|
if (cb) cb->debug_log("*** UDP_TRACKER [ IP blocked by filter: " + print_address(i->address()) + " ]");
|
||||||
|
#endif
|
||||||
i = m_endpoints.erase(i);
|
i = m_endpoints.erase(i);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user