libtorrent-rasterbar can't download metadata using magnet links

社会主义新天地 提交于 2020-01-04 15:57:32

问题


I'm trying to download a remote metadata file (.torrent) using no-DHT, tracker-only behavior with libtorrent-rasterbar 0.16.13.

Unfortunately, I get a lot of peer_disconnected errors; seeding from my program and downloading through clients such as BT or QBittorrent works.

I'm using hex-encoded hashes, I don't know if this is the problem as libtorrent-rasterbar seems to support both Hex and Base32 hashes in the Magnet URI.

Remember that I already have a tracker and I dont want to use DHT, but magnet just for downloading the remote torrent to my local filesystem.

Here's my AddMagnetLink code:

RESULT SessionManager::addMagnetLink(const QString& info_hash,
                                        const QString& torrentPath,
                                        libtorrent::torrent_handle &thndl)
{
    try
    {
        libtorrent::add_torrent_params tp;
        boost::filesystem::path path(torrentPath.toStdWString());

        std::string url;
        url.append("magnet:?xt=urn:btih:");
        url.append(info_hash.toStdString());
        url.append("&tr=udp://tracker.publicbt.com:80");

        qDebug() << "Using magnet URI:  "<< url.c_str();    
        qDebug() << "Save path is " << tp.save_path.c_str();    

        tp.paused = false;
        tp.auto_managed = true;
        tp.save_path = path.string();

        libtorrent::error_code ec;
        thndl = libtorrent::add_magnet_uri(*_lt_session, url, tp,ec);


        qDebug() << "add_torrent error_code = " << ec.message().c_str();
        qDebug() << "Has metadata";

    }
    catch (std::exception& e)
    {
        qWarning() << "(!) Exception thrown: " << e.what();
        return NKT_E_FAIL;
    }

    return S_OK;

}

Example output:

peer_disconnected_alert: 8061b09e2229111ed93a48080835e371c89c1111 peer (1xx.1xx.3x.x5, libtorrent 0.16.0) disconnecting: [libtorrent error] connected to ourselves
peer_disconnected_alert: 8061b09e2229111ed93a48080835e371c89c1111 peer (1xx.1xx.3x.x5, Unknown) disconnecting: [asio.misc] End of file

Im trying this in my local LAN, between my machines.

EDIT: (Added more data)

Surprisngly, this occurs only with metadata transfer, as I've tried with normal torrent files and it works (seeds and downloads). I've enabled metadata_transfer and ut_metadata extensions; also, DHT, PEX, UPNP, NATPMP and Local Discovery are enabled. Seems there is some problem with transferring metadata.

Thanks in advance.,


回答1:


Trackers will only report back your public IP and port.

If you have two clients on the same network, with the same external IP, and they have not mapped a port (with UPnP or NAT-PMP) they won't be able to find each other via a tracker.

You could either enable local peer discovery (local service discovery) to make the peers advertise their presence on the local network, or you could make sure they are both reachable via their external IP, by enabling UPnP and NAT-PMP (assuming your router supports that). You'd probably want to enable both.

The disconnect message you post indicate that the peer can only see itself.



来源:https://stackoverflow.com/questions/22471139/libtorrent-rasterbar-cant-download-metadata-using-magnet-links

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!