fix internal use of deprecated function identify_client
This commit is contained in:
parent
fc0cbfb789
commit
f3d319b677
|
@ -48,13 +48,20 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
// remove its internal use
|
// remove its internal use
|
||||||
namespace libtorrent {
|
namespace libtorrent {
|
||||||
|
|
||||||
|
namespace aux {
|
||||||
|
|
||||||
|
TORRENT_EXTRA_EXPORT
|
||||||
|
std::string identify_client_impl(const peer_id& p);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// these functions don't really need to be public. This mechanism of
|
// these functions don't really need to be public. This mechanism of
|
||||||
// advertising client software and version is also out-dated.
|
// advertising client software and version is also out-dated.
|
||||||
|
|
||||||
// This function can can be used to extract a string describing a client
|
// This function can can be used to extract a string describing a client
|
||||||
// version from its peer-id. It will recognize most clients that have this
|
// version from its peer-id. It will recognize most clients that have this
|
||||||
// kind of identification in the peer-id.
|
// kind of identification in the peer-id.
|
||||||
TORRENT_DEPRECATED_EXPORT TORRENT_DEPRECATED
|
TORRENT_DEPRECATED_EXPORT
|
||||||
std::string identify_client(const peer_id& p);
|
std::string identify_client(const peer_id& p);
|
||||||
|
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
|
|
|
@ -128,7 +128,7 @@ TORRENT_TEST(dht_bootstrap)
|
||||||
else if (lt::session_stats_alert const* sa = lt::alert_cast<lt::session_stats_alert>(a))
|
else if (lt::session_stats_alert const* sa = lt::alert_cast<lt::session_stats_alert>(a))
|
||||||
{
|
{
|
||||||
int const dht_nodes = lt::find_metric_idx("dht.nodes");
|
int const dht_nodes = lt::find_metric_idx("dht.nodes");
|
||||||
TEST_CHECK(sa->values[dht_nodes] > 2);
|
TEST_CHECK(sa->counters()[dht_nodes] > 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// terminate?
|
// terminate?
|
||||||
|
|
|
@ -133,8 +133,8 @@ TORRENT_TEST(session_stats)
|
||||||
if (!ss) return;
|
if (!ss) return;
|
||||||
|
|
||||||
// there's one downloading torrent
|
// there's one downloading torrent
|
||||||
TEST_EQUAL(ss->values[downloading_idx], 1);
|
TEST_EQUAL(ss->counters()[downloading_idx], 1);
|
||||||
TEST_EQUAL(ss->values[incoming_extended_idx], 1);
|
TEST_EQUAL(ss->counters()[incoming_extended_idx], 1);
|
||||||
}
|
}
|
||||||
// terminate
|
// terminate
|
||||||
, [](int const ticks, lt::session& ses) -> bool
|
, [](int const ticks, lt::session& ses) -> bool
|
||||||
|
|
|
@ -89,8 +89,8 @@ int get_cache_size(lt::session& ses)
|
||||||
{
|
{
|
||||||
if (auto const* st = alert_cast<session_stats_alert>(a))
|
if (auto const* st = alert_cast<session_stats_alert>(a))
|
||||||
{
|
{
|
||||||
cache_size = st->values[read_cache_idx];
|
cache_size = st->counters()[read_cache_idx];
|
||||||
cache_size += st->values[write_cache_idx];
|
cache_size += st->counters()[write_cache_idx];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,7 +113,7 @@ namespace libtorrent {
|
||||||
std::string peer_alert::message() const
|
std::string peer_alert::message() const
|
||||||
{
|
{
|
||||||
return torrent_alert::message() + " peer (" + print_endpoint(endpoint)
|
return torrent_alert::message() + " peer (" + print_endpoint(endpoint)
|
||||||
+ ", " + identify_client(pid) + ")";
|
+ ", " + aux::identify_client_impl(pid) + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
tracker_alert::tracker_alert(aux::stack_allocator& alloc
|
tracker_alert::tracker_alert(aux::stack_allocator& alloc
|
||||||
|
|
|
@ -367,6 +367,13 @@ namespace libtorrent {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::string identify_client(peer_id const& p)
|
std::string identify_client(peer_id const& p)
|
||||||
|
{
|
||||||
|
return aux::identify_client_impl(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace aux {
|
||||||
|
|
||||||
|
std::string identify_client_impl(peer_id const& p)
|
||||||
{
|
{
|
||||||
char const* PID = p.data();
|
char const* PID = p.data();
|
||||||
|
|
||||||
|
@ -424,5 +431,7 @@ namespace libtorrent {
|
||||||
unknown += "]";
|
unknown += "]";
|
||||||
return unknown;
|
return unknown;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
} // aux
|
||||||
|
} // libtorrent
|
||||||
|
|
||||||
|
|
|
@ -37,14 +37,12 @@ using namespace lt;
|
||||||
|
|
||||||
TORRENT_TEST(identify_client)
|
TORRENT_TEST(identify_client)
|
||||||
{
|
{
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
TEST_EQUAL(aux::identify_client_impl(peer_id("-AZ123B-............")), "Azureus 1.2.3.11");
|
||||||
TEST_EQUAL(identify_client(peer_id("-AZ123B-............")), "Azureus 1.2.3.11");
|
TEST_EQUAL(aux::identify_client_impl(peer_id("-AZ1230-............")), "Azureus 1.2.3");
|
||||||
TEST_EQUAL(identify_client(peer_id("-AZ1230-............")), "Azureus 1.2.3");
|
TEST_EQUAL(aux::identify_client_impl(peer_id("S123--..............")), "Shadow 1.2.3");
|
||||||
TEST_EQUAL(identify_client(peer_id("S123--..............")), "Shadow 1.2.3");
|
TEST_EQUAL(aux::identify_client_impl(peer_id("S\x1\x2\x3....\0...........")), "Shadow 1.2.3");
|
||||||
TEST_EQUAL(identify_client(peer_id("S\x1\x2\x3....\0...........")), "Shadow 1.2.3");
|
TEST_EQUAL(aux::identify_client_impl(peer_id("M1-2-3--............")), "Mainline 1.2.3");
|
||||||
TEST_EQUAL(identify_client(peer_id("M1-2-3--............")), "Mainline 1.2.3");
|
TEST_EQUAL(aux::identify_client_impl(peer_id("\0\0\0\0\0\0\0\0\0\0\0\0........")), "Generic");
|
||||||
TEST_EQUAL(identify_client(peer_id("\0\0\0\0\0\0\0\0\0\0\0\0........")), "Generic");
|
TEST_EQUAL(aux::identify_client_impl(peer_id("-xx1230-............")), "xx 1.2.3");
|
||||||
TEST_EQUAL(identify_client(peer_id("-xx1230-............")), "xx 1.2.3");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue