Example #1
0
        private void ConnectionReceived(object sender, NewConnectionEventArgs e)
        {
            if (_engine.ConnectionManager.ShouldBanPeer(e.Peer))
            {
                e.Connection.Dispose();
                return;
            }
            var id = new PeerId(e.Peer, e.TorrentManager) {Connection = e.Connection};

            Logger.Log(id.Connection, "ListenManager - ConnectionReceived");

            if (id.Connection.IsIncoming)
            {
                var skeys = new List<InfoHash>();

                ClientEngine.MainLoop.QueueWait(delegate
                                                    {
                                                        for (var i = 0; i < _engine.Torrents.Count; i++)
                                                            skeys.Add(_engine.Torrents[i].InfoHash);
                                                    });

                EncryptorFactory.BeginCheckEncryption(id, HandshakeMessage.HandshakeLength, _endCheckEncryptionCallback,
                                                      id, skeys.ToArray());
            }
            else
            {
                ClientEngine.MainLoop.Queue(() => _engine.ConnectionManager.ProcessFreshConnection(id));
            }
        }
Example #2
0
        private void ConnectionReceived(object sender, NewConnectionEventArgs e)
        {
            if (_engine.ConnectionManager.ShouldBanPeer(e.Peer))
            {
                e.Connection.Dispose();
                return;
            }
            var id = new PeerId(e.Peer, e.TorrentManager)
            {
                Connection = e.Connection
            };

            Logger.Log(id.Connection, "ListenManager - ConnectionReceived");

            if (id.Connection.IsIncoming)
            {
                var skeys = new List <InfoHash>();

                ClientEngine.MainLoop.QueueWait(delegate
                {
                    for (var i = 0; i < _engine.Torrents.Count; i++)
                    {
                        skeys.Add(_engine.Torrents[i].InfoHash);
                    }
                });

                EncryptorFactory.BeginCheckEncryption(id, HandshakeMessage.HandshakeLength, _endCheckEncryptionCallback,
                                                      id, skeys.ToArray());
            }
            else
            {
                ClientEngine.MainLoop.Queue(() => _engine.ConnectionManager.ProcessFreshConnection(id));
            }
        }