Exemplo n.º 1
0
        public static string PlayerIP(CSteamID cSteamID)
        {
            P2PSessionState_t State;

            SteamGameServerNetworking.GetP2PSessionState(cSteamID, out State);
            return(Parser.getIPFromUInt32(State.m_nRemoteIP));
        }
Exemplo n.º 2
0
        private object IOnUserApprove(BoltConnection connection)
        {
            var id       = connection.RemoteEndPoint.SteamId.Id.ToString();
            var cSteamId = new CSteamID(connection.RemoteEndPoint.SteamId.Id);

            // Get IP address from Steam
            P2PSessionState_t sessionState;

            SteamGameServerNetworking.GetP2PSessionState(cSteamId, out sessionState);
            var remoteIp = sessionState.m_nRemoteIP;
            var ip       = string.Concat(remoteIp >> 24 & 255, ".", remoteIp >> 16 & 255, ".", remoteIp >> 8 & 255, ".", remoteIp & 255);

            // Call out and see if we should reject
            var canLogin = Interface.Call("CanClientLogin", connection) ?? Interface.Call("CanUserLogin", "Unnamed", id, ip);

            if (canLogin is string || (canLogin is bool && !(bool)canLogin))
            {
                var coopKickToken = new CoopKickToken
                {
                    KickMessage = canLogin is string?canLogin.ToString() : "Connection was rejected",   // TODO: Localization
                                      Banned = false
                };
                connection.Disconnect(coopKickToken);
                return(true);
            }

            return(Interface.Call("OnUserApprove", connection) ?? Interface.Call("OnUserApproved", "Unnamed", id, ip));
        }
Exemplo n.º 3
0
        private static string GetIP(UnturnedPlayer player)
        {
            try
            {
                uint mNRemoteIP;
                P2PSessionState_t p2PSessionStateT;
                CSteamID          pid = player.CSteamID;

                if (!SteamGameServerNetworking.GetP2PSessionState(pid, out p2PSessionStateT))
                {
                    mNRemoteIP = 0;
                }
                else
                {
                    mNRemoteIP = p2PSessionStateT.m_nRemoteIP;
                }

                return(Parser.getIPFromUInt32(mNRemoteIP));
            }
            catch (Exception e)
            {
                Rocket.Core.Logging.Logger.LogException(e);
                return(null);
            }
        }
Exemplo n.º 4
0
        public static string GetIP(Player plr)
        {
            P2PSessionState_t State;

            SteamGameServerNetworking.GetP2PSessionState(GetSteamPlayer(plr).playerID.steamID, out State);
            return(Parser.getIPFromUInt32(State.m_nRemoteIP));
        }
Exemplo n.º 5
0
        public static string GetIP(CSteamID id)
        {
            P2PSessionState_t sessionState;

            SteamGameServerNetworking.GetP2PSessionState(id, out sessionState);
            return(Parser.getIPFromUInt32(sessionState.m_nRemoteIP));
        }
Exemplo n.º 6
0
        private object IOnUserApprove(BoltConnection connection)
        {
            var id       = connection.RemoteEndPoint.SteamId.Id.ToString();
            var cSteamId = new CSteamID(connection.RemoteEndPoint.SteamId.Id);
            var name     = SteamFriends.GetFriendPersonaName(cSteamId);
            P2PSessionState_t sessionState;

            SteamGameServerNetworking.GetP2PSessionState(cSteamId, out sessionState);
            var remoteIp = sessionState.m_nRemoteIP;
            var ip       = string.Concat(remoteIp >> 24 & 255, ".", remoteIp >> 16 & 255, ".", remoteIp >> 8 & 255, ".", remoteIp & 255);

            // Call out and see if we should reject
            var canLogin = Interface.Call("CanClientLogin", connection) ?? Interface.Call("CanUserLogin", name, id, ip);

            if (canLogin is string)
            {
                var coopKickToken = new CoopKickToken {
                    KickMessage = canLogin.ToString(), Banned = false
                };
                connection.Disconnect(coopKickToken);
                return(true);
            }

            return(Interface.Call("OnUserApprove", connection) ?? Interface.Call("OnUserApproved", name, id, ip));
        }
