public override void Process(Level a) { if (Client.CState >= 1) { CheckClient(); // IF THE USER IS TOTALLY NEW, WITH ID 0 AND NO TOKEN if (UserID == 0 || string.IsNullOrEmpty(UserToken)) { NewUser(); return; } level = ResourcesManager.GetPlayer(UserID); // THE USER HAVE AN ID, WE CHECK IF IT'S IN DATABASE if (level != null) { if (level.Banned()) // IF THE USER IS FOUND BUT BANNED { var p = new LoginFailedMessage(Client); p.SetErrorCode(11); PacketManager.ProcessOutgoingPacket(p); return; } if (String.Equals(level.GetPlayerAvatar().GetUserToken(), UserToken, StringComparison.Ordinal)) // IF THE USER TOKEN MATCH THE CLIENT TOKEN { LogUser(); } else // ELSE, HE IS TRYING TO STEAL AN ACCOUNT { var p = new LoginFailedMessage(Client); p.SetErrorCode(11); p.SetReason("We have detected unrecognized token sended from your devices. Please contact server owner for more information"); PacketManager.ProcessOutgoingPacket(p); return; } } else // IF NOTHING IS FOUND IN DATABASE WITH THIS ID, WE CREATE A NEW { NewUser(); } if (ResourcesManager.IsPlayerOnline(level)) { var mail = new AllianceMailStreamEntry(); mail.SetId((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds); mail.SetSenderId(0); mail.SetSenderAvatarId(0); mail.SetSenderName("Server Manager"); mail.SetIsNew(0); mail.SetAllianceId(0); mail.SetSenderLeagueId(22); mail.SetAllianceBadgeData(1728059989); mail.SetAllianceName("Server Admin"); mail.SetMessage(ConfigurationManager.AppSettings["AdminMessage"]); mail.SetSenderLevel(500); var p = new AvatarStreamEntryMessage(level.GetClient()); p.SetAvatarStreamEntry(mail); PacketManager.ProcessOutgoingPacket(p); } } }
private LoginFailedMessage GetLoginFailedMessage(int errCode) { var message = new LoginFailedMessage(Client); message.SetErrorCode(6); message.SetReason($"CoM{errCode}\r\nWe have detected an issue with you ID, clean app data to continue."); return(message); }
private LoginFailedMessage GetCleanUpLoginFailedMessage() { var message = new LoginFailedMessage(Client); message.SetErrorCode(6); message.SetReason("We have detected an issue with your ID. Please clear your app data to continue playing! \n\nSettings -> Application Manager -> Clear App Data\n\nFor more informations, please check our official Website.\n\nhttps://www.clashofmagic.net/"); return(message); }
public override void Process(Level level) { MainWindow.RemoteWindow.WriteConsole(Convert.ToString(Unknown1), (int)MainWindow.level.WARNING); MainWindow.RemoteWindow.WriteConsole(Convert.ToString(Unknown2), (int)MainWindow.level.WARNING); MainWindow.RemoteWindow.WriteConsole(Convert.ToString(Unknown3), (int)MainWindow.level.WARNING); MainWindow.RemoteWindow.WriteConsole(Convert.ToString(Unknown4), (int)MainWindow.level.WARNING); MainWindow.RemoteWindow.WriteConsole(Convert.ToString(Unknown5), (int)MainWindow.level.WARNING); MainWindow.RemoteWindow.WriteConsole(Convert.ToString(Unknown6), (int)MainWindow.level.WARNING); MainWindow.RemoteWindow.WriteConsole(Convert.ToString(Unknown7), (int)MainWindow.level.WARNING); var p = new LoginFailedMessage(Client); p.SetErrorCode(10); p.RemainingTime(0); p.SetReason("You are connecting with 8.67 client but UCS not support it yet"); PacketManager.ProcessOutgoingPacket(p); }
async void CheckClient() { try { if (UserID == 0 || string.IsNullOrEmpty(UserToken)) { NewUser(); return; } level = await ResourcesManager.GetPlayer(UserID); if (level != null) { if (level.Banned()) { LoginFailedMessage p = new LoginFailedMessage(Client); p.SetErrorCode(11); PacketProcessor.Send(p); return; } if (string.Equals(level.GetPlayerAvatar().GetUserToken(), UserToken, StringComparison.Ordinal)) { LogUser(); } else { LoginFailedMessage p = new LoginFailedMessage(Client); p.SetErrorCode(11); /*FOR FHX*/ // p.SetReason("Please clean the Data of your CoH app. \n\nSettings -> Application Manager -> Clear Data.(#1)\n\nMore Info, please check our official Website.\nOfficial Site: http://www.clashofheroes.net"); p.SetReason("We have some Problems with your Account. Please clean your App Data. https://ultrapowa.com/forum"); PacketProcessor.Send(p); return; } } else { LoginFailedMessage p = new LoginFailedMessage(Client); p.SetErrorCode(11); /*FOR FHX*/ // p.SetReason("Please clean the Data of your CoH app. \n\nSettings -> Application Manager -> Clear Data.(#1)\n\nMore Info, please check our official Website.\nOfficial Site: http://www.clashofheroes.net"); p.SetReason("We have some Problems with your Account. Please clean your App Data. https://ultrapowa.com/forum"); PacketProcessor.Send(p); return; } } catch (Exception) { } }
public override void Process(Level a) { if (Client.CState >= 1) { CheckClient(); // IF THE USER IS TOTALLY NEW, WITH ID 0 AND NO TOKEN if (UserID == 0 || string.IsNullOrEmpty(UserToken)) { NewUser(); return; } level = ResourcesManager.GetPlayer(UserID); // THE USER HAVE AN ID, WE CHECK IF IT'S IN DATABASE if (level != null) { if (level.Banned()) // IF THE USER IS FOUND BUT BANNED { var p = new LoginFailedMessage(Client); p.SetErrorCode(11); PacketManager.ProcessOutgoingPacket(p); return; } if (String.Equals(level.GetPlayerAvatar().GetUserToken(), UserToken, StringComparison.Ordinal)) // IF THE USER TOKEN MATCH THE CLIENT TOKEN { LogUser(); } else // ELSE, HE IS TRYING TO STEAL AN ACCOUNT { var p = new LoginFailedMessage(Client); p.SetErrorCode(11); p.SetReason("We have detected unrecognized token sended from your devices. Please contact server owner for more information"); PacketManager.ProcessOutgoingPacket(p); return; } } else // IF NOTHING IS FOUND IN DATABASE WITH THIS ID, WE CREATE A NEW { NewUser(); } } }
void CheckClient() { if (UserID == 0 || string.IsNullOrEmpty(UserToken)) { NewUser(); return; } level = ResourcesManager.GetPlayer(UserID); if (level != null) { if (level.Banned()) { var p = new LoginFailedMessage(Client); p.SetErrorCode(11); PacketManager.ProcessOutgoingPacket(p); return; } if (string.Equals(level.GetPlayerAvatar().GetUserToken(), UserToken, StringComparison.Ordinal)) { LogUser(); } else { var p = new LoginFailedMessage(Client); p.SetErrorCode(11); p.SetReason("We have detected unrecognized token sended from your devices. Please clean your App Data."); PacketManager.ProcessOutgoingPacket(p); return; } } else { var p = new LoginFailedMessage(Client); p.SetErrorCode(11); p.SetReason("We have detected unrecognized token sended from your devices. Please clean your App Data."); PacketManager.ProcessOutgoingPacket(p); return; } }
private bool CheckServerCapabilities() { if ((ServerStatus.Status == ServerStatusType.SHUTDOWN_STARTED || ServerStatus.Status == ServerStatusType.MAINTENANCE) && !EnvironmentSettings.IsDeveloperIP(this.m_connection.ClientIP.ToString())) { LoginFailedMessage loginFailedMessage = new LoginFailedMessage(); loginFailedMessage.SetErrorCode(LoginFailedMessage.ErrorCode.SERVER_MAINTENANCE); loginFailedMessage.SetEndMaintenanceTime(LogicMath.Max(ServerStatus.Time + ServerStatus.NextTime - TimeUtil.GetTimestamp(), 0)); this.SendMessage(loginFailedMessage); return(false); } if (ProxySessionManager.Count >= EnvironmentSettings.Settings.Proxy.SessionCapacity) { LoginFailedMessage loginFailedMessage = new LoginFailedMessage(); loginFailedMessage.SetErrorCode((LoginFailedMessage.ErrorCode) 1000); loginFailedMessage.SetReason("The servers are not able to connect you at this time. Try again in a few minutes."); this.SendMessage(loginFailedMessage); return(false); } return(true); }
public override void Process(Level a) { if (Client.State == ClientState.Login) { if (Constants.IsRc4) { Client.ClientSeed = Seed; new RC4SessionKey(Client).Send(); } if (ParserThread.GetMaintenanceMode() == true) { var p = new LoginFailedMessage(Client); p.SetErrorCode(10); p.RemainingTime(ParserThread.GetMaintenanceTime()); p.SetMessageVersion(8); p.Send(); return; } if (Constants.IsPremiumServer == false) { if (ResourcesManager.GetOnlinePlayers().Count >= 100) { var p = new LoginFailedMessage(Client); p.SetErrorCode(11); p.SetReason("This is a free Version of UCS. Please Upgrade to Premium on https://ultrapowa.com/forum"); p.Send(); return; } } int time = Convert.ToInt32(ConfigurationManager.AppSettings["maintenanceTimeleft"]); if (time != 0) { var p = new LoginFailedMessage(Client); p.SetErrorCode(10); p.RemainingTime(time); p.SetMessageVersion(8); p.Send(); return; } if (ConfigurationManager.AppSettings["CustomMaintenance"] != string.Empty) { var p = new LoginFailedMessage(Client); p.SetErrorCode(10); p.SetReason(ConfigurationManager.AppSettings["CustomMaintenance"]); p.Send(); return; } var cv2 = ConfigurationManager.AppSettings["ClientVersion"].Split('.'); var cv = ClientVersion.Split('.'); if (cv[0] != cv2[0] || cv[1] != cv2[1]) { var p = new LoginFailedMessage(Client); p.SetErrorCode(8); p.SetUpdateURL(Convert.ToString(ConfigurationManager.AppSettings["UpdateUrl"])); p.Send(); return; } if (Convert.ToBoolean(ConfigurationManager.AppSettings["useCustomPatch"]) && MasterHash != ObjectManager.FingerPrint.sha) { var p = new LoginFailedMessage(Client); p.SetErrorCode(7); p.SetResourceFingerprintData(ObjectManager.FingerPrint.SaveToJson()); p.SetContentURL(ConfigurationManager.AppSettings["patchingServer"]); p.SetUpdateURL(ConfigurationManager.AppSettings["UpdateUrl"]); p.Send(); return; } CheckClient(); } }
private async void LoginMessageReceived(LoginMessage message) { if (this.m_connection.State == ClientConnectionState.DEFAULT && this.CheckClientVersion(message.GetClientMajorVersion(), message.GetClientBuildVersion(), message.GetAppVersion(), message.GetResourceSha(), message.IsAndroidClient()) && this.CheckServerCapabilities()) { this.m_connection.Messaging.SetScramblerSeed(message.GetScramblerSeed()); this.m_connection.SetState(ClientConnectionState.LOGIN); AccountDocument accountDocument; if (message.GetAccountId().IsZero() && message.GetPassToken() == null) { IOperationResult <ulong> incrementSeedResult = await ServerProxy.AccountDatabase.IncrementSeed(); if (!incrementSeedResult.Success) { LoginFailedMessage loginFailedMessage = new LoginFailedMessage(); loginFailedMessage.SetErrorCode(LoginFailedMessage.ErrorCode.SERVER_MAINTENANCE); loginFailedMessage.SetReason("Internal server error"); this.SendMessage(loginFailedMessage); return; } accountDocument = new AccountDocument((long)incrementSeedResult.Value); accountDocument.Init(); accountDocument.Country = this.m_connection.Location; IOperationResult <string> createAccountResult = await ServerProxy.AccountDatabase.Insert((long)incrementSeedResult.Value, CouchbaseDocument.Save(accountDocument)); if (!createAccountResult.Success) { LoginFailedMessage loginFailedMessage = new LoginFailedMessage(); loginFailedMessage.SetErrorCode(LoginFailedMessage.ErrorCode.SERVER_MAINTENANCE); loginFailedMessage.SetReason("Internal server error"); this.SendMessage(loginFailedMessage); return; } } else { IOperationResult <string> getResult = await ServerProxy.AccountDatabase.Get(message.GetAccountId()); if (!getResult.Success) { if (getResult.Status == ResponseStatus.KeyNotFound) { LoginFailedMessage loginFailedMessage = new LoginFailedMessage(); loginFailedMessage.SetErrorCode(LoginFailedMessage.ErrorCode.ACCOUNT_NOT_EXISTS); this.SendMessage(loginFailedMessage); } else { LoginFailedMessage loginFailedMessage = new LoginFailedMessage(); loginFailedMessage.SetErrorCode(LoginFailedMessage.ErrorCode.SERVER_MAINTENANCE); loginFailedMessage.SetReason("Internal server error"); this.SendMessage(loginFailedMessage); } return; } accountDocument = CouchbaseDocument.Load <AccountDocument>(getResult.Value); if (accountDocument.PassToken != message.GetPassToken()) { LoginFailedMessage loginFailedMessage = new LoginFailedMessage(); loginFailedMessage.SetErrorCode(LoginFailedMessage.ErrorCode.ACCOUNT_NOT_EXISTS); this.SendMessage(loginFailedMessage); return; } } if (accountDocument.State != AccountState.NORMAL) { switch (accountDocument.State) { case AccountState.BANNED: { LoginFailedMessage loginFailedMessage = new LoginFailedMessage(); loginFailedMessage.SetErrorCode(LoginFailedMessage.ErrorCode.BANNED); loginFailedMessage.SetReason(accountDocument.StateArg); this.SendMessage(loginFailedMessage); return; } case AccountState.LOCKED: { LoginFailedMessage loginFailedMessage = new LoginFailedMessage(); loginFailedMessage.SetErrorCode(LoginFailedMessage.ErrorCode.ACCOUNT_LOCKED); this.SendMessage(loginFailedMessage); return; } } } ProxySession session = ProxySessionManager.Create(this.m_connection, accountDocument); RedisValue prevSession = await ServerProxy.SessionDatabase.GetSet(accountDocument.Id, session.Id.ToString()); if (!prevSession.IsNull) { long prevSessionId = long.Parse(prevSession); ServerMessageManager.SendMessage(new StopSessionMessage { Reason = 1, SessionId = prevSessionId }, ServerManager.GetProxySocket(prevSessionId)); } session.SetSocket(ServerCore.Socket); // Proxy LoginOkMessage loginOkMessage = new LoginOkMessage(); loginOkMessage.SetAccountId(accountDocument.Id); loginOkMessage.SetHomeId(accountDocument.Id); loginOkMessage.SetPassToken(accountDocument.PassToken); loginOkMessage.SetFacebookId(accountDocument.FacebookId); loginOkMessage.SetGamecenterId(accountDocument.GamecenterId); loginOkMessage.SetServerMajorVersion(LogicVersion.MAJOR_VERSION); loginOkMessage.SetServerBuildVersion(LogicVersion.BUILD_VERSION); loginOkMessage.SetContentVersion(ResourceManager.GetContentVersion()); loginOkMessage.SetServerEnvironment(EnvironmentSettings.Environment); loginOkMessage.SetSessionCount(accountDocument.SessionCount); loginOkMessage.SetPlayTimeSeconds(accountDocument.PlayTimeSeconds); loginOkMessage.SetAccountCreatedDate(accountDocument.CreateTime.ToString()); loginOkMessage.SetStartupCooldownSeconds(ServerProxy.GetStartupCooldownSeconds()); loginOkMessage.SetRegion(this.m_connection.Location); loginOkMessage.SetFacebookAppId(ResourceSettings.FacebookAppId); loginOkMessage.SetGoogleServiceId(ResourceSettings.GoogleServiceId); loginOkMessage.SetContentUrlList(ResourceSettings.ContentUrlList); loginOkMessage.SetChronosContentUrlList(ResourceSettings.ChronosContentUrlList); this.SendMessage(loginOkMessage); this.m_connection.SetSession(session); this.m_connection.SetState(ClientConnectionState.LOGGED); if (this.m_connection.State == ClientConnectionState.LOGGED) { accountDocument.SessionCount += 1; accountDocument.LastSessionTime = TimeUtil.GetTimestamp(); ServerRequestManager.Create(new BindServerSocketRequestMessage { ServerType = 9, ServerId = ServerManager.GetDocumentSocket(9, accountDocument.Id).ServerId, SessionId = session.Id }, ServerCore.Socket, 5).OnComplete = this.OnGameServerBound; await ServerProxy.AccountDatabase.Update(accountDocument.Id, CouchbaseDocument.Save(accountDocument)); } else { this.m_connection.DestructSession(); } } }
public override void Process(Level a) { try { if (Client.State == ClientState.Login) { if (Constants.IsRc4) { Client.ClientSeed = Seed; PacketProcessor.Send(new RC4SessionKey(Client)); } if (Constants.LicensePlanID == 3) { if (ResourcesManager.GetOnlinePlayers().Count >= Constants.MaxOnlinePlayers) { LoginFailedMessage p = new LoginFailedMessage(Client); p.SetErrorCode(12); p.SetReason("Sorry the Server is currently full! \n\nPlease try again in a few Minutes.\n"); PacketProcessor.Send(p); return; } } if (ParserThread.GetMaintenanceMode()) { LoginFailedMessage p = new LoginFailedMessage(Client); p.SetErrorCode(10); p.RemainingTime(ParserThread.GetMaintenanceTime()); p.SetMessageVersion(8); PacketProcessor.Send(p); return; } if (Constants.LicensePlanID < 1) { if (ResourcesManager.GetOnlinePlayers().Count >= 350) { LoginFailedMessage p = new LoginFailedMessage(Client); p.SetErrorCode(11); p.SetReason("This is a Free Version of UCS. Please Upgrade on https://ultrapowa.com/forum"); PacketProcessor.Send(p); return; } } else if (Constants.LicensePlanID < 2) { if (ResourcesManager.GetOnlinePlayers().Count >= 700) { LoginFailedMessage p = new LoginFailedMessage(Client); p.SetErrorCode(11); p.SetReason("This is a Pro Version of UCS. Please Upgrade to Ultra on https://ultrapowa.com/forum"); PacketProcessor.Send(p); return; } } int time = Convert.ToInt32(ConfigurationManager.AppSettings["maintenanceTimeleft"]); if (time != 0) { LoginFailedMessage p = new LoginFailedMessage(Client); p.SetErrorCode(10); p.RemainingTime(time); p.SetMessageVersion(8); PacketProcessor.Send(p); return; } if (ConfigurationManager.AppSettings["CustomMaintenance"] != string.Empty) { LoginFailedMessage p = new LoginFailedMessage(Client); p.SetErrorCode(10); p.SetReason(ConfigurationManager.AppSettings["CustomMaintenance"]); PacketProcessor.Send(p); return; } string[] cv2 = ConfigurationManager.AppSettings["ClientVersion"].Split('.'); string[] cv = ClientVersion.Split('.'); if (cv[0] != cv2[0] || cv[1] != cv2[1]) { LoginFailedMessage p = new LoginFailedMessage(Client); p.SetErrorCode(8); /*FOR FHX*/ //p.SetReason("Please re-downoad the APK on the Official FHX Site! \n Official Site: \n\n https://fhx-server.com, or \nhttp://fhxservercoc.com \n\n Or click the Update Button below!"); p.SetUpdateURL(Convert.ToString(ConfigurationManager.AppSettings["UpdateUrl"])); PacketProcessor.Send(p); return; } if (Convert.ToBoolean(ConfigurationManager.AppSettings["useCustomPatch"]) && MasterHash != ObjectManager.FingerPrint.sha) { LoginFailedMessage p = new LoginFailedMessage(Client); p.SetErrorCode(7); p.SetResourceFingerprintData(ObjectManager.FingerPrint.SaveToJson()); p.SetContentURL(ConfigurationManager.AppSettings["patchingServer"]); p.SetUpdateURL(ConfigurationManager.AppSettings["UpdateUrl"]); PacketProcessor.Send(p); return; } CheckClient(); } } catch (Exception) { } }