diff --git a/libtorrent/include/libtorrent/kademlia/routing_table.hpp b/libtorrent/include/libtorrent/kademlia/routing_table.hpp index e3f2e7ded..c037199c1 100644 --- a/libtorrent/include/libtorrent/kademlia/routing_table.hpp +++ b/libtorrent/include/libtorrent/kademlia/routing_table.hpp @@ -104,9 +104,9 @@ namespace aux , bucket_iterator_t end) : m_bucket_iterator(begin) , m_bucket_end(end) - , m_iterator(begin != end ? begin->first.begin() : bucket_t::const_iterator()) { if (m_bucket_iterator == m_bucket_end) return; + m_iterator = begin->first.begin(); while (m_iterator == m_bucket_iterator->first.end()) { if (++m_bucket_iterator == m_bucket_end) @@ -119,14 +119,14 @@ namespace aux { return m_bucket_iterator == other.m_bucket_iterator && (m_bucket_iterator == m_bucket_end - || m_iterator == other.m_iterator); + || *m_iterator == other.m_iterator); } void increment() { TORRENT_ASSERT(m_bucket_iterator != m_bucket_end); - ++m_iterator; - while (m_iterator == m_bucket_iterator->first.end()) + ++*m_iterator; + while (*m_iterator == m_bucket_iterator->first.end()) { if (++m_bucket_iterator == m_bucket_end) break; @@ -137,12 +137,16 @@ namespace aux node_entry const& dereference() const { TORRENT_ASSERT(m_bucket_iterator != m_bucket_end); - return *m_iterator; + return **m_iterator; } bucket_iterator_t m_bucket_iterator; bucket_iterator_t m_bucket_end; - bucket_t::const_iterator m_iterator; + // when debug iterators are enabled, default constructed + // iterators are not allowed to be copied. In the case + // where the routing table is empty, m_iterator would be + // default constructed and not copyable. + boost::optional m_iterator; }; } // namespace aux diff --git a/libtorrent/src/broadcast_socket.cpp b/libtorrent/src/broadcast_socket.cpp index cfb1a9f1a..d9fd2470f 100644 --- a/libtorrent/src/broadcast_socket.cpp +++ b/libtorrent/src/broadcast_socket.cpp @@ -79,6 +79,8 @@ namespace libtorrent { if (addr.is_v4()) return addr.to_v4() == address_v4::any(); + else if (addr.to_v6().is_v4_mapped()) + return (addr.to_v6().to_v4() == address_v4::any()); else return addr.to_v6() == address_v6::any(); } diff --git a/libtorrent/src/bt_peer_connection.cpp b/libtorrent/src/bt_peer_connection.cpp index 9d1b7f9e5..c96b8ba33 100755 --- a/libtorrent/src/bt_peer_connection.cpp +++ b/libtorrent/src/bt_peer_connection.cpp @@ -1314,7 +1314,11 @@ namespace libtorrent { address_v6::bytes_type bytes; std::copy(myip.begin(), myip.end(), bytes.begin()); - m_ses.set_external_address(address_v6(bytes)); + address_v6 ipv6_address(bytes); + if (ipv6_address.is_v4_mapped()) + m_ses.set_external_address(ipv6_address.to_v4()); + else + m_ses.set_external_address(ipv6_address); } } @@ -1567,7 +1571,7 @@ namespace libtorrent if (t->is_finished()) handshake["upload_only"] = 1; tcp::endpoint ep = m_ses.get_ipv6_interface(); - if (ep != tcp::endpoint()) + if (!is_any(ep.address())) { std::string ipv6_address; std::back_insert_iterator out(ipv6_address); @@ -2635,6 +2639,8 @@ namespace libtorrent TORRENT_ASSERT(!m_rc4_encrypted || m_RC4_handler.get()); #endif + if (is_seed()) TORRENT_ASSERT(upload_only()); + if (!in_handshake()) { TORRENT_ASSERT(m_sent_handshake); diff --git a/libtorrent/src/http_tracker_connection.cpp b/libtorrent/src/http_tracker_connection.cpp index f83163bd2..f3a647fa8 100755 --- a/libtorrent/src/http_tracker_connection.cpp +++ b/libtorrent/src/http_tracker_connection.cpp @@ -236,7 +236,7 @@ namespace libtorrent entry e; e = bdecode(data, data + size); - if (e.type() != entry::undefined_t) + if (e.type() == entry::dictionary_t) { parse(parser.status_code(), e); } diff --git a/libtorrent/src/peer_connection.cpp b/libtorrent/src/peer_connection.cpp index 46cea6184..778f81d87 100755 --- a/libtorrent/src/peer_connection.cpp +++ b/libtorrent/src/peer_connection.cpp @@ -519,6 +519,7 @@ namespace libtorrent #endif // if this is a web seed. we don't have a peer_info struct if (m_peer_info) m_peer_info->seed = true; + m_upload_only = true; t->peer_has_all(); if (t->is_finished()) send_not_interested(); diff --git a/libtorrent/src/storage.cpp b/libtorrent/src/storage.cpp index 208c9d3c4..dd6e82201 100755 --- a/libtorrent/src/storage.cpp +++ b/libtorrent/src/storage.cpp @@ -770,8 +770,7 @@ namespace libtorrent seed = true; for (int i = 0; i < slots->list_size(); ++i) { - lazy_entry const* e = slots->list_at(i); - if (e->list_int_value_at(i, -1) >= 0) continue; + if (slots->list_int_value_at(i, -1) >= 0) continue; seed = false; break; }