Exemplo n.º 1
0
        public void EncryptorFactoryPeerAPlain()
        {
            rig.Engine.StartAll();

            rig.AddConnection(conn.Incoming);

            HandshakeMessage message = new HandshakeMessage(rig.Manager.InfoHash, "ABC123ABC123ABC123AB", VersionInfo.ProtocolStringV100);

            byte[] buffer = message.Encode();

            conn.Outgoing.EndSend(conn.Outgoing.BeginSend(buffer, 0, buffer.Length, null, null));
            conn.Outgoing.EndReceive(conn.Outgoing.BeginReceive(buffer, 0, buffer.Length, null, null));

            message.Decode(buffer, 0, buffer.Length);
            Assert.Equal(VersionInfo.ProtocolStringV100, message.ProtocolString);
        }
Exemplo n.º 2
0
        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;
            PeerId id         = new PeerId(new Peer("", connection.Uri), rig.Manager);

            id.Connection = connection;
            byte[] data;

            EncryptorFactory.EndCheckEncryption(EncryptorFactory.BeginCheckEncryption(id, 68, null, null, new InfoHash[] { id.TorrentManager.InfoHash }), out data);
            decryptor = id.Decryptor;
            encryptor = id.Encryptor;
        }
 public void IncomingEncrypted()
 {
     rig.Engine.Settings.PreferEncryption = true;
     rig.AddConnection(pair.Outgoing);
     InitiateTransfer(pair.Incoming);
 }