public static void AuthSessionRequest(IRealmClient client, RealmPacketIn packet) { if (client.ActiveCharacter != null || client.Account != null) { // Already logged in SendAuthSessionErrorReply(client, LoginErrorCode.AUTH_ALREADY_ONLINE); client.Disconnect(); } else if (!client.IsEncrypted) { var builtNumberClient = packet.ReadUInt32(); var new302 = packet.ReadUInt32(); // NEW 0.0.2.8970 var accName = packet.ReadCString(); var unk322 = packet.ReadUInt32(); client.ClientSeed = packet.ReadUInt32(); var unk1 = packet.ReadUInt32(); // 3.3.5a var unk2 = packet.ReadUInt32(); // 3.3.5a var unk3 = packet.ReadUInt32(); // 3.3.5a var unk4 = packet.ReadUInt64(); client.ClientDigest = packet.ReadBigInteger(20); #if DEBUG log.Debug("builtNumberClient:{0} new302:{1} accName:{2} unk322:{3} client.ClientSeed:{4} unk4:{5} ClientDigest:{6}", builtNumberClient, new302, accName, unk322, client.ClientSeed, unk4, client.ClientDigest); #endif var decompressedDataLength = packet.ReadInt32(); var compressedData = packet.ReadBytes(packet.RemainingLength); client.Addons = new byte[decompressedDataLength]; Compression.DecompressZLib(compressedData, client.Addons); var acctLoadTask = Message.Obtain(() => RealmAccount.InitializeAccount(client, accName)); RealmServer.IOQueue.AddMessage(acctLoadTask); } }
private static void QueryAccountCallback(IRealmClient client, Account acct) { if (client == null || !client.IsConnected) { return; } var accName = client.AccountName; var realmAcc = RealmServer.Instance.GetLoggedInAccount(accName); if (acct != null && acct.IsLogedOn) { Log.Create(Log.Types.AccountOperations, LogSourceType.Account, (uint)acct.AccountId) .AddAttribute("operation", 1, "account_in_use") .AddAttribute("name", 0, acct.Name) .AddAttribute("ip", 0, client.ClientAddress.ToString()) .Write(); OnLoginError(client, AccountStatus.AccountInUse); return; } if (realmAcc != null && realmAcc.ActiveCharacter != null && realmAcc.Client != null && realmAcc.Client.IsConnected) { Log.Create(Log.Types.AccountOperations, LogSourceType.Account, (uint)acct.AccountId) .AddAttribute("operation", 1, "account_in_use") .AddAttribute("name", 0, acct.Name) .AddAttribute("ip", 0, client.ClientAddress.ToString()) .Write(); OnLoginError(client, AccountStatus.AccountInUse); return; } if (acct == null) { // Account doesn't exist yet -> Check for auto creation if (RealmServerConfiguration.AutocreateAccounts) { if (!AccountMgr.NameValidator(ref accName) || client.Password == null || client.Password.Length > 20) { OnLoginError(client, AccountStatus.WrongLoginOrPass); return; } client.AuthAccount = AccountMgr.Instance.CreateAccount(accName, client.Password, "", RealmServerConfiguration.DefaultRole); client.AuthAccount.Save(); //client.Account = new RealmAccount(accName,new AccountInfo(){ClientId = ClientId.Original,AccountId = client.AuthAccount.AccountId,EmailAddress = "",LastIP = client.ClientAddress.GetAddressBytes(),LastLogin = DateTime.Now,Locale = ClientLocale.English,RoleGroupName = "Player"}); SendAuthChallengeSuccessReply(client); } else { OnLoginError(client, AccountStatus.WrongLoginOrPass); return; } client.AuthAccount.IsLogedOn = true; } else { // check if Account may be used if (acct.CheckActive()) { client.AuthAccount = acct; if (realmAcc == null) { SendAuthChallengeSuccessReply(client); } } else { Log.Create(Log.Types.AccountOperations, LogSourceType.Account, (uint)acct.AccountId) .AddAttribute("operation", 1, "login_banned") .AddAttribute("name", 0, acct.Name) .AddAttribute("ip", 0, client.ClientAddress.ToString()) .Write(); // Account has been deactivated if (client.AuthAccount == null || client.AuthAccount.StatusUntil == null) { // temporarily suspended OnLoginError(client, AccountStatus.WrongLoginOrPass); } else { // deactivated OnLoginError(client, AccountStatus.WrongLoginOrPass); } return; } } if (realmAcc == null) { if (acct != null) { Log.Create(Log.Types.AccountOperations, LogSourceType.Account, (uint)acct.AccountId) .AddAttribute("operation", 1, "login_ok") .AddAttribute("name", 0, acct.Name) .AddAttribute("ip", 0, client.ClientAddress.ToString()) .Write(); } RealmAccount.InitializeAccount(client, client.AuthAccount.Name); } else if (acct != null) { if (realmAcc.Client != null) { if (realmAcc.Client.ActiveCharacter != null) { realmAcc.Client.ActiveCharacter.SendInfoMsg("Some one loggin in to your account. Disconnecting."); } realmAcc.Client.Disconnect(); } if (client.ClientAddress == null) { return; } realmAcc.LastIP = client.ClientAddress.GetAddressBytes(); acct.LastIP = client.ClientAddress.GetAddressBytes(); acct.Save(); client.Account = realmAcc; if (realmAcc.ActiveCharacter != null) { ConnectClientToIngameCharacter(client, acct, realmAcc); } else { Log.Create(Log.Types.AccountOperations, LogSourceType.Account, (uint)acct.AccountId) .AddAttribute("operation", 1, "character_select_menu") .AddAttribute("name", 0, acct.Name) .AddAttribute("ip", 0, client.ClientAddress.ToString()) .Write(); SendAuthChallengeSuccessReply(client); } } }
private static void QueryAccountCallback(IRealmClient client, Account acct) { if (client == null || !client.IsConnected) { return; } if (acct != null) { Character characterByAccId = World.GetCharacterByAccId((uint)acct.AccountId); if (characterByAccId != null) { characterByAccId.Logout(true, 0); AuthenticationHandler.OnLoginError(client, AccountStatus.WrongLoginOrPass | AccountStatus.AccountInUse); return; } } string accountName = client.AccountName; RealmAccount loggedInAccount = ServerApp <WCell.RealmServer.RealmServer> .Instance.GetLoggedInAccount(accountName); if (acct != null && acct.IsLogedOn) { Log.Create(Log.Types.AccountOperations, LogSourceType.Account, (uint)acct.AccountId) .AddAttribute("operation", 1.0, "account_in_use").AddAttribute("name", 0.0, acct.Name) .AddAttribute("ip", 0.0, client.ClientAddress.ToString()).Write(); AuthenticationHandler.OnLoginError(client, AccountStatus.AccountInUse); } else if (loggedInAccount != null && loggedInAccount.ActiveCharacter != null && (loggedInAccount.Client != null && loggedInAccount.Client.IsConnected)) { Log.Create(Log.Types.AccountOperations, LogSourceType.Account, (uint)acct.AccountId) .AddAttribute("operation", 1.0, "account_in_use").AddAttribute("name", 0.0, acct.Name) .AddAttribute("ip", 0.0, client.ClientAddress.ToString()).Write(); AuthenticationHandler.OnLoginError(client, AccountStatus.AccountInUse); } else { if (acct == null) { if (RealmServerConfiguration.AutocreateAccounts) { if (!AccountMgr.NameValidator(ref accountName) || client.Password == null || client.Password.Length > 20) { AuthenticationHandler.OnLoginError(client, AccountStatus.WrongLoginOrPass); return; } client.AuthAccount = AccountMgr.Instance.CreateAccount(accountName, client.Password, "", RealmServerConfiguration.DefaultRole); client.AuthAccount.Save(); AuthenticationHandler.SendAuthChallengeSuccessReply(client); client.AuthAccount.IsLogedOn = true; } else { AuthenticationHandler.OnLoginError(client, AccountStatus.WrongLoginOrPass); return; } } else if (acct.CheckActive()) { client.AuthAccount = acct; if (loggedInAccount == null) { AuthenticationHandler.SendAuthChallengeSuccessReply(client); } } else { Log.Create(Log.Types.AccountOperations, LogSourceType.Account, (uint)acct.AccountId) .AddAttribute("operation", 1.0, "login_banned").AddAttribute("name", 0.0, acct.Name) .AddAttribute("ip", 0.0, client.ClientAddress.ToString()).Write(); if (client.AuthAccount == null || !client.AuthAccount.StatusUntil.HasValue) { AuthenticationHandler.OnLoginError(client, AccountStatus.WrongLoginOrPass); return; } AuthenticationHandler.OnLoginError(client, AccountStatus.WrongLoginOrPass); return; } if (loggedInAccount == null) { if (acct != null) { Log.Create(Log.Types.AccountOperations, LogSourceType.Account, (uint)acct.AccountId) .AddAttribute("operation", 1.0, "login_ok").AddAttribute("name", 0.0, acct.Name) .AddAttribute("ip", 0.0, client.ClientAddress.ToString()).Write(); } RealmAccount.InitializeAccount(client, client.AuthAccount.Name); } else { if (acct == null) { return; } if (loggedInAccount.Client != null) { if (loggedInAccount.Client.ActiveCharacter != null) { loggedInAccount.Client.ActiveCharacter.SendInfoMsg( "Some one loggin in to your account. Disconnecting."); } loggedInAccount.Client.Disconnect(false); } if (client.ClientAddress == null) { return; } loggedInAccount.LastIP = client.ClientAddress.GetAddressBytes(); acct.LastIP = client.ClientAddress.GetAddressBytes(); acct.Save(); client.Account = loggedInAccount; if (loggedInAccount.ActiveCharacter != null) { AuthenticationHandler.ConnectClientToIngameCharacter(client, acct, loggedInAccount); } else { Log.Create(Log.Types.AccountOperations, LogSourceType.Account, (uint)acct.AccountId) .AddAttribute("operation", 1.0, "character_select_menu") .AddAttribute("name", 0.0, acct.Name) .AddAttribute("ip", 0.0, client.ClientAddress.ToString()).Write(); AuthenticationHandler.SendAuthChallengeSuccessReply(client); } } } }