public BEncodedValue Handle(PeerDetails d, TorrentEvent e, ITrackable trackable)
        {
            var c = new NameValueCollection();
            c.Add("info_hash", trackable.InfoHash.UrlEncode());
            c.Add("peer_id", d.peerId);
            c.Add("port", d.Port.ToString());
            c.Add("uploaded", d.Uploaded.ToString());
            c.Add("downloaded", d.Downloaded.ToString());
            c.Add("left", d.Remaining.ToString());
            c.Add("compact", "0");

            return base.Handle(c, d.ClientAddress, false);
        }
Esempio n. 2
0
        public BEncodedValue Handle(PeerDetails peerDetails, ITrackable trackable)
        {
            var c = new NameValueCollection
                        {
                            {"info_hash", trackable.InfoHash.UrlEncode()},
                            {"peer_id", peerDetails.PeerId},
                            {"port", peerDetails.Port.ToString(CultureInfo.InvariantCulture)},
                            {"uploaded", peerDetails.Uploaded.ToString(CultureInfo.InvariantCulture)},
                            {"downloaded", peerDetails.Downloaded.ToString(CultureInfo.InvariantCulture)},
                            {"left", peerDetails.Remaining.ToString(CultureInfo.InvariantCulture)},
                            {"compact", "0"}
                        };

            return base.Handle(c, peerDetails.ClientAddress, false);
        }
Esempio n. 3
0
 private void GeneratePeers()
 {
     Peers = new List<PeerDetails>();
     for (var i = 0; i < 100; i++)
     {
         var peerDetails = new PeerDetails
                     {
                         ClientAddress = IPAddress.Parse(string.Format("127.0.{0}.2", i)),
                         Downloaded = (int) (10000*_random.NextDouble()),
                         PeerId = string.Format("-----------------{0:0.000}", i),
                         Port = _random.Next(65000),
                         Remaining = _random.Next(10000, 100000),
                         Uploaded = _random.Next(10000, 100000)
                     };
         Peers.Add(peerDetails);
     }
 }