fixed bug where tracker authentication was not sent to the tracker

This commit is contained in:
Arvid Norberg 2005-02-23 09:13:42 +00:00
parent 5c5aabe7b1
commit d32f0ba755
4 changed files with 20 additions and 15 deletions

View File

@ -149,10 +149,9 @@ namespace libtorrent
void tick(); void tick();
void queue_request( void queue_request(
tracker_request r tracker_request r
, std::string const& auth
, boost::weak_ptr<request_callback> c , boost::weak_ptr<request_callback> c
= boost::weak_ptr<request_callback>() = boost::weak_ptr<request_callback>());
, std::string const& password = "");
// void abort_request(request_callback* c);
void abort_all_requests(); void abort_all_requests();
bool send_finished() const; bool send_finished() const;

View File

@ -85,7 +85,7 @@ namespace libtorrent
, std::string const& request , std::string const& request
, boost::weak_ptr<request_callback> c , boost::weak_ptr<request_callback> c
, const http_settings& stn , const http_settings& stn
, std::string const& password) , std::string const& auth)
: tracker_connection(c) : tracker_connection(c)
, m_man(man) , m_man(man)
, m_state(read_status) , m_state(read_status)
@ -95,7 +95,7 @@ namespace libtorrent
, m_request_time(second_clock::universal_time()) , m_request_time(second_clock::universal_time())
, m_settings(stn) , m_settings(stn)
, m_req(req) , m_req(req)
, m_password(password) , m_password(auth)
, m_code(0) , m_code(0)
{ {
const std::string* connect_to_host; const std::string* connect_to_host;
@ -186,10 +186,10 @@ namespace libtorrent
m_send_buffer += "\r\nProxy-Authorization: Basic "; m_send_buffer += "\r\nProxy-Authorization: Basic ";
m_send_buffer += base64encode(m_settings.proxy_login + ":" + m_settings.proxy_password); m_send_buffer += base64encode(m_settings.proxy_login + ":" + m_settings.proxy_password);
} }
if (password != "") if (auth != "")
{ {
m_send_buffer += "\r\nAuthorization: Basic "; m_send_buffer += "\r\nAuthorization: Basic ";
m_send_buffer += base64encode(password); m_send_buffer += base64encode(auth);
} }
m_send_buffer += "\r\n\r\n"; m_send_buffer += "\r\n\r\n";
#ifndef NDEBUG #ifndef NDEBUG
@ -451,7 +451,7 @@ namespace libtorrent
else else
m_req.url.assign(m_location.begin(), m_location.begin() + i); m_req.url.assign(m_location.begin(), m_location.begin() + i);
m_man.queue_request(m_req, m_requester, m_password); m_man.queue_request(m_req, m_password, m_requester);
return true; return true;
} }
} }

View File

@ -82,6 +82,13 @@ using namespace boost::posix_time;
namespace libtorrent { namespace detail namespace libtorrent { namespace detail
{ {
std::string generate_auth_string(std::string const& user
, std::string const& passwd)
{
if (user.empty()) return std::string();
return user + ":" + passwd;
}
// This is the checker thread // This is the checker thread
// it is looping in an infinite loop // it is looping in an infinite loop
// until the session is aborted. It will // until the session is aborted. It will
@ -408,7 +415,7 @@ namespace libtorrent { namespace detail
tracker_request req = i->second->generate_tracker_request(); tracker_request req = i->second->generate_tracker_request();
req.listen_port = m_listen_interface.port; req.listen_port = m_listen_interface.port;
req.key = m_key; req.key = m_key;
m_tracker_manager.queue_request(req); m_tracker_manager.queue_request(req, i->second->tracker_login());
} }
m_connections.clear(); m_connections.clear();
m_torrents.clear(); m_torrents.clear();
@ -682,7 +689,7 @@ namespace libtorrent { namespace detail
assert(req.event == tracker_request::stopped); assert(req.event == tracker_request::stopped);
req.listen_port = m_listen_interface.port; req.listen_port = m_listen_interface.port;
req.key = m_key; req.key = m_key;
m_tracker_manager.queue_request(req); m_tracker_manager.queue_request(req, t.tracker_login());
t.disconnect_all(); t.disconnect_all();
purge_connections(); purge_connections();
#ifndef NDEBUG #ifndef NDEBUG
@ -697,8 +704,7 @@ namespace libtorrent { namespace detail
tracker_request req = t.generate_tracker_request(); tracker_request req = t.generate_tracker_request();
req.listen_port = m_listen_interface.port; req.listen_port = m_listen_interface.port;
req.key = m_key; req.key = m_key;
m_tracker_manager.queue_request( m_tracker_manager.queue_request(req, t.tracker_login(), i->second);
req, i->second);
} }
// tick() will set the used upload quota // tick() will set the used upload quota

View File

@ -359,8 +359,8 @@ namespace libtorrent
void tracker_manager::queue_request( void tracker_manager::queue_request(
tracker_request req tracker_request req
, boost::weak_ptr<request_callback> c , std::string const& auth
, std::string const& password) , boost::weak_ptr<request_callback> c)
{ {
assert(req.num_want >= 0); assert(req.num_want >= 0);
if (req.event == tracker_request::stopped) if (req.event == tracker_request::stopped)
@ -425,7 +425,7 @@ namespace libtorrent
, request_string , request_string
, c , c
, m_settings , m_settings
, password)); , auth));
} }
else if (protocol == "udp") else if (protocol == "udp")
{ {