Exemplo n.º 1
0
        public async Task Setup(bool metadataMode, bool multiFile = false, bool metadataOnly = false)
        {
            pair = new ConnectionPair().WithTimeout();
            rig  = multiFile ? TestRig.CreateMultiFile(32768, metadataMode) : TestRig.CreateSingleFile(1024 * 1024 * 1024, 32768, metadataMode);
            rig.RecreateManager().Wait();

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

            rig.AddConnection(pair.Outgoing);

            var    connection = pair.Incoming;
            PeerId id         = new PeerId(new Peer("", connection.Uri), connection, rig.Manager.Bitfield?.Clone().SetAll(false));

            var result = await EncryptorFactory.CheckIncomingConnectionAsync(id.Connection, id.Peer.AllowedEncryption, new[] { rig.Manager.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();

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

            var connection = pair.Incoming;
            var id = new PeerId(new Peer("", connection.Uri), rig.Manager);
            id.Connection = connection;
            byte[] data;

            EncryptorFactory.EndCheckEncryption(
                EncryptorFactory.BeginCheckEncryption(id, 68, null, null, new[] {id.TorrentManager.InfoHash}),
                out data);
            decryptor = id.Decryptor;
            encryptor = id.Encryptor;
        }
Exemplo n.º 3
0
        public async Task Setup(bool metadataMode, bool multiFile = false, bool metadataOnly = false)
        {
            pair = new ConnectionPair().WithTimeout();
            rig  = multiFile ? TestRig.CreateMultiFile(32768, metadataMode) : TestRig.CreateSingleFile(Piece.BlockSize * 27, Piece.BlockSize * 2, metadataMode);
            rig.RecreateManager().Wait();

            // Mark the torrent as hash check complete with no data downloaded
            if (rig.Manager.HasMetadata)
            {
                rig.Manager.LoadFastResume(new FastResume(rig.Manager.InfoHash, rig.Manager.Bitfield.Clone().SetAll(false), rig.Manager.Bitfield.Clone().SetAll(false)));
            }
            await rig.Manager.StartAsync(metadataOnly);

            rig.AddConnection(pair.Outgoing);

            var    connection = pair.Incoming;
            PeerId id         = new PeerId(new Peer("", connection.Uri), connection, rig.Manager.Bitfield?.Clone().SetAll(false));

            var result = await EncryptorFactory.CheckIncomingConnectionAsync(id.Connection, id.Peer.AllowedEncryption, new[] { rig.Manager.InfoHash });

            decryptor = id.Decryptor = result.Decryptor;
            encryptor = id.Encryptor = result.Encryptor;
        }