made tracker errors use error_code
This commit is contained in:
parent
eff49e42a7
commit
aa5fc72fbf
|
@ -6404,6 +6404,31 @@ I2P errors:
|
||||||
160 no_i2p_router The URL specified an i2p address, but no i2p router is configured
|
160 no_i2p_router The URL specified an i2p address, but no i2p router is configured
|
||||||
====== ========================================= =================================================================
|
====== ========================================= =================================================================
|
||||||
|
|
||||||
|
tracker errors:
|
||||||
|
|
||||||
|
====== ========================================= =================================================================
|
||||||
|
170 scrape_not_available The tracker URL doesn't support transforming it into a scrape
|
||||||
|
URL. i.e. it doesn't contain "announce.
|
||||||
|
------ ----------------------------------------- -----------------------------------------------------------------
|
||||||
|
171 invalid_tracker_response invalid tracker response
|
||||||
|
------ ----------------------------------------- -----------------------------------------------------------------
|
||||||
|
172 invalid_peer_dict invalid peer dictionary entry. Not a dictionary
|
||||||
|
------ ----------------------------------------- -----------------------------------------------------------------
|
||||||
|
173 tracker_failure tracker sent a failure message
|
||||||
|
------ ----------------------------------------- -----------------------------------------------------------------
|
||||||
|
174 invalid_files_entry missing or invalid 'files' entry
|
||||||
|
------ ----------------------------------------- -----------------------------------------------------------------
|
||||||
|
175 invalid_hash_entry missing or invalid 'hash' entry
|
||||||
|
------ ----------------------------------------- -----------------------------------------------------------------
|
||||||
|
176 invalid_peers_entry missing or invalid 'peers' and 'peers6' entry
|
||||||
|
------ ----------------------------------------- -----------------------------------------------------------------
|
||||||
|
177 invalid_tracker_response_length udp tracker response packet has invalid size
|
||||||
|
------ ----------------------------------------- -----------------------------------------------------------------
|
||||||
|
178 invalid_tracker_transaction_id invalid transaction id in udp tracker response
|
||||||
|
------ ----------------------------------------- -----------------------------------------------------------------
|
||||||
|
179 invalid_tracker_action invalid action field in udp tracker response
|
||||||
|
====== ========================================= =================================================================
|
||||||
|
|
||||||
The names of these error codes are declared in then ``libtorrent::errors`` namespace.
|
The names of these error codes are declared in then ``libtorrent::errors`` namespace.
|
||||||
|
|
||||||
There is also another error category, ``libtorrent::upnp_category``, defining errors
|
There is also another error category, ``libtorrent::upnp_category``, defining errors
|
||||||
|
|
|
@ -241,24 +241,13 @@ namespace libtorrent
|
||||||
, int times
|
, int times
|
||||||
, int status
|
, int status
|
||||||
, std::string const& url_
|
, std::string const& url_
|
||||||
, error_code const& e)
|
, error_code const& e
|
||||||
|
, std::string const& m)
|
||||||
: tracker_alert(h, url_)
|
: tracker_alert(h, url_)
|
||||||
, times_in_row(times)
|
, times_in_row(times)
|
||||||
, status_code(status)
|
, status_code(status)
|
||||||
, msg(e.message())
|
, error(e)
|
||||||
{
|
, msg(msg)
|
||||||
TORRENT_ASSERT(!url.empty());
|
|
||||||
}
|
|
||||||
|
|
||||||
tracker_error_alert(torrent_handle const& h
|
|
||||||
, int times
|
|
||||||
, int status
|
|
||||||
, std::string const& url_
|
|
||||||
, std::string const& msg_)
|
|
||||||
: tracker_alert(h, url_)
|
|
||||||
, times_in_row(times)
|
|
||||||
, status_code(status)
|
|
||||||
, msg(msg_)
|
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(!url.empty());
|
TORRENT_ASSERT(!url.empty());
|
||||||
}
|
}
|
||||||
|
@ -270,6 +259,7 @@ namespace libtorrent
|
||||||
|
|
||||||
int times_in_row;
|
int times_in_row;
|
||||||
int status_code;
|
int status_code;
|
||||||
|
error_code error;
|
||||||
std::string msg;
|
std::string msg;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -224,6 +224,27 @@ namespace libtorrent
|
||||||
reserved159,
|
reserved159,
|
||||||
// i2p errors
|
// i2p errors
|
||||||
no_i2p_router, // 160
|
no_i2p_router, // 160
|
||||||
|
reserved161,
|
||||||
|
reserved162,
|
||||||
|
reserved163,
|
||||||
|
reserved164,
|
||||||
|
reserved165,
|
||||||
|
reserved166,
|
||||||
|
reserved167,
|
||||||
|
reserved168,
|
||||||
|
reserved169,
|
||||||
|
|
||||||
|
// tracker errors
|
||||||
|
scrape_not_available, // 170
|
||||||
|
invalid_tracker_response,
|
||||||
|
invalid_peer_dict,
|
||||||
|
tracker_failure,
|
||||||
|
invalid_files_entry,
|
||||||
|
invalid_hash_entry,
|
||||||
|
invalid_peers_entry,
|
||||||
|
invalid_tracker_response_length,
|
||||||
|
invalid_tracker_transaction_id,
|
||||||
|
invalid_tracker_action,
|
||||||
|
|
||||||
error_code_max
|
error_code_max
|
||||||
};
|
};
|
||||||
|
|
|
@ -423,10 +423,9 @@ namespace libtorrent
|
||||||
, std::list<address> const& ip_list
|
, std::list<address> const& ip_list
|
||||||
, std::vector<peer_entry>& e, int interval, int min_interval
|
, std::vector<peer_entry>& e, int interval, int min_interval
|
||||||
, int complete, int incomplete, address const& external_ip);
|
, int complete, int incomplete, address const& external_ip);
|
||||||
virtual void tracker_request_timed_out(
|
|
||||||
tracker_request const& r);
|
|
||||||
virtual void tracker_request_error(tracker_request const& r
|
virtual void tracker_request_error(tracker_request const& r
|
||||||
, int response_code, const std::string& str, int retry_interval);
|
, int response_code, error_code const& ec, const std::string& msg
|
||||||
|
, int retry_interval);
|
||||||
virtual void tracker_warning(tracker_request const& req
|
virtual void tracker_warning(tracker_request const& req
|
||||||
, std::string const& msg);
|
, std::string const& msg);
|
||||||
virtual void tracker_scrape_response(tracker_request const& req
|
virtual void tracker_scrape_response(tracker_request const& req
|
||||||
|
|
|
@ -135,12 +135,11 @@ namespace libtorrent
|
||||||
, int complete
|
, int complete
|
||||||
, int incomplete
|
, int incomplete
|
||||||
, address const& external_ip) = 0;
|
, address const& external_ip) = 0;
|
||||||
virtual void tracker_request_timed_out(
|
|
||||||
tracker_request const& req) = 0;
|
|
||||||
virtual void tracker_request_error(
|
virtual void tracker_request_error(
|
||||||
tracker_request const& req
|
tracker_request const& req
|
||||||
, int response_code
|
, int response_code
|
||||||
, const std::string& description
|
, error_code const& ec
|
||||||
|
, const std::string& msg
|
||||||
, int retry_interval) = 0;
|
, int retry_interval) = 0;
|
||||||
|
|
||||||
union_endpoint m_tracker_address;
|
union_endpoint m_tracker_address;
|
||||||
|
@ -201,9 +200,9 @@ namespace libtorrent
|
||||||
|
|
||||||
tracker_request const& tracker_req() const { return m_req; }
|
tracker_request const& tracker_req() const { return m_req; }
|
||||||
|
|
||||||
void fail_disp(int code, std::string const& msg) { fail(code, msg.c_str()); }
|
void fail_disp(error_code ec) { fail(ec); }
|
||||||
void fail(int code, char const* msg, int interval = 0, int min_interval = 0);
|
void fail(error_code const& ec, int code = -1, char const* msg = ""
|
||||||
void fail_timeout();
|
, int interval = 0, int min_interval = 0);
|
||||||
virtual void start() = 0;
|
virtual void start() = 0;
|
||||||
virtual void close();
|
virtual void close();
|
||||||
address const& bind_interface() const { return m_req.bind_ip; }
|
address const& bind_interface() const { return m_req.bind_ip; }
|
||||||
|
|
|
@ -213,6 +213,26 @@ namespace libtorrent
|
||||||
"",
|
"",
|
||||||
// i2p errors
|
// i2p errors
|
||||||
"no i2p router is set up",
|
"no i2p router is set up",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
// tracker errors
|
||||||
|
"scrape not available on tracker",
|
||||||
|
"invalid tracker response",
|
||||||
|
"invalid peer dictionary entry",
|
||||||
|
"tracker sent a failure message",
|
||||||
|
"missing or invalid 'files' entry",
|
||||||
|
"missing or invalid 'hash' entry",
|
||||||
|
"missing or invalid 'peers' and 'peers6' entry",
|
||||||
|
"udp tracker response packet has invalid size",
|
||||||
|
"invalid transaction id in udp tracker response",
|
||||||
|
"invalid action field in udp tracker response",
|
||||||
};
|
};
|
||||||
if (ev < 0 || ev >= sizeof(msgs)/sizeof(msgs[0]))
|
if (ev < 0 || ev >= sizeof(msgs)/sizeof(msgs[0]))
|
||||||
return "Unknown error";
|
return "Unknown error";
|
||||||
|
|
|
@ -108,7 +108,7 @@ namespace libtorrent
|
||||||
if (pos == std::string::npos)
|
if (pos == std::string::npos)
|
||||||
{
|
{
|
||||||
m_ios.post(boost::bind(&http_tracker_connection::fail_disp, self()
|
m_ios.post(boost::bind(&http_tracker_connection::fail_disp, self()
|
||||||
, -1, "scrape is not available on url: '" + tracker_req().url +"'"));
|
, error_code(errors::scrape_not_available)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
url.replace(pos, 8, "scrape");
|
url.replace(pos, 8, "scrape");
|
||||||
|
@ -247,7 +247,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
|
|
||||||
if (endpoints.empty())
|
if (endpoints.empty())
|
||||||
fail(-1, "blocked by IP filter");
|
fail(error_code(errors::banned_by_ip_filter));
|
||||||
}
|
}
|
||||||
|
|
||||||
void http_tracker_connection::on_connect(http_connection& c)
|
void http_tracker_connection::on_connect(http_connection& c)
|
||||||
|
@ -267,25 +267,25 @@ namespace libtorrent
|
||||||
|
|
||||||
if (ec && ec != asio::error::eof)
|
if (ec && ec != asio::error::eof)
|
||||||
{
|
{
|
||||||
fail(-1, ec.message().c_str());
|
fail(ec);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!parser.header_finished())
|
if (!parser.header_finished())
|
||||||
{
|
{
|
||||||
fail(-1, "premature end of file");
|
fail(asio::error::eof);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parser.status_code() != 200)
|
if (parser.status_code() != 200)
|
||||||
{
|
{
|
||||||
fail(parser.status_code(), parser.message().c_str());
|
fail(error_code(errors::http_error), parser.status_code(), parser.message().c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ec && ec != asio::error::eof)
|
if (ec && ec != asio::error::eof)
|
||||||
{
|
{
|
||||||
fail(parser.status_code(), ec.message().c_str());
|
fail(ec, parser.status_code());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,19 +301,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::string error_str("invalid encoding of tracker response: \"");
|
fail(error_code(errors::invalid_bencoding), parser.status_code());
|
||||||
for (char const* i = data, *end(data + size); i != end; ++i)
|
|
||||||
{
|
|
||||||
if (*i >= ' ' && *i <= '~') error_str += *i;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
char val[30];
|
|
||||||
snprintf(val, sizeof(val), "0x%02x ", *i);
|
|
||||||
error_str += val;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
error_str += "\"";
|
|
||||||
fail(parser.status_code(), error_str.c_str());
|
|
||||||
}
|
}
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
@ -323,7 +311,7 @@ namespace libtorrent
|
||||||
// extract peer id (if any)
|
// extract peer id (if any)
|
||||||
if (info.type() != lazy_entry::dict_t)
|
if (info.type() != lazy_entry::dict_t)
|
||||||
{
|
{
|
||||||
fail(-1, "invalid response from tracker (invalid peer entry)");
|
fail(error_code(errors::invalid_peer_dict));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
lazy_entry const* i = info.dict_find_string("peer id");
|
lazy_entry const* i = info.dict_find_string("peer id");
|
||||||
|
@ -341,7 +329,7 @@ namespace libtorrent
|
||||||
i = info.dict_find_string("ip");
|
i = info.dict_find_string("ip");
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
{
|
{
|
||||||
fail(-1, "invalid response from tracker");
|
fail(error_code(errors::invalid_tracker_response));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ret.ip = i->string_value();
|
ret.ip = i->string_value();
|
||||||
|
@ -350,7 +338,7 @@ namespace libtorrent
|
||||||
i = info.dict_find_int("port");
|
i = info.dict_find_int("port");
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
{
|
{
|
||||||
fail(-1, "invalid response from tracker");
|
fail(error_code(errors::invalid_tracker_response));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ret.port = (unsigned short)i->int_value();
|
ret.port = (unsigned short)i->int_value();
|
||||||
|
@ -370,7 +358,8 @@ namespace libtorrent
|
||||||
lazy_entry const* failure = e.dict_find_string("failure reason");
|
lazy_entry const* failure = e.dict_find_string("failure reason");
|
||||||
if (failure)
|
if (failure)
|
||||||
{
|
{
|
||||||
fail(status_code, failure->string_value().c_str(), interval, min_interval);
|
fail(error_code(errors::tracker_failure), status_code
|
||||||
|
, failure->string_value().c_str(), interval, min_interval);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -387,7 +376,7 @@ namespace libtorrent
|
||||||
lazy_entry const* files = e.dict_find_dict("files");
|
lazy_entry const* files = e.dict_find_dict("files");
|
||||||
if (files == 0)
|
if (files == 0)
|
||||||
{
|
{
|
||||||
fail(-1, "invalid or missing 'files' entry in scrape response"
|
fail(error_code(errors::invalid_files_entry), -1, ""
|
||||||
, interval, min_interval);
|
, interval, min_interval);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -395,7 +384,7 @@ namespace libtorrent
|
||||||
lazy_entry const* scrape_data = files->dict_find_dict(ih.c_str());
|
lazy_entry const* scrape_data = files->dict_find_dict(ih.c_str());
|
||||||
if (scrape_data == 0)
|
if (scrape_data == 0)
|
||||||
{
|
{
|
||||||
fail(-1, "missing or invalid info-hash entry in scrape response"
|
fail(error_code(errors::invalid_hash_entry), -1, ""
|
||||||
, interval, min_interval);
|
, interval, min_interval);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -469,7 +458,7 @@ namespace libtorrent
|
||||||
|
|
||||||
if (peers_ent == 0 && ipv6_peers == 0)
|
if (peers_ent == 0 && ipv6_peers == 0)
|
||||||
{
|
{
|
||||||
fail(-1, "missing 'peers' and 'peers6' entry in tracker response"
|
fail(error_code(errors::invalid_peers_entry), -1, ""
|
||||||
, interval, min_interval);
|
, interval, min_interval);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6257,49 +6257,11 @@ namespace libtorrent
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void torrent::tracker_request_timed_out(
|
|
||||||
tracker_request const& r)
|
|
||||||
{
|
|
||||||
mutex::scoped_lock l(m_ses.m_mutex);
|
|
||||||
|
|
||||||
INVARIANT_CHECK;
|
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
|
||||||
debug_log("*** tracker timed out");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (r.kind == tracker_request::announce_request)
|
|
||||||
{
|
|
||||||
announce_entry* ae = find_tracker(r);
|
|
||||||
if (ae)
|
|
||||||
{
|
|
||||||
ae->failed();
|
|
||||||
int tracker_index = ae - &m_trackers[0];
|
|
||||||
deprioritize_tracker(tracker_index);
|
|
||||||
}
|
|
||||||
if (m_ses.m_alerts.should_post<tracker_error_alert>())
|
|
||||||
{
|
|
||||||
m_ses.m_alerts.post_alert(tracker_error_alert(get_handle()
|
|
||||||
, ae?ae->fails:0, 0, r.url
|
|
||||||
, errors::timed_out));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (r.kind == tracker_request::scrape_request)
|
|
||||||
{
|
|
||||||
if (m_ses.m_alerts.should_post<scrape_failed_alert>())
|
|
||||||
{
|
|
||||||
m_ses.m_alerts.post_alert(scrape_failed_alert(get_handle()
|
|
||||||
, r.url, errors::timed_out));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
update_tracker_timer();
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: with some response codes, we should just consider
|
// TODO: with some response codes, we should just consider
|
||||||
// the tracker as a failure and not retry
|
// the tracker as a failure and not retry
|
||||||
// it anymore
|
// it anymore
|
||||||
void torrent::tracker_request_error(tracker_request const& r
|
void torrent::tracker_request_error(tracker_request const& r
|
||||||
, int response_code, const std::string& str
|
, int response_code, error_code const& ec, const std::string& msg
|
||||||
, int retry_interval)
|
, int retry_interval)
|
||||||
{
|
{
|
||||||
mutex::scoped_lock l(m_ses.m_mutex);
|
mutex::scoped_lock l(m_ses.m_mutex);
|
||||||
|
@ -6307,7 +6269,7 @@ namespace libtorrent
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
||||||
debug_log(std::string("*** tracker error: ") + str);
|
debug_log("*** tracker error: " + ec.message() + " " + msg);
|
||||||
#endif
|
#endif
|
||||||
if (r.kind == tracker_request::announce_request)
|
if (r.kind == tracker_request::announce_request)
|
||||||
{
|
{
|
||||||
|
@ -6321,14 +6283,14 @@ namespace libtorrent
|
||||||
if (m_ses.m_alerts.should_post<tracker_error_alert>())
|
if (m_ses.m_alerts.should_post<tracker_error_alert>())
|
||||||
{
|
{
|
||||||
m_ses.m_alerts.post_alert(tracker_error_alert(get_handle()
|
m_ses.m_alerts.post_alert(tracker_error_alert(get_handle()
|
||||||
, ae?ae->fails:0, response_code, r.url, str));
|
, ae?ae->fails:0, response_code, r.url, ec, msg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (r.kind == tracker_request::scrape_request)
|
else if (r.kind == tracker_request::scrape_request)
|
||||||
{
|
{
|
||||||
if (m_ses.m_alerts.should_post<scrape_failed_alert>())
|
if (m_ses.m_alerts.should_post<scrape_failed_alert>())
|
||||||
{
|
{
|
||||||
m_ses.m_alerts.post_alert(scrape_failed_alert(get_handle(), r.url, str));
|
m_ses.m_alerts.post_alert(scrape_failed_alert(get_handle(), r.url, ec));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
update_tracker_timer();
|
update_tracker_timer();
|
||||||
|
|
|
@ -140,10 +140,11 @@ namespace libtorrent
|
||||||
return m_requester.lock();
|
return m_requester.lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void tracker_connection::fail(int code, char const* msg, int interval, int min_interval)
|
void tracker_connection::fail(error_code const& ec, int code
|
||||||
|
, char const* msg, int interval, int min_interval)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<request_callback> cb = requester();
|
boost::shared_ptr<request_callback> cb = requester();
|
||||||
if (cb) cb->tracker_request_error(m_req, code, msg
|
if (cb) cb->tracker_request_error(m_req, code, ec, msg
|
||||||
, interval == 0 ? min_interval : interval);
|
, interval == 0 ? min_interval : interval);
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
@ -158,13 +159,6 @@ namespace libtorrent
|
||||||
m_man.received_bytes(bytes);
|
m_man.received_bytes(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tracker_connection::fail_timeout()
|
|
||||||
{
|
|
||||||
boost::shared_ptr<request_callback> cb = requester();
|
|
||||||
if (cb) cb->tracker_request_timed_out(m_req);
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
|
|
||||||
void tracker_connection::close()
|
void tracker_connection::close()
|
||||||
{
|
{
|
||||||
cancel();
|
cancel();
|
||||||
|
@ -246,8 +240,9 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
// we need to post the error to avoid deadlock
|
// we need to post the error to avoid deadlock
|
||||||
if (boost::shared_ptr<request_callback> r = c.lock())
|
if (boost::shared_ptr<request_callback> r = c.lock())
|
||||||
ios.post(boost::bind(&request_callback::tracker_request_error, r, req, -1
|
ios.post(boost::bind(&request_callback::tracker_request_error, r, req
|
||||||
, "unknown protocol in tracker url: " + req.url, 0));
|
, -1, error_code(errors::unsupported_url_protocol)
|
||||||
|
, "", 0));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -97,7 +97,7 @@ namespace libtorrent
|
||||||
|
|
||||||
if (ec)
|
if (ec)
|
||||||
{
|
{
|
||||||
fail(-1, ec.message().c_str());
|
fail(ec);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ namespace libtorrent
|
||||||
if (error == asio::error::operation_aborted) return;
|
if (error == asio::error::operation_aborted) return;
|
||||||
if (error || i == udp::resolver::iterator())
|
if (error || i == udp::resolver::iterator())
|
||||||
{
|
{
|
||||||
fail(-1, error.message().c_str());
|
fail(error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ namespace libtorrent
|
||||||
|
|
||||||
if (m_endpoints.empty())
|
if (m_endpoints.empty())
|
||||||
{
|
{
|
||||||
fail(-1, "blocked by IP filter");
|
fail(error_code(errors::banned_by_ip_filter));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,7 +194,7 @@ namespace libtorrent
|
||||||
m_socket.bind(udp::endpoint(bind_interface(), 0), ec);
|
m_socket.bind(udp::endpoint(bind_interface(), 0), ec);
|
||||||
if (ec)
|
if (ec)
|
||||||
{
|
{
|
||||||
fail(-1, ec.message().c_str());
|
fail(ec);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,7 +231,7 @@ namespace libtorrent
|
||||||
#endif
|
#endif
|
||||||
m_socket.close();
|
m_socket.close();
|
||||||
m_name_lookup.cancel();
|
m_name_lookup.cancel();
|
||||||
fail_timeout();
|
fail(error_code(errors::timed_out));
|
||||||
}
|
}
|
||||||
|
|
||||||
void udp_tracker_connection::close()
|
void udp_tracker_connection::close()
|
||||||
|
@ -254,7 +254,7 @@ namespace libtorrent
|
||||||
if (m_target != ep) return;
|
if (m_target != ep) return;
|
||||||
|
|
||||||
received_bytes(size + 28); // assuming UDP/IP header
|
received_bytes(size + 28); // assuming UDP/IP header
|
||||||
if (e) fail(-1, e.message().c_str());
|
if (e) fail(e);
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
||||||
boost::shared_ptr<request_callback> cb = requester();
|
boost::shared_ptr<request_callback> cb = requester();
|
||||||
|
@ -289,7 +289,7 @@ namespace libtorrent
|
||||||
|
|
||||||
if (action == action_error)
|
if (action == action_error)
|
||||||
{
|
{
|
||||||
fail(-1, std::string(ptr, size - 8).c_str());
|
fail(error_code(errors::tracker_failure), -1, std::string(ptr, size - 8).c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -379,7 +379,7 @@ namespace libtorrent
|
||||||
++m_attempts;
|
++m_attempts;
|
||||||
if (ec)
|
if (ec)
|
||||||
{
|
{
|
||||||
fail(-1, ec.message().c_str());
|
fail(ec);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -415,7 +415,7 @@ namespace libtorrent
|
||||||
++m_attempts;
|
++m_attempts;
|
||||||
if (ec)
|
if (ec)
|
||||||
{
|
{
|
||||||
fail(-1, ec.message().c_str());
|
fail(ec);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -433,7 +433,7 @@ namespace libtorrent
|
||||||
int num_peers = (size - 20) / 6;
|
int num_peers = (size - 20) / 6;
|
||||||
if ((size - 20) % 6 != 0)
|
if ((size - 20) % 6 != 0)
|
||||||
{
|
{
|
||||||
fail(-1, "invalid udp tracker response length");
|
fail(error_code(errors::invalid_tracker_response_length));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -495,25 +495,25 @@ namespace libtorrent
|
||||||
|
|
||||||
if (transaction != m_transaction_id)
|
if (transaction != m_transaction_id)
|
||||||
{
|
{
|
||||||
fail(-1, "incorrect transaction id");
|
fail(error_code(errors::invalid_tracker_transaction_id));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action == action_error)
|
if (action == action_error)
|
||||||
{
|
{
|
||||||
fail(-1, std::string(buf, size - 8).c_str());
|
fail(error_code(errors::tracker_failure), -1, std::string(buf, size - 8).c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action != action_scrape)
|
if (action != action_scrape)
|
||||||
{
|
{
|
||||||
fail(-1, "invalid action in announce response");
|
fail(error_code(errors::invalid_tracker_action));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size < 20)
|
if (size < 20)
|
||||||
{
|
{
|
||||||
fail(-1, "got a message with size < 20");
|
fail(error_code(errors::invalid_tracker_response_length));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -602,7 +602,7 @@ namespace libtorrent
|
||||||
++m_attempts;
|
++m_attempts;
|
||||||
if (ec)
|
if (ec)
|
||||||
{
|
{
|
||||||
fail(-1, ec.message().c_str());
|
fail(ec);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue