Example #1
0
        void server_PacketReceived(object sender, UdpPacketReceivedEventArgs e)
        {
            var packet  = e.Packet;
            var reader  = packet.GetReader();
            var request = new IPRequestPacket1(reader);

            if (request.Type3 == 0x14) // only type we handle right now?
            {
                Log.Debug("Handling IP request from " + request.XUID.ToString("X16"));

                bool breakNAT = false;

                if (!Client.IsHostAllowed(request.XUID))
                {
                    breakNAT = true;
                }

                /*var lclient = Client.Get(request.XUID);
                 *                 bool breakGame = false;
                 * if (lclient.GameVersion != 0)
                 * {
                 *  if (!Client.IsVersionAllowed(lclient.GameVersion, lclient.GameBuild))
                 *  {
                 *      breakGame = true;
                 *  }
                 * }*/

                // we don't have what client thinks is his port, but this is just an override anyway
                var responsePacket = new IPResponsePacket1(packet.GetSource(), request.Sequence, false, breakNAT);

                var response = packet.MakeResponse();
                responsePacket.Write(response.GetWriter());
                response.Send();

                if (!breakNAT && packet.GetSource().Port >= 28960 && packet.GetSource().Port <= 29960)
                {
                    responsePacket = new IPResponsePacket1(packet.GetSource(), request.Sequence, true, false);

                    response = packet.MakeResponse();
                    responsePacket.Write(response.GetWriter());
                    response.Send();
                }
            }

            // and afterwards, update client's stuff
            var client = Client.Get(request.XUID);

            client.SetLastTouched();
        }
Example #2
0
        void server_PacketReceived(object sender, UdpPacketReceivedEventArgs e)
        {
            var packet = e.Packet;
            var reader = packet.GetReader();
            var request = new IPRequestPacket1(reader);

            if (request.Type3 == 0x14) // only type we handle right now?
            {
                Log.Debug("Handling IP request from " + request.XUID.ToString("X16"));

                bool breakGame = false;
                bool breakNAT = false;

                if (!Client.IsHostAllowed(request.XUID))
                {
                    breakNAT = true;
                }

                /*var lclient = Client.Get(request.XUID);
                if (lclient.GameVersion != 0)
                {
                    if (!Client.IsVersionAllowed(lclient.GameVersion, lclient.GameBuild))
                    {
                        breakGame = true;
                    }
                }*/

                // we don't have what client thinks is his port, but this is just an override anyway
                var responsePacket = new IPResponsePacket1(packet.GetSource(), request.Sequence, false, breakNAT);

                var response = packet.MakeResponse();
                responsePacket.Write(response.GetWriter());
                response.Send();

                if (!breakNAT && packet.GetSource().Port >= 28960 && packet.GetSource().Port <= 29960)
                {
                    responsePacket = new IPResponsePacket1(packet.GetSource(), request.Sequence, true, false);

                    response = packet.MakeResponse();
                    responsePacket.Write(response.GetWriter());
                    response.Send();
                }
            }

            // and afterwards, update client's stuff
            var client = Client.Get(request.XUID);
            client.SetLastTouched();
        }