diff --git a/src/http_tracker_connection.cpp b/src/http_tracker_connection.cpp index 2ac1d4f95..64367a9cb 100644 --- a/src/http_tracker_connection.cpp +++ b/src/http_tracker_connection.cpp @@ -115,7 +115,7 @@ namespace libtorrent url += "?"; url += "info_hash="; - url += escape_string((const char*)&tracker_req().info_hash[0], 20); + url += escape_string(tracker_req().info_hash.data(), 20); if (0 == (tracker_req().kind & tracker_request::scrape_request)) { @@ -135,7 +135,7 @@ namespace libtorrent "&numwant=%d" "&compact=1" "&no_peer_id=1" - , escape_string((const char*)&tracker_req().pid[0], 20).c_str() + , escape_string(tracker_req().pid.data(), 20).c_str() // the i2p tracker seems to verify that the port is not 0, // even though it ignores it otherwise , i2p ? 1 : tracker_req().listen_port @@ -169,9 +169,14 @@ namespace libtorrent if (i2p && tracker_req().i2pconn) { if (tracker_req().i2pconn->local_endpoint().empty()) + { fail(error_code(errors::no_i2p_endpoint), -1, "Waiting for i2p acceptor from SAM bridge", 5); + return; + } else + { url += "&ip=" + tracker_req ().i2pconn->local_endpoint () + ".i2p"; + } } else #endif @@ -363,9 +368,9 @@ namespace libtorrent std::list
ip_list; if (m_tracker_connection) { - error_code ec; + error_code ignore; ip_list.push_back( - m_tracker_connection->socket().remote_endpoint(ec).address()); + m_tracker_connection->socket().remote_endpoint(ignore).address()); std::vector const& epts = m_tracker_connection->endpoints(); for (std::vector::const_iterator i = epts.begin() , end(epts.end()); i != end; ++i) @@ -416,7 +421,7 @@ namespace libtorrent ec.assign(errors::invalid_tracker_response, get_libtorrent_category()); return false; } - ret.port = (unsigned short)i.int_value(); + ret.port = boost::uint16_t(i.int_value()); return true; } @@ -521,7 +526,6 @@ namespace libtorrent if (len - i < 6) break; ipv4_peer_entry p; - error_code ec; p.ip = detail::read_v4_address(peers).to_v4().to_bytes(); p.port = detail::read_uint16(peers); resp.peers4.push_back(p); diff --git a/test/test_tracker.cpp b/test/test_tracker.cpp index cc1f23115..4a59032a3 100644 --- a/test/test_tracker.cpp +++ b/test/test_tracker.cpp @@ -104,7 +104,7 @@ TORRENT_TEST(parse_peers4) TORRENT_TEST(parse_i2p_peers) { // d8:completei8e10:incompletei4e8:intervali3600e5:peers352: ... - char const response[] = { 0x64, 0x38, 0x3a, 0x63, 0x6f, 0x6d, + boost::uint8_t const response[] = { 0x64, 0x38, 0x3a, 0x63, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x69, 0x38, 0x65, 0x31, 0x30, 0x3a, 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x69, 0x34, 0x65, 0x38, 0x3a, 0x69, 0x6e, 0x74, 0x65, @@ -147,7 +147,8 @@ TORRENT_TEST(parse_i2p_peers) 0xc2, 0x8a, 0x22, 0x6b, 0x47, 0xc1, 0xd1, 0x52, 0x61, 0x66, 0xa0, 0x75, 0xab, 0x65 }; error_code ec; - tracker_response resp = parse_tracker_response(response, sizeof(response) + tracker_response resp = parse_tracker_response( + reinterpret_cast(response), sizeof(response) , ec, tracker_request::i2p, sha1_hash()); TEST_EQUAL(ec, error_code()); @@ -156,7 +157,6 @@ TORRENT_TEST(parse_i2p_peers) if (resp.peers.size() == 11) { TEST_EQUAL(resp.peers[0].hostname, "wgcobfq73pzmtmcttiy2knon5bm2a7gn6j6idaiccf53ikwrecdq.b32.i2p"); -// TEST_EQUAL(resp.peers[9].hostname, "cbmvhhhgdmxha4toqj5qhphse2n3henk6g5geev3orfxardudgza.b32.i2p"); TEST_EQUAL(resp.peers[10].hostname, "ufunemgwuun5t2sn3oay4zv7jvwdezwcrirgwr6b2fjgczvaowvq.b32.i2p"); } }