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