Exemple #1
0
        public override void Handle(IDhtEngine engine, Node node)
        {
            base.Handle(engine, node);

            DhtMessage response;

            if (engine.TokenManager.VerifyToken(node, Token))
            {
                engine.GetAnnounced(new InfoHash(InfoHash.Bytes),
                                    new IPEndPoint(node.EndPoint.Address, (int)Port.Number));
                response = new AnnouncePeerResponse(engine.GetNeighborId(Id), TransactionId);
            }
            else
            {
                response = new ErrorMessage(ErrorCode.ProtocolError, "Invalid or expired token received");
            }

            engine.Send(response, node.EndPoint);
        }