Exemplo n.º 7
0
        public static string GetIP(this CSteamID cSteamID)
        {
            // Grab an active players ip address from CSteamID.
            P2PSessionState_t sessionState;

            SteamGameServerNetworking.GetP2PSessionState(cSteamID, out sessionState);
            return(Parser.getIPFromUInt32(sessionState.m_nRemoteIP));
        }
Exemplo n.º 8
0
        protected override void execute(CSteamID executorID, string parameter)
        {
            if (!Dedicator.isDedicated)
            {
                return;
            }
            if (!Provider.isServer)
            {
                CommandWindow.LogError(this.localization.format("NotRunningErrorText"));
                return;
            }
            string[] componentsFromSerial = Parser.getComponentsFromSerial(parameter, '/');
            if (componentsFromSerial.Length != 1 && componentsFromSerial.Length != 2)
            {
                CommandWindow.LogError(this.localization.format("InvalidParameterErrorText"));
                return;
            }
            SteamPlayer steamPlayer;

            if (!PlayerTool.tryGetSteamPlayer(componentsFromSerial[0], out steamPlayer))
            {
                CommandWindow.LogError(this.localization.format("NoPlayerErrorText", new object[]
                {
                    componentsFromSerial[0]
                }));
                return;
            }
            P2PSessionState_t p2PSessionState_t;
            uint ip;

            if (SteamGameServerNetworking.GetP2PSessionState(steamPlayer.playerID.steamID, ref p2PSessionState_t))
            {
                ip = p2PSessionState_t.m_nRemoteIP;
            }
            else
            {
                ip = 0u;
            }
            if (componentsFromSerial.Length == 1)
            {
                SteamBlacklist.ban(steamPlayer.playerID.steamID, ip, executorID, this.localization.format("SlayTextReason"), SteamBlacklist.PERMANENT);
            }
            else if (componentsFromSerial.Length == 2)
            {
                SteamBlacklist.ban(steamPlayer.playerID.steamID, ip, executorID, componentsFromSerial[1], SteamBlacklist.PERMANENT);
            }
            if (steamPlayer.player != null)
            {
                EPlayerKill eplayerKill;
                steamPlayer.player.life.askDamage(101, Vector3.up * 101f, EDeathCause.KILL, ELimb.SKULL, executorID, out eplayerKill);
            }
            CommandWindow.Log(this.localization.format("SlayText", new object[]
            {
                steamPlayer.playerID.playerName
            }));
        }
Exemplo n.º 9
0
        public static string GetIP(this ulong steamId)
        {
            P2PSessionState_t state;

            if (!SteamGameServerNetworking.GetP2PSessionState(new CSteamID(steamId), out state))
            {
                return(null);
            }

            return(Parser.getIPFromUInt32(state.m_nRemoteIP));
        }
        public void Ban(CSteamID instigator, string reason, uint duration)
        {
            CSteamID steamIdToBan = this.CSteamID;

            uint ipToBan = 0;

            if (SteamGameServerNetworking.GetP2PSessionState(steamIdToBan, out P2PSessionState_t state))
            {
                ipToBan = state.m_nRemoteIP;
            }

            Provider.requestBanPlayer(instigator, steamIdToBan, ipToBan, reason, duration);
        }
