fix build with IPv6 disabled
This commit is contained in:
parent
20d4279177
commit
de3a5784be
|
@ -98,14 +98,16 @@ struct static_ { static_() { std::srand(std::time(0)); } } static__;
|
|||
|
||||
void hash_address(address const& ip, sha1_hash& h)
|
||||
{
|
||||
if (ip.is_v4())
|
||||
#if TORRENT_USE_IPV6
|
||||
if (ip.is_v6())
|
||||
{
|
||||
address_v4::bytes_type b = ip.to_v4().to_bytes();
|
||||
address_v6::bytes_type b = ip.to_v6().to_bytes();
|
||||
h = hasher((char*)&b[0], b.size()).final();
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
address_v6::bytes_type b = ip.to_v6().to_bytes();
|
||||
address_v4::bytes_type b = ip.to_v4().to_bytes();
|
||||
h = hasher((char*)&b[0], b.size()).final();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -348,6 +348,7 @@ bool rpc_manager::incoming(msg const& m, node_id* id)
|
|||
memcpy(&b[0], ext_ip->string_ptr(), 4);
|
||||
m_ses.set_external_address(address_v4(b));
|
||||
}
|
||||
#if TORRENT_USE_IPV6
|
||||
else if (ext_ip && ext_ip->string_length() == 16)
|
||||
{
|
||||
// this node claims we use the wrong node-ID!
|
||||
|
@ -355,6 +356,7 @@ bool rpc_manager::incoming(msg const& m, node_id* id)
|
|||
memcpy(&b[0], ext_ip->string_ptr(), 16);
|
||||
m_ses.set_external_address(address_v6(b));
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef TORRENT_DHT_VERBOSE_LOGGING
|
||||
TORRENT_LOG(rpc) << "[" << o->m_algorithm.get() << "] Reply with transaction id: "
|
||||
|
|
|
@ -49,14 +49,16 @@ namespace libtorrent
|
|||
|
||||
std::string address_to_bytes(address const& a)
|
||||
{
|
||||
if (a.is_v4())
|
||||
#if TORRENT_USE_IPV6
|
||||
if (a.is_v6())
|
||||
{
|
||||
address_v4::bytes_type b = a.to_v4().to_bytes();
|
||||
address_v6::bytes_type b = a.to_v6().to_bytes();
|
||||
return std::string((char*)&b[0], b.size());
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
address_v6::bytes_type b = a.to_v6().to_bytes();
|
||||
address_v4::bytes_type b = a.to_v4().to_bytes();
|
||||
return std::string((char*)&b[0], b.size());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue