public override void Handle(DhtEngine engine, Node node) { base.Handle(engine, node); if (!engine.Torrents.ContainsKey(InfoHash)) { engine.Torrents.Add(InfoHash, new List <Node>()); } Message response; if (engine.TokenManager.VerifyToken(node, Token)) { engine.Torrents[InfoHash].Add(node); response = new AnnouncePeerResponse(engine.RoutingTable.LocalNode.Id, TransactionId); } else { response = new ErrorMessage(ErrorCode.ProtocolError, "Invalid or expired token received"); } engine.MessageLoop.EnqueueSend(response, node.EndPoint); }
public void AnnouncePeerResponseEncode() { var message = new AnnouncePeerResponse(_infohash, _transactionId); Compare(message, "d1:rd2:id20:mnopqrstuvwxyz123456e1:t2:aa1:y1:re"); }
public override void Handle(DhtEngine engine, Node node) { base.Handle(engine, node); if (!engine.Torrents.ContainsKey(InfoHash)) engine.Torrents.Add(InfoHash, new List<Node>()); Message response; if (engine.TokenManager.VerifyToken(node, Token)) { engine.Torrents[InfoHash].Add(node); response = new AnnouncePeerResponse(engine.RoutingTable.LocalNode.Id, TransactionId); } else response = new ErrorMessage(ErrorCode.ProtocolError, "Invalid or expired token received"); engine.MessageLoop.EnqueueSend(response, node.EndPoint); }