summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-09-20 15:53:28 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-09-20 15:53:28 +0000
commit4ff15924b648cf82a1d60f028f56b007d6e39674 (patch)
treec56f95bb01b4f1a36f0ffb905bc50290a705e685 /src
parente93004bb19f00e545c6eaf92cc1da86c18948fd3 (diff)
downloadhercules-4ff15924b648cf82a1d60f028f56b007d6e39674.tar.gz
hercules-4ff15924b648cf82a1d60f028f56b007d6e39674.tar.bz2
hercules-4ff15924b648cf82a1d60f028f56b007d6e39674.tar.xz
hercules-4ff15924b648cf82a1d60f028f56b007d6e39674.zip
Synced some more :)
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11249 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src')
-rw-r--r--src/login/login.c146
-rw-r--r--src/login_sql/login.c198
2 files changed, 174 insertions, 170 deletions
diff --git a/src/login/login.c b/src/login/login.c
index f69bcba6d..f53bd3d26 100644
--- a/src/login/login.c
+++ b/src/login/login.c
@@ -66,7 +66,7 @@ struct gm_account* gm_account_db = NULL;
unsigned int GM_num = 0; // number of gm accounts
unsigned int GM_max = 0;
-//Account flood protection [Kevin]
+//Account registration flood protection [Kevin]
int allowed_regs = 1;
int time_allowed = 10; //in seconds
unsigned int new_reg_tick = 0;
@@ -1054,7 +1054,8 @@ int check_GM_file(int tid, unsigned int tick, int id, int data)
bool check_encrypted(const char* str1, const char* str2, const char* passwd)
{
char md5str[64], md5bin[32];
- snprintf(md5str, sizeof(md5str), "%s%s", str1, str2); md5str[sizeof(md5str)-1] = '\0';
+ snprintf(md5str, sizeof(md5str), "%s%s", str1, str2);
+ md5str[sizeof(md5str)-1] = '\0';
MD5_String2binary(md5str, md5bin);
return (0==memcmp(passwd, md5bin, 16));
@@ -1079,7 +1080,7 @@ bool check_password(struct login_session_data* ld, int passwdenc, const char* pa
//-------------------------------------
-// Account creation (with e-mail check)
+// Make new account
//-------------------------------------
int mmo_auth_new(struct mmo_account* account, char sex, char* email)
{
@@ -1146,7 +1147,7 @@ int mmo_auth(struct mmo_account* account, int fd)
char ip[16];
uint8* sin_addr = (uint8*)&session[fd]->client_addr;
- sprintf(ip, "%d.%d.%d.%d", sin_addr[3], sin_addr[2], sin_addr[1], sin_addr[0]);
+ sprintf(ip, "%u.%u.%u.%u", sin_addr[3], sin_addr[2], sin_addr[1], sin_addr[0]);
// DNS Blacklist check
if( login_config.use_dnsbl )
@@ -1156,7 +1157,7 @@ int mmo_auth(struct mmo_account* account, int fd)
char* dnsbl_serv;
bool matched = false;
- sprintf(r_ip, "%d.%d.%d.%d", sin_addr[0], sin_addr[1], sin_addr[2], sin_addr[3]);
+ sprintf(r_ip, "%u.%u.%u.%u", sin_addr[0], sin_addr[1], sin_addr[2], sin_addr[3]);
for( dnsbl_serv = strtok(login_config.dnsbl_servs,","); !matched && dnsbl_serv != NULL; dnsbl_serv = strtok(NULL,",") )
{
@@ -1351,16 +1352,18 @@ int mmo_auth(struct mmo_account* account, int fd)
static int online_db_setoffline(DBKey key, void* data, va_list ap)
{
- struct online_login_data *p = (struct online_login_data *)data;
+ struct online_login_data* p = (struct online_login_data*)data;
int server = va_arg(ap, int);
- if (server == -1) {
+ if( server == -1 )
+ {
p->char_server = -1;
- if (p->waiting_disconnect != -1)
+ if( p->waiting_disconnect != -1 )
{
delete_timer(p->waiting_disconnect, waiting_disconnect_timer);
p->waiting_disconnect = -1;
}
- } else if (p->char_server == server)
+ }
+ else if( p->char_server == server )
p->char_server = -2; //Char server disconnected.
return 0;
}
@@ -1377,33 +1380,33 @@ int parse_fromchar(int fd)
char ip[16];
ip2str(ipl, ip);
- for(id = 0; id < MAX_SERVERS; id++)
- if (server_fd[id] == fd)
- break;
- if (id == MAX_SERVERS) { // not a char server
+ ARR_FIND(0, MAX_SERVERS, id, server_fd[id] == fd);
+ if (id == MAX_SERVERS)
+ {// not a char server
set_eof(fd);
do_close(fd);
return 0;
}
- if(session[fd]->eof) {
+ if( session[fd]->eof )
+ {
ShowStatus("Char-server '%s' has disconnected.\n", server[id].name);
login_log("Char-server '%s' has disconnected (ip: %s).\n", server[id].name, ip);
server_fd[id] = -1;
memset(&server[id], 0, sizeof(struct mmo_char_server));
- online_db->foreach(online_db,online_db_setoffline,id); //Set all chars from this char server to offline.
+ online_db->foreach(online_db, online_db_setoffline, id); //Set all chars from this char server to offline.
do_close(fd);
return 0;
}
- while (RFIFOREST(fd) >= 2)
+ while( RFIFOREST(fd) >= 2 )
{
uint16 command = RFIFOW(fd,0);
if (display_parse_fromchar == 2 || (display_parse_fromchar == 1 && command != 0x2714)) // 0x2714 is done very often (number of players)
ShowDebug("parse_fromchar: connection #%d, packet: 0x%x (with being read: %d bytes).\n", fd, command, RFIFOREST(fd));
- switch (command)
+ switch( command )
{
case 0x2709: // request from map-server via char-server to reload GM accounts
@@ -1412,49 +1415,55 @@ int parse_fromchar(int fd)
// send GM accounts to all char-servers
send_GM_accounts(-1);
RFIFOSKIP(fd,2);
- break;
+ break;
case 0x2712: // request from char-server to authenticate an account
- if (RFIFOREST(fd) < 19)
+ if( RFIFOREST(fd) < 19 )
return 0;
{
uint32 account_id = RFIFOL(fd,2);
- for(i = 0; i < AUTH_FIFO_SIZE; i++)
+ for( i = 0; i < AUTH_FIFO_SIZE; ++i )
{
- if (auth_fifo[i].account_id == RFIFOL(fd,2) &&
+ if( auth_fifo[i].account_id == RFIFOL(fd,2) &&
auth_fifo[i].login_id1 == RFIFOL(fd,6) &&
auth_fifo[i].login_id2 == RFIFOL(fd,10) &&
auth_fifo[i].sex == RFIFOB(fd,14) &&
auth_fifo[i].ip == ntohl(RFIFOL(fd,15)) &&
!auth_fifo[i].delflag)
{
- unsigned int k;
- time_t connect_until_time = 0;
- char email[40] = "";
auth_fifo[i].delflag = 1;
- login_log("Char-server '%s': authentification of the account %d accepted (ip: %s).\n",
- server[id].name, account_id, ip);
- for(k = 0; k < auth_num; k++) {
- if (auth_dat[k].account_id == account_id) {
- strcpy(email, auth_dat[k].email);
- connect_until_time = auth_dat[k].connect_until_time;
- break;
- }
- }
- WFIFOHEAD(fd,51);
- WFIFOW(fd,0) = 0x2713;
- WFIFOL(fd,2) = account_id;
- WFIFOB(fd,6) = 0;
- memcpy(WFIFOP(fd, 7), email, 40);
- WFIFOL(fd,47) = (unsigned long)connect_until_time;
- WFIFOSET(fd,51);
break;
}
}
- // authentification not found
- if (i == AUTH_FIFO_SIZE) {
- login_log("Char-server '%s': authentification of the account %d REFUSED (ip: %s).\n",
- server[id].name, account_id, ip);
+
+ if( i != AUTH_FIFO_SIZE && account_id > 0 )
+ {// send ack
+ time_t connect_until_time;
+ char email[40];
+ unsigned int k;
+
+ login_log("Char-server '%s': authentification of the account %d accepted (ip: %s).\n", server[id].name, account_id, ip);
+
+ ARR_FIND(0, auth_num, k, auth_dat[k].account_id == account_id);
+ if( k != auth_num ) {
+ strcpy(email, auth_dat[k].email);
+ connect_until_time = auth_dat[k].connect_until_time;
+ } else {
+ memset(email, 0, sizeof(email));
+ connect_until_time = 0;
+ }
+
+ WFIFOHEAD(fd,51);
+ WFIFOW(fd,0) = 0x2713;
+ WFIFOL(fd,2) = account_id;
+ WFIFOB(fd,6) = 0;
+ memcpy(WFIFOP(fd, 7), email, 40);
+ WFIFOL(fd,47) = (unsigned long)connect_until_time;
+ WFIFOSET(fd,51);
+ }
+ else
+ {// authentification not found
+ login_log("Char-server '%s': authentification of the account %d REFUSED (ip: %s).\n", server[id].name, account_id, ip);
WFIFOHEAD(fd,51);
WFIFOW(fd,0) = 0x2713;
WFIFOL(fd,2) = account_id;
@@ -1869,7 +1878,7 @@ int parse_fromchar(int fd)
struct online_login_data *p;
int aid;
uint32 i, users;
- online_db->foreach(online_db,online_db_setoffline,id); //Set all chars from this char-server offline first
+ online_db->foreach(online_db, online_db_setoffline, id); //Set all chars from this char-server offline first
users = RFIFOW(fd,4);
for (i = 0; i < users; i++) {
aid = RFIFOL(fd,6+i*4);
@@ -1926,7 +1935,7 @@ int parse_fromchar(int fd)
case 0x2737: //Request to set all offline.
ShowInfo("Setting accounts from char-server %d offline.\n", id);
- online_db->foreach(online_db,online_db_setoffline,id);
+ online_db->foreach(online_db, online_db_setoffline, id);
RFIFOSKIP(fd,2);
break;
@@ -1988,26 +1997,27 @@ int parse_fromchar(int fd)
int parse_admin(int fd)
{
unsigned int i, j;
- uint32 ipl = session[fd]->client_addr;
char* account_name;
- char ip[16];
+ uint32 ipl = session[fd]->client_addr;
+ char ip[16];
ip2str(ipl, ip);
- if (session[fd]->eof) {
+ if( session[fd]->eof )
+ {
do_close(fd);
ShowInfo("Remote administration has disconnected (session #%d).\n", fd);
return 0;
}
- while (RFIFOREST(fd) >= 2)
+ while( RFIFOREST(fd) >= 2 )
{
uint16 command = RFIFOW(fd,0);
if (display_parse_admin)
ShowDebug("parse_admin: connection #%d, packet: 0x%x (with being read: %d).\n", fd, command, RFIFOREST(fd));
- switch(command)
+ switch( command )
{
case 0x7530: // Request of the server version
@@ -2980,7 +2990,7 @@ int parse_login(int fd)
ip2str(ipl, ip);
- while (RFIFOREST(fd) >= 2)
+ while( RFIFOREST(fd) >= 2 )
{
uint16 command = RFIFOW(fd,0);
@@ -3152,23 +3162,20 @@ int parse_login(int fd)
case 0x791a: // Sending request of the coding key (administration packet)
{
struct login_session_data* ld;
- if (session[fd]->session_data) {
+ if( session[fd]->session_data )
+ {
ShowWarning("login: abnormal request of MD5 key (already opened session).\n");
set_eof(fd);
return 0;
}
- ld = (struct login_session_data*)aCalloc(1, sizeof(struct login_session_data));
+ CREATE(ld, struct login_session_data, 1);
session[fd]->session_data = ld;
- if (command == 0x01db)
- login_log("Sending request of the coding key (ip: %s)\n", ip);
- else
- login_log("'ladmin': Sending request of the coding key (ip: %s)\n", ip);
// Creation of the coding key
memset(ld->md5key, '\0', sizeof(ld->md5key));
ld->md5keylen = (uint16)(12 + rand() % 4);
- for(i = 0; i < ld->md5keylen; i++)
+ for( i = 0; i < ld->md5keylen; ++i )
ld->md5key[i] = (char)(1 + rand() % 255);
WFIFOHEAD(fd,4 + ld->md5keylen);
@@ -3374,6 +3381,7 @@ int parse_console(char* buf)
sscanf(buf, "%[^\n]", command);
+ ShowInfo("Console command :%s", command);
login_log("Console command :%s\n", command);
if( strcmpi("shutdown", command) == 0 ||
@@ -3485,19 +3493,17 @@ int login_config_read(const char* cfgName)
if (line[0] == '/' && line[1] == '/')
continue;
- memset(w2, 0, sizeof(w2));
-
if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) < 2)
continue;
remove_control_chars(w1);
remove_control_chars(w2);
- if(strcmpi(w1,"timestamp_format") == 0) {
+ if(!strcmpi(w1,"timestamp_format"))
strncpy(timestamp_format, w2, 20);
- } else if(strcmpi(w1,"stdout_with_ansisequence")==0){
+ else if(!strcmpi(w1,"stdout_with_ansisequence"))
stdout_with_ansisequence = config_switch(w2);
- } else if(strcmpi(w1,"console_silent")==0){
+ else if(!strcmpi(w1,"console_silent")) {
ShowInfo("Console Silent Setting: %d\n", atoi(w2));
msg_silent = atoi(w2);
}
@@ -3546,6 +3552,7 @@ int login_config_read(const char* cfgName)
}
else if( !strcmpi(w1, "login_port") ) {
login_config.login_port = (uint16)atoi(w2);
+ ShowStatus("set login_port : %s\n",w2);
}
else if (strcmpi(w1, "account_filename") == 0) {
memset(account_filename, 0, sizeof(account_filename));
@@ -3991,17 +3998,16 @@ void do_abort(void)
{
}
-//------------------------------
-// Main function of login-server
-//------------------------------
void set_server_type(void)
{
SERVER_TYPE = ATHENA_SERVER_LOGIN;
}
-int do_init(int argc, char **argv)
+//------------------------------
+// Login server initialization
+//------------------------------
+int do_init(int argc, char** argv)
{
- // initialize login server
int i, j;
login_set_defaults();
@@ -4066,7 +4072,7 @@ int do_init(int argc, char **argv)
login_fd = make_listen_bind(login_config.login_ip, login_config.login_port);
login_log("The login-server is ready (Server is listening on the port %d).\n", login_config.login_port);
- ShowStatus("The login-server is "CL_GREEN"ready"CL_RESET" (Server is listening on the port %d).\n\n", login_config.login_port);
+ ShowStatus("The login-server is "CL_GREEN"ready"CL_RESET" (Server is listening on the port %u).\n\n", login_config.login_port);
return 0;
}
diff --git a/src/login_sql/login.c b/src/login_sql/login.c
index a1ef693f6..2b2105eca 100644
--- a/src/login_sql/login.c
+++ b/src/login_sql/login.c
@@ -347,6 +347,62 @@ void mmo_db_close(void)
do_close(login_fd);
}
+
+//--------------------------------------------------------------------
+// Packet send to all char-servers, except one (wos: without our self)
+//--------------------------------------------------------------------
+int charif_sendallwos(int sfd, uint8* buf, size_t len)
+{
+ int i, c;
+
+ for( i = 0, c = 0; i < MAX_SERVERS; ++i )
+ {
+ int fd = server_fd[i];
+ if( session_isValid(fd) && fd != sfd )
+ {
+ WFIFOHEAD(fd,len);
+ memcpy(WFIFOP(fd,0), buf, len);
+ WFIFOSET(fd,len);
+ ++c;
+ }
+ }
+
+ return c;
+}
+
+
+//-----------------------------------------------------
+// encrypted/unencrypted password check
+//-----------------------------------------------------
+bool check_encrypted(const char* str1, const char* str2, const char* passwd)
+{
+ char md5str[64], md5bin[32];
+
+ snprintf(md5str, sizeof(md5str), "%s%s", str1, str2);
+ md5str[sizeof(md5str)-1] = '\0';
+ MD5_String2binary(md5str, md5bin);
+
+ return (0==memcmp(passwd, md5bin, 16));
+}
+
+bool check_password(struct login_session_data* ld, int passwdenc, const char* passwd, const char* refpass)
+{
+ if(passwdenc == 0)
+ {
+ return (0==strcmp(passwd, refpass));
+ }
+ else if (ld)
+ {
+ // password mode set to 1 -> (md5key, refpass) enable with <passwordencrypt></passwordencrypt>
+ // password mode set to 2 -> (refpass, md5key) enable with <passwordencrypt2></passwordencrypt2>
+
+ return ((passwdenc&0x01) && check_encrypted(ld->md5key, refpass, passwd)) ||
+ ((passwdenc&0x02) && check_encrypted(refpass, ld->md5key, passwd));
+ }
+ return false;
+}
+
+
//-----------------------------------------------------
// Make new account
//-----------------------------------------------------
@@ -417,61 +473,6 @@ int mmo_auth_new(struct mmo_account* account, char sex)
}
-//--------------------------------------------------------------------
-// Packet send to all char-servers, except one (wos: without our self)
-//--------------------------------------------------------------------
-int charif_sendallwos(int sfd, uint8* buf, size_t len)
-{
- int i, c;
-
- for( i = 0, c = 0; i < MAX_SERVERS; ++i )
- {
- int fd = server_fd[i];
- if( session_isValid(fd) && fd != sfd )
- {
- WFIFOHEAD(fd,len);
- memcpy(WFIFOP(fd,0), buf, len);
- WFIFOSET(fd,len);
- ++c;
- }
- }
-
- return c;
-}
-
-
-//-----------------------------------------------------
-// encrypted/unencrypted password check
-//-----------------------------------------------------
-bool check_encrypted(const char* str1, const char* str2, const char* passwd)
-{
- char md5str[64], md5bin[32];
-
- snprintf(md5str, sizeof(md5str), "%s%s", str1, str2);
- md5str[sizeof(md5str)-1] = '\0';
- MD5_String2binary(md5str, md5bin);
-
- return (0==memcmp(passwd, md5bin, 16));
-}
-
-bool check_password(struct login_session_data* ld, int passwdenc, const char* passwd, const char* refpass)
-{
- if(passwdenc == 0)
- {
- return (0==strcmp(passwd, refpass));
- }
- else if (ld)
- {
- // password mode set to 1 -> (md5key, refpass) enable with <passwordencrypt></passwordencrypt>
- // password mode set to 2 -> (refpass, md5key) enable with <passwordencrypt2></passwordencrypt2>
-
- return ((passwdenc&0x01) && check_encrypted(ld->md5key, refpass, passwd)) ||
- ((passwdenc&0x02) && check_encrypted(refpass, ld->md5key, passwd));
- }
- return false;
-}
-
-
//-----------------------------------------------------
// Check/authentication of a connection
//-----------------------------------------------------
@@ -524,7 +525,7 @@ int mmo_auth(struct mmo_account* account, int fd)
if( login_config.new_account_flag )
{
if( len > 2 && strnlen(account->passwd, NAME_LENGTH) >= 4 && // valid user and password lengths
- account->passwdenc == 0 &&// unencoded password
+ account->passwdenc == 0 && // unencoded password
account->userid[len-2] == '_' && memchr("FfMm", (unsigned char)account->userid[len-1], 4) ) // _M/_F suffix
{
int result;
@@ -703,9 +704,7 @@ int parse_fromchar(int fd)
char ip[16];
ip2str(ipl, ip);
- for( id = 0; id < MAX_SERVERS; ++id )
- if( server_fd[id] == fd )
- break;
+ ARR_FIND(0, MAX_SERVERS, id, server_fd[id] == fd);
if( id == MAX_SERVERS )
{// not a char server
set_eof(fd);
@@ -748,16 +747,15 @@ int parse_fromchar(int fd)
if( RFIFOREST(fd) < 19 )
return 0;
{
- int account_id;
- account_id = RFIFOL(fd,2); // speed up
+ uint32 account_id = RFIFOL(fd,2);
for( i = 0; i < AUTH_FIFO_SIZE; ++i )
{
- if( auth_fifo[i].account_id == account_id &&
- auth_fifo[i].login_id1 == RFIFOL(fd,6) &&
- auth_fifo[i].login_id2 == RFIFOL(fd,10) &&
- auth_fifo[i].sex == RFIFOB(fd,14) &&
- auth_fifo[i].ip == ntohl(RFIFOL(fd,15)) &&
- !auth_fifo[i].delflag)
+ if( auth_fifo[i].account_id == RFIFOL(fd,2) &&
+ auth_fifo[i].login_id1 == RFIFOL(fd,6) &&
+ auth_fifo[i].login_id2 == RFIFOL(fd,10) &&
+ auth_fifo[i].sex == RFIFOB(fd,14) &&
+ auth_fifo[i].ip == ntohl(RFIFOL(fd,15)) &&
+ !auth_fifo[i].delflag)
{
auth_fifo[i].delflag = 1;
break;
@@ -766,11 +764,9 @@ int parse_fromchar(int fd)
if( i != AUTH_FIFO_SIZE && account_id > 0 )
{// send ack
- uint32 connect_until_time = 0;
+ uint32 connect_until_time;
char email[40];
- memset(email, 0, sizeof(email));
- account_id = RFIFOL(fd,2);
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `email`,`connect_until` FROM `%s` WHERE `%s`='%d'", login_db, login_db_account_id, account_id) )
Sql_ShowDebug(sql_handle);
if( SQL_SUCCESS == Sql_NextRow(sql_handle) )
@@ -778,21 +774,19 @@ int parse_fromchar(int fd)
char* data = NULL;
size_t len = 0;
- Sql_GetData(sql_handle, 0, &data, &len);
+ Sql_GetData(sql_handle, 0, &data, &len); safestrncpy(email, data, sizeof(email));
+ Sql_GetData(sql_handle, 1, &data, NULL); connect_until_time = (uint32)strtoul(data, NULL, 10);
if( len > sizeof(email) )
- {
-#if defined(DEBUG)
ShowDebug("parse_fromchar:0x2712: email is too long (len=%u,maxlen=%u)\n", len, sizeof(email));
-#endif
- len = sizeof(email);
- }
- memcpy(email, data, len);
-
- Sql_GetData(sql_handle, 1, &data, NULL);
- connect_until_time = (uint32)strtoul(data, NULL, 10);
Sql_FreeResult(sql_handle);
}
+ else
+ {
+ memset(email, 0, sizeof(email));
+ connect_until_time = 0;
+ }
+
WFIFOHEAD(fd,51);
WFIFOW(fd,0) = 0x2713;
WFIFOL(fd,2) = account_id;
@@ -802,11 +796,13 @@ int parse_fromchar(int fd)
WFIFOSET(fd,51);
}
else
- {
+ {// authentification not found
WFIFOHEAD(fd,51);
WFIFOW(fd,0) = 0x2713;
WFIFOL(fd,2) = account_id;
WFIFOB(fd,6) = 1;
+ // It is unnecessary to send email
+ // It is unnecessary to send validity date of the account
WFIFOSET(fd,51);
}
@@ -828,7 +824,7 @@ int parse_fromchar(int fd)
Sql_ShowDebug(sql_handle);
}
// send some answer
- WFIFOHEAD(fd,6);
+ WFIFOHEAD(fd,2);
WFIFOW(fd,0) = 0x2718;
WFIFOSET(fd,2);
@@ -1177,7 +1173,7 @@ int parse_fromchar(int fd)
struct online_login_data *p;
int aid;
uint32 i, users;
- online_db->foreach(online_db,online_db_setoffline,id); //Set all chars from this char-server offline first
+ online_db->foreach(online_db, online_db_setoffline, id); //Set all chars from this char-server offline first
users = RFIFOW(fd,4);
for (i = 0; i < users; i++) {
aid = RFIFOL(fd,6+i*4);
@@ -1245,12 +1241,12 @@ int parse_fromchar(int fd)
case 0x2737: //Request to set all offline.
ShowInfo("Setting accounts from char-server %d offline.\n", id);
- online_db->foreach(online_db,online_db_setoffline,id);
+ online_db->foreach(online_db, online_db_setoffline, id);
RFIFOSKIP(fd,2);
break;
default:
- ShowError("parse_fromchar: Unknown packet 0x%x from a char-server! Disconnecting!\n", RFIFOW(fd,0));
+ ShowError("parse_fromchar: Unknown packet 0x%x from a char-server! Disconnecting!\n", command);
set_eof(fd);
return 0;
} // switch
@@ -1602,7 +1598,7 @@ int parse_login(int fd)
memset(&server[account.account_id], 0, sizeof(struct mmo_char_server));
server[account.account_id].ip = ntohl(RFIFOL(fd,54));
server[account.account_id].port = ntohs(RFIFOW(fd,58));
- memcpy(server[account.account_id].name, server_name, 20);
+ safestrncpy(server[account.account_id].name, server_name, sizeof(server[account.account_id].name));
server[account.account_id].users = 0;
server[account.account_id].maintenance = RFIFOW(fd,82);
server[account.account_id].new_ = RFIFOW(fd,84);
@@ -1741,8 +1737,8 @@ int login_lan_config_read(const char *lancfgName)
if ((line[0] == '/' && line[1] == '/') || line[0] == '\n' || line[1] == '\n')
continue;
- if(sscanf(line,"%[^:]: %[^:]:%[^:]:%[^\r\n]", w1, w2, w3, w4) != 4) {
-
+ if(sscanf(line,"%[^:]: %[^:]:%[^:]:%[^\r\n]", w1, w2, w3, w4) != 4)
+ {
ShowWarning("Error syntax of configuration file %s in line %d.\n", lancfgName, line_num);
continue;
}
@@ -1807,11 +1803,11 @@ int login_config_read(const char* cfgName)
remove_control_chars(w1);
remove_control_chars(w2);
- if(!strcmpi(w1,"timestamp_format")) {
+ if(!strcmpi(w1,"timestamp_format"))
strncpy(timestamp_format, w2, 20);
- } else if(!strcmpi(w1,"stdout_with_ansisequence")) {
+ else if(!strcmpi(w1,"stdout_with_ansisequence"))
stdout_with_ansisequence = config_switch(w2);
- } else if(!strcmpi(w1,"console_silent")) {
+ else if(!strcmpi(w1,"console_silent")) {
ShowInfo("Console Silent Setting: %d\n", atoi(w2));
msg_silent = atoi(w2);
}
@@ -1825,18 +1821,18 @@ int login_config_read(const char* cfgName)
login_config.login_port = (uint16)atoi(w2);
ShowStatus("set login_port : %s\n",w2);
}
- else if (!strcmpi(w1, "log_login"))
+ else if(!strcmpi(w1, "log_login"))
login_config.log_login = config_switch(w2);
- else if (!strcmpi(w1, "ipban"))
+ else if(!strcmpi(w1, "ipban"))
login_config.ipban = config_switch(w2);
- else if (!strcmpi(w1, "dynamic_pass_failure_ban"))
+ else if(!strcmpi(w1, "dynamic_pass_failure_ban"))
login_config.dynamic_pass_failure_ban = config_switch(w2);
- else if (!strcmpi(w1, "dynamic_pass_failure_ban_interval"))
+ else if(!strcmpi(w1, "dynamic_pass_failure_ban_interval"))
login_config.dynamic_pass_failure_ban_interval = atoi(w2);
- else if (!strcmpi(w1, "dynamic_pass_failure_ban_limit"))
+ else if(!strcmpi(w1, "dynamic_pass_failure_ban_limit"))
login_config.dynamic_pass_failure_ban_limit = atoi(w2);
- else if (!strcmpi(w1, "dynamic_pass_failure_ban_duration"))
+ else if(!strcmpi(w1, "dynamic_pass_failure_ban_duration"))
login_config.dynamic_pass_failure_ban_duration = atoi(w2);
else if(!strcmpi(w1, "new_account"))
@@ -1865,9 +1861,9 @@ int login_config_read(const char* cfgName)
login_config.use_dnsbl = (bool)config_switch(w2);
else if(!strcmpi(w1, "dnsbl_servers"))
safestrncpy(login_config.dnsbl_servs, w2, sizeof(login_config.dnsbl_servs));
- else if (!strcmpi(w1, "ip_sync_interval"))
+ else if(!strcmpi(w1, "ip_sync_interval"))
login_config.ip_sync_interval = (unsigned int)1000*60*atoi(w2); //w2 comes in minutes.
- else if (!strcmpi(w1, "import"))
+ else if(!strcmpi(w1, "import"))
login_config_read(w2);
}
fclose(fp);
@@ -1979,9 +1975,11 @@ void set_server_type(void)
SERVER_TYPE = ATHENA_SERVER_LOGIN;
}
+//------------------------------
+// Login server initialization
+//------------------------------
int do_init(int argc, char** argv)
{
- // initialize login server
int i;
login_set_defaults();