Пример #1
0
        public void Start()
        {
            orig_Start();

            CustomNetworkManager.Modded = true;
            AddLog("[PHEGGMOD] THIS SERVER IS RUNNING PHEGGMOD");

            //Commented out until SmartGuard is fixed
            //new SmartGuard();

            _debug       = ConfigFile.ServerConfig.GetBool("pheggmod_debug", false);
            _restartTime = ConfigFile.ServerConfig.GetString("auto_restart_time", "04:30");

            if (_debug)
            {
                Base.Debug("Debug mode enabled!");
                Base.Debug("Printing file paths:"
                           + $"\nUserIdBans.txt: {BanHandler.GetPath(BanHandler.BanType.UserId)}"
                           + $"\nIpBans.txt: {BanHandler.GetPath(BanHandler.BanType.IP)}"
                           + $"\nUserIdWhitelist.txt: {ConfigSharing.Paths[2] + "UserIDWhitelist.txt"}"
                           + $"\nUserIdReservedSlots.txt: {ConfigSharing.Paths[3] + "UserIDReservedSlots.txt"}");
            }

            ///This is the time that the server will check for with the auto-restarting system.
            ///Uses 24 hour formatting (16:00 is 4PM), and uses the time relative to the server.
            ///Set to 25:00 to disable;


            new Commands.CustomInternalCommands();
            PluginManager.PluginPreLoad();
        }
Пример #2
0
        public bool Execute(ArraySegment <string> arguments, ICommandSender sender, out string response)
        {
            EasyUnban.IpBans = new List <UserBans>();
            EasyUnban.IdBans = new List <UserBans>();

            bool ipBans = true;
            bool idBans = true;

            string[] ipBansTxt;
            string[] idBansTxt;

            if (EasyUnban.Singleton.Config.ManualDirectory == false)
            {
                ipBansTxt = File.ReadAllLines(BanHandler.GetPath(BanHandler.BanType.IP));
                idBansTxt = File.ReadAllLines(BanHandler.GetPath(BanHandler.BanType.UserId));
            }
            else
            {
                try
                {
                    ipBansTxt = File.ReadAllLines(EasyUnban.Singleton.Config.ManualIpBanDirectory);
                    idBansTxt = File.ReadAllLines(EasyUnban.Singleton.Config.ManualIdBanDirectory);
                }
                catch
                {
                    Log.Error("MANUAL IP OR ID DIRECTORIES DOES NOT EXIST! DOES THE FILE EXISTS AT LEAST??");
                    Log.Error("MANUAL IP OR ID DIRECTORIES DOES NOT EXIST! DOES THE FILE EXISTS AT LEAST??");
                    Log.Error("MANUAL IP OR ID DIRECTORIES DOES NOT EXIST! DOES THE FILE EXISTS AT LEAST??");
                    response = "ERROR: could not update! the Manual directories are invalid in config file!";
                    return(false);
                }
            }

            List <BannedUserInfo> bannedUserIds = new List <BannedUserInfo>();
            List <BannedUserInfo> bannedUserIps = new List <BannedUserInfo>();

            for (int i = 0; i < ipBansTxt.Length; i++)
            {
                string[] e = ipBansTxt[i].Split(';');
                bannedUserIps.Add(new BannedUserInfo(e[0], e[1]));
            }

            for (int i = 0; i < idBansTxt.Length; i++)
            {
                string[] e = idBansTxt[i].Split(';');
                bannedUserIds.Add(new BannedUserInfo(e[0], e[1]));
            }

            if (bannedUserIds.Count == 0)
            {
                idBans = false;
            }
            else
            {
                for (int i = 0; i < bannedUserIds.Count; i++)
                {
                    EasyUnban.IdBans.Add(new UserBans(bannedUserIds[i].Name, bannedUserIds[i].Ban, i));
                }
            }

            if (bannedUserIps.Count == 0)
            {
                ipBans = false;
            }
            else
            {
                for (int i = 0; i < bannedUserIps.Count; i++)
                {
                    EasyUnban.IpBans.Add(new UserBans(bannedUserIps[i].Name, bannedUserIps[i].Ban, i));
                }
            }

            if (idBans == false && ipBans == false)
            {
                EasyUnban.IdBans = null;
                EasyUnban.IpBans = null;
            }

            response = EasyUnban.Singleton.Config.ReloadBansCmdDoneMsg;
            return(true);
        }
