forked from premiere/premiere-libtorrent
fixed two bugs related to http proxy requests and ports
This commit is contained in:
parent
beee914277
commit
aaf6f0f19a
|
@ -100,29 +100,31 @@ namespace libtorrent
|
||||||
, m_code(0)
|
, m_code(0)
|
||||||
{
|
{
|
||||||
const std::string* connect_to_host;
|
const std::string* connect_to_host;
|
||||||
|
int connect_to_port = port;
|
||||||
bool using_proxy = false;
|
bool using_proxy = false;
|
||||||
|
|
||||||
|
m_send_buffer.assign("GET ");
|
||||||
|
|
||||||
// should we use the proxy?
|
// should we use the proxy?
|
||||||
if (!m_settings.proxy_ip.empty())
|
if (!m_settings.proxy_ip.empty())
|
||||||
{
|
{
|
||||||
connect_to_host = &m_settings.proxy_ip;
|
connect_to_host = &m_settings.proxy_ip;
|
||||||
if (m_settings.proxy_port != 0) port = m_settings.proxy_port;
|
|
||||||
using_proxy = true;
|
using_proxy = true;
|
||||||
|
m_send_buffer += "http://";
|
||||||
|
m_send_buffer += hostname;
|
||||||
|
if (port != 80)
|
||||||
|
{
|
||||||
|
m_send_buffer += ":";
|
||||||
|
m_send_buffer += boost::lexical_cast<std::string>(port);
|
||||||
|
}
|
||||||
|
connect_to_port = m_settings.proxy_port != 0
|
||||||
|
? m_settings.proxy_port : 80 ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
connect_to_host = &hostname;
|
connect_to_host = &hostname;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_send_buffer.assign("GET ");
|
|
||||||
if (using_proxy)
|
|
||||||
{
|
|
||||||
m_send_buffer += "http://";
|
|
||||||
m_send_buffer += hostname;
|
|
||||||
if (port != 80)
|
|
||||||
m_send_buffer += boost::lexical_cast<std::string>(port);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_req.kind == tracker_request::scrape_request)
|
if (m_req.kind == tracker_request::scrape_request)
|
||||||
{
|
{
|
||||||
// find and replace "announce" with "scrape"
|
// find and replace "announce" with "scrape"
|
||||||
|
@ -219,7 +221,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_name_lookup = dns_lookup(connect_to_host->c_str(), port);
|
m_name_lookup = dns_lookup(connect_to_host->c_str(), connect_to_port);
|
||||||
m_socket.reset(new socket(socket::tcp, false));
|
m_socket.reset(new socket(socket::tcp, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue