Better api for peers() method in dht_get_peers_reply_alert (#628)
This commit is contained in:
parent
bd6efe1179
commit
0fddd403b2
|
@ -198,8 +198,7 @@ list dht_get_peers_reply_alert_peers(dht_get_peers_reply_alert const& a)
|
|||
{
|
||||
list result;
|
||||
|
||||
std::vector<tcp::endpoint> v;
|
||||
a.peers(v);
|
||||
std::vector<tcp::endpoint> v(a.peers());
|
||||
|
||||
for (std::vector<tcp::endpoint>::const_iterator i = v.begin();
|
||||
i != v.end(); ++i)
|
||||
|
|
|
@ -2403,7 +2403,12 @@ namespace libtorrent
|
|||
sha1_hash info_hash;
|
||||
|
||||
int num_peers() const;
|
||||
void peers(std::vector<tcp::endpoint>& peers) const;
|
||||
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
TORRENT_DEPRECATED
|
||||
void peers(std::vector<tcp::endpoint>& v) const;
|
||||
#endif
|
||||
std::vector<tcp::endpoint> peers() const;
|
||||
|
||||
private:
|
||||
aux::stack_allocator& m_alloc;
|
||||
|
|
|
@ -63,7 +63,7 @@ namespace aux {
|
|||
// set to authenticate with the proxy.
|
||||
std::string hostname;
|
||||
|
||||
// when using a proy type that requires authentication, the username
|
||||
// when using a proxy type that requires authentication, the username
|
||||
// and password fields must be set to the credentials for the proxy.
|
||||
std::string username;
|
||||
std::string password;
|
||||
|
@ -128,7 +128,7 @@ namespace aux {
|
|||
// This is only supported by SOCKS5 and HTTP.
|
||||
bool proxy_hostnames;
|
||||
|
||||
// determines whether or not to excempt peer and web seed connections
|
||||
// determines whether or not to exempt peer and web seed connections
|
||||
// from using the proxy. This defaults to true, i.e. peer connections are
|
||||
// proxied by default.
|
||||
bool proxy_peer_connections;
|
||||
|
|
|
@ -1918,17 +1918,24 @@ namespace libtorrent {
|
|||
return m_num_peers;
|
||||
}
|
||||
|
||||
void dht_get_peers_reply_alert::peers(std::vector<tcp::endpoint>& peers) const
|
||||
{
|
||||
peers.resize(m_num_peers);
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
void dht_get_peers_reply_alert::peers(std::vector<tcp::endpoint> &v) const {
|
||||
std::vector<tcp::endpoint> p(peers());
|
||||
v.reserve(p.size());
|
||||
std::copy(p.begin(), p.end(), std::back_inserter(v));
|
||||
}
|
||||
#endif
|
||||
std::vector<tcp::endpoint> dht_get_peers_reply_alert::peers() const {
|
||||
std::vector<tcp::endpoint> peers(m_num_peers);
|
||||
|
||||
const char *ptr = m_alloc.ptr(m_peers_idx);
|
||||
for (int i = 0; i < m_num_peers; i++) {
|
||||
|
||||
std::size_t size = detail::read_uint8(ptr);
|
||||
memcpy(peers[i].data(), ptr, size);
|
||||
ptr += size;
|
||||
}
|
||||
|
||||
return peers;
|
||||
}
|
||||
|
||||
dht_direct_response_alert::dht_direct_response_alert(
|
||||
|
|
Loading…
Reference in New Issue