diff --git a/ChangeLog b/ChangeLog index 207b05e42..e3a8fea9b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,4 @@ + * support magnet links wrapped in .torrent files * rate limiter optimization * rate limiter overflow fix (for very high limits) * non-auto-managed torrents no longer count against the torrent limits diff --git a/src/torrent_info.cpp b/src/torrent_info.cpp index 9554d0a32..83f0121de 100644 --- a/src/torrent_info.cpp +++ b/src/torrent_info.cpp @@ -65,6 +65,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/time.hpp" #include "libtorrent/invariant_check.hpp" #include "libtorrent/session_settings.hpp" +#include "libtorrent/add_torrent_params.hpp" +#include "libtorrent/magnet_uri.hpp" #if TORRENT_USE_I2P #include "libtorrent/parse_url.hpp" @@ -1195,6 +1197,23 @@ namespace libtorrent lazy_entry const* info = torrent_file.dict_find_dict("info"); 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::iterator i = p.trackers.begin() + , end(p.trackers.end()); i != end; ++i) + m_urls.push_back(*i); + + return true; + } + ec = errors::torrent_missing_info; return false; }