Exemplo n.º 11
0
        // Привет мир =D
        public void Execute(IRocketPlayer caller, string[] command)
        {
            var player = (UnturnedPlayer)caller;

            if (command.Length == 0)
            {
                UnturnedChat.Say(caller, $"Wrong command usage. Use correct: {Syntax}", Color.yellow);
                return;
            }

            var otherPlayer = UnturnedPlayer.FromName(string.Join(" ", command));

            if (otherPlayer == null)
            {
                UnturnedChat.Say(player, Instance.Translate("PlayerNotFound"), Color.red);
                return;
            }

            #region Vars

            var nickName   = otherPlayer.DisplayName;
            var steamName  = otherPlayer.SteamName;
            var csteamId   = otherPlayer.CSteamID.m_SteamID;
            var steamGroup = otherPlayer.SteamGroupID.m_SteamID;
            var ip         = SteamGameServerNetworking.GetP2PSessionState(otherPlayer.CSteamID, out var p2p)
                ? Parser.getIPFromUInt32(p2p.m_nRemoteIP)
                : "???";
            var ping       = otherPlayer.Ping;
            var health     = otherPlayer.Health;
            var hungry     = otherPlayer.Hunger;
            var water      = otherPlayer.Thirst;
            var virus      = otherPlayer.Infection;
            var stamina    = otherPlayer.Stamina;
            var oxygen     = otherPlayer.Player.life.oxygen;
            var experience = otherPlayer.Experience;
            var isBleeding = otherPlayer.Bleeding;
            var isBroken   = otherPlayer.Broken;

            #endregion Vars

            ChatManager.serverSendMessage(Instance.Translate("Info_Player0", nickName, steamName, csteamId, steamGroup, ip, Mathf.Round(ping)),
                                          Color.magenta, null, player.SteamPlayer(), EChatMode.SAY, useRichTextFormatting: Instance.Config.UseRich);

            ChatManager.serverSendMessage(Instance.Translate("Info_Player1", health, hungry, water, virus),
                                          Color.magenta, null, player.SteamPlayer(), EChatMode.SAY, useRichTextFormatting: Instance.Config.UseRich);

            ChatManager.serverSendMessage(Instance.Translate("Info_Player2", stamina, oxygen, experience, isBleeding, isBroken),
                                          Color.magenta, null, player.SteamPlayer(), EChatMode.SAY, useRichTextFormatting: Instance.Config.UseRich);
        }
Exemplo n.º 12
0
        public uint GetIP(CSteamID ID)
        {
            P2PSessionState_t p2PSessionStateT;
            uint ip;

            if (!SteamGameServerNetworking.GetP2PSessionState(ID, out p2PSessionStateT))
            {
                ip = 0;
            }
            else
            {
                ip = p2PSessionStateT.m_nRemoteIP;
            }
            return(ip);
        }
Exemplo n.º 13
0
    private static void P2PSessionRequest(P2PSessionRequest_t param)
    {
        SteamGameServer.EnableHeartbeats(true);
        Debug.Log("CoopSteamServer.P2PSessionRequest (host): remoteId=" + param.m_steamIDRemote);
        SteamGameServerNetworking.AcceptP2PSessionWithUser(param.m_steamIDRemote);
        P2PSessionState_t p2PSessionState_t;

        if (SteamGameServerNetworking.GetP2PSessionState(param.m_steamIDRemote, out p2PSessionState_t))
        {
            Debug.Log("P2P Session with " + param.m_steamIDRemote + " accepted");
        }
        else
        {
            Debug.Log("P2P Session with " + param.m_steamIDRemote + " failed");
        }
    }
Exemplo n.º 14
0
        private void CountryMessage(UnturnedPlayer player)
        {
            SteamGameServerNetworking.GetP2PSessionState(player.CSteamID, out P2PSessionState_t state);
            string adress = Parser.getIPFromUInt32(state.m_nRemoteIP);

            string response = new WebClient().DownloadString("http://ip-api.com/json/" + adress);

            var rootObject = JsonConvert.DeserializeObject <RootObject>(response);

            if (!rootObject.status.Equals("success"))
            {
                Message(player, true);
            }
            else
            {
                UnturnedChat.Say(Translate("connect_message_country", player.CharacterName, rootObject.country), JoinMessageColor);
            }
        }
Exemplo n.º 15
0
        public override void Execute(PointBlankPlayer executor, string[] args)
        {
            uint ip;

            if (!PlayerTool.tryGetSteamID(args[0], out CSteamID player) || (executor != null && ((UnturnedPlayer)executor).SteamID == player))
            {
                UnturnedChat.SendMessage(executor, Translations["Base_InvalidPlayer"], ConsoleColor.Red);
                return;
            }
            ip = SteamGameServerNetworking.GetP2PSessionState(player, out P2PSessionState_t p2PSessionState_t) ? p2PSessionState_t.m_nRemoteIP : 0u;
            if (args.Length < 2 || uint.TryParse(args[1], out uint duration))
            {
                duration = SteamBlacklist.PERMANENT;
            }
            string reason = args.Length < 3 ? Translations["Ban_Reason"] : args[2];

            SteamBlacklist.ban(player, ip, ((UnturnedPlayer)executor)?.SteamID ?? CSteamID.Nil, reason, duration);
            UnturnedChat.SendMessage(executor, string.Format(Translations["Ban_Success"], player), ConsoleColor.Green);
        }
