Esempio n. 1
0
        public void  Receive_CrawlAck(CrawlAck ack, G2ReceivedPacket packet)
        {
            DhtContact source = new DhtContact(ack.Source, packet.Source.IP);

            if (!CrawlMap.ContainsKey(source.RoutingID))
            {
                return;
            }

            CrawlNode node = CrawlMap[source.RoutingID];

            node.Ack = ack;

            foreach (DhtContact contact in ack.ProxyServers)
            {
                if (!CrawlMap.ContainsKey(contact.RoutingID))
                {
                    CrawlMap[contact.RoutingID] = new CrawlNode(contact);
                }
            }

            foreach (DhtContact contact in ack.ProxyClients)
            {
                if (!CrawlMap.ContainsKey(contact.RoutingID))
                {
                    CrawlNode newNode = new CrawlNode(contact);
                    newNode.Proxy = node;

                    CrawlMap[contact.RoutingID] = newNode;
                }
            }
        }
Esempio n. 2
0
        string GetProxyIDs(bool server, CrawlNode node)
        {
            List <DhtContact> list = server ? node.Ack.ProxyClients : node.Ack.ProxyServers;

            string idList = "";

            foreach (DhtContact contact in list)
            {
                idList += contact.UserID + ", ";
            }

            if (idList.Length > 0)
            {
                idList = idList.Substring(0, idList.Length - 2);
            }

            return(idList);
        }
Esempio n. 3
0
        public void Receive_CrawlAck(CrawlAck ack, G2ReceivedPacket packet)
        {
            DhtContact source = new DhtContact(ack.Source, packet.Source.IP);

            if (!CrawlMap.ContainsKey(source.RoutingID))
                return;

            CrawlNode node = CrawlMap[source.RoutingID];

            node.Ack = ack;

            foreach(DhtContact contact in ack.ProxyServers)
                if (!CrawlMap.ContainsKey(contact.RoutingID))
                    CrawlMap[contact.RoutingID] = new CrawlNode(contact);

            foreach(DhtContact contact in ack.ProxyClients)
                if (!CrawlMap.ContainsKey(contact.RoutingID))
                {
                    CrawlNode newNode = new CrawlNode(contact);
                    newNode.Proxy = node;

                    CrawlMap[contact.RoutingID] = newNode;
                }
        }
Esempio n. 4
0
        private void SecondTimer_Tick(object sender, System.EventArgs e)
        {
            if (Status != CrawlStatus.Active)
            {
                return;
            }


            // Total Crawled
            int crawled = 0;

            foreach (CrawlNode node in CrawlMap.Values)
            {
                if (node.Ack != null)
                {
                    crawled++;
                }
            }

            labelCount.Text = crawled.ToString() + " Crawled";


            // Send Packets
            int sendPackets = 20;

            foreach (CrawlNode nodeX in CrawlMap.Values)
            {
                // if async funcs called with nodeX, then they get reset with each loop, give node its own object
                CrawlNode node = nodeX;

                // send crawl request
                if (node.Ack == null && node.Attempts < 3 && Core.TimeNow > node.NextTry)
                {
                    CrawlNode targetNode = node.OpenConnection ? node : node.Proxy;

                    Core.RunInCoreAsync(delegate()
                    {
                        Network.Send_CrawlRequest(targetNode.Contact, node.Contact);
                    });

                    sendPackets--;

                    node.Attempts++;
                    node.NextTry = Core.TimeNow.AddSeconds(15);
                }

                if (node.OpenConnection && !node.Searched)
                {
                    Core.RunInCoreAsync(delegate()
                    {
                        Network.Searches.SendRequest(node.Contact, node.Contact.UserID + 1, 0, Core.DhtServiceID, 0, null);
                    });

                    node.Searched = true;
                    sendPackets--;
                }

                if (sendPackets <= 0)
                {
                    break;
                }
            }
        }
Esempio n. 5
0
        string GetProxyIDs(bool server, CrawlNode node)
        {
            List<DhtContact> list = server ? node.Ack.ProxyClients : node.Ack.ProxyServers;

            string idList = "";
            foreach (DhtContact contact in list)
                idList += contact.UserID + ", ";

            if(idList.Length > 0)
                idList = idList.Substring(0, idList.Length - 2);

            return idList;
        }