mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 01:11:29 +00:00
Update loginserver commands to use the new and more proper argument format
This commit is contained in:
parent
4b69f56a65
commit
4fa14e44aa
@ -84,20 +84,22 @@ namespace EQEmuCommand {
|
||||
}
|
||||
|
||||
std::string options_string;
|
||||
for (auto &opt : options) {
|
||||
for (auto &opt : options) {
|
||||
options_string += " " + opt + "\n";
|
||||
}
|
||||
|
||||
std::stringstream str;
|
||||
str << termcolor::yellow << "\nCommand" << termcolor::reset << "\n\n";
|
||||
std::stringstream command_string;
|
||||
|
||||
std::cout << fmt::format(
|
||||
"{0}{1}{2}\n\nOptions\n{3}",
|
||||
str.str(),
|
||||
argv[1],
|
||||
arguments_string,
|
||||
options_string
|
||||
) << std::endl;
|
||||
command_string <<
|
||||
termcolor::colorize <<
|
||||
termcolor::yellow <<
|
||||
"\nCommand" <<
|
||||
termcolor::reset << "\n\n" <<
|
||||
termcolor::green << argv[1] << arguments_string << termcolor::reset << "\n" <<
|
||||
termcolor::yellow << (!options_string.empty() ? "\nOptions\n\n" : "") <<
|
||||
termcolor::reset << termcolor::cyan << options_string << termcolor::reset;
|
||||
|
||||
std::cout << command_string.str() << std::endl;
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -112,6 +112,9 @@ namespace LoginserverCommandHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
server.token_manager = new LoginserverWebserver::TokenManager;
|
||||
server.token_manager->LoadApiTokens();
|
||||
|
||||
for (auto &it : server.token_manager->loaded_api_tokens) {
|
||||
LogInfo(
|
||||
"token [{0}] can_write [{1}] can_read [{2}]",
|
||||
@ -133,8 +136,8 @@ namespace LoginserverCommandHandler {
|
||||
description = "Creates Local Loginserver Account";
|
||||
|
||||
std::vector<std::string> arguments = {
|
||||
"--username",
|
||||
"--password"
|
||||
"{username}",
|
||||
"{password}"
|
||||
};
|
||||
std::vector<std::string> options = {
|
||||
"--email=*"
|
||||
@ -147,8 +150,8 @@ namespace LoginserverCommandHandler {
|
||||
EQEmuCommand::ValidateCmdInput(arguments, options, cmd, argc, argv);
|
||||
|
||||
AccountManagement::CreateLoginServerAccount(
|
||||
cmd("--username").str(),
|
||||
cmd("--password").str(),
|
||||
cmd(2).str(),
|
||||
cmd(3).str(),
|
||||
cmd("--email").str()
|
||||
);
|
||||
}
|
||||
@ -164,9 +167,9 @@ namespace LoginserverCommandHandler {
|
||||
description = "Creates Loginserver World Administrator Account";
|
||||
|
||||
std::vector<std::string> arguments = {
|
||||
"--username",
|
||||
"--password",
|
||||
"--email"
|
||||
"{username}",
|
||||
"{password}",
|
||||
"{email}"
|
||||
};
|
||||
std::vector<std::string> options = {};
|
||||
|
||||
@ -177,9 +180,9 @@ namespace LoginserverCommandHandler {
|
||||
EQEmuCommand::ValidateCmdInput(arguments, options, cmd, argc, argv);
|
||||
|
||||
AccountManagement::CreateLoginserverWorldAdminAccount(
|
||||
cmd("--username").str(),
|
||||
cmd("--password").str(),
|
||||
cmd("--email").str()
|
||||
cmd(2).str(),
|
||||
cmd(3).str(),
|
||||
cmd(4).str()
|
||||
);
|
||||
}
|
||||
|
||||
@ -194,8 +197,8 @@ namespace LoginserverCommandHandler {
|
||||
description = "Check user login credentials";
|
||||
|
||||
std::vector<std::string> arguments = {
|
||||
"--username",
|
||||
"--password"
|
||||
"{username}",
|
||||
"{password}"
|
||||
};
|
||||
std::vector<std::string> options = {};
|
||||
|
||||
@ -206,11 +209,11 @@ namespace LoginserverCommandHandler {
|
||||
EQEmuCommand::ValidateCmdInput(arguments, options, cmd, argc, argv);
|
||||
|
||||
auto res = AccountManagement::CheckLoginserverUserCredentials(
|
||||
cmd("--username").str(),
|
||||
cmd("--password").str()
|
||||
cmd(2).str(),
|
||||
cmd(3).str()
|
||||
);
|
||||
|
||||
LogInfo("Credentials were {0}", res == true ? "accepted" : "not accepted");
|
||||
LogInfo("Credentials were {0}", res != 0 ? "accepted" : "not accepted");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -224,8 +227,8 @@ namespace LoginserverCommandHandler {
|
||||
description = "Change user login credentials";
|
||||
|
||||
std::vector<std::string> arguments = {
|
||||
"--username",
|
||||
"--password"
|
||||
"{username}",
|
||||
"{password}"
|
||||
};
|
||||
std::vector<std::string> options = {};
|
||||
|
||||
@ -236,8 +239,8 @@ namespace LoginserverCommandHandler {
|
||||
EQEmuCommand::ValidateCmdInput(arguments, options, cmd, argc, argv);
|
||||
|
||||
AccountManagement::UpdateLoginserverUserCredentials(
|
||||
cmd("--username").str(),
|
||||
cmd("--password").str()
|
||||
cmd(2).str(),
|
||||
cmd(3).str()
|
||||
);
|
||||
}
|
||||
|
||||
@ -252,8 +255,8 @@ namespace LoginserverCommandHandler {
|
||||
description = "Check user external login credentials";
|
||||
|
||||
std::vector<std::string> arguments = {
|
||||
"--username",
|
||||
"--password"
|
||||
"{username}",
|
||||
"{password}"
|
||||
};
|
||||
std::vector<std::string> options = {};
|
||||
|
||||
@ -264,8 +267,8 @@ namespace LoginserverCommandHandler {
|
||||
EQEmuCommand::ValidateCmdInput(arguments, options, cmd, argc, argv);
|
||||
|
||||
auto res = AccountManagement::CheckExternalLoginserverUserCredentials(
|
||||
cmd("--username").str(),
|
||||
cmd("--password").str()
|
||||
cmd(2).str(),
|
||||
cmd(3).str()
|
||||
);
|
||||
|
||||
LogInfo("Credentials were {0}", res ? "accepted" : "not accepted");
|
||||
@ -282,8 +285,8 @@ namespace LoginserverCommandHandler {
|
||||
description = "Update world admin account password";
|
||||
|
||||
std::vector<std::string> arguments = {
|
||||
"--username",
|
||||
"--password"
|
||||
"{username}",
|
||||
"{password}"
|
||||
};
|
||||
std::vector<std::string> options = {};
|
||||
|
||||
@ -294,8 +297,8 @@ namespace LoginserverCommandHandler {
|
||||
EQEmuCommand::ValidateCmdInput(arguments, options, cmd, argc, argv);
|
||||
|
||||
AccountManagement::UpdateLoginserverWorldAdminAccountPasswordByName(
|
||||
cmd("--username").str(),
|
||||
cmd("--password").str()
|
||||
cmd(2).str(),
|
||||
cmd(3).str()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,22 +43,28 @@ void CatchSignal(int sig_num)
|
||||
{
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
void LoadDatabaseConnection()
|
||||
{
|
||||
RegisterExecutablePlatform(ExePlatformLogin);
|
||||
set_exception_handler();
|
||||
LogInfo("MySQL Database Init");
|
||||
|
||||
LogInfo("Logging System Init");
|
||||
server.db = new Database(
|
||||
server.config.GetVariableString("database", "user", "root"),
|
||||
server.config.GetVariableString("database", "password", ""),
|
||||
server.config.GetVariableString("database", "host", "localhost"),
|
||||
server.config.GetVariableString("database", "port", "3306"),
|
||||
server.config.GetVariableString("database", "db", "peq")
|
||||
);
|
||||
|
||||
if (argc == 1) {
|
||||
LogSys.LoadLogSettingsDefaults();
|
||||
}
|
||||
}
|
||||
|
||||
void LoadServerConfig()
|
||||
{
|
||||
server.config = EQ::JsonConfigFile::Load("login.json");
|
||||
LogInfo("Config System Init");
|
||||
|
||||
|
||||
/**
|
||||
* options: logging
|
||||
* Logging
|
||||
*/
|
||||
server.options.Trace(server.config.GetVariableBool("logging", "trace", false));
|
||||
server.options.WorldTrace(server.config.GetVariableBool("logging", "world_trace", false));
|
||||
@ -66,7 +72,7 @@ int main(int argc, char **argv)
|
||||
server.options.DumpOutPackets(server.config.GetVariableBool("logging", "dump_packets_out", false));
|
||||
|
||||
/**
|
||||
* options: worldservers
|
||||
* Worldservers
|
||||
*/
|
||||
server.options.RejectDuplicateServers(
|
||||
server.config.GetVariableBool(
|
||||
@ -77,7 +83,7 @@ int main(int argc, char **argv)
|
||||
server.options.AllowUnregistered(server.config.GetVariableBool("worldservers", "unregistered_allowed", true));
|
||||
|
||||
/**
|
||||
* options: account
|
||||
* Account
|
||||
*/
|
||||
server.options.AutoCreateAccounts(server.config.GetVariableBool("account", "auto_create_accounts", true));
|
||||
server.options.AutoLinkAccounts(server.config.GetVariableBool("account", "auto_link_accounts", false));
|
||||
@ -92,6 +98,9 @@ int main(int argc, char **argv)
|
||||
);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Default Loginserver Name (Don't change)
|
||||
*/
|
||||
server.options.DefaultLoginServerName(
|
||||
server.config.GetVariableString(
|
||||
"general",
|
||||
@ -100,6 +109,10 @@ int main(int argc, char **argv)
|
||||
)
|
||||
);
|
||||
|
||||
/**
|
||||
* Security
|
||||
*/
|
||||
|
||||
#ifdef ENABLE_SECURITY
|
||||
server.options.EncryptionMode(server.config.GetVariableInt("security", "mode", 13));
|
||||
#else
|
||||
@ -115,19 +128,41 @@ int main(int argc, char **argv)
|
||||
true
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
RegisterExecutablePlatform(ExePlatformLogin);
|
||||
set_exception_handler();
|
||||
|
||||
LogInfo("Logging System Init");
|
||||
|
||||
if (argc == 1) {
|
||||
LogSys.LoadLogSettingsDefaults();
|
||||
}
|
||||
|
||||
/**
|
||||
* Command handler
|
||||
*/
|
||||
if (argc > 1) {
|
||||
LogSys.SilenceConsoleLogging();
|
||||
|
||||
LoadServerConfig();
|
||||
LoadDatabaseConnection();
|
||||
|
||||
LogSys.LoadLogSettingsDefaults();
|
||||
LogSys.log_settings[Logs::Debug].log_to_console = static_cast<uint8>(Logs::General);
|
||||
LogSys.log_settings[Logs::Debug].is_category_enabled = 1;
|
||||
|
||||
LoginserverCommandHandler::CommandHandler(argc, argv);
|
||||
}
|
||||
|
||||
LoadServerConfig();
|
||||
|
||||
/**
|
||||
* mysql connect
|
||||
*/
|
||||
LogInfo("MySQL Database Init");
|
||||
|
||||
server.db = new Database(
|
||||
server.config.GetVariableString("database", "user", "root"),
|
||||
server.config.GetVariableString("database", "password", ""),
|
||||
server.config.GetVariableString("database", "host", "localhost"),
|
||||
server.config.GetVariableString("database", "port", "3306"),
|
||||
server.config.GetVariableString("database", "db", "peq")
|
||||
);
|
||||
LoadDatabaseConnection();
|
||||
|
||||
if (argc == 1) {
|
||||
server.db->LoadLogSettings(LogSys.log_settings);
|
||||
@ -195,17 +230,6 @@ int main(int argc, char **argv)
|
||||
LoginserverWebserver::RegisterRoutes(api);
|
||||
}
|
||||
|
||||
/**
|
||||
* Command handler
|
||||
*/
|
||||
if (argc > 1) {
|
||||
LogSys.LoadLogSettingsDefaults();
|
||||
LogSys.log_settings[Logs::Debug].log_to_console = static_cast<uint8>(Logs::General);
|
||||
LogSys.log_settings[Logs::Debug].is_category_enabled = 1;
|
||||
|
||||
LoginserverCommandHandler::CommandHandler(argc, argv);
|
||||
}
|
||||
|
||||
LogInfo("[Config] [Logging] IsTraceOn [{0}]", server.options.IsTraceOn());
|
||||
LogInfo("[Config] [Logging] IsWorldTraceOn [{0}]", server.options.IsWorldTraceOn());
|
||||
LogInfo("[Config] [Logging] IsDumpInPacketsOn [{0}]", server.options.IsDumpInPacketsOn());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user