Skip to content

Commit f3d319b

Browse files
committed
fix internal use of deprecated function identify_client
1 parent fc0cbfb commit f3d319b

File tree

7 files changed

+31
-17
lines changed

7 files changed

+31
-17
lines changed

include/libtorrent/identify_client.hpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,20 @@ POSSIBILITY OF SUCH DAMAGE.
4848
// remove its internal use
4949
namespace libtorrent {
5050

51+
namespace aux {
52+
53+
TORRENT_EXTRA_EXPORT
54+
std::string identify_client_impl(const peer_id& p);
55+
56+
}
57+
5158
// these functions don't really need to be public. This mechanism of
5259
// advertising client software and version is also out-dated.
5360

5461
// This function can can be used to extract a string describing a client
5562
// version from its peer-id. It will recognize most clients that have this
5663
// kind of identification in the peer-id.
57-
TORRENT_DEPRECATED_EXPORT TORRENT_DEPRECATED
64+
TORRENT_DEPRECATED_EXPORT
5865
std::string identify_client(const peer_id& p);
5966

6067
#ifndef TORRENT_NO_DEPRECATE

simulation/test_dht.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ TORRENT_TEST(dht_bootstrap)
128128
else if (lt::session_stats_alert const* sa = lt::alert_cast<lt::session_stats_alert>(a))
129129
{
130130
int const dht_nodes = lt::find_metric_idx("dht.nodes");
131-
TEST_CHECK(sa->values[dht_nodes] > 2);
131+
TEST_CHECK(sa->counters()[dht_nodes] > 2);
132132
}
133133
}
134134
// terminate?

simulation/test_swarm.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ TORRENT_TEST(session_stats)
133133
if (!ss) return;
134134

135135
// there's one downloading torrent
136-
TEST_EQUAL(ss->values[downloading_idx], 1);
137-
TEST_EQUAL(ss->values[incoming_extended_idx], 1);
136+
TEST_EQUAL(ss->counters()[downloading_idx], 1);
137+
TEST_EQUAL(ss->counters()[incoming_extended_idx], 1);
138138
}
139139
// terminate
140140
, [](int const ticks, lt::session& ses) -> bool

simulation/utils.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ int get_cache_size(lt::session& ses)
8989
{
9090
if (auto const* st = alert_cast<session_stats_alert>(a))
9191
{
92-
cache_size = st->values[read_cache_idx];
93-
cache_size += st->values[write_cache_idx];
92+
cache_size = st->counters()[read_cache_idx];
93+
cache_size += st->counters()[write_cache_idx];
9494
break;
9595
}
9696
}

src/alert.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ namespace libtorrent {
113113
std::string peer_alert::message() const
114114
{
115115
return torrent_alert::message() + " peer (" + print_endpoint(endpoint)
116-
+ ", " + identify_client(pid) + ")";
116+
+ ", " + aux::identify_client_impl(pid) + ")";
117117
}
118118

119119
tracker_alert::tracker_alert(aux::stack_allocator& alloc

src/identify_client.cpp

+10-1
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,13 @@ namespace libtorrent {
367367
#endif
368368

369369
std::string identify_client(peer_id const& p)
370+
{
371+
return aux::identify_client_impl(p);
372+
}
373+
374+
namespace aux {
375+
376+
std::string identify_client_impl(peer_id const& p)
370377
{
371378
char const* PID = p.data();
372379

@@ -424,5 +431,7 @@ namespace libtorrent {
424431
unknown += "]";
425432
return unknown;
426433
}
427-
}
434+
435+
} // aux
436+
} // libtorrent
428437

test/test_identify_client.cpp

+7-9
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,12 @@ using namespace lt;
3737

3838
TORRENT_TEST(identify_client)
3939
{
40-
#ifndef TORRENT_NO_DEPRECATE
41-
TEST_EQUAL(identify_client(peer_id("-AZ123B-............")), "Azureus 1.2.3.11");
42-
TEST_EQUAL(identify_client(peer_id("-AZ1230-............")), "Azureus 1.2.3");
43-
TEST_EQUAL(identify_client(peer_id("S123--..............")), "Shadow 1.2.3");
44-
TEST_EQUAL(identify_client(peer_id("S\x1\x2\x3....\0...........")), "Shadow 1.2.3");
45-
TEST_EQUAL(identify_client(peer_id("M1-2-3--............")), "Mainline 1.2.3");
46-
TEST_EQUAL(identify_client(peer_id("\0\0\0\0\0\0\0\0\0\0\0\0........")), "Generic");
47-
TEST_EQUAL(identify_client(peer_id("-xx1230-............")), "xx 1.2.3");
48-
#endif
40+
TEST_EQUAL(aux::identify_client_impl(peer_id("-AZ123B-............")), "Azureus 1.2.3.11");
41+
TEST_EQUAL(aux::identify_client_impl(peer_id("-AZ1230-............")), "Azureus 1.2.3");
42+
TEST_EQUAL(aux::identify_client_impl(peer_id("S123--..............")), "Shadow 1.2.3");
43+
TEST_EQUAL(aux::identify_client_impl(peer_id("S\x1\x2\x3....\0...........")), "Shadow 1.2.3");
44+
TEST_EQUAL(aux::identify_client_impl(peer_id("M1-2-3--............")), "Mainline 1.2.3");
45+
TEST_EQUAL(aux::identify_client_impl(peer_id("\0\0\0\0\0\0\0\0\0\0\0\0........")), "Generic");
46+
TEST_EQUAL(aux::identify_client_impl(peer_id("-xx1230-............")), "xx 1.2.3");
4947
}
5048

0 commit comments

Comments
 (0)