Пример #3
0
        public bool Execute(ArraySegment <string> arguments, ICommandSender sender, out string response)
        {
            BanHandler.GetPath(BanHandler.BanType.IP);
            if (arguments.Count != 0)
            {
                response = EasyUnban.Singleton.Config.PardonCmdRunningMsg;

                string plyName = arguments.At(0);

                string steamId = string.Empty;
                string userIp  = string.Empty;

                string[] ipBansTxt = File.ReadAllLines(BanHandler.GetPath(BanHandler.BanType.IP));
                string[] idBansTxt = File.ReadAllLines(BanHandler.GetPath(BanHandler.BanType.UserId));

                List <BannedUserInfo> bannedUserIds = new List <BannedUserInfo>();
                List <BannedUserInfo> bannedUserIps = new List <BannedUserInfo>();

                for (int i = 0; i < ipBansTxt.Length; i++)
                {
                    string[] e = ipBansTxt[i].Split(';');
                    bannedUserIps.Add(new BannedUserInfo(e[0], e[1]));
                }

                for (int i = 0; i < idBansTxt.Length; i++)
                {
                    string[] e = idBansTxt[i].Split(';');
                    bannedUserIds.Add(new BannedUserInfo(e[0], e[1]));
                }

                if (bannedUserIps.Exists(e => e.Name == plyName))
                {
                    userIp = bannedUserIps.Find(e => e.Name == plyName).Ban;
                }
                else
                {
                    response += "\n" +
                                EasyUnban.Singleton.Config.PardonCmdUserNotIpOrIdBanned.Replace("{BanType}", "Ip");
                }

                if (bannedUserIds.Exists(e => e.Name == plyName))
                {
                    steamId = bannedUserIds.Find(e => e.Name == plyName).Ban;
                }
                else
                {
                    response += "\n" +
                                EasyUnban.Singleton.Config.PardonCmdUserNotIpOrIdBanned.Replace("{BanType}", "UserId");
                }

                if (steamId != string.Empty)
                {
                    BanHandler.RemoveBan(steamId, BanHandler.BanType.UserId);
                }
                if (userIp != string.Empty)
                {
                    BanHandler.RemoveBan(userIp, BanHandler.BanType.IP);
                }
                if (steamId == string.Empty && userIp == string.Empty)
                {
                    response += EasyUnban.Singleton.Config.PardonCmdUserIsNotBanned;
                    return(false);
                }

                response += EasyUnban.Singleton.Config.PardonCmdUserIsUnbanned;
                return(true);
            }

            response = EasyUnban.Singleton.Config.PardonCmdUserArgumentMissing;
            return(false);
        }
Пример #4
0
        public override void OnEnabled()
        {
            Singleton = this;
            bool ipBans = true;
            bool idBans = true;

            string[] idBansTxt;
            string[] ipBansTxt;

            if (Config.ManualDirectory == false)
            {
                ipBansTxt = File.ReadAllLines(BanHandler.GetPath(BanHandler.BanType.IP));
                idBansTxt = File.ReadAllLines(BanHandler.GetPath(BanHandler.BanType.UserId));
            }
            else
            {
                try
                {
                    ipBansTxt = File.ReadAllLines(Config.ManualIpBanDirectory);
                    idBansTxt = File.ReadAllLines(Config.ManualIdBanDirectory);
                }
                catch
                {
                    Log.Error("MANUAL IP OR ID DIRECTORIES DOES NOT EXIST! DOES THE FILE EXISTS AT LEAST??");
                    Log.Error("MANUAL IP OR ID DIRECTORIES DOES NOT EXIST! DOES THE FILE EXISTS AT LEAST??");
                    Log.Error("MANUAL IP OR ID DIRECTORIES DOES NOT EXIST! DOES THE FILE EXISTS AT LEAST??");
                    return;
                }
            }


            List <BannedUserInfo> bannedUserIds = new List <BannedUserInfo>();
            List <BannedUserInfo> bannedUserIps = new List <BannedUserInfo>();

            for (int i = 0; i < ipBansTxt.Length; i++)
            {
                string[] e = ipBansTxt[i].Split(';');
                bannedUserIps.Add(new BannedUserInfo(e[0], e[1]));
            }

            for (int i = 0; i < idBansTxt.Length; i++)
            {
                string[] e = idBansTxt[i].Split(';');
                bannedUserIds.Add(new BannedUserInfo(e[0], e[1]));
            }

            if (bannedUserIds.Count == 0)
            {
                idBans = false;
            }
            else
            {
                for (int i = 0; i < bannedUserIds.Count; i++)
                {
                    IdBans.Add(new UserBans(bannedUserIds[i].Name, bannedUserIds[i].Ban, i));
                }
            }

            if (bannedUserIps.Count == 0)
            {
                ipBans = false;
            }
            else
            {
                for (int i = 0; i < bannedUserIps.Count; i++)
                {
                    IpBans.Add(new UserBans(bannedUserIps[i].Name, bannedUserIps[i].Ban, i));
                }
            }

            if (idBans == false && ipBans == false)
            {
                IdBans = null;
                IpBans = null;
            }

            base.OnEnabled();
        }