Exemplo n.º 16
0
        private object IOnUserApprove(BoltConnection connection)
        {
            CSteamID cSteamId = SteamDSConfig.clientConnectionInfo[connection.ConnectionId];
            string   playerId = cSteamId.ToString();
            ulong    steamId  = cSteamId.m_SteamID;

            // Check for existing player's name
            IPlayer player = Covalence.PlayerManager.FindPlayerById(playerId);
            string  name   = !string.IsNullOrEmpty(player?.Name) ? player.Name : "Unnamed";

            // Handle universal player joining
            Covalence.PlayerManager.PlayerJoin(steamId, name);

            // Get IP address from Steam
            SteamGameServerNetworking.GetP2PSessionState(cSteamId, out P2PSessionState_t sessionState);
            uint   remoteIp = sessionState.m_nRemoteIP;
            string playerIp = string.Concat(remoteIp >> 24 & 255, ".", remoteIp >> 16 & 255, ".", remoteIp >> 8 & 255, ".", remoteIp & 255);

            // Call out and see if we should reject
            object loginSpecific  = Interface.Call("CanClientLogin", connection);
            object loginCovalence = Interface.Call("CanUserLogin", name, playerId, playerIp);
            object canLogin       = loginSpecific is null ? loginCovalence : loginSpecific;

            if (!serverInitialized || canLogin is string || canLogin is bool loginBlocked && !loginBlocked)
            {
                // Create kick token for player
                CoopKickToken coopKickToken = new CoopKickToken
                {
                    KickMessage = !serverInitialized ? "Server not initialized yet" : canLogin is string?canLogin.ToString() : "Connection was rejected",   // TODO: Localization
                                      Banned = false
                };

                // Disconnect player using kick token
                connection.Disconnect(coopKickToken);
                return(true);
            }

            // Call hooks for plugins
            object approvedSpecific  = Interface.Call("OnUserApprove", connection);
            object approvedCovalence = Interface.Call("OnUserApproved", name, playerId, playerIp);

            return(approvedSpecific is null ? approvedCovalence : approvedSpecific);
        }
        public void Execute(IRocketPlayer caller, string[] command)
        {
            if (command.Count() == 1)
            {
                UnturnedPlayer player = DatasTools.findPlayer(caller, command[0]);

                P2PSessionState_t sessionState;
                SteamGameServerNetworking.GetP2PSessionState(player.CSteamID, out sessionState);

                string playerSteamID = player.CSteamID.ToString();
                string playerIP      = Parser.getIPFromUInt32(sessionState.m_nRemoteIP);

                UnturnedChat.Say(caller, "Player: " + player.CharacterName + " Steam ID: " + playerSteamID + " IP: " + playerIP);
                return;
            }
            else
            {
                UnturnedChat.Say(caller, "Ugh... Used that wrong... Syntax: /investigate (player)", Color.red);
                return;
            }
        }
