summaryrefslogtreecommitdiff
path: root/src/login
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2015-01-03 12:11:33 -0800
committerBen Longbons <b.r.longbons@gmail.com>2015-01-03 12:11:33 -0800
commit6f6529a4bbc4dceaaed7e9c56b482e83fb809de9 (patch)
tree27c05065aaa38893ffb5677aebdb7f65286751c4 /src/login
parent29ec8b3f3910b4b9bb0724953c9628dc039df06b (diff)
downloadtmwa-6f6529a4bbc4dceaaed7e9c56b482e83fb809de9.tar.gz
tmwa-6f6529a4bbc4dceaaed7e9c56b482e83fb809de9.tar.bz2
tmwa-6f6529a4bbc4dceaaed7e9c56b482e83fb809de9.tar.xz
tmwa-6f6529a4bbc4dceaaed7e9c56b482e83fb809de9.zip
Document every network packet's pre, post, and desc
With pretty pictures (not a submodule because large images). Part of this commit was originally made by Rawng.
Diffstat (limited to 'src/login')
-rw-r--r--src/login/login.cpp219
1 files changed, 5 insertions, 214 deletions
diff --git a/src/login/login.cpp b/src/login/login.cpp
index fa528ba..526eb5d 100644
--- a/src/login/login.cpp
+++ b/src/login/login.cpp
@@ -177,8 +177,6 @@ GmLevel min_level_to_connect = GmLevel::from(0_u32); // minimum level of player
static
int add_to_unlimited_account = 0; // Give possibility or not to adjust (ladmin command: timeadd) the time of an unlimited account.
static
-int start_limited_time = -1; // Starting additional sec from now for the limited time at creation of accounts (-1: unlimited time, 0 or more: additional sec from now)
-static
int check_ip_flag = 1; // It's to check IP of a player between login-server and char-server (part of anti-hacking system)
DIAG_PUSH();
@@ -216,7 +214,6 @@ struct AuthData
AccountEmail email; // e-mail (by default: a@a.com)
timestamp_seconds_buffer error_message; // Message of error code #6 = Your are Prohibited to log in until %s (packet 0x006a)
TimeT ban_until_time; // # of seconds 1/1/1970 (timestamp): ban time limit of the account (0 = no ban)
- TimeT connect_until_time; // # of seconds 1/1/1970 (timestamp): Validity limit of the account (0 = unlimited)
IP4Address last_ip; // save of last IP of connection
VString<254> memo; // a memo field
int account_reg2_num;
@@ -482,7 +479,7 @@ AString mmo_auth_tostr(const AuthData *p)
p->state,
p->email,
p->error_message,
- p->connect_until_time,
+ TimeT(),
p->last_ip,
p->memo,
p->ban_until_time);
@@ -499,6 +496,7 @@ AString mmo_auth_tostr(const AuthData *p)
static
bool extract(XString line, AuthData *ad)
{
+ TimeT unused_connect_until_time;
std::vector<GlobalReg> vars;
VString<1> sex;
VString<15> ip;
@@ -513,7 +511,7 @@ bool extract(XString line, AuthData *ad)
&ad->state,
&ad->email,
&ad->error_message,
- &ad->connect_until_time,
+ &unused_connect_until_time,
&ip,
&ad->memo,
&ad->ban_until_time,
@@ -797,17 +795,6 @@ AccountId mmo_auth_new(struct mmo_account *account, SEX sex, AccountEmail email)
ad.error_message = stringish<timestamp_seconds_buffer>("-"_s);
ad.ban_until_time = TimeT();
- if (start_limited_time < 0)
- ad.connect_until_time = TimeT(); // unlimited
- else
- {
- // limited time
- TimeT timestamp = static_cast<time_t>(TimeT::now()) + start_limited_time;
- // there used to be a silly overflow check here, but it wasn't
- // correct, and we don't support time-limited accounts.
- ad.connect_until_time = timestamp;
- }
-
ad.last_ip = IP4Address();
ad.memo = "!"_s;
ad.account_reg2_num = 0;
@@ -901,14 +888,6 @@ int mmo_auth(struct mmo_account *account, Session *s)
}
}
- if (ad->connect_until_time
- && ad->connect_until_time < TimeT::now())
- {
- LOGIN_LOG("Connection refused (account: %s, expired ID, ip: %s)\n"_fmt,
- account->userid, ip);
- return 2; // 2 = This ID is expired
- }
-
LOGIN_LOG("Authentification accepted (account: %s (id: %d), ip: %s)\n"_fmt,
account->userid, ad->account_id, ip);
}
@@ -997,22 +976,6 @@ void parse_fromchar(Session *s)
switch (packet_id)
{
- // request from map-server via char-server to reload GM accounts (by Yor).
- case 0x2709:
- {
- Packet_Fixed<0x2709> fixed;
- rv = recv_fpacket<0x2709, 2>(s, fixed);
- if (rv != RecvResult::Complete)
- break;
-
- LOGIN_LOG("Char-server '%s': Request to re-load GM configuration file (ip: %s).\n"_fmt,
- server[id].name, ip);
- read_gm_account();
- // send GM accounts to all char-servers
- send_GM_accounts();
- break;
- }
-
case 0x2712: // request from char-server to authentify an account
{
Packet_Fixed<0x2712> fixed;
@@ -1059,7 +1022,6 @@ void parse_fromchar(Session *s)
fixed_13.account_id = acc;
fixed_13.invalid = 0;
fixed_13.email = ad.email;
- fixed_13.connect_until = ad.connect_until_time;
send_fpacket<0x2713, 51>(s, fixed_13);
break;
@@ -1118,7 +1080,6 @@ void parse_fromchar(Session *s)
Packet_Fixed<0x2717> fixed_17;
fixed_17.account_id = account_id;
fixed_17.email = ad.email;
- fixed_17.connect_until = ad.connect_until_time;
send_fpacket<0x2717, 50>(s, fixed_17);
if (rv != RecvResult::Complete)
@@ -1720,23 +1681,6 @@ void parse_admin(Session *s)
break;
}
- case 0x7924:
- { // [Fate] Itemfrob package: change item IDs
- Packet_Fixed<0x7924> fixed;
- rv = recv_fpacket<0x7924, 10>(s, fixed);
- if (rv != RecvResult::Complete)
- break;
-
- for (Session *ss : iter_char_sessions())
- {
- send_fpacket<0x7924, 10>(ss, fixed);
- }
-
- Packet_Fixed<0x7925> fixed_25;
- send_fpacket<0x7925, 2>(s, fixed_25);
- break;
- }
-
case 0x7930: // Request for an account creation
{
Packet_Fixed<0x7930> fixed;
@@ -2332,48 +2276,6 @@ void parse_admin(Session *s)
break;
}
- case 0x7948: // Request to change the validity limit (timestamp) (absolute value)
- {
- Packet_Fixed<0x7948> fixed;
- rv = recv_fpacket<0x7948, 30>(s, fixed);
- if (rv != RecvResult::Complete)
- break;
-
- Packet_Fixed<0x7949> fixed_49;
- {
- fixed_49.account_id = AccountId();
- AccountName account_name = stringish<AccountName>(fixed.account_name.to_print());
- TimeT timestamp = fixed.valid_until;
- timestamp_seconds_buffer tmpstr = stringish<timestamp_seconds_buffer>("unlimited"_s);
- if (timestamp)
- stamp_time(tmpstr, &timestamp);
- AuthData *ad = search_account(account_name);
- if (ad)
- {
- fixed_49.account_name = ad->userid;
- LOGIN_LOG("'ladmin': Change of a validity limit (account: %s, new validity: %lld (%s), ip: %s)\n"_fmt,
- ad->userid,
- timestamp,
- tmpstr,
- ip);
- ad->connect_until_time = timestamp;
- fixed_49.account_id = ad->account_id;
- }
- else
- {
- fixed_49.account_name = account_name;
- LOGIN_LOG("'ladmin': Attempt to change the validity limit of an unknown account (account: %s, received validity: %lld (%s), ip: %s)\n"_fmt,
- account_name,
- timestamp,
- tmpstr,
- ip);
- }
- fixed_49.valid_until = timestamp;
- }
- send_fpacket<0x7949, 34>(s, fixed_49);
- break;
- }
-
case 0x794a: // Request to change the final date of a banishment (timestamp) (absolute value)
{
Packet_Fixed<0x794a> fixed;
@@ -2585,99 +2487,6 @@ void parse_admin(Session *s)
break;
}
- case 0x7950: // Request to change the validity limite (timestamp) (relative change)
- {
- Packet_Fixed<0x7950> fixed;
- rv = recv_fpacket<0x7950, 38>(s, fixed);
- if (rv != RecvResult::Complete)
- break;
-
- Packet_Fixed<0x7951> fixed_51;
- {
- fixed_51.account_id = AccountId();
- AccountName account_name = stringish<AccountName>(fixed.account_name.to_print());
- AuthData *ad = search_account(account_name);
- if (ad)
- {
- fixed_51.account_id = ad->account_id;
- fixed_51.account_name = ad->userid;
- if (add_to_unlimited_account == 0 && !ad->connect_until_time)
- {
- LOGIN_LOG("'ladmin': Attempt to adjust the validity limit of an unlimited account (account: %s, ip: %s)\n"_fmt,
- ad->userid, ip);
- fixed_51.valid_until = TimeT();
- }
- else
- {
- TimeT now = TimeT::now();
- TimeT timestamp = ad->connect_until_time;
- if (!timestamp || timestamp < now)
- timestamp = now;
- struct tm tmtime = timestamp;
- HumanTimeDiff v_diff = fixed.valid_add;
- tmtime.tm_year += v_diff.year;
- tmtime.tm_mon += v_diff.month;
- tmtime.tm_mday += v_diff.day;
- tmtime.tm_hour += v_diff.hour;
- tmtime.tm_min += v_diff.minute;
- tmtime.tm_sec += v_diff.second;
- timestamp = tmtime;
- if (timestamp.okay())
- {
- timestamp_seconds_buffer tmpstr = stringish<timestamp_seconds_buffer>("unlimited"_s);
- timestamp_seconds_buffer tmpstr2 = stringish<timestamp_seconds_buffer>("unlimited"_s);
- if (ad->connect_until_time)
- stamp_time(tmpstr, &ad->connect_until_time);
- if (timestamp)
- stamp_time(tmpstr2, &timestamp);
- LOGIN_LOG("'ladmin': Adjustment of a validity limit (account: %s, %lld (%s) + (%+d y %+d m %+d d %+d h %+d mn %+d s) -> new validity: %lld (%s), ip: %s)\n"_fmt,
- ad->userid,
- ad->connect_until_time,
- tmpstr,
- v_diff.year,
- v_diff.month,
- v_diff.day,
- v_diff.hour,
- v_diff.minute,
- v_diff.second,
- timestamp,
- tmpstr2,
- ip);
- ad->connect_until_time = timestamp;
- fixed_51.valid_until = timestamp;
- }
- else
- {
- timestamp_seconds_buffer tmpstr = stringish<timestamp_seconds_buffer>("unlimited"_s);
- if (ad->connect_until_time)
- stamp_time(tmpstr, &ad->connect_until_time);
- LOGIN_LOG("'ladmin': Impossible to adjust a validity limit (account: %s, %lld (%s) + (%+d y %+d m %+d d %+d h %+d mn %+d s) -> ???, ip: %s)\n"_fmt,
- ad->userid,
- ad->connect_until_time,
- tmpstr,
- v_diff.year,
- v_diff.month,
- v_diff.day,
- v_diff.hour,
- v_diff.minute,
- v_diff.second,
- ip);
- fixed_51.valid_until = TimeT();
- }
- }
- }
- else
- {
- fixed_51.account_name = account_name;
- LOGIN_LOG("'ladmin': Attempt to adjust the validity limit of an unknown account (account: %s, ip: %s)\n"_fmt,
- account_name, ip);
- fixed_51.valid_until = TimeT();
- }
- }
- send_fpacket<0x7951, 34>(s, fixed_51);
- break;
- }
-
case 0x7952: // Request about informations of an account (by account name)
{
Packet_Fixed<0x7952> fixed;
@@ -2701,7 +2510,6 @@ void parse_admin(Session *s)
head_53.last_login_string = ad->lastlogin;
head_53.ip_string = convert_for_printf(ad->last_ip);
head_53.email = ad->email;
- head_53.connect_until = ad->connect_until_time;
head_53.ban_until = ad->ban_until_time;
XString repeat_53 = ad->memo;
@@ -2747,7 +2555,6 @@ void parse_admin(Session *s)
head_53.last_login_string = ad.lastlogin;
head_53.ip_string = convert_for_printf(ad.last_ip);
head_53.email = ad.email;
- head_53.connect_until = ad.connect_until_time;
head_53.ban_until = ad.ban_until_time;
XString repeat_53 = ad.memo;
send_vpacket<0x7953, 150, 1>(s, head_53, repeat_53);
@@ -3401,10 +3208,6 @@ bool login_config(XString w1, ZString w2)
{
add_to_unlimited_account = config_switch(w2);
}
- else if (w1 == "start_limited_time"_s)
- {
- start_limited_time = atoi(w2.c_str());
- }
else if (w1 == "check_ip_flag"_s)
{
check_ip_flag = config_switch(w2);
@@ -3626,14 +3429,6 @@ bool display_conf_warnings(void)
rv = false;
}
- if (start_limited_time < -1)
- { // -1: create unlimited account, 0 or more: additionnal sec from now to create limited time
- PRINTF("***WARNING: Invalid value for start_limited_time parameter\n"_fmt);
- PRINTF(" -> set to -1 (new accounts are created with unlimited time).\n"_fmt);
- start_limited_time = -1;
- rv = false;
- }
-
if (check_ip_flag != 0 && check_ip_flag != 1)
{ // 0: no, 1: yes
PRINTF("***WARNING: Invalid value for check_ip_flag parameter\n"_fmt);
@@ -3775,13 +3570,9 @@ void save_config_in_log(void)
else
LOGIN_LOG("- to refuse adjustment (with timeadd ladmin) on an unlimited account. You must use timeset (ladmin command) before.\n"_fmt);
- if (start_limited_time < 0)
+ {
LOGIN_LOG("- to create new accounts with an unlimited time.\n"_fmt);
- else if (start_limited_time == 0)
- LOGIN_LOG("- to create new accounts with a limited time: time of creation.\n"_fmt);
- else
- LOGIN_LOG("- to create new accounts with a limited time: time of creation + %d second(s).\n"_fmt,
- start_limited_time);
+ }
if (check_ip_flag)
LOGIN_LOG("- with control of players IP between login-server and char-server.\n"_fmt);