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 }); }
private static void WantCheckFirewall(UdpItem item, UdpListener udp, ulong time) { UdpPacketReader packet = new UdpPacketReader(item.Data); ushort port = packet; FirewallTest fw = udp.TestRemoteFirewall; if (fw != null) { fw.Cookie = AccountManager.NextCookie; fw.EndPoint = item.EndPoint; fw.Time = time; udp.SendDatagram(new UdpItem { Data = UdpOutbound.ReadyCheckFirewall(fw), EndPoint = item.EndPoint, Msg = UdpMsg.OP_SERVERLIST_READYTOCHECKFIREWALL }); } else { udp.SendDatagram(new UdpItem { Data = UdpOutbound.CheckFirewallBusy(((IPEndPoint)item.EndPoint).Address, time), EndPoint = item.EndPoint, Msg = UdpMsg.OP_SERVERLIST_CHECKFIREWALLBUSY }); } }
public void TestNext(UdpListener udp) { if (this.nodes.Count > 0) { udp.SendDatagram(new UdpItem { Data = UdpOutbound.WantCheckFirewall(), EndPoint = this.nodes.Dequeue(), Msg = UdpMsg.OP_SERVERLIST_WANTCHECKFIREWALL }); } }
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 }); } }
private static void SendInfo(UdpItem item, UdpListener udp, ulong time) { if (udp.Showing) { UdpStats.SENDINFO++; udp.SendDatagram(new UdpItem { Data = UdpOutbound.AckInfo(time), EndPoint = item.EndPoint, Msg = UdpMsg.OP_SERVERLIST_ACKINFO }); } }
private static void ReadyToCheckFirewall(UdpItem item, UdpListener udp, ulong time) { UdpPacketReader packet = new UdpPacketReader(item.Data); uint cookie = packet; if (!udp.ServerAddressReceived) { udp.ServerAddressReceived = true; Settings.ExternalIP = packet; ServerCore.Log("server address reported as " + Settings.ExternalIP); } udp.SendDatagram(new UdpItem { Data = UdpOutbound.ProceedCheckFirewall(cookie), EndPoint = item.EndPoint, Msg = UdpMsg.OP_SERVERLIST_PROCEEDCHECKFIREWALL }); udp.AddChecker(((IPEndPoint)item.EndPoint).Address); }
private static void SendNodes(UdpItem item, UdpListener udp, ulong time) { var linq = from x in UserPool.AUsers where x.NodePort > 0 && (x.Version.StartsWith("Ares 2.") || x.Version.StartsWith("Ares_2.")) select new IPEndPoint(x.ExternalIP, x.DataPort); if (linq.Count() > 0) { List <IPEndPoint> nodes = linq.ToList(); nodes.Randomize(); if (nodes.Count > 20) { nodes = nodes.GetRange(0, 20); } udp.SendDatagram(new UdpItem { Data = UdpOutbound.AckNodes(nodes.ToArray()), EndPoint = item.EndPoint, Msg = UdpMsg.OP_SERVERLIST_ACKNODES }); } }