Don't attempt to resolve base64 destination for i2p tracker

This commit is contained in:
Mikhail Titov 2015-06-27 17:03:03 -05:00
parent 020f0816df
commit 70a99e6f62
2 changed files with 25 additions and 15 deletions

View File

@ -132,6 +132,7 @@ struct TORRENT_EXTRA_EXPORT http_connection
private: private:
#if TORRENT_USE_I2P #if TORRENT_USE_I2P
void connect_i2p_tracker(char const* destination);
void on_i2p_resolve(error_code const& e void on_i2p_resolve(error_code const& e
, char const* destination); , char const* destination);
#endif #endif

View File

@ -370,11 +370,16 @@ void http_connection::start(std::string const& hostname, int port
#if TORRENT_USE_I2P #if TORRENT_USE_I2P
if (is_i2p) if (is_i2p)
{ {
if (hostname.length() < 516) // Base64 encoded destination with optional .i2p
{
#if defined TORRENT_ASIO_DEBUGGING #if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("http_connection::on_i2p_resolve"); add_outstanding_async("http_connection::on_i2p_resolve");
#endif #endif
i2p_conn->async_name_lookup(hostname.c_str(), boost::bind(&http_connection::on_i2p_resolve i2p_conn->async_name_lookup(hostname.c_str(), boost::bind(&http_connection::on_i2p_resolve
, me, _1, _2)); , me, _1, _2));
}
else
connect_i2p_tracker(hostname.c_str());
} }
else else
#endif #endif
@ -471,19 +476,8 @@ void http_connection::close(bool force)
} }
#if TORRENT_USE_I2P #if TORRENT_USE_I2P
void http_connection::on_i2p_resolve(error_code const& e void http_connection::connect_i2p_tracker(char const* destination)
, char const* destination)
{ {
#if defined TORRENT_ASIO_DEBUGGING
complete_async("http_connection::on_i2p_resolve");
#endif
if (e)
{
callback(e);
close();
return;
}
#ifdef TORRENT_USE_OPENSSL #ifdef TORRENT_USE_OPENSSL
TORRENT_ASSERT(m_ssl == false); TORRENT_ASSERT(m_ssl == false);
TORRENT_ASSERT(m_sock.get<socket_type>()); TORRENT_ASSERT(m_sock.get<socket_type>());
@ -502,6 +496,21 @@ void http_connection::on_i2p_resolve(error_code const& e
m_sock.async_connect(tcp::endpoint(), boost::bind(&http_connection::on_connect m_sock.async_connect(tcp::endpoint(), boost::bind(&http_connection::on_connect
, shared_from_this(), _1)); , shared_from_this(), _1));
} }
void http_connection::on_i2p_resolve(error_code const& e
, char const* destination)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("http_connection::on_i2p_resolve");
#endif
if (e)
{
callback(e);
close();
return;
}
connect_i2p_tracker(destination);
}
#endif #endif
void http_connection::on_resolve(error_code const& e void http_connection::on_resolve(error_code const& e