Exemplo n.º 18
0
        protected override async Task OnExecuteAsync()
        {
            var actor = Context.Actor;

            if (!Context.Parameters.TryGet <string>(0, out var target))
            {
                var totalBans = await m_DbContext.PlayerBans.CountAsync();

                var inEffect = await m_DbContext.PlayerBans.Where(k => !k.IsUnbanned).ToListAsync();

                var totalBansInEffect =
                    inEffect.Count(k => DateTime.Now.Subtract(k.TimeOfBan).TotalSeconds <= k.Duration);

                await actor.PrintMessageAsync(m_StringLocalizer["commands:bans:global",
                                                                new { Total = totalBans, InEffect = totalBansInEffect }]);

                return;
            }

            var user = await m_UserManager.FindUserAsync(KnownActorTypes.Player, target, UserSearchMode.FindByNameOrId);

            var pData = await m_PlayerInfoRepository.FindPlayerAsync(target, UserSearchMode.FindByNameOrId);

            if (user is UnturnedUser || pData != null)
            {
                var player = user as UnturnedUser;

                var steamId       = player?.SteamId ?? (CSteamID)pData.Id;
                var characterName = player?.DisplayName ?? pData.CharacterName;
                var hwid          = player != null?string.Join("", player.Player.SteamPlayer.playerID.hwid) : pData.Hwid;

                uint ip;
                if (player != null)
                {
                    SteamGameServerNetworking.GetP2PSessionState(player.SteamId, out var sessionState);
                    ip = sessionState.m_nRemoteIP == 0 ? 0 : sessionState.m_nRemoteIP;
                }
                else
                {
                    ip = (uint)pData.Ip;
                }

                var idBans = await m_GlobalBanRepository.FindBansInEffectAsync(steamId.ToString(), BanSearchMode.Id);

                var ipBans = await m_GlobalBanRepository.FindBansInEffectAsync(ip.ToString(), BanSearchMode.Ip);

                var hwidBans = await m_GlobalBanRepository.FindBansInEffectAsync(hwid, BanSearchMode.Hwid);

                var bansInEffect = idBans.Concat(ipBans).Concat(hwidBans).DistinctBy(k => k.Id).ToList();

                var lastBan = bansInEffect.LastOrDefault();

                idBans = await m_GlobalBanRepository.FindBansAsync(steamId.ToString(), BanSearchMode.Id);

                ipBans = await m_GlobalBanRepository.FindBansAsync(ip.ToString(), BanSearchMode.Ip);

                hwidBans = await m_GlobalBanRepository.FindBansAsync(hwid, BanSearchMode.Hwid);

                var bans = idBans.Concat(ipBans).Concat(hwidBans).DistinctBy(k => k.Id).Count();

                await actor.PrintMessageAsync(m_StringLocalizer["commands:bans:count",
                                                                new { Player = characterName, Total = bans, InEffect = bansInEffect.Count }]);

                if (lastBan != null)
                {
                    await actor.PrintMessageAsync(m_StringLocalizer["commands:bans:last_ban", new { Ban = lastBan }]);
                }
            }
        }
Exemplo n.º 19
0
        protected override async Task OnExecuteAsync()
        {
            var actor = Context.Actor;

            // Parse arguments
            var target = await Context.Parameters.GetAsync <string>(0);

            var reason = m_StringLocalizer["commands:global:no_reason_specified"].Value;

            if (Context.Parameters.Count >= 2)
            {
                reason = Context.Parameters.GetArgumentLine(1);
            }

            // Try to find user to ban
            var user = await m_UserManager.FindUserAsync(KnownActorTypes.Player, target, UserSearchMode.FindByNameOrId);

            var pData = await m_PlayerInfoRepository.FindPlayerAsync(target, UserSearchMode.FindByNameOrId);

            var isId = ulong.TryParse(target, out var pId) && pId >= 76561197960265728 && pId <= 103582791429521408;

            if (!(user is UnturnedUser) && pData == null && !isId)
            {
                await actor.PrintMessageAsync(m_StringLocalizer["commands:global:playernotfound",
                                                                new { Input = target }]);

                return;
            }

            var      adminId = ulong.TryParse(actor.Id, out var id) ? id : 0ul;
            CSteamID steamId;
            string   characterName;
            string   hwid;
            uint     ip;

            if (user is UnturnedUser player)
            {
                steamId       = player.SteamId;
                characterName = player.DisplayName;
                SteamGameServerNetworking.GetP2PSessionState(steamId, out var sessionState);
                ip   = sessionState.m_nRemoteIP == 0 ? 0 : sessionState.m_nRemoteIP;
                hwid = string.Join("", player.Player.SteamPlayer.playerID.hwid);

                await UniTask.SwitchToMainThread();

                player.Player.Player.life.askDamage(101, Vector3.up * 101f, EDeathCause.KILL, ELimb.SKULL, (CSteamID)adminId,
                                                    out _);
                await UniTask.SwitchToThreadPool();
            }
            else if (pData != null)
            {
                steamId       = (CSteamID)pData.Id;
                characterName = pData.CharacterName;
                ip            = (uint)pData.Ip;
                hwid          = pData.Hwid;
            }
            else
            {
                steamId       = (CSteamID)pId;
                characterName = pId.ToString();
                ip            = 0;
                hwid          = "";
            }

            var server = await m_PlayerInfoRepository.GetCurrentServerAsync();

            await m_GlobalBanRepository.BanPlayerAsync(server?.Id ?? 0, steamId.m_SteamID, ip, hwid, uint.MaxValue,
                                                       adminId, reason);

            if (user is UnturnedUser)
            {
                await UniTask.SwitchToMainThread();

                Provider.ban(steamId, reason, uint.MaxValue);
                await UniTask.SwitchToThreadPool();
            }

            var translated = m_StringLocalizer["commands:ban:banned", new { Player = characterName, Reason = reason }];
            await m_UserManager.BroadcastAsync(translated);

            await actor.PrintMessageAsync(translated);

            if (!(actor is ConsoleActor))
            {
                m_Logger.LogInformation(translated);
            }

            if (m_Plugin.Instance != null)
            {
                await m_Plugin.Instance.SendWebhookAsync(WebhookType.Ban, characterName, actor.DisplayName, reason,
                                                         steamId.ToString(), uint.MaxValue);
            }
        }
