support trackerid tracker extension
This commit is contained in:
parent
40ed231366
commit
a05acc4bac
|
@ -1,3 +1,4 @@
|
||||||
|
* support trackerid tracker extension
|
||||||
* graceful peer disconnect mode which finishes transactions before disconnecting peers
|
* graceful peer disconnect mode which finishes transactions before disconnecting peers
|
||||||
* support chunked encoding for web seeds
|
* support chunked encoding for web seeds
|
||||||
* optimized session startup time
|
* optimized session startup time
|
||||||
|
|
|
@ -84,6 +84,7 @@ namespace libtorrent
|
||||||
bool upload_mode;
|
bool upload_mode;
|
||||||
std::vector<boost::uint8_t> const* file_priorities;
|
std::vector<boost::uint8_t> const* file_priorities;
|
||||||
bool share_mode;
|
bool share_mode;
|
||||||
|
std::string trackerid;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1167,6 +1167,23 @@ namespace libtorrent
|
||||||
virtual std::string message() const;
|
virtual std::string message() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct TORRENT_EXPORT trackerid_alert: tracker_alert
|
||||||
|
{
|
||||||
|
trackerid_alert(torrent_handle const& h
|
||||||
|
, std::string const& url_
|
||||||
|
, const std::string& id)
|
||||||
|
: tracker_alert(h, url_)
|
||||||
|
, trackerid(id)
|
||||||
|
{}
|
||||||
|
|
||||||
|
TORRENT_DEFINE_ALERT(trackerid_alert);
|
||||||
|
|
||||||
|
const static int static_category = alert::status_notification;
|
||||||
|
virtual std::string message() const;
|
||||||
|
|
||||||
|
std::string trackerid;
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -444,7 +444,8 @@ namespace libtorrent
|
||||||
, address const& tracker_ip
|
, address const& tracker_ip
|
||||||
, 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
|
||||||
|
, std::string const& trackerid);
|
||||||
virtual void tracker_request_error(tracker_request const& r
|
virtual void tracker_request_error(tracker_request const& r
|
||||||
, int response_code, error_code const& ec, const std::string& msg
|
, int response_code, error_code const& ec, const std::string& msg
|
||||||
, int retry_interval);
|
, int retry_interval);
|
||||||
|
@ -942,6 +943,7 @@ namespace libtorrent
|
||||||
// this list is sorted by time_critical_piece::deadline
|
// this list is sorted by time_critical_piece::deadline
|
||||||
std::list<time_critical_piece> m_time_critical_pieces;
|
std::list<time_critical_piece> m_time_critical_pieces;
|
||||||
|
|
||||||
|
std::string m_trackerid;
|
||||||
std::string m_username;
|
std::string m_username;
|
||||||
std::string m_password;
|
std::string m_password;
|
||||||
|
|
||||||
|
|
|
@ -91,6 +91,7 @@ namespace libtorrent
|
||||||
|
|
||||||
// tracker URL as it appeared in the torrent file
|
// tracker URL as it appeared in the torrent file
|
||||||
std::string url;
|
std::string url;
|
||||||
|
std::string trackerid;
|
||||||
|
|
||||||
// if this tracker has returned an error or warning message
|
// if this tracker has returned an error or warning message
|
||||||
// that message is stored here
|
// that message is stored here
|
||||||
|
|
|
@ -115,6 +115,7 @@ namespace libtorrent
|
||||||
unsigned short listen_port;
|
unsigned short listen_port;
|
||||||
event_t event;
|
event_t event;
|
||||||
std::string url;
|
std::string url;
|
||||||
|
std::string trackerid;
|
||||||
int key;
|
int key;
|
||||||
int num_want;
|
int num_want;
|
||||||
std::string ipv6;
|
std::string ipv6;
|
||||||
|
@ -142,7 +143,8 @@ namespace libtorrent
|
||||||
, int min_interval
|
, int min_interval
|
||||||
, int complete
|
, int complete
|
||||||
, int incomplete
|
, int incomplete
|
||||||
, address const& external_ip) = 0;
|
, address const& external_ip
|
||||||
|
, std::string const& trackerid) = 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
|
||||||
|
|
|
@ -486,5 +486,10 @@ namespace libtorrent {
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string trackerid_alert::message() const
|
||||||
|
{
|
||||||
|
return "trackerid received: " + trackerid;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace libtorrent
|
} // namespace libtorrent
|
||||||
|
|
||||||
|
|
|
@ -156,6 +156,12 @@ namespace libtorrent
|
||||||
if (m_ses.get_pe_settings().in_enc_policy != pe_settings::disabled)
|
if (m_ses.get_pe_settings().in_enc_policy != pe_settings::disabled)
|
||||||
url += "&supportcrypto=1";
|
url += "&supportcrypto=1";
|
||||||
#endif
|
#endif
|
||||||
|
if (!tracker_req().trackerid.empty())
|
||||||
|
{
|
||||||
|
std::string id = tracker_req().trackerid;
|
||||||
|
url += "&trackerid=";
|
||||||
|
url += escape_string(id.c_str(), id.length());
|
||||||
|
}
|
||||||
|
|
||||||
if (tracker_req().event != tracker_request::none)
|
if (tracker_req().event != tracker_request::none)
|
||||||
{
|
{
|
||||||
|
@ -363,6 +369,10 @@ namespace libtorrent
|
||||||
int interval = e.dict_find_int_value("interval", 1800);
|
int interval = e.dict_find_int_value("interval", 1800);
|
||||||
int min_interval = e.dict_find_int_value("min interval", 60);
|
int min_interval = e.dict_find_int_value("min interval", 60);
|
||||||
|
|
||||||
|
std::string trackerid;
|
||||||
|
lazy_entry const* tracker_id = e.dict_find_string("tracker id");
|
||||||
|
if (tracker_id)
|
||||||
|
trackerid = tracker_id->string_value();
|
||||||
// parse the response
|
// parse the response
|
||||||
lazy_entry const* failure = e.dict_find_string("failure reason");
|
lazy_entry const* failure = e.dict_find_string("failure reason");
|
||||||
if (failure)
|
if (failure)
|
||||||
|
@ -506,7 +516,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
|
|
||||||
cb->tracker_response(tracker_req(), m_tracker_ip, ip_list, peer_list
|
cb->tracker_response(tracker_req(), m_tracker_ip, ip_list, peer_list
|
||||||
, interval, min_interval, complete, incomplete, external_ip);
|
, interval, min_interval, complete, incomplete, external_ip, trackerid);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -329,6 +329,7 @@ namespace libtorrent
|
||||||
, m_ses(ses)
|
, m_ses(ses)
|
||||||
, m_trackers(m_torrent_file->trackers())
|
, m_trackers(m_torrent_file->trackers())
|
||||||
, m_save_path(complete(p.save_path))
|
, m_save_path(complete(p.save_path))
|
||||||
|
, m_trackerid(p.trackerid)
|
||||||
, m_storage_constructor(p.storage)
|
, m_storage_constructor(p.storage)
|
||||||
, m_ratio(0.f)
|
, m_ratio(0.f)
|
||||||
, m_available_free_upload(0)
|
, m_available_free_upload(0)
|
||||||
|
@ -1494,6 +1495,8 @@ namespace libtorrent
|
||||||
for (int i = 0; i < int(m_trackers.size()); ++i)
|
for (int i = 0; i < int(m_trackers.size()); ++i)
|
||||||
{
|
{
|
||||||
announce_entry& ae = m_trackers[i];
|
announce_entry& ae = m_trackers[i];
|
||||||
|
// if trackerid is not specified for tracker use default one, probably set explicitly
|
||||||
|
req.trackerid = ae.trackerid.empty() ? m_trackerid : ae.trackerid;
|
||||||
if (settings().announce_to_all_tiers
|
if (settings().announce_to_all_tiers
|
||||||
&& !settings().announce_to_all_trackers
|
&& !settings().announce_to_all_trackers
|
||||||
&& sent_announce
|
&& sent_announce
|
||||||
|
@ -1652,7 +1655,8 @@ namespace libtorrent
|
||||||
, int min_interval
|
, int min_interval
|
||||||
, int complete
|
, int complete
|
||||||
, int incomplete
|
, int incomplete
|
||||||
, address const& external_ip)
|
, address const& external_ip
|
||||||
|
, const std::string& trackerid)
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(m_ses.is_network_thread());
|
TORRENT_ASSERT(m_ses.is_network_thread());
|
||||||
|
|
||||||
|
@ -1681,6 +1685,13 @@ namespace libtorrent
|
||||||
ae->min_announce = now + seconds(min_interval);
|
ae->min_announce = now + seconds(min_interval);
|
||||||
int tracker_index = ae - &m_trackers[0];
|
int tracker_index = ae - &m_trackers[0];
|
||||||
m_last_working_tracker = prioritize_tracker(tracker_index);
|
m_last_working_tracker = prioritize_tracker(tracker_index);
|
||||||
|
|
||||||
|
if ((!trackerid.empty()) && (ae->trackerid != trackerid))
|
||||||
|
{
|
||||||
|
ae->trackerid = trackerid;
|
||||||
|
if (m_ses.m_alerts.should_post<trackerid_alert>())
|
||||||
|
m_ses.m_alerts.post_alert(trackerid_alert(get_handle(), r.url, trackerid));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
update_tracker_timer(now);
|
update_tracker_timer(now);
|
||||||
|
|
||||||
|
|
|
@ -527,7 +527,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
|
|
||||||
cb->tracker_response(tracker_req(), m_target.address(), ip_list
|
cb->tracker_response(tracker_req(), m_target.address(), ip_list
|
||||||
, peer_list, interval, min_interval, complete, incomplete, address());
|
, peer_list, interval, min_interval, complete, incomplete, address(), "" /*trackerid*/);
|
||||||
|
|
||||||
close();
|
close();
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue