*** empty log message ***
This commit is contained in:
parent
a997a43d30
commit
1fbb33f6d2
|
@ -62,6 +62,8 @@ namespace libtorrent
|
||||||
struct request_callback;
|
struct request_callback;
|
||||||
class tracker_manager;
|
class tracker_manager;
|
||||||
|
|
||||||
|
address parse_url(std::string const& url);
|
||||||
|
|
||||||
// encodes a string using the base64 scheme
|
// encodes a string using the base64 scheme
|
||||||
std::string base64encode(const std::string& s);
|
std::string base64encode(const std::string& s);
|
||||||
|
|
||||||
|
|
|
@ -558,13 +558,16 @@ namespace libtorrent { namespace detail
|
||||||
++i)
|
++i)
|
||||||
{
|
{
|
||||||
connection_map::iterator p = m_connections.find(*i);
|
connection_map::iterator p = m_connections.find(*i);
|
||||||
if (m_alerts.should_post(alert::debug))
|
if (p != m_connections.end())
|
||||||
{
|
{
|
||||||
m_alerts.post_alert(
|
if (m_alerts.should_post(alert::debug))
|
||||||
peer_error_alert(
|
{
|
||||||
p->first->sender()
|
m_alerts.post_alert(
|
||||||
, p->second->id()
|
peer_error_alert(
|
||||||
, "connection closed"));
|
p->first->sender()
|
||||||
|
, p->second->id()
|
||||||
|
, "connection closed"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_selector.remove(*i);
|
m_selector.remove(*i);
|
||||||
|
|
|
@ -369,11 +369,11 @@ namespace libtorrent
|
||||||
|
|
||||||
if (m_files.size() == 1)
|
if (m_files.size() == 1)
|
||||||
{
|
{
|
||||||
info["name"] = m_files.front().path.string();
|
info["name"] = m_name;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
info["name"] = m_files.front().path.root_name();
|
info["name"] = m_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_files.size() > 1)
|
if (m_files.size() > 1)
|
||||||
|
|
|
@ -74,6 +74,51 @@ namespace
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
|
|
||||||
|
address parse_url(std::string const& url)
|
||||||
|
{
|
||||||
|
std::string hostname; // hostname only
|
||||||
|
int port = 80;
|
||||||
|
|
||||||
|
// PARSE URL
|
||||||
|
std::string::const_iterator start = url.begin();
|
||||||
|
std::string::const_iterator end
|
||||||
|
= std::find(url.begin(), url.end(), ':');
|
||||||
|
|
||||||
|
if (end == url.end()) throw std::runtime_error("invalid url");
|
||||||
|
++end;
|
||||||
|
if (end == url.end()) throw std::runtime_error("invalid url");
|
||||||
|
if (*end != '/') throw std::runtime_error("invalid url");
|
||||||
|
++end;
|
||||||
|
if (end == url.end()) throw std::runtime_error("invalid url");
|
||||||
|
if (*end != '/') throw std::runtime_error("invalid url");
|
||||||
|
++end;
|
||||||
|
start = end;
|
||||||
|
|
||||||
|
end = std::find(start, url.end(), '/');
|
||||||
|
std::string::const_iterator port_pos
|
||||||
|
= std::find(start, url.end(), ':');
|
||||||
|
|
||||||
|
if (port_pos < end)
|
||||||
|
{
|
||||||
|
hostname.assign(start, port_pos);
|
||||||
|
++port_pos;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
port = boost::lexical_cast<int>(std::string(port_pos, end));
|
||||||
|
}
|
||||||
|
catch(boost::bad_lexical_cast&)
|
||||||
|
{
|
||||||
|
throw std::runtime_error("invalid url: \"" + url + "\"");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hostname.assign(start, end);
|
||||||
|
}
|
||||||
|
|
||||||
|
return address(hostname.c_str(), port);
|
||||||
|
}
|
||||||
|
|
||||||
// returns -1 if gzip header is invalid or the header size in bytes
|
// returns -1 if gzip header is invalid or the header size in bytes
|
||||||
int gzip_header(const char* buf, int size)
|
int gzip_header(const char* buf, int size)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue