dotnet BitTorrent library written in C#

System.Net.Torrent is an open source bittorrent scraper and peer wire implementation written in C#

It includes:

Resolving a magnet link to metadata (.torrent file)

static void TestAsyncMagnetLink()
{
    var ubuntuMagnetLink = "magnet:?xt=urn:btih:e4be9e4db876e3e3179778b03e906297be5c8dbe&dn=ubuntu-18.04-desktop-amd64.iso&tr=http://torrent.ubuntu.com:6969/announce";

    var magnetMetadata = MagnetLink.ResolveToMetadata(ubuntuMagnetLink);

    foreach (var item in magnetMetadata.AnnounceList)
    {
        Console.WriteLine(item);
    }
}

Scraping announce/tracker URLs

static void ScrapeTorrent()
{
    var scraper = new HTTPTrackerClient(15);
    var announce = scraper.Scrape("http://torrent.ubuntu.com:6969/announce", new string[] { "e4be9e4db876e3e3179778b03e906297be5c8dbe" });
}

Announce (request peers from the tracker)

static void AnnounceTorrent()
{
    var scraper = new HTTPTrackerClient(15);
    var peers = scraper.Announce("http://torrent.ubuntu.com:6969/announce", "e4be9e4db876e3e3179778b03e906297be5c8dbe", "-LW2222-011345223110");
}

Comments

comments powered by Disqus