Exemplo n.º 1
0
        public static void OnLoginError(IRealmClient client, AccountStatus error, bool silent)
        {
            if (!silent)
            {
                s_log.Debug("Client {0} failed to login: {1}", client, error);
            }

            LoginFailInfo failInfo;

            if (!failedLogins.TryGetValue(client.ClientAddress, out failInfo))
            {
                failedLogins.Add(client.ClientAddress, failInfo = new LoginFailInfo(DateTime.Now));
            }
            else
            {
                failInfo.LastAttempt = DateTime.Now;
                failInfo.Count++;
                // TODO: Ban, if trying too often?
            }

            // delay the reply
            ThreadPool.RegisterWaitForSingleObject(failInfo.Handle, (state, timedOut) =>
            {
                if (client.IsConnected)
                {
                    var evt = LoginFailed;
                    if (evt != null)
                    {
                        evt(client, error);
                    }

                    SendAuthChallengeFailReply(client, error);
                }
            }, null, FailedLoginDelay, true);
        }
Exemplo n.º 2
0
        public static void OnLoginError(IRealmClient client, AccountStatus error, bool silent)
        {
            if (!silent)
            {
                AuthenticationHandler.s_log.Debug("Client {0} failed to login: {1}", (object)client, (object)error);
            }
            LoginFailInfo loginFailInfo;

            if (!AuthenticationHandler.failedLogins.TryGetValue(client.ClientAddress, out loginFailInfo))
            {
                AuthenticationHandler.failedLogins.Add(client.ClientAddress,
                                                       loginFailInfo = new LoginFailInfo(DateTime.Now));
            }
            else
            {
                loginFailInfo.LastAttempt = DateTime.Now;
                ++loginFailInfo.Count;
            }

            ThreadPool.RegisterWaitForSingleObject(loginFailInfo.Handle, (WaitOrTimerCallback)((state, timedOut) =>
            {
                if (!client.IsConnected)
                {
                    return;
                }
                AuthenticationHandler.LoginFailedHandler loginFailed = AuthenticationHandler.LoginFailed;
                if (loginFailed != null)
                {
                    loginFailed(client, error);
                }
                AuthenticationHandler.SendAuthChallengeFailReply(client, error);
            }), (object)null, AuthenticationHandler.FailedLoginDelay, true);
        }