Exemple #1
0
        private async void DownloadThread(object state)
        {
            var socket = new AresUdpSocket(new ChannelFormatter());

            socket.PacketReceived += UdpPacketReceived;
            socket.ReceiveAsync();

            int i = 0;

            while (IsDownloading)
            {
                DateTime now = DateTime.Now;
                Channels
                .Skip(i)
                .Take(10)
                .ForEach(s => {
                    s.LastSendInfo = now;
                    socket.SendAsync(
                        new SendInfo(),
                        new IPEndPoint(s.ExternalIp, s.Port));
                });

                i = Math.Min(Channels.Count, i + 10);
                await CheckDownloadTimeout(socket);
            }
        }
Exemple #2
0
        private void OnTimer(object state)
        {
            if (running)
            {
                if (TestingFirewall)
                {
                    CheckFirewall();
                }

                else if (Listing)
                {
                    AresChannel tosend = GetOldestContacted();

                    if (tosend != null)
                    {
                        uint num = 6;
                        socket.SendAsync(
                            new AddIps(
                                (ushort)socket.LocalEndPoint.Port,
                                GetSendServers(tosend.ExternalIp, ref num)),
                            new IPEndPoint(tosend.ExternalIp, tosend.Port));
                    }

                    DateTime now = DateTime.Now;

                    if (now.Subtract(lastmars).TotalMinutes >= 10)
                    {
                        lastmars = now;
                        UpdateMars();
                        UpdateZorbo();
                    }

                    if (now.Subtract(lastexpire).TotalMinutes >= 1)
                    {
                        lastexpire = now;
                        PurgeOld();
                    }

                    if (now.Subtract(lastpurge).TotalMinutes >= 10)
                    {
                        lastpurge = now;
                        PurgeExceeding();
                    }
                }

                ExpireBans();
            }
        }
Exemple #3
0
        private void OnTimer(object state)
        {
            if (running)
            {
                if (!FinishedTestingFirewall)
                {
                    CheckFirewall();
                }

                else if (server.Config.ShowChannel)
                {
                    ServerRecord tosend = GetOldestContacted();

                    if (tosend != null)
                    {
                        uint num = 6;

                        socket.SendAsync(
                            new AddIps(server.Config.Port, GetSendServers(tosend.ExternalIp, ref num)),
                            new IPEndPoint(tosend.ExternalIp, tosend.Port));
                    }

                    DateTime now = TimeBank.CurrentTime;

                    if (now.Subtract(lastexpire).TotalMinutes >= 1)
                    {
                        lastexpire = now;
                        PurgeOld();
                    }

                    if (now.Subtract(lastpurge).TotalMinutes >= 10)
                    {
                        lastpurge = now;
                        PurgeExceeding();
                    }
                }
            }
        }