support magnet links wrapped in .torrent files

This commit is contained in:
Arvid Norberg 2014-02-01 03:47:29 +00:00
parent 3a03debcee
commit c02159f143
2 changed files with 20 additions and 0 deletions

View File

@ -1,3 +1,4 @@
* support magnet links wrapped in .torrent files
* rate limiter optimization * rate limiter optimization
* rate limiter overflow fix (for very high limits) * rate limiter overflow fix (for very high limits)
* non-auto-managed torrents no longer count against the torrent limits * non-auto-managed torrents no longer count against the torrent limits

View File

@ -65,6 +65,8 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/time.hpp" #include "libtorrent/time.hpp"
#include "libtorrent/invariant_check.hpp" #include "libtorrent/invariant_check.hpp"
#include "libtorrent/session_settings.hpp" #include "libtorrent/session_settings.hpp"
#include "libtorrent/add_torrent_params.hpp"
#include "libtorrent/magnet_uri.hpp"
#if TORRENT_USE_I2P #if TORRENT_USE_I2P
#include "libtorrent/parse_url.hpp" #include "libtorrent/parse_url.hpp"
@ -1195,6 +1197,23 @@ namespace libtorrent
lazy_entry const* info = torrent_file.dict_find_dict("info"); lazy_entry const* info = torrent_file.dict_find_dict("info");
if (info == 0) if (info == 0)
{ {
lazy_entry const* link = torrent_file.dict_find_string("magnet-uri");
if (link)
{
std::string uri = link->string_value();
add_torrent_params p;
parse_magnet_uri(uri, p, ec);
if (ec) return false;
m_info_hash = p.info_hash;
for (std::vector<std::string>::iterator i = p.trackers.begin()
, end(p.trackers.end()); i != end; ++i)
m_urls.push_back(*i);
return true;
}
ec = errors::torrent_missing_info; ec = errors::torrent_missing_info;
return false; return false;
} }