示例#1
0
        public async Task SingleFileTorrent()
        {
            rig.Dispose();
            rig = TestRig.CreateSingleFile();
            rig.Torrent.HttpSeeds.Add($"{ListenerURL}File1.exe");

            string url = rig.Torrent.HttpSeeds[0];

            connection         = new HttpConnection(new Uri(url));
            connection.Manager = rig.Manager;
            rig.Manager.UnhashedPieces.SetAll(false);

            id              = new PeerId(new Peer("this is my id", connection.Uri), id.Connection, rig.Manager.Bitfield?.Clone().SetAll(false));
            id.IsChoking    = false;
            id.AmInterested = true;
            id.BitField.SetAll(true);
            id.MaxPendingRequests = numberOfPieces;
            id.MessageQueue.SetReady();

            rig.Manager.PieceManager.AddPieceRequests(id);
            requests = (RequestBundle)id.MessageQueue.TryDequeue();
            await ReceiveFirst();

            Assert.AreEqual(url, requestedUrl[0]);
        }
示例#2
0
        public void SingleFileTorrent()
        {
            rig.Dispose();
            rig = TestRig.CreateSingleFile();
            string url = rig.Torrent.GetRightHttpSeeds[0];

            connection         = new HttpConnection(new Uri(url));
            connection.Manager = rig.Manager;

            id              = new PeerId(new Peer("this is my id", connection.Uri), rig.Manager);
            id.Connection   = connection;
            id.IsChoking    = false;
            id.AmInterested = true;
            id.BitField.SetAll(true);
            id.MaxPendingRequests = numberOfPieces;

            requests = rig.Manager.PieceManager.Picker.PickPiece(id, new List <PeerId>(), numberOfPieces);
            RecieveFirst();
            Assert.AreEqual(url, requestedUrl[0]);
        }
示例#3
0
        public async Task Setup(bool metadataMode, string metadataPath)
        {
            pair             = new ConnectionPair(55432);
            rig              = TestRig.CreateSingleFile(1024 * 1024 * 1024, 32768, metadataMode);
            rig.MetadataPath = metadataPath;
            rig.RecreateManager().Wait();

            rig.Manager.HashChecked = true;
            await rig.Manager.StartAsync();

            rig.AddConnection(pair.Outgoing);

            var    connection = pair.Incoming;
            PeerId id         = new PeerId(new Peer("", connection.Uri), rig.Manager, connection);

            var result = await EncryptorFactory.CheckIncomingConnectionAsync(id.Connection, id.Peer.AllowedEncryption, rig.Engine.Settings, HandshakeMessage.HandshakeLength, new InfoHash[] { id.TorrentManager.InfoHash });

            decryptor = id.Decryptor = result.Decryptor;
            encryptor = id.Encryptor = result.Encryptor;
        }
        public void Setup(bool metadataMode, string metadataPath)
        {
            pair             = new ConnectionPair(55432);
            rig              = TestRig.CreateSingleFile(1024 * 1024 * 1024, 32768, metadataMode);
            rig.MetadataPath = metadataPath;
            rig.RecreateManager().Wait();

            rig.Manager.HashChecked = true;
            rig.Manager.Start();
            rig.AddConnection(pair.Outgoing);

            var    connection = pair.Incoming;
            PeerId id         = new PeerId(new Peer("", connection.Uri), rig.Manager);

            id.Connection = connection;


            byte[] data = EncryptorFactory.CheckEncryptionAsync(id, 68, new InfoHash[] { id.TorrentManager.InfoHash }).Result;
            decryptor = id.Decryptor;
            encryptor = id.Encryptor;
        }
示例#5
0
        public async Task SingleFileTorrent()
        {
            rig.Dispose();
            rig = TestRig.CreateSingleFile();
            string url = rig.Torrent.GetRightHttpSeeds[0];

            connection         = new HttpConnection(new Uri(url));
            connection.Manager = rig.Manager;
            rig.Manager.UnhashedPieces.SetAll(false);

            id              = new PeerId(new Peer("this is my id", connection.Uri), id.Connection, rig.Manager.Bitfield?.Clone().SetAll(false));
            id.IsChoking    = false;
            id.AmInterested = true;
            id.BitField.SetAll(true);
            id.MaxPendingRequests = numberOfPieces;

            requests = new MessageBundle(rig.Manager.PieceManager.Picker.PickPiece(id, id.BitField, new List <PeerId>(), numberOfPieces));
            await RecieveFirst();

            Assert.AreEqual(url, requestedUrl[0]);
        }
 public void Setup()
 {
     Rig = TestRig.CreateSingleFile(Piece.BlockSize * 20, Piece.BlockSize * 2);
     Rig.Manager.Bitfield.Not();
     Rig.Manager.Mode = new InitialSeedingMode(Rig.Manager);
 }