public static void AddFailedLogin(string acc, string ip) { FailedLoginInfo value = null; checked { if (banlist.TryGetValue(ip, out value)) { if (DateAndTime.Now.Subtract(value.Time).TotalMilliseconds > (double)(LoginConfig.PASSWORD_CHECK_TIME * 60 * 1000)) { banlist.Remove(ip); banlist.Add(ip, new FailedLoginInfo(acc, ip)); } else if (value.Count + 1 >= LoginConfig.PASSWORD_CHECK_COUNT) { banlist.Remove(ip); BannedIpController.BanIP(ip, DateAndTime.Now.AddMinutes(LoginConfig.PASSWORD_CHECK_BANTIME)); } else { value.IncreseCount(); } } else { banlist.Add(ip, new FailedLoginInfo(acc, ip)); } } }
public static void Main() { try { log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo("log4net.config")); System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance); //try //{ // Test(); //} //catch (Exception err) //{ //} AppDomain.CurrentDomain.UnhandledException += UnhandledException; Util.RemoveMenu(); Util.RegeditCloseEvent(ref handler, add: true); Console.Title = title; Util.SystemInfo(); Stopwatch stopwatch = Stopwatch.StartNew(); CronService.GetInstance().Initialize(); Util.Section("服务配置"); Configs.LoadConfig(); Util.Section("核心服务"); DAOManager.Initialize(); KeyGen.Initial(); GameService.LoadGameservers(); BannedIpController.Initialize(); LunaController.GetInstance().Initial(); Util.Section("网络服务"); AionPacketFactory.GetInstance(); LoginListener.GetInstance().Start(); GamePacketFactory.GetInstance(); GameListener.GetInstance().Start(); Util.Section("充值奖励"); PayRewardService.GetInstance(); Util.Section(""); stopwatch.Stop(); string text = string.Format("登陆服务器启动完成,耗时{0}秒!", ((double)stopwatch.ElapsedMilliseconds / 1000.0).ToString("0.00")); string text2 = "使用快捷键 Ctrl + C 关闭服务并保存数据!"; Console.WriteLine(new string(' ', Conversions.ToInteger(Util.StringLength(text))) + text); Console.WriteLine(new string(' ', Conversions.ToInteger(Util.StringLength(text2))) + text2); Util.Section(""); if (LoginConfig.WORKING_MEMORY_SET_ENABLE) { WorkingMemorySet.GetInstance().Initialize(LoginConfig.WORKING_MEMORY_SET_CRON); } } catch (Exception err) { log.Error(err.Message, err); } }
protected override void runImpl() { if (type == 2) { if (time > 0) { DateTime dateTime = DateAndTime.Now.AddMinutes(time); BannedIpController.BanIP(ip, dateTime); } else { BannedIpController.UnBan(ip); } SendPacket(new SM_GS_BAN_RESPONE(type, accountId, ip, time, adminObj, result: true)); } else { log.Warn((object)"未实现的封禁方法!"); } }
internal static AionAuthResponse Login(string userName, string password, AionConnection client) { Account account = LoadAccount(userName); if (Information.IsNothing(account) & LoginConfig.ACCOUNT_AUTO_CREATION) { account = CreateAccount(userName, password); } if (Information.IsNothing(account)) { return(AionAuthResponse.INVALID_PASSWORD); } if (!account.Password.Equals(RuntimeHelpers.GetObjectValue(EncodePassword(password)))) { if (LoginConfig.PASSWORD_CHECK_ENABLE) { BruteForceProtector.AddFailedLogin(userName, client.IP); } return(AionAuthResponse.INVALID_PASSWORD); } if (account.Activated != 1) { return(AionAuthResponse.BAN_ACCOUNT); } string text = client.IP.Split(':')[0]; if (BannedIpController.IsBannedIp(text)) { return(AionAuthResponse.BAN_IP); } if (!GameService.HahServerOnline()) { return(AionAuthResponse.NOT_SERVER_ONLINE); } object @lock = _lock; ObjectFlowControl.CheckForSyncLockOnValueType(@lock); bool lockTaken = false; try { Monitor.Enter(@lock, ref lockTaken); if (GameService.ContainsAccount(account.Id)) { GameService.KickAccountFromGameServer(account.Id); return(AionAuthResponse.ALREADY_LOGGED_IN); } if (accountOnLS.ContainsKey(account.Id)) { accountOnLS[account.Id].Disconnect(); accountOnLS.Remove(account.Id); return(AionAuthResponse.ALREADY_LOGGED_IN); } client.Account = account; accountOnLS.Add(account.Id, client); } finally { if (lockTaken) { Monitor.Exit(@lock); } } account.LastIp = text; account.AccountTime.LastLoginTime = DateAndTime.Now; AccountTimeController.UpDataLoginTime(account); return(AionAuthResponse.AUTHED); }