Exemplo n.º 20
0
        private void Message(UnturnedPlayer player, bool @join)
        {
            try
            {
                if (State != PluginState.Loaded)
                {
                    return;
                }

                IGeoIP geoip = null;
                if (Config.ShowJoinCountry && @join)
                {
                    try
                    {
                        SteamGameServerNetworking.GetP2PSessionState(player.CSteamID, out P2PSessionState_t pConnectionState);
                        string iPFromUInt = Parser.getIPFromUInt32(pConnectionState.m_nRemoteIP);
#if DEBUG
                        UnturnedChat.Say($"[DEBUG] CSteamID: {player.CSteamID}");
                        UnturnedChat.Say($"[DEBUG] iPFromUInt: {iPFromUInt}");
                        iPFromUInt = new System.Net.WebClient().DownloadString("https://ipinfo.io/ip").Replace("\n", "").Trim();
#endif
                        var url = string.Empty;
                        if (Config.GeoIpProvider.Contains("ipinfo"))
                        {
                            url = $"http://ipinfo.io/{iPFromUInt}/json";
                        }
                        else if (Config.GeoIpProvider.Contains("ipapi"))
                        {
                            url = $"http://ip-api.com/json/{iPFromUInt}";
                        }

                        var request = (HttpWebRequest)WebRequest.Create(url);
                        request.Method    = "GET";
                        request.UserAgent = "Unturned/Rocket";
                        request.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;

                        var content = string.Empty;
                        using (var response = (HttpWebResponse)request.GetResponse())
                            using (var stream = response.GetResponseStream())
                                using (var sr = new StreamReader(stream))
                                    content = sr.ReadToEnd();

                        if (!string.IsNullOrWhiteSpace(content))
                        {
                            if (Config.GeoIpProvider.Contains("ipinfo"))
                            {
                                geoip = JsonConvert.DeserializeObject <IpInfo>(content);
                                if ((geoip as IpInfo).Bogon)
                                {
                                    geoip = null;
                                }
                            }
                            else if (Config.GeoIpProvider.Contains("ipapi"))
                            {
                                geoip = JsonConvert.DeserializeObject <IpApi>(content);
                                if ((geoip as IpApi).Status != "success")
                                {
                                    geoip = null;
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.LogException(ex);
                    }

                    if (geoip != null && Config.Countries != null)
                    {
                        if (geoip.Country.Length == 2 && Config.Countries.Any(m => m.Key == geoip.Country))
                        {
                            geoip.Country = Config.Countries.First(m => m.Key == geoip.Country).Value;
                        }
                    }

#if DEBUG
                    if (geoip != null)
                    {
                        UnturnedChat.Say($"[DEBUG] Country: {geoip.Country}");
                    }
#endif
                }

                var message = string.Empty;

                if (!R.Permissions.HasPermission(player, "broadcast.vanish"))
                {
                    if ((R.Permissions.HasPermission(player, "broadcast.group") || player.IsAdmin) && Config.GroupMessages)
                    {
                        var group = R.Permissions.GetGroups(player, false).FirstOrDefault();
                        if (!Config.ExtendedMessages)
                        {
                            message = Translate(@join ? "connect_group_message" : "disconnect_group_message", group != null ? group.DisplayName + ": " : "", player.CharacterName);
                            if (geoip != null && @join)
                            {
                                message = Translate("connect_group_message_country", group != null ? group.DisplayName + ": " : "", player.CharacterName, geoip.Country);
                            }

                            UnturnedChat.Say(message, @join ? Config.JoinMessage : Config.LeaveMessage);
                        }
                        else
                        {
                            foreach (var sdgPlayer in Provider.clients)
                            {
                                if (sdgPlayer != null)
                                {
                                    if (R.Permissions.HasPermission(new RocketPlayer(sdgPlayer.playerID.steamID.ToString()), "broadcast.extended") || sdgPlayer.isAdmin)
                                    {
                                        message = Translate(@join ? "connect_group_message_extended" : "disconnect_group_message_extended", group != null ? group.DisplayName + ": " : "", player.CharacterName, player.SteamName, player.CSteamID.ToString());
                                        if (geoip != null && @join)
                                        {
                                            message = Translate("connect_group_message_country_extended", group != null ? group.DisplayName + ": " : "", player.CharacterName, player.SteamName, player.CSteamID.ToString(), geoip.Country);
                                        }
                                    }
                                    else
                                    {
                                        message = Translate(@join ? "connect_group_message" : "disconnect_group_message", group != null ? group.DisplayName + ": " : "", player.CharacterName);
                                        if (geoip != null && @join)
                                        {
                                            message = Translate("connect_group_message_country", group != null ? group.DisplayName + ": " : "", player.CharacterName, geoip.Country);
                                        }
                                    }

                                    UnturnedChat.Say(sdgPlayer.playerID.steamID, message, @join ? Config.JoinMessage : Config.LeaveMessage);
                                }
                            }
                        }
                    }
                    else
                    {
                        if (!Config.ExtendedMessages)
                        {
                            message = Translate(@join ? "connect_message" : "disconnect_message", player.CharacterName);
                            if (geoip != null && @join)
                            {
                                message = Translate("connect_message_country", player.CharacterName, geoip.Country);
                            }
                            UnturnedChat.Say(message, @join ? Config.JoinMessage : Config.LeaveMessage);
                        }
                        else
                        {
                            foreach (var sdgPlayer in Provider.clients)
                            {
                                if (sdgPlayer != null)
                                {
                                    if (R.Permissions.HasPermission(new RocketPlayer(sdgPlayer.playerID.steamID.ToString()), "broadcast.extended") || sdgPlayer.isAdmin)
                                    {
                                        message = Translate(@join ? "connect_message_extended" : "disconnect_message_extended", player.CharacterName, player.SteamName, player.CSteamID.ToString());
                                        if (geoip != null && @join)
                                        {
                                            message = Translate("connect_message_country_extended", player.CharacterName, player.SteamName, player.CSteamID.ToString(), geoip.Country);
                                        }
                                    }
                                    else
                                    {
                                        message = Translate(@join ? "connect_message" : "disconnect_message", player.CharacterName);
                                        if (geoip != null && @join)
                                        {
                                            message = Translate("connect_message_country", player.CharacterName, geoip.Country);
                                        }
                                    }
                                    UnturnedChat.Say(sdgPlayer.playerID.steamID, message, @join ? Config.JoinMessage : Config.LeaveMessage);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }
        }
Exemplo n.º 21
0
        protected override void execute(CSteamID executorID, string parameter)
        {
            if (!Dedicator.isDedicated)
            {
                return;
            }
            if (!Provider.isServer)
            {
                CommandWindow.LogError(this.localization.format("NotRunningErrorText"));
                return;
            }
            string[] componentsFromSerial = Parser.getComponentsFromSerial(parameter, '/');
            if (componentsFromSerial.Length != 1 && componentsFromSerial.Length != 2 && componentsFromSerial.Length != 3)
            {
                CommandWindow.LogError(this.localization.format("InvalidParameterErrorText"));
                return;
            }
            CSteamID csteamID;

            if (!PlayerTool.tryGetSteamID(componentsFromSerial[0], out csteamID))
            {
                CommandWindow.LogError(this.localization.format("NoPlayerErrorText", new object[]
                {
                    componentsFromSerial[0]
                }));
                return;
            }
            P2PSessionState_t p2PSessionState_t;
            uint ip;

            if (SteamGameServerNetworking.GetP2PSessionState(csteamID, ref p2PSessionState_t))
            {
                ip = p2PSessionState_t.m_nRemoteIP;
            }
            else
            {
                ip = 0u;
            }
            if (componentsFromSerial.Length == 1)
            {
                SteamBlacklist.ban(csteamID, ip, executorID, this.localization.format("BanTextReason"), SteamBlacklist.PERMANENT);
                CommandWindow.Log(this.localization.format("BanTextPermanent", new object[]
                {
                    csteamID
                }));
            }
            else if (componentsFromSerial.Length == 2)
            {
                SteamBlacklist.ban(csteamID, ip, executorID, componentsFromSerial[1], SteamBlacklist.PERMANENT);
                CommandWindow.Log(this.localization.format("BanTextPermanent", new object[]
                {
                    csteamID
                }));
            }
            else
            {
                uint num;
                if (!uint.TryParse(componentsFromSerial[2], out num))
                {
                    CommandWindow.LogError(this.localization.format("InvalidNumberErrorText", new object[]
                    {
                        componentsFromSerial[2]
                    }));
                    return;
                }
                SteamBlacklist.ban(csteamID, ip, executorID, componentsFromSerial[1], num);
                CommandWindow.Log(this.localization.format("BanText", new object[]
                {
                    csteamID,
                    num
                }));
            }
        }
        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);
        }
Exemplo n.º 23
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);
        }
Exemplo n.º 24
0
 public void askCallVote(CSteamID steamID, CSteamID target)
 {
     if (Provider.isServer)
     {
         if (ChatManager.isVoting)
         {
             return;
         }
         SteamPlayer steamPlayer = PlayerTool.getSteamPlayer(steamID);
         if (steamPlayer == null || Time.realtimeSinceStartup < steamPlayer.nextVote)
         {
             ChatManager.manager.channel.send("tellVoteMessage", steamID, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
             {
                 1
             });
             return;
         }
         if (!steamPlayer.player.tryToPerformRateLimitedAction())
         {
             return;
         }
         if (!ChatManager.voteAllowed)
         {
             ChatManager.manager.channel.send("tellVoteMessage", steamID, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
             {
                 0
             });
             return;
         }
         SteamPlayer steamPlayer2 = PlayerTool.getSteamPlayer(target);
         if (steamPlayer2 == null || steamPlayer2.isAdmin)
         {
             return;
         }
         if (Provider.clients.Count < (int)ChatManager.votePlayers)
         {
             ChatManager.manager.channel.send("tellVoteMessage", steamID, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
             {
                 2
             });
             return;
         }
         CommandWindow.Log(Provider.localization.format("Vote_Kick", new object[]
         {
             steamPlayer.playerID.characterName,
             steamPlayer.playerID.playerName,
             steamPlayer2.playerID.characterName,
             steamPlayer2.playerID.playerName
         }));
         ChatManager.lastVote      = Time.realtimeSinceStartup;
         ChatManager.isVoting      = true;
         ChatManager.voteYes       = 0;
         ChatManager.voteNo        = 0;
         ChatManager.votesPossible = (byte)Provider.clients.Count;
         ChatManager.votesNeeded   = (byte)Mathf.Ceil((float)ChatManager.votesPossible * ChatManager.votePercentage);
         ChatManager.voteOrigin    = steamPlayer;
         ChatManager.voteTarget    = target;
         ChatManager.votes         = new List <CSteamID>();
         P2PSessionState_t p2PSessionState_t;
         if (SteamGameServerNetworking.GetP2PSessionState(ChatManager.voteTarget, out p2PSessionState_t))
         {
             ChatManager.voteIP = p2PSessionState_t.m_nRemoteIP;
         }
         else
         {
             ChatManager.voteIP = 0u;
         }
         ChatManager.manager.channel.send("tellVoteStart", ESteamCall.CLIENTS, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
         {
             steamID,
             target,
             ChatManager.votesNeeded
         });
     }
 }