private static void AddIps(UdpItem item, UdpListener udp, ulong time)
        {
            UdpPacketReader packet = new UdpPacketReader(item.Data);
            ushort          port   = packet;
            UdpNode         node   = UdpNodeManager.Find(x => x.IP.Equals(((IPEndPoint)item.EndPoint).Address));

            if (node != null)
            {
                node.Port = port;
            }
            else
            {
                UdpNodeManager.Add(item.EndPoint);
            }

            while (packet.Remaining > 5)
            {
                UdpNode n = new UdpNode();
                n.IP   = packet;
                n.Port = packet;
                UdpNodeManager.Add(n);
            }

            udp.SendDatagram(new UdpItem
            {
                Data     = UdpOutbound.AckIps(((IPEndPoint)item.EndPoint).Address, time),
                EndPoint = item.EndPoint,
                Msg      = UdpMsg.OP_SERVERLIST_ACKIPS
            });
        }
 public void PopulateNodes()
 {
     foreach (UdpNode node in UdpNodeManager.GetServers())
     {
         this.nodes.Enqueue(node.EndPoint);
     }
 }
Пример #3
0
        public static void Update()
        {
            UdpNode[] nodes = UdpNodeManager.GetServers();

            if (nodes.Length > 0)
            {
                Thread thread = new Thread(new ParameterizedThreadStart(BackgroundWorker));
                thread.Start(nodes);
            }
        }
        private static void CheckFirewallBusy(UdpItem item, UdpListener udp, ulong time)
        {
            UdpPacketReader packet = new UdpPacketReader(item.Data);
            ushort          port   = packet;

            while (packet.Remaining > 5)
            {
                UdpNode n = new UdpNode();
                n.IP   = packet;
                n.Port = packet;
                UdpNodeManager.Add(n);
            }
        }
        public void Start()
        {
            UdpStats.Reset();
            UdpNodeManager.Initialize();

            this.TcpTester.PopulateNodes();
            this.Showing          = Settings.Get <bool>("udp");
            this.Timer_1_Second   = Time.Now;
            this.Timer_1_Minute   = Time.Now;
            this.Timer_15_Minutes = Time.Now;
            this.Sock             = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            this.Sock.Blocking    = false;
            this.Sock.Bind(this.EndPoint);
        }
        private void Push(ulong time)
        {
            UdpNode node = UdpNodeManager.NextPusher(time);

            if (node != null)
            {
                this.SendDatagram(new UdpItem
                {
                    Data     = UdpOutbound.AddIps(node.IP, time),
                    EndPoint = node.EndPoint,
                    Msg      = UdpMsg.OP_SERVERLIST_ADDIPS
                });
            }
        }
Пример #7
0
        public static byte[] AckIps(IPAddress target_ip, ulong time)
        {
            UdpPacketWriter packet = new UdpPacketWriter();

            packet.WriteUInt16(Settings.Port);

            UdpNode[] servers = UdpNodeManager.GetServers(target_ip, 6, time);

            foreach (UdpNode s in servers)
            {
                packet.WriteIP(s.IP);
                packet.WriteUInt16(s.Port);
            }

            return(packet.ToAresPacket(UdpMsg.OP_SERVERLIST_ACKIPS));
        }
Пример #8
0
        public static byte[] CheckFirewallBusy(IPAddress target_ip, ulong time)
        {
            UdpPacketWriter packet = new UdpPacketWriter();

            packet.WriteUInt16(Settings.Port);

            UdpNode[] servers = UdpNodeManager.GetServers(target_ip, 6, time);

            foreach (UdpNode s in servers)
            {
                packet.WriteIP(s.IP);
                packet.WriteUInt16(s.Port);
            }

            return(packet.ToAresPacket(UdpMsg.OP_SERVERLIST_CHECKFIREWALLBUSY));
        }
        public void ServiceUdp(ulong time)
        {
            this.SendReceive();

            while (this.data_in.Count > 0)
            {
                try
                {
                    UdpProcessor.Eval(this.data_in.Dequeue(), this, time);
                }
                catch { }
            }

            if ((this.Timer_1_Second + 1000) < time)
            {
                this.Timer_1_Second = time;
                this.firewall_tests.ForEachWhere(x => x.Stop(), x => (x.Time + 10000) < time);
                this.firewall_tests.RemoveAll(x => x.Completed);

                if (this.TcpTester.IsTesting)
                {
                    this.TcpTester.TestNext(this);
                }
                else if (this.Showing)
                {
                    this.Push(time);
                }
            }

            if ((this.Timer_1_Minute + 60000) < time)
            {
                this.Timer_1_Minute = time;
                this.TcpTester.Timeout();
                UdpNodeManager.Expire(time);
            }

            if ((this.Timer_15_Minutes + 900000) < time)
            {
                this.Timer_15_Minutes = time;
                UdpNodeManager.Update(time);
                ServerCore.Log("local node list updated [" + UdpStats.SENDINFO + ":" + UdpStats.ACKINFO + ":" + UdpStats.ADDIPS + ":" + UdpStats.ACKIPS + "]");
                UdpStats.Reset();
            }
        }
Пример #10
0
        public static byte[] AckInfo(ulong time)
        {
            UdpPacketWriter packet = new UdpPacketWriter();

            packet.WriteUInt16(Settings.Port);
            packet.WriteUInt16(UserPool.UserCount);
            packet.WriteString(Settings.Name);
            packet.WriteString(Settings.Topic);
            packet.WriteByte(Settings.Language);
            packet.WriteString(Settings.VERSION);
            UdpNode[] servers = UdpNodeManager.GetServers(6, time);
            packet.WriteByte((byte)servers.Length);

            foreach (UdpNode s in servers)
            {
                packet.WriteIP(s.IP);
                packet.WriteUInt16(s.Port);
            }

            return(packet.ToAresPacket(UdpMsg.OP_SERVERLIST_ACKINFO));
        }
        private static void AckIps(UdpItem item, UdpListener udp, ulong time)
        {
            UdpStats.ACKIPS++;
            UdpPacketReader packet = new UdpPacketReader(item.Data);
            ushort          port   = packet;
            UdpNode         node   = UdpNodeManager.Find(x => x.IP.Equals(((IPEndPoint)item.EndPoint).Address));

            if (node != null)
            {
                node.Port = port;
                node.Ack++;
                node.LastConnect = time;
                node.Try         = 0;
            }

            while (packet.Remaining > 5)
            {
                UdpNode n = new UdpNode();
                n.IP   = packet;
                n.Port = packet;
                UdpNodeManager.Add(n);
            }
        }