3

monotorrent の dht 実装を機能させようとしていますが、ピアが見つからないようです。

testclient や dhttest のように、ネット上で入手可能なサンプル コード コードのほとんどを試してみました。

いくつかの異なる情報ハッシュを試しました。

ここで誰かがそれを機能させましたか?または、どこで開発者を見つけることができるか知っていますか?

これは私のコードがどのように見えるかです:

using System;
using System.Collections.Generic;
using System.Text;
using MonoTorrent.Dht;
using MonoTorrent.Dht.Listeners;
using System.Net;
using System.IO;
using MonoTorrent.Common;
using MonoTorrent.Tracker.Listeners;

namespace SampleClient
{
    class Program
    {
    static void Main(string[] args)
    {

    string basePath = Environment.CurrentDirectory;
    string torrentsPath = Path.Combine(basePath, "Torrents");
    Torrent torrent = null;
    // If the torrentsPath does not exist, we want to create it
    if (!Directory.Exists(torrentsPath))
        Directory.CreateDirectory(torrentsPath);
    // For each file in the torrents path that is a .torrent file, load it into the engine.
    foreach (string file in Directory.GetFiles(torrentsPath))
    {
        if (file.EndsWith(".torrent"))
        {
            try
            {
                // Load the .torrent from the file into a Torrent instance
                // You can use this to do preprocessing should you need to
                torrent = Torrent.Load(file);
                Console.WriteLine(torrent.InfoHash.ToString());
            }
            catch (Exception e)
            {
                Console.Write("Couldn't decode {0}: ", file);
                Console.WriteLine(e.Message);
                continue;
            }
        }
    }
        DhtListener listener = new DhtListener(new IPEndPoint(IPAddress.Parse("192.168.2.3"), 10000));
        DhtEngine engine = new DhtEngine(listener);

        //engine.RegisterDht(dht);

        byte[] nodes = null;
        if (File.Exists("mynodes"))
            nodes = File.ReadAllBytes("mynodes");

        listener.Start();
        int i = 0;
        bool running = true;
        StringBuilder sb = new StringBuilder(1024);
        while (running)
        {
            engine.Start(nodes);

            while (Console.ReadLine() != "q")
            {
                engine.GetPeers(torrent.InfoHash);
            }
            File.WriteAllBytes("mynodes", engine.SaveNodes());
        }
    }
}

}

4

1 に答える 1

0

それが非常に古い質問であることは知っていますが、なぜまだ誰も答えていないのかわかりません。問題は次の行のようです。

DhtListener listener = new DhtListener(new IPEndPoint(IPAddress.Parse("192.168.2.3"), 10000));

この ip は実際の ip ではないため、実際には asl ピアを使用して unkonw アドレスに応答を送信します。何をすべきか?自分の住所を登録します。

于 2016-01-21T16:45:11.173 に答える