Beispiel #1
0
        public static bool Prefix(CSteamID steamID, byte[] packet, int offset, int size, int channel)
        {
            if (!Dedicator.isDedicated)
            {
                return(true);
            }
            byte index1 = packet[offset];

            if (!(index1 < (byte)26))
            {
                UnityEngine.Debug.LogWarning((object)("Received invalid packet index from " + (object)steamID + ", so we're refusing them"));
                SDG.Unturned.Provider.refuseGarbageConnection(steamID, "sv invalid packet index");
            }
            else
            {
                ESteamPacket packet1 = (ESteamPacket)index1;
                if (packet1 == ESteamPacket.AUTHENTICATE || packet1 == ESteamPacket.CONNECT)
                {
                    Console.WriteLine(packet1);
                }
                if (packet1 == ESteamPacket.CONNECT)
                {
                    RocketPlayer player = new RocketPlayer(steamID.ToString());
                    bool         result = player.HasPermission("QueueBypasser.Skip");
                    Console.WriteLine(result);
                    if (!result)
                    {
                        return(true); //We don't need to do jack shit because he doesn't have the right permission.
                    }
                    for (int index2 = 0; index2 < SDG.Unturned.Provider.pending.Count; ++index2)
                    {
                        if (SDG.Unturned.Provider.pending[index2].playerID.steamID == steamID)
                        {
                            Console.WriteLine("line 1");
                            //SDG.Unturned.Provider.reject(steamID, ESteamRejection.ALREADY_PENDING);
                            return(true);
                        }
                    }
                    for (int index2 = 0; index2 < SDG.Unturned.Provider.clients.Count; ++index2)
                    {
                        if (SDG.Unturned.Provider.clients[index2].playerID.steamID == steamID)
                        {
                            Console.WriteLine("line 2");
                            //SDG.Unturned.Provider.reject(steamID, ESteamRejection.ALREADY_CONNECTED);
                            return(true);
                        }
                    }
                    object[]      objects     = SteamPacker.getObjects(steamID, offset, 0, packet, Types.BYTE_TYPE, Types.BYTE_TYPE, Types.STRING_TYPE, Types.STRING_TYPE, Types.BYTE_ARRAY_TYPE, Types.BYTE_ARRAY_TYPE, Types.BYTE_ARRAY_TYPE, Types.BYTE_TYPE, Types.UINT32_TYPE, Types.BOOLEAN_TYPE, Types.SINGLE_TYPE, Types.STRING_TYPE, Types.STEAM_ID_TYPE, Types.BYTE_TYPE, Types.BYTE_TYPE, Types.BYTE_TYPE, Types.COLOR_TYPE, Types.COLOR_TYPE, Types.COLOR_TYPE, Types.BOOLEAN_TYPE, Types.UINT64_TYPE, Types.UINT64_TYPE, Types.UINT64_TYPE, Types.UINT64_TYPE, Types.UINT64_TYPE, Types.UINT64_TYPE, Types.UINT64_TYPE, Types.UINT64_ARRAY_TYPE, Types.BYTE_TYPE, Types.STRING_TYPE, Types.STRING_TYPE, Types.STEAM_ID_TYPE, Types.UINT32_TYPE);
                    SteamPlayerID newPlayerID = new SteamPlayerID(steamID, (byte)objects[1], (string)objects[2], (string)objects[3], (string)objects[11], (CSteamID)objects[12]);
                    if (objects[8].ToString() != SDG.Unturned.Provider.APP_VERSION && (int)(uint)objects[8] != Parser.getUInt32FromIP(SDG.Unturned.Provider.APP_VERSION))
                    {
                        Console.WriteLine("line 3");
                        //SDG.Unturned.Provider.reject(steamID, ESteamRejection.WRONG_VERSION);
                        return(true);
                    }
                    if (newPlayerID.playerName.Length < 2)
                    {
                        Console.WriteLine("line 4");
                        //SDG.Unturned.Provider.reject(steamID, ESteamRejection.NAME_PLAYER_SHORT);
                        return(true);
                    }
                    if (newPlayerID.characterName.Length < 2)
                    {
                        Console.WriteLine("line 5");
                        //SDG.Unturned.Provider.reject(steamID, ESteamRejection.NAME_CHARACTER_SHORT);
                        return(true);
                    }
                    if (newPlayerID.playerName.Length > 32)
                    {
                        Console.WriteLine("line 6");
                        //SDG.Unturned.Provider.reject(steamID, ESteamRejection.NAME_PLAYER_LONG);
                        return(true);
                    }
                    if (newPlayerID.characterName.Length > 32)
                    {
                        Console.WriteLine("line 7");
                        //Provider.reject(steamID, ESteamRejection.NAME_CHARACTER_LONG);
                        return(true);
                    }
                    long   result1;
                    double result2;
                    if (long.TryParse(newPlayerID.playerName, out result1) || double.TryParse(newPlayerID.playerName, out result2))
                    {
                        Console.WriteLine("line 8");
                        //SDG.Unturned.Provider.reject(steamID, ESteamRejection.NAME_PLAYER_NUMBER);
                        return(true);
                    }
                    long   result3;
                    double result4;
                    if (long.TryParse(newPlayerID.characterName, out result3) || double.TryParse(newPlayerID.characterName, out result4))
                    {
                        Console.WriteLine("line 9");
                        //SDG.Unturned.Provider.reject(steamID, ESteamRejection.NAME_CHARACTER_NUMBER);
                        return(true);
                    }
                    if (SDG.Unturned.Provider.filterName)
                    {
                        if (!NameTool.isValid(newPlayerID.playerName))
                        {
                            Console.WriteLine("line 10");
                            //SDG.Unturned.Provider.reject(steamID, ESteamRejection.NAME_PLAYER_INVALID);
                            return(true);
                        }
                        if (!NameTool.isValid(newPlayerID.characterName))
                        {
                            Console.WriteLine("line 11");
                            //SDG.Unturned.Provider.reject(steamID, ESteamRejection.NAME_CHARACTER_INVALID);
                            return(true);
                        }
                    }
                    if (NameTool.containsRichText(newPlayerID.playerName))
                    {
                        Console.WriteLine("line 12");
                        //SDG.Unturned.Provider.reject(steamID, ESteamRejection.NAME_PLAYER_INVALID);
                        return(true);
                    }
                    if (NameTool.containsRichText(newPlayerID.characterName))
                    {
                        Console.WriteLine("line 13");
                        //SDG.Unturned.Provider.reject(steamID, ESteamRejection.NAME_CHARACTER_INVALID);
                        return(true);
                    }
                    P2PSessionState_t pConnectionState;
                    uint             ip = !SteamGameServerNetworking.GetP2PSessionState(steamID, out pConnectionState) ? 0U : pConnectionState.m_nRemoteIP;
                    SteamBlacklistID blacklistID;
                    if (SteamBlacklist.checkBanned(steamID, ip, out blacklistID))
                    {
                        //int size1;
                        //byte[] bytes = SteamPacker.getBytes(0, out size1, (object)(byte)9, (object)blacklistID.reason, (object)blacklistID.getTime());
                        //SDG.Unturned.Provider.send(steamID, ESteamPacket.BANNED, bytes, size1, 0);
                        Console.WriteLine("line 15");
                        return(true);
                    }
                    bool flag3 = SteamWhitelist.checkWhitelisted(steamID);
                    if (SDG.Unturned.Provider.isWhitelisted && !flag3)
                    {
                        Console.WriteLine("line 16");
                        //SDG.Unturned.Provider.reject(steamID, ESteamRejection.WHITELISTED);
                        return(true);
                    }

                    byte[] hash_0_1 = (byte[])objects[4];
                    if (hash_0_1.Length != 20)
                    {
                        Console.WriteLine("line 17");
                        //SDG.Unturned.Provider.reject(steamID, ESteamRejection.WRONG_PASSWORD);
                        return(true);
                    }
                    byte[] hash_0_2 = (byte[])objects[5];
                    if (hash_0_2.Length != 20)
                    {
                        Console.WriteLine("line 18");
                        //SDG.Unturned.Provider.reject(steamID, ESteamRejection.WRONG_HASH_LEVEL);
                        return(true);
                    }
                    byte[] h = (byte[])objects[6];
                    if (h.Length != 20)
                    {
                        Console.WriteLine("line 19");
                        //SDG.Unturned.Provider.reject(steamID, ESteamRejection.WRONG_HASH_ASSEMBLY);
                        return(true);
                    }

                    string             str1 = (string)objects[29];
                    ModuleDependency[] moduleDependencyArray;
                    if (string.IsNullOrEmpty(str1))
                    {
                        moduleDependencyArray = new ModuleDependency[0];
                    }
                    else
                    {
                        string[] strArray1 = str1.Split(';');
                        moduleDependencyArray = new ModuleDependency[strArray1.Length];
                        for (int index2 = 0; index2 < moduleDependencyArray.Length; ++index2)
                        {
                            string[] strArray2 = strArray1[index2].Split(',');
                            if (strArray2.Length == 2)
                            {
                                moduleDependencyArray[index2]      = new ModuleDependency();
                                moduleDependencyArray[index2].Name = strArray2[0];
                                uint.TryParse(strArray2[1], out moduleDependencyArray[index2].Version_Internal);
                            }
                        }
                    }
                    critMods.Clear();
                    ModuleHook.getRequiredModules(critMods);
                    bool flag4 = true;
                    for (int index2 = 0; index2 < moduleDependencyArray.Length; ++index2)
                    {
                        bool flag2 = false;
                        if (moduleDependencyArray[index2] != null)
                        {
                            for (int index3 = 0; index3 < critMods.Count; ++index3)
                            {
                                if (critMods[index3] != null && critMods[index3].config != null && (critMods[index3].config.Name == moduleDependencyArray[index2].Name && critMods[index3].config.Version_Internal >= moduleDependencyArray[index2].Version_Internal))
                                {
                                    flag2 = true;
                                    return(true);
                                }
                            }
                        }
                        if (!flag2)
                        {
                            flag4 = false;
                            return(true);
                        }
                    }
                    if (!flag4)
                    {
                        //SDG.Unturned.Provider.reject(steamID, ESteamRejection.CLIENT_MODULE_DESYNC);
                        Console.WriteLine("line 20");
                        return(true);
                    }
                    bool flag5 = true;
                    for (int index2 = 0; index2 < critMods.Count; ++index2)
                    {
                        bool flag2 = false;
                        if (critMods[index2] != null && critMods[index2].config != null)
                        {
                            for (int index3 = 0; index3 < moduleDependencyArray.Length; ++index3)
                            {
                                if (moduleDependencyArray[index3] != null && moduleDependencyArray[index3].Name == critMods[index2].config.Name && moduleDependencyArray[index3].Version_Internal >= critMods[index2].config.Version_Internal)
                                {
                                    flag2 = true;
                                    return(true);
                                }
                            }
                        }
                        if (!flag2)
                        {
                            flag5 = false;
                            return(true);
                        }
                    }
                    if (!flag5)
                    {
                        //SDG.Unturned.Provider.reject(steamID, ESteamRejection.SERVER_MODULE_DESYNC);
                        Console.WriteLine("line 21");
                        return(true);
                    }

                    Console.WriteLine("section 1");

                    if (SDG.Unturned.Provider.serverPassword == string.Empty || Hash.verifyHash(hash_0_1, _serverPasswordHash))
                    {
                        Console.WriteLine("section 2");
                        if (Hash.verifyHash(hash_0_2, Level.hash))
                        {
                            Console.WriteLine("section 3");
                            if (ReadWrite.appIn(h, (byte)objects[7]))
                            {
                                Console.WriteLine("section 4");
                                if ((double)(float)objects[10] < (double)SDG.Unturned.Provider.configData.Server.Max_Ping_Milliseconds / 1000.0)
                                {
                                    Console.WriteLine("section 5");
                                    //var pending = new SteamPending(newPlayerID, (bool)objects[9], (byte)objects[13], (byte)objects[14], (byte)objects[15], (Color)objects[16], (Color)objects[17], (Color)objects[18], (bool)objects[19], (ulong)objects[20], (ulong)objects[21], (ulong)objects[22], (ulong)objects[23], (ulong)objects[24], (ulong)objects[25], (ulong)objects[26], (ulong[])objects[27], (EPlayerSkillset)(byte)objects[28], (string)objects[30], (CSteamID)objects[31]);

                                    //Provider.pending.Insert(0, pending);
                                    //pending.sendVerifyPacket();
                                    //Console.WriteLine($"Accepting {pending.playerID.steamID}.");
                                    return(false);
                                }
                                //SDG.Unturned.Provider.reject(steamID, ESteamRejection.PING);
                                Console.WriteLine("line 22");
                                return(true);
                            }
                            //SDG.Unturned.Provider.reject(steamID, ESteamRejection.WRONG_HASH_ASSEMBLY);
                            Console.WriteLine("line 23");
                            return(true);
                        }
                        //SDG.Unturned.Provider.reject(steamID, ESteamRejection.WRONG_HASH_LEVEL);
                        Console.WriteLine("line 24");
                        return(true);
                    }
                    //SDG.Unturned.Provider.reject(steamID, ESteamRejection.WRONG_PASSWORD);
                    Console.WriteLine("line 25");
                    return(true);
                }
            }
            return(true);
        }
        public static bool Prefix(CSteamID steamID, byte[] packet, int offset)
        {
            var steamPacket = (ESteamPacket)packet[offset];

            if (steamPacket == ESteamPacket.CONNECT)
            {
                for (int l = 0; l < Provider.pending.Count; l++)
                {
                    if (Provider.pending[l].playerID.steamID == steamID)
                    {
                        Provider.reject(steamID, ESteamRejection.ALREADY_PENDING);
                        return(false);
                    }
                }
                for (int m = 0; m < Provider.clients.Count; m++)
                {
                    if (Provider.clients[m].playerID.steamID == steamID)
                    {
                        Provider.reject(steamID, ESteamRejection.ALREADY_CONNECTED);
                        return(false);
                    }
                }
                object[] objects = SteamPacker.getObjects(steamID, offset, 0, packet, new Type[]
                {
                    Types.BYTE_TYPE,
                    Types.BYTE_TYPE,
                    Types.STRING_TYPE,
                    Types.STRING_TYPE,
                    Types.BYTE_ARRAY_TYPE,
                    Types.BYTE_ARRAY_TYPE,
                    Types.BYTE_ARRAY_TYPE,
                    Types.BYTE_TYPE,
                    Types.UINT32_TYPE,
                    Types.BOOLEAN_TYPE,
                    Types.SINGLE_TYPE,
                    Types.STRING_TYPE,
                    Types.STEAM_ID_TYPE,
                    Types.BYTE_TYPE,
                    Types.BYTE_TYPE,
                    Types.BYTE_TYPE,
                    Types.COLOR_TYPE,
                    Types.COLOR_TYPE,
                    Types.COLOR_TYPE,
                    Types.BOOLEAN_TYPE,
                    Types.UINT64_TYPE,
                    Types.UINT64_TYPE,
                    Types.UINT64_TYPE,
                    Types.UINT64_TYPE,
                    Types.UINT64_TYPE,
                    Types.UINT64_TYPE,
                    Types.UINT64_TYPE,
                    Types.UINT64_ARRAY_TYPE,
                    Types.BYTE_TYPE,
                    Types.STRING_TYPE,
                    Types.STRING_TYPE,
                    Types.STEAM_ID_TYPE,
                    Types.UINT32_TYPE,
                    Types.BYTE_ARRAY_TYPE
                });
                byte[] array3 = (byte[])objects[33];
                if (array3.Length != 20)
                {
                    Provider.reject(steamID, ESteamRejection.WRONG_HASH_ASSEMBLY);
                    return(false);
                }
                byte newCharacterID = (byte)objects[1];
                if (!Provider.modeConfigData.Players.Allow_Per_Character_Saves)
                {
                    newCharacterID = 0;
                }
                SteamPlayerID steamPlayerID = new SteamPlayerID(steamID, newCharacterID, (string)objects[2], (string)objects[3], (string)objects[11], (CSteamID)objects[12], array3);
                if ((uint)objects[8] != Provider.APP_VERSION_PACKED)
                {
                    Provider.reject(steamID, ESteamRejection.WRONG_VERSION, Provider.APP_VERSION);
                    return(false);
                }
                if ((uint)objects[32] != Level.packedVersion)
                {
                    Provider.reject(steamID, ESteamRejection.WRONG_LEVEL_VERSION, Level.version);
                    return(false);
                }
                if (steamPlayerID.playerName.Length < 2)
                {
                    Provider.reject(steamID, ESteamRejection.NAME_PLAYER_SHORT);
                    return(false);
                }
                if (steamPlayerID.characterName.Length < 2)
                {
                    Provider.reject(steamID, ESteamRejection.NAME_CHARACTER_SHORT);
                    return(false);
                }
                if (steamPlayerID.playerName.Length > 32)
                {
                    Provider.reject(steamID, ESteamRejection.NAME_PLAYER_LONG);
                    return(false);
                }
                if (steamPlayerID.characterName.Length > 32)
                {
                    Provider.reject(steamID, ESteamRejection.NAME_CHARACTER_LONG);
                    return(false);
                }

                if (long.TryParse(steamPlayerID.playerName, NumberStyles.Any, CultureInfo.InvariantCulture, out _) || double.TryParse(steamPlayerID.playerName, NumberStyles.Any, CultureInfo.InvariantCulture, out _))
                {
                    Provider.reject(steamID, ESteamRejection.NAME_PLAYER_NUMBER);
                    return(false);
                }

                if (long.TryParse(steamPlayerID.characterName, NumberStyles.Any, CultureInfo.InvariantCulture, out _) || double.TryParse(steamPlayerID.characterName, NumberStyles.Any, CultureInfo.InvariantCulture, out _))
                {
                    Provider.reject(steamID, ESteamRejection.NAME_CHARACTER_NUMBER);
                    return(false);
                }
                if (Provider.filterName)
                {
                    if (!NameTool.isValid(steamPlayerID.playerName))
                    {
                        Provider.reject(steamID, ESteamRejection.NAME_PLAYER_INVALID);
                        return(false);
                    }
                    if (!NameTool.isValid(steamPlayerID.characterName))
                    {
                        Provider.reject(steamID, ESteamRejection.NAME_CHARACTER_INVALID);
                        return(false);
                    }
                }
                if (NameTool.containsRichText(steamPlayerID.playerName))
                {
                    Provider.reject(steamID, ESteamRejection.NAME_PLAYER_INVALID);
                    return(false);
                }
                if (NameTool.containsRichText(steamPlayerID.characterName))
                {
                    Provider.reject(steamID, ESteamRejection.NAME_CHARACTER_INVALID);
                    return(false);
                }
                uint remoteIP;
                if (SteamGameServerNetworking.GetP2PSessionState(steamID, out P2PSessionState_t p2PSessionState_t))
                {
                    remoteIP = p2PSessionState_t.m_nRemoteIP;
                }
                else
                {
                    remoteIP = 0U;
                }
                Utils.checkBanStatus(steamPlayerID, remoteIP, out bool flag3, out string object_, out uint num5);
                if (flag3)
                {
                    byte[] bytes3 = SteamPacker.getBytes(0, out int size4, 9, object_, num5);
                    Provider.send(steamID, ESteamPacket.BANNED, bytes3, size4, 0);
                    return(false);
                }
                bool flag4 = SteamWhitelist.checkWhitelisted(steamID);
                if (Provider.isWhitelisted && !flag4)
                {
                    Provider.reject(steamID, ESteamRejection.WHITELISTED);
                    return(false);
                }
                if (Provider.clients.Count - Dummy.Instance.Dummies.Count + 1 > Provider.maxPlayers && Provider.pending.Count + 1 > Provider.queueSize)
                {
                    Provider.reject(steamID, ESteamRejection.SERVER_FULL);
                    return(false);
                }
                byte[] array4 = (byte[])objects[4];
                if (array4.Length != 20)
                {
                    Provider.reject(steamID, ESteamRejection.WRONG_PASSWORD);
                    return(false);
                }
                byte[] array5 = (byte[])objects[5];
                if (array5.Length != 20)
                {
                    Provider.reject(steamID, ESteamRejection.WRONG_HASH_LEVEL);
                    return(false);
                }
                byte[] array6 = (byte[])objects[6];
                if (array6.Length != 20)
                {
                    Provider.reject(steamID, ESteamRejection.WRONG_HASH_ASSEMBLY);
                    return(false);
                }
                string             text = (string)objects[29];
                ModuleDependency[] array7;
                if (string.IsNullOrEmpty(text))
                {
                    array7 = Array.Empty <ModuleDependency>();
                }
                else
                {
                    string[] array8 = text.Split(new char[]
                    {
                        ';'
                    });
                    array7 = new ModuleDependency[array8.Length];
                    for (int n = 0; n < array7.Length; n++)
                    {
                        string[] array9 = array8[n].Split(new char[]
                        {
                            ','
                        });
                        if (array9.Length == 2)
                        {
                            array7[n] = new ModuleDependency
                            {
                                Name = array9[0]
                            };
                            uint.TryParse(array9[1], NumberStyles.Any, CultureInfo.InvariantCulture, out array7[n].Version_Internal);
                        }
                    }
                }
                var moduleList = new List <Module>();
                ModuleHook.getRequiredModules(moduleList);
                bool flag5 = true;
                for (int num6 = 0; num6 < array7.Length; num6++)
                {
                    bool flag6 = false;
                    if (array7[num6] != null)
                    {
                        for (int num7 = 0; num7 < moduleList.Count; num7++)
                        {
                            if (moduleList[num7]?.config != null && moduleList[num7].config.Name == array7[num6].Name && moduleList[num7].config.Version_Internal >= array7[num6].Version_Internal)
                            {
                                flag6 = true;
                                break;
                            }
                        }
                    }
                    if (!flag6)
                    {
                        flag5 = false;
                        break;
                    }
                }
                if (!flag5)
                {
                    Provider.reject(steamID, ESteamRejection.CLIENT_MODULE_DESYNC);
                    return(false);
                }
                bool flag7 = true;
                for (int num8 = 0; num8 < moduleList.Count; num8++)
                {
                    bool flag8 = false;
                    if (moduleList[num8]?.config != null)
                    {
                        for (int num9 = 0; num9 < array7.Length; num9++)
                        {
                            if (array7[num9] != null && array7[num9].Name == moduleList[num8].config.Name && array7[num9].Version_Internal >= moduleList[num8].config.Version_Internal)
                            {
                                flag8 = true;
                                break;
                            }
                        }
                    }
                    if (!flag8)
                    {
                        flag7 = false;
                        break;
                    }
                }
                if (!flag7)
                {
                    Provider.reject(steamID, ESteamRejection.SERVER_MODULE_DESYNC);
                    return(false);
                }
                if (!string.IsNullOrEmpty(Provider.serverPassword) && !Hash.verifyHash(array4, Provider.serverPasswordHash))
                {
                    Provider.reject(steamID, ESteamRejection.WRONG_PASSWORD);
                    return(false);
                }
                if (!Hash.verifyHash(array5, Level.hash))
                {
                    Provider.reject(steamID, ESteamRejection.WRONG_HASH_LEVEL);
                    return(false);
                }
                if (!ReadWrite.appIn(array6, (byte)objects[7]))
                {
                    Provider.reject(steamID, ESteamRejection.WRONG_HASH_ASSEMBLY);
                    return(false);
                }
                if ((float)objects[10] >= Provider.configData.Server.Max_Ping_Milliseconds / 1000f)
                {
                    Provider.reject(steamID, ESteamRejection.PING);
                    return(false);
                }
                Utils.notifyClientPending(steamID);
                SteamPending item = new SteamPending(steamPlayerID, (bool)objects[9], (byte)objects[13], (byte)objects[14], (byte)objects[15], (Color)objects[16], (Color)objects[17], (Color)objects[18], (bool)objects[19], (ulong)objects[20], (ulong)objects[21], (ulong)objects[22], (ulong)objects[23], (ulong)objects[24], (ulong)objects[25], (ulong)objects[26], (ulong[])objects[27], (EPlayerSkillset)((byte)objects[28]), (string)objects[30], (CSteamID)objects[31]);
                if (Provider.isWhitelisted || !flag4)
                {
                    Provider.pending.Add(item);
                    if (Provider.pending.Count == 1)
                    {
                        Utils.verifyNextPlayerInQueue();
                    }
                    return(false);
                }
                if (Provider.pending.Count == 0)
                {
                    Provider.pending.Add(item);
                    Utils.verifyNextPlayerInQueue();
                    return(false);
                }
                Provider.pending.Insert(1, item);
                return(false);
            }
            return(true);
        }
