Increases the server config character limit (#7006)

* Fixes #5324.
* Adjusts the Login, Character and Map server's ID, password, schema, and codepage character limit from 31 to 1023.
* Adjusts the Login, Character, and Map server's IP character limit from 63 to 1023.
* Removes password echos during failed connections.
Thanks to @reunite-ro!
This commit is contained in:
Aleos 2022-06-07 11:23:50 -04:00 committed by GitHub
parent 354d2605f2
commit a7a9b68ed2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 54 additions and 54 deletions

View File

@ -44,11 +44,11 @@ InterServerDatabase interServerDb;
Sql* sql_handle = NULL; ///Link to mysql db, connection FD
int char_server_port = 3306;
char char_server_ip[64] = "127.0.0.1";
char char_server_id[32] = "ragnarok";
char char_server_pw[32] = ""; // Allow user to send empty password (bugreport:7787)
char char_server_db[32] = "ragnarok";
char default_codepage[32] = ""; //Feature by irmin.
std::string char_server_ip = "127.0.0.1";
std::string char_server_id = "ragnarok";
std::string char_server_pw = ""; // Allow user to send empty password (bugreport:7787)
std::string char_server_db = "ragnarok";
std::string default_codepage = ""; //Feature by irmin.
unsigned int party_share_level = 10;
/// Received packet Lengths from map-server
@ -844,17 +844,17 @@ int inter_config_read(const char* cfgName)
continue;
if(!strcmpi(w1,"char_server_ip"))
safestrncpy(char_server_ip,w2,sizeof(char_server_ip));
char_server_ip = w2;
else if(!strcmpi(w1,"char_server_port"))
char_server_port = atoi(w2);
else if(!strcmpi(w1,"char_server_id"))
safestrncpy(char_server_id,w2,sizeof(char_server_id));
char_server_id = w2;
else if(!strcmpi(w1,"char_server_pw"))
safestrncpy(char_server_pw,w2,sizeof(char_server_pw));
char_server_pw = w2;
else if(!strcmpi(w1,"char_server_db"))
safestrncpy(char_server_db,w2,sizeof(char_server_db));
char_server_db = w2;
else if(!strcmpi(w1,"default_codepage"))
safestrncpy(default_codepage,w2,sizeof(default_codepage));
default_codepage = w2;
else if(!strcmpi(w1,"party_share_level"))
party_share_level = (unsigned int)atof(w2);
else if(!strcmpi(w1,"log_inter"))
@ -973,17 +973,17 @@ int inter_init_sql(const char *file)
//DB connection initialized
sql_handle = Sql_Malloc();
ShowInfo("Connect Character DB server.... (Character Server)\n");
if( SQL_ERROR == Sql_Connect(sql_handle, char_server_id, char_server_pw, char_server_ip, (uint16)char_server_port, char_server_db) )
if( SQL_ERROR == Sql_Connect(sql_handle, char_server_id.c_str(), char_server_pw.c_str(), char_server_ip.c_str(), (uint16)char_server_port, char_server_db.c_str()))
{
ShowError("Couldn't connect with username = '%s', password = '%s', host = '%s', port = '%d', database = '%s'\n",
char_server_id, char_server_pw, char_server_ip, char_server_port, char_server_db);
ShowError("Couldn't connect with username = '%s', host = '%s', port = '%d', database = '%s'\n",
char_server_id.c_str(), char_server_ip.c_str(), char_server_port, char_server_db.c_str());
Sql_ShowDebug(sql_handle);
Sql_Free(sql_handle);
exit(EXIT_FAILURE);
}
if( *default_codepage ) {
if( SQL_ERROR == Sql_SetEncoding(sql_handle, default_codepage) )
if( !default_codepage.empty() ) {
if( SQL_ERROR == Sql_SetEncoding(sql_handle, default_codepage.c_str()) )
Sql_ShowDebug(sql_handle);
}

View File

@ -22,12 +22,12 @@
typedef struct AccountDB_SQL {
AccountDB vtable; // public interface
Sql* accounts; // SQL handle accounts storage
char db_hostname[64]; // Doubled for long hostnames (bugreport:8003)
char db_hostname[1024]; // Doubled for long hostnames (bugreport:8003)
uint16 db_port;
char db_username[32];
char db_password[32];
char db_database[32];
char codepage[32];
char db_username[1024];
char db_password[1024];
char db_database[1024];
char codepage[1024];
// other settings
bool case_sensitive;
//table name
@ -131,8 +131,8 @@ static bool account_db_sql_init(AccountDB* self) {
if( SQL_ERROR == Sql_Connect(sql_handle, username, password, hostname, port, database) )
{
ShowError("Couldn't connect with uname='%s',passwd='%s',host='%s',port='%d',database='%s'\n",
username, password, hostname, port, database);
ShowError("Couldn't connect with uname='%s',host='%s',port='%d',database='%s'\n",
username, hostname, port, database);
Sql_ShowDebug(sql_handle);
Sql_Free(db->accounts);
db->accounts = NULL;

View File

@ -52,13 +52,13 @@
using namespace rathena;
char default_codepage[32] = "";
std::string default_codepage = "";
int map_server_port = 3306;
char map_server_ip[64] = "127.0.0.1";
char map_server_id[32] = "ragnarok";
char map_server_pw[32] = "";
char map_server_db[32] = "ragnarok";
std::string map_server_ip = "127.0.0.1";
std::string map_server_id = "ragnarok";
std::string map_server_pw = "";
std::string map_server_db = "ragnarok";
Sql* mmysql_handle;
Sql* qsmysql_handle; /// For query_sql
@ -91,11 +91,11 @@ char roulette_table[32] = "db_roulette";
char guild_storage_log_table[32] = "guild_storage_log";
// log database
char log_db_ip[64] = "127.0.0.1";
std::string log_db_ip = "127.0.0.1";
int log_db_port = 3306;
char log_db_id[32] = "ragnarok";
char log_db_pw[32] = "";
char log_db_db[32] = "log";
std::string log_db_id = "ragnarok";
std::string log_db_pw = "";
std::string log_db_db = "log";
Sql* logmysql_handle;
uint32 start_status_points = 48;
@ -4162,41 +4162,41 @@ int inter_config_read(const char *cfgName)
else
//Map Server SQL DB
if(strcmpi(w1,"map_server_ip")==0)
safestrncpy(map_server_ip, w2, sizeof(map_server_ip));
map_server_ip = w2;
else
if(strcmpi(w1,"map_server_port")==0)
map_server_port=atoi(w2);
else
if(strcmpi(w1,"map_server_id")==0)
safestrncpy(map_server_id, w2, sizeof(map_server_id));
map_server_id = w2;
else
if(strcmpi(w1,"map_server_pw")==0)
safestrncpy(map_server_pw, w2, sizeof(map_server_pw));
map_server_pw = w2;
else
if(strcmpi(w1,"map_server_db")==0)
safestrncpy(map_server_db, w2, sizeof(map_server_db));
map_server_db = w2;
else
if(strcmpi(w1,"default_codepage")==0)
safestrncpy(default_codepage, w2, sizeof(default_codepage));
default_codepage = w2;
else
if(strcmpi(w1,"use_sql_db")==0) {
db_use_sqldbs = config_switch(w2);
ShowStatus ("Using SQL dbs: %s\n",w2);
} else
if(strcmpi(w1,"log_db_ip")==0)
safestrncpy(log_db_ip, w2, sizeof(log_db_ip));
log_db_ip = w2;
else
if(strcmpi(w1,"log_db_id")==0)
safestrncpy(log_db_id, w2, sizeof(log_db_id));
log_db_id = w2;
else
if(strcmpi(w1,"log_db_pw")==0)
safestrncpy(log_db_pw, w2, sizeof(log_db_pw));
log_db_pw = w2;
else
if(strcmpi(w1,"log_db_port")==0)
log_db_port = atoi(w2);
else
if(strcmpi(w1,"log_db_db")==0)
safestrncpy(log_db_db, w2, sizeof(log_db_db));
log_db_db = w2;
else
if(strcmpi(w1,"start_status_points")==0)
start_status_points=atoi(w2);
@ -4223,11 +4223,11 @@ int map_sql_init(void)
qsmysql_handle = Sql_Malloc();
ShowInfo("Connecting to the Map DB Server....\n");
if( SQL_ERROR == Sql_Connect(mmysql_handle, map_server_id, map_server_pw, map_server_ip, map_server_port, map_server_db) ||
SQL_ERROR == Sql_Connect(qsmysql_handle, map_server_id, map_server_pw, map_server_ip, map_server_port, map_server_db) )
if( SQL_ERROR == Sql_Connect(mmysql_handle, map_server_id.c_str(), map_server_pw.c_str(), map_server_ip.c_str(), map_server_port, map_server_db.c_str()) ||
SQL_ERROR == Sql_Connect(qsmysql_handle, map_server_id.c_str(), map_server_pw.c_str(), map_server_ip.c_str(), map_server_port, map_server_db.c_str()) )
{
ShowError("Couldn't connect with uname='%s',passwd='%s',host='%s',port='%d',database='%s'\n",
map_server_id, map_server_pw, map_server_ip, map_server_port, map_server_db);
ShowError("Couldn't connect with uname='%s',host='%s',port='%d',database='%s'\n",
map_server_id.c_str(), map_server_ip.c_str(), map_server_port, map_server_db.c_str());
Sql_ShowDebug(mmysql_handle);
Sql_Free(mmysql_handle);
Sql_ShowDebug(qsmysql_handle);
@ -4236,10 +4236,10 @@ int map_sql_init(void)
}
ShowStatus("Connect success! (Map Server Connection)\n");
if( strlen(default_codepage) > 0 ) {
if ( SQL_ERROR == Sql_SetEncoding(mmysql_handle, default_codepage) )
if( !default_codepage.empty() ) {
if ( SQL_ERROR == Sql_SetEncoding(mmysql_handle, default_codepage.c_str()) )
Sql_ShowDebug(mmysql_handle);
if ( SQL_ERROR == Sql_SetEncoding(qsmysql_handle, default_codepage) )
if ( SQL_ERROR == Sql_SetEncoding(qsmysql_handle, default_codepage.c_str()) )
Sql_ShowDebug(qsmysql_handle);
}
return 0;
@ -4268,18 +4268,18 @@ int log_sql_init(void)
// log db connection
logmysql_handle = Sql_Malloc();
ShowInfo("" CL_WHITE "[SQL]" CL_RESET ": Connecting to the Log Database " CL_WHITE "%s" CL_RESET " At " CL_WHITE "%s" CL_RESET "...\n",log_db_db,log_db_ip);
if ( SQL_ERROR == Sql_Connect(logmysql_handle, log_db_id, log_db_pw, log_db_ip, log_db_port, log_db_db) ){
ShowError("Couldn't connect with uname='%s',passwd='%s',host='%s',port='%d',database='%s'\n",
log_db_id, log_db_pw, log_db_ip, log_db_port, log_db_db);
ShowInfo("" CL_WHITE "[SQL]" CL_RESET ": Connecting to the Log Database " CL_WHITE "%s" CL_RESET " At " CL_WHITE "%s" CL_RESET "...\n",log_db_db.c_str(), log_db_ip.c_str());
if ( SQL_ERROR == Sql_Connect(logmysql_handle, log_db_id.c_str(), log_db_pw.c_str(), log_db_ip.c_str(), log_db_port, log_db_db.c_str()) ){
ShowError("Couldn't connect with uname='%s',host='%s',port='%d',database='%s'\n",
log_db_id.c_str(), log_db_ip.c_str(), log_db_port, log_db_db.c_str());
Sql_ShowDebug(logmysql_handle);
Sql_Free(logmysql_handle);
exit(EXIT_FAILURE);
}
ShowStatus("" CL_WHITE "[SQL]" CL_RESET ": Successfully '" CL_GREEN "connected" CL_RESET "' to Database '" CL_WHITE "%s" CL_RESET "'.\n", log_db_db);
ShowStatus("" CL_WHITE "[SQL]" CL_RESET ": Successfully '" CL_GREEN "connected" CL_RESET "' to Database '" CL_WHITE "%s" CL_RESET "'.\n", log_db_db.c_str());
if( strlen(default_codepage) > 0 )
if ( SQL_ERROR == Sql_SetEncoding(logmysql_handle, default_codepage) )
if( !default_codepage.empty() )
if ( SQL_ERROR == Sql_SetEncoding(logmysql_handle, default_codepage.c_str()) )
Sql_ShowDebug(logmysql_handle);
return 0;