コード例 #1
0
 public override void HandlePeerConnected(PeerId id, MonoTorrent.Common.Direction direction)
 {
     if (!ShouldConnect(id))
     {
         id.CloseConnection();
     }
     base.HandlePeerConnected(id, direction);
 }
コード例 #2
0
        internal static IAsyncResult BeginCheckEncryption(PeerId id, int bytesToReceive, AsyncCallback callback, object state, InfoHash[] sKeys)
        {
            EncryptorAsyncResult result = new EncryptorAsyncResult(id, callback, state);
            result.SKeys = sKeys;

            IConnection c = id.Connection;
            ClientEngine.MainLoop.QueueTimeout(TimeSpan.FromSeconds(10), delegate {
                if (id.Encryptor == null || id.Decryptor == null)
                    id.CloseConnection();
                return false;
            });

            try
            {
                // If the connection is incoming, receive the handshake before
                // trying to decide what encryption to use
                if (id.Connection.IsIncoming)
                {
                    result.Buffer = new byte[bytesToReceive];
                    NetworkIO.EnqueueReceive(c, result.Buffer, 0, result.Buffer.Length, null, null, null, HandshakeReceivedCallback, result);
                }
                else
                {
                    EncryptionTypes usable = CheckRC4(id);
                    bool hasPlainText = Toolbox.HasEncryption(usable, EncryptionTypes.PlainText);
                    bool hasRC4 = Toolbox.HasEncryption(usable, EncryptionTypes.RC4Full) || Toolbox.HasEncryption(usable, EncryptionTypes.RC4Header);
                    if (id.Engine.Settings.PreferEncryption)
                    {
                        if (hasRC4)
                        {
                            result.EncSocket = new PeerAEncryption(id.TorrentManager.InfoHash, usable);
                            result.EncSocket.BeginHandshake(id.Connection, CompletedEncryptedHandshakeCallback, result);
                        }
                        else
                        {
                            result.Complete();
                        }
                    }
                    else
                    {
                        if (hasPlainText)
                        {
                            result.Complete();
                        }
                        else
                        {
                            result.EncSocket = new PeerAEncryption(id.TorrentManager.InfoHash, usable);
                            result.EncSocket.BeginHandshake(id.Connection, CompletedEncryptedHandshakeCallback, result);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                result.Complete(ex);
            }
            return result;
        }
コード例 #3
0
 public override void HandlePeerConnected(PeerId id, Direction direction)
 {
     id.CloseConnection();
 }
コード例 #4
0
ファイル: HashingMode.cs プロジェクト: mkirov0/MultiPoolMiner
 public override void HandlePeerConnected(PeerId id, MonoTorrent.Common.Direction direction)
 {
     id.CloseConnection();
 }
コード例 #5
0
ファイル: StoppingMode.cs プロジェクト: dontnod/monotorrent
		public override void HandlePeerConnected(PeerId id, MonoTorrent.Common.Direction direction)
		{
			id.CloseConnection();
		}
コード例 #6
0
 public override void HandlePeerConnected(PeerId id, Direction direction)
 {
     if (!ShouldConnect(id))
         id.CloseConnection();
     base.HandlePeerConnected(id, direction);
 }
コード例 #7
0
 public override void HandlePeerConnected(PeerId id, Direction direction)
 {
     id.CloseConnection();
 }