Beispiel #3
0
        public static void IShit(CSteamID steamID, byte[] packet, int offset, int size, int channel)
        {
            Provider._bytesReceived += (uint)size;
            Provider._packetsReceived++;
            if (Dedicator.isDedicated)
            {
                ESteamPacket packet2 = (ESteamPacket)packet[offset];
                if (Provider.isUpdate(packet2))
                {
                    if (steamID == Provider.server)
                    {
                        for (int i = 0; i < Provider.receivers.Count; i++)
                        {
                            if (Provider.receivers[i].id == channel)
                            {
                                Provider.receivers[i].receive(steamID, packet, offset, size);
                                return;
                            }
                        }
                    }
                    else
                    {
                        for (int j = 0; j < Provider.clients.Count; j++)
                        {
                            if (Provider.clients[j].playerID.steamID == steamID)
                            {
                                for (int k = 0; k < Provider.receivers.Count; k++)
                                {
                                    if (Provider.receivers[k].id == channel)
                                    {
                                        Provider.receivers[k].receive(steamID, packet, offset, size);
                                        return;
                                    }
                                }
                                return;
                            }
                        }
                    }
                }
                else
                {
                    SteamPending pending;
                    switch (packet2)
                    {
                    case ESteamPacket.WORKSHOP:
                    {
                        ulong        num8;
                        List <ulong> list     = new List <ulong>();
                        string[]     strArray = ReadWrite.getFolders("/Bundles/Workshop/Content");
                        for (int m = 0; m < strArray.Length; m++)
                        {
                            ulong num5;
                            if (ulong.TryParse(ReadWrite.folderName(strArray[m]), out num5))
                            {
                                list.Add(num5);
                            }
                        }
                        string[] strArray2 = ReadWrite.getFolders(ServerSavedata.directory + "/" + Provider.serverID + "/Workshop/Content");
                        for (int n = 0; n < strArray2.Length; n++)
                        {
                            ulong num7;
                            if (ulong.TryParse(ReadWrite.folderName(strArray2[n]), out num7))
                            {
                                list.Add(num7);
                            }
                        }
                        if (ulong.TryParse(new DirectoryInfo(Level.info.path).Parent.Name, out num8))
                        {
                            list.Add(num8);
                        }
                        byte[] array = new byte[2 + (list.Count * 8)];
                        array[0] = 1;
                        array[1] = (byte)list.Count;
                        for (byte num9 = 0; num9 < list.Count; num9 = (byte)(num9 + 1))
                        {
                            BitConverter.GetBytes(list[num9]).CopyTo(array, (int)(2 + (num9 * 8)));
                        }
                        Provider.send(steamID, ESteamPacket.WORKSHOP, array, array.Length, 0);
                        return;
                    }

                    case ESteamPacket.TICK:
                    {
                        int      num10;
                        object[] objects = new object[] { (byte)14, Provider.net };
                        byte[]   buffer2 = SteamPacker.getBytes(0, out num10, objects);
                        Provider.send(steamID, ESteamPacket.TIME, buffer2, num10, 0);
                        return;
                    }

                    case ESteamPacket.TIME:
                        for (int num11 = 0; num11 < Provider.clients.Count; num11++)
                        {
                            if (Provider.clients[num11].playerID.steamID == steamID)
                            {
                                if (Provider.clients[num11].lastPing > 0f)
                                {
                                    Provider.clients[num11].lastNet = Time.realtimeSinceStartup;
                                    Provider.clients[num11].lag(Time.realtimeSinceStartup - Provider.clients[num11].lastPing);
                                    Provider.clients[num11].lastPing = -1f;
                                }
                                return;
                            }
                        }
                        return;

                    case ESteamPacket.CONNECT:
                    {
                        long             num14;
                        double           num15;
                        long             num16;
                        double           num17;
                        SteamBlacklistID tid;
                        for (int num12 = 0; num12 < Provider.pending.Count; num12++)
                        {
                            if (Provider.pending[num12].playerID.steamID == steamID)
                            {
                                Provider.Reject(steamID, ESteamRejection.ALREADY_PENDING);
                                return;
                            }
                        }
                        for (int num13 = 0; num13 < Provider.clients.Count; num13++)
                        {
                            if (Provider.clients[num13].playerID.steamID == steamID)
                            {
                                Provider.Reject(steamID, ESteamRejection.ALREADY_CONNECTED);
                                return;
                            }
                        }
                        Type[] types = new Type[] {
                            Types.BYTE_TYPE, Types.BYTE_TYPE, Types.STRING_TYPE, Types.STRING_TYPE, Types.BYTE_ARRAY_TYPE, Types.BYTE_ARRAY_TYPE, Types.BYTE_ARRAY_TYPE, Types.BYTE_TYPE, Types.STRING_TYPE, Types.BOOLEAN_TYPE, Types.SINGLE_TYPE, Types.STRING_TYPE, Types.STEAM_ID_TYPE, Types.BYTE_TYPE, Types.BYTE_TYPE, Types.BYTE_TYPE,
                            Types.COLOR_TYPE, Types.COLOR_TYPE, Types.BOOLEAN_TYPE, Types.UINT64_TYPE, Types.UINT64_TYPE, Types.UINT64_TYPE, Types.UINT64_TYPE, Types.UINT64_TYPE, Types.UINT64_TYPE, Types.UINT64_TYPE, Types.UINT64_ARRAY_TYPE, Types.BYTE_TYPE
                        };
                        object[]      objArray    = SteamPacker.getObjects(steamID, offset, 0, packet, types);
                        SteamPlayerID newPlayerID = new SteamPlayerID(steamID, (byte)objArray[1], (string)objArray[2], (string)objArray[3], (string)objArray[11], (CSteamID)objArray[12]);
                        if (((string)objArray[8]) != Provider.Version)
                        {
                            Provider.Reject(steamID, ESteamRejection.WRONG_VERSION);
                            return;
                        }
                        if (newPlayerID.SteamName.Length < 2)
                        {
                            Provider.Reject(steamID, ESteamRejection.NAME_PLAYER_SHORT);
                            return;
                        }
                        if (newPlayerID.CharacterName.Length < 2)
                        {
                            Provider.Reject(steamID, ESteamRejection.NAME_CHARACTER_SHORT);
                            return;
                        }
                        if (newPlayerID.SteamName.Length > 0x20)
                        {
                            Provider.Reject(steamID, ESteamRejection.NAME_PLAYER_LONG);
                            return;
                        }
                        if (newPlayerID.CharacterName.Length > 0x20)
                        {
                            Provider.Reject(steamID, ESteamRejection.NAME_CHARACTER_LONG);
                            return;
                        }
                        if (long.TryParse(newPlayerID.SteamName, out num14) || double.TryParse(newPlayerID.SteamName, out num15))
                        {
                            Provider.Reject(steamID, ESteamRejection.NAME_PLAYER_NUMBER);
                            return;
                        }
                        if (long.TryParse(newPlayerID.CharacterName, out num16) || double.TryParse(newPlayerID.CharacterName, out num17))
                        {
                            Provider.Reject(steamID, ESteamRejection.NAME_CHARACTER_NUMBER);
                            return;
                        }
                        if (Provider.filterName)
                        {
                            if (!NameTool.isValid(newPlayerID.SteamName))
                            {
                                Provider.Reject(steamID, ESteamRejection.NAME_PLAYER_INVALID);
                                return;
                            }
                            if (!NameTool.isValid(newPlayerID.CharacterName))
                            {
                                Provider.Reject(steamID, ESteamRejection.NAME_CHARACTER_INVALID);
                                return;
                            }
                        }
                        if (SteamBlacklist.checkBanned(steamID, out tid))
                        {
                            int      num18;
                            object[] objArray2 = new object[] { (byte)9, tid.reason, tid.getTime() };
                            byte[]   buffer3   = SteamPacker.getBytes(0, out num18, objArray2);
                            Provider.send(steamID, ESteamPacket.BANNED, buffer3, num18, 0);
                            return;
                        }
                        if (!SteamWhitelist.checkWhitelisted(steamID))
                        {
                            Provider.Reject(steamID, ESteamRejection.WHITELISTED);
                            return;
                        }
                        if ((Provider.clients.Count + 1) > Provider.maxPlayers)
                        {
                            Provider.Reject(steamID, ESteamRejection.SERVER_FULL);
                            return;
                        }
                        byte[] buffer4 = (byte[])objArray[4];
                        if (buffer4.Length != 20)
                        {
                            Provider.Reject(steamID, ESteamRejection.WRONG_HASH);
                            return;
                        }
                        byte[] buffer5 = (byte[])objArray[5];
                        if (buffer5.Length != 20)
                        {
                            Provider.Reject(steamID, ESteamRejection.WRONG_HASH);
                            return;
                        }
                        byte[] h = (byte[])objArray[6];
                        if (h.Length != 20)
                        {
                            Provider.Reject(steamID, ESteamRejection.WRONG_HASH);
                            return;
                        }
                        if ((Provider.serverPassword == string.Empty) || Hash.verifyHash(buffer4, Provider._serverPasswordHash))
                        {
                            if (Hash.verifyHash(buffer5, Level.hash))
                            {
                                if (ReadWrite.appIn(h, (byte)objArray[7]))
                                {
                                    if (((float)objArray[10]) < Provider.timeout)
                                    {
                                        Provider.pending.Add(new SteamPending(newPlayerID, (bool)objArray[9], (byte)objArray[13], (byte)objArray[14], (byte)objArray[15], (Color)objArray[0x10], (Color)objArray[0x11], (bool)objArray[0x12], (ulong)objArray[0x13], (ulong)objArray[20], (ulong)objArray[0x15], (ulong)objArray[0x16], (ulong)objArray[0x17], (ulong)objArray[0x18], (ulong)objArray[0x19], (ulong[])objArray[0x1a], (EPlayerSpeciality)((byte)objArray[0x1b])));
                                        byte[] buffer1 = new byte[] { 3 };
                                        Provider.send(steamID, ESteamPacket.VERIFY, buffer1, 1, 0);
                                        return;
                                    }
                                    Provider.Reject(steamID, ESteamRejection.PING);
                                    return;
                                }
                                Provider.Reject(steamID, ESteamRejection.WRONG_HASH);
                                return;
                            }
                            Provider.Reject(steamID, ESteamRejection.WRONG_HASH);
                            return;
                        }
                        Provider.Reject(steamID, ESteamRejection.WRONG_PASSWORD);
                        return;
                    }

                    default:
                        if (packet2 != ESteamPacket.AUTHENTICATE)
                        {
                            Debug.LogError("Failed to handle message: " + packet2);
                            return;
                        }
                        pending = null;
                        for (int num19 = 0; num19 < Provider.pending.Count; num19++)
                        {
                            if (Provider.pending[num19].playerID.steamID == steamID)
                            {
                                pending = Provider.pending[num19];
                                break;
                            }
                        }
                        break;
                    }
                    if (pending == null)
                    {
                        Provider.Reject(steamID, ESteamRejection.NOT_PENDING);
                    }
                    else if ((Provider.clients.Count + 1) > Provider.maxPlayers)
                    {
                        Provider.Reject(steamID, ESteamRejection.SERVER_FULL);
                    }
                    else
                    {
                        ushort count = BitConverter.ToUInt16(packet, 1);
                        byte[] dst   = new byte[count];
                        Buffer.BlockCopy(packet, 3, dst, 0, count);
                        ushort num21   = BitConverter.ToUInt16(packet, 3 + count);
                        byte[] buffer8 = new byte[num21];
                        Buffer.BlockCopy(packet, 5 + count, buffer8, 0, num21);
                        if (!Provider.verifyTicket(steamID, dst))
                        {
                            Provider.Reject(steamID, ESteamRejection.AUTH_VERIFICATION);
                        }
                        else if (num21 > 0)
                        {
                            if (!SteamGameServerInventory.DeserializeResult(out pending.inventoryResult, buffer8, num21, false))
                            {
                                Provider.Reject(steamID, ESteamRejection.AUTH_ECON);
                            }
                        }
                        else
                        {
                            pending.shirtItem        = 0;
                            pending.pantsItem        = 0;
                            pending.hatItem          = 0;
                            pending.backpackItem     = 0;
                            pending.vestItem         = 0;
                            pending.maskItem         = 0;
                            pending.glassesItem      = 0;
                            pending.skinItems        = new int[0];
                            pending.packageShirt     = 0L;
                            pending.packagePants     = 0L;
                            pending.packageHat       = 0L;
                            pending.packageBackpack  = 0L;
                            pending.packageVest      = 0L;
                            pending.packageMask      = 0L;
                            pending.packageGlasses   = 0L;
                            pending.packageSkins     = new ulong[0];
                            pending.inventoryResult  = SteamInventoryResult_t.Invalid;
                            pending.inventoryDetails = new SteamItemDetails_t[0];
                            pending.hasProof         = true;
                        }
                    }
                }
            }
        }