diff options
Diffstat (limited to 'src/admin/ladmin.cpp')
-rw-r--r-- | src/admin/ladmin.cpp | 518 |
1 files changed, 52 insertions, 466 deletions
diff --git a/src/admin/ladmin.cpp b/src/admin/ladmin.cpp index 9dae089..e0d6b06 100644 --- a/src/admin/ladmin.cpp +++ b/src/admin/ladmin.cpp @@ -35,49 +35,48 @@ #include "../strings/vstring.hpp" #include "../io/cxxstdio.hpp" +#include "../io/extract.hpp" #include "../io/read.hpp" +#include "../io/span.hpp" #include "../io/tty.hpp" #include "../io/write.hpp" #include "../net/ip.hpp" -#include "../net/packets.hpp" +#include "../net/timestamp-utils.hpp" #include "../proto2/any-user.hpp" #include "../proto2/login-admin.hpp" #include "../mmo/config_parse.hpp" -#include "../mmo/core.hpp" #include "../mmo/human_time_diff.hpp" -#include "../mmo/mmo.hpp" -#include "../mmo/utils.hpp" +#include "../high/mmo.hpp" #include "../mmo/version.hpp" +#include "../high/core.hpp" +#include "../high/utils.hpp" + +#include "../wire/packets.hpp" + +#include "admin_conf.hpp" +#include "globals.hpp" + #include "../poison.hpp" namespace tmwa { -static -int eathena_interactive_session; -#define Iprintf if (eathena_interactive_session) PRINTF - -//-------------------------------INSTRUCTIONS------------------------------ -// Set the variables below: -// IP of the login server. -// Port where the login-server listens incoming packets. -// Password of administration (same of config_athena.conf). -// IMPORTANT: -// Be sure that you authorize remote administration in login-server -// (see login_athena.conf, 'admin_state' parameter) -//------------------------------------------------------------------------- -static -IP4Address login_ip = IP4_LOCALHOST; // IP of login-server -static -int login_port = 6900; // Port of login-server -static -AccountPass admin_pass = stringish<AccountPass>("admin"_s); // Administration password -static -AString ladmin_log_filename = "log/ladmin.log"_s; +DIAG_PUSH(); +DIAG_I(missing_noreturn); +void SessionDeleter::operator()(SessionData *) +{ + assert(false && "ladmin does not have sessions"_s); +} +DIAG_POP(); + +namespace admin +{ +#define Iprintf if (tmwa::admin::eathena_interactive_session) PRINTF + //------------------------------------------------------------------------- // LIST of COMMANDs that you can type at the prompt: // To use these commands you can only type only the first letters. @@ -220,29 +219,6 @@ AString ladmin_log_filename = "log/ladmin.log"_s; // all other values are 'No MSG', then use state 9 please. // 'error_message_#7': message of the code error 6 = Your are Prohibited to log in until %s (packet 0x006a) // -// timeadd <account_name> <modifier> -// Adds or substracts time from the validity limit of an account. -// Modifier is done as follows: -// Adjustment value (-1, 1, +1, etc...) -// Modified element: -// a or y: year -// m: month -// j or d: day -// h: hour -// mn: minute -// s: second -// <example> timeadd testname +1m-2mn1s-6y -// this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time. -// NOTE: You can not modify a unlimited validity limit. -// If you want modify it, you want probably create a limited validity limit. -// So, at first, you must set the validity limit to a date/time. -// -// timeset <account_name> yyyy/mm/dd [hh:mm:ss] -// Changes the validity limit of an account. -// Default time [hh:mm:ss]: 23:59:59. -// timeset <account_name> 0 -// Gives an unlimited validity limit (0 = unlimited). -// // unban/unbanish <account name> // Unban an account. // Like banset <account name> 0. @@ -258,37 +234,16 @@ AString ladmin_log_filename = "log/ladmin.log"_s; // Displays complete information of an account. // //------------------------------------------------------------------------- -static -Session *login_session; -static -int bytes_to_read = 0; // flag to know if we waiting bytes from login-server -static -TString parameters; // needs to be global since it's passed to the parse function -// really should be added to session data -static -AccountId list_first, list_last; -static -int list_type, list_count; // parameter to display a list of accounts -static -int already_exit_function = 0; // sometimes, the exit function is called twice... so, don't log twice the message - -DIAG_PUSH(); -DIAG_I(missing_noreturn); -void SessionDeleter::operator()(SessionData *) -{ - assert(false && "ladmin does not have sessions"_s); -} -DIAG_POP(); //------------------------------ // Writing function of logs file //------------------------------ #define LADMIN_LOG(fmt, ...) \ - ladmin_log(STRPRINTF(fmt, ## __VA_ARGS__)) + tmwa::admin::ladmin_log(STRPRINTF(fmt, ## __VA_ARGS__)) static void ladmin_log(XString line) { - io::AppendFile logfp(ladmin_log_filename); + io::AppendFile logfp(admin_conf.ladmin_log_filename); if (!logfp.is_open()) return; log_with_timestamp(logfp, line); @@ -300,9 +255,9 @@ void delete_fromlogin(Session *) login_session = nullptr; { PRINTF("Impossible to have a connection with the login-server [%s:%d] !\n"_fmt, - login_ip, login_port); + admin_conf.login_ip, admin_conf.login_port); LADMIN_LOG("Impossible to have a connection with the login-server [%s:%d] !\n"_fmt, - login_ip, login_port); + admin_conf.login_ip, admin_conf.login_port); exit(0); } } @@ -487,13 +442,6 @@ void display_help(ZString param) PRINTF(" Research by name is not possible with this command.\n"_fmt); PRINTF(" <example> list 10 9999999\n"_fmt); } - else if (command == "itemfrob"_s) - { - PRINTF("itemfrob <source-id> <dest-id>\n"_fmt); - PRINTF(" Translates item IDs for all accounts.\n"_fmt); - PRINTF(" Any items matching the source item ID will be mapped to the dest-id.\n"_fmt); - PRINTF(" <example> itemfrob 500 700\n"_fmt); - } else if (command == "listban"_s) { PRINTF("listban [start_id [end_id]]\n"_fmt); @@ -565,34 +513,6 @@ void display_help(ZString param) PRINTF(" 'error_message_#7': message of the code error 6\n"_fmt); PRINTF(" = Your are Prohibited to log in until... (packet 0x006a)\n"_fmt); } - else if (command == "timeadd"_s) - { - PRINTF("timeadd <account_name> <modifier>\n"_fmt); - PRINTF(" Adds or substracts time from the validity limit of an account.\n"_fmt); - PRINTF(" Modifier is done as follows:\n"_fmt); - PRINTF(" Adjustment value (-1, 1, +1, etc...)\n"_fmt); - PRINTF(" Modified element:\n"_fmt); - PRINTF(" a or y: year\n"_fmt); - PRINTF(" m: month\n"_fmt); - PRINTF(" j or d: day\n"_fmt); - PRINTF(" h: hour\n"_fmt); - PRINTF(" mn: minute\n"_fmt); - PRINTF(" s: second\n"_fmt); - PRINTF(" <example> timeadd testname +1m-2mn1s-6y\n"_fmt); - PRINTF(" this example adds 1 month and 1 second, and substracts 2 minutes\n"_fmt); - PRINTF(" and 6 years at the same time.\n"_fmt); - PRINTF("NOTE: You can not modify a unlimited validity limit.\n"_fmt); - PRINTF(" If you want modify it, you want probably create a limited validity limit.\n"_fmt); - PRINTF(" So, at first, you must set the validity limit to a date/time.\n"_fmt); - } - else if (command == "timeadd"_s) - { - PRINTF("timeset <account_name> yyyy/mm/dd [hh:mm:ss]\n"_fmt); - PRINTF(" Changes the validity limit of an account.\n"_fmt); - PRINTF(" Default time [hh:mm:ss]: 23:59:59.\n"_fmt); - PRINTF("timeset <account_name> 0\n"_fmt); - PRINTF(" Gives an unlimited validity limit (0 = unlimited).\n"_fmt); - } else if (command == "unban"_s) { PRINTF("unban/unbanish <account name>\n"_fmt); @@ -644,7 +564,6 @@ void display_help(ZString param) PRINTF(" gm <account_name> [GM_level] -- Modify the GM level of an account\n"_fmt); PRINTF(" id <account name> -- Give the id of an account\n"_fmt); PRINTF(" info <account_id> -- Display all information of an account\n"_fmt); - PRINTF(" itemfrob <source-id> <dest-id> -- Map all items from one item ID to another\n"_fmt); PRINTF(" kami <message> -- Sends a broadcast message (in yellow)\n"_fmt); PRINTF(" kamib <message> -- Sends a broadcast message (in blue)\n"_fmt); PRINTF(" list [First_id [Last_id]] -- Display a list of accounts\n"_fmt); @@ -661,10 +580,6 @@ void display_help(ZString param) PRINTF(" search <expression> -- Seek accounts\n"_fmt); PRINTF(" sex <nomcompte> <sexe> -- Modify the sex of an account\n"_fmt); PRINTF(" state <account_name> <new_state> <error_message_#7> -- Change the state\n"_fmt); - PRINTF(" timeadd <account_name> <modifier> -- Add or substract time from the\n"_fmt); - PRINTF(" example: ta apple +1m-2mn1s-2y validity limit of an account\n"_fmt); - PRINTF(" timeset <account_name> yyyy/mm/dd [hh:mm:ss] -- Change the validify limit\n"_fmt); - PRINTF(" timeset <account_name> 0 -- Give a unlimited validity limit\n"_fmt); PRINTF(" unban <account name> -- Remove the banishment of an account\n"_fmt); PRINTF(" unblock <account name> -- Set state 0 (Account ok) to an account\n"_fmt); PRINTF(" version -- Gives the version of the login-server\n"_fmt); @@ -1260,29 +1175,6 @@ void listaccount(ZString param, int type) list_count = 0; } -//-------------------------------------------------------- -// Sub-function: Frobnicate items -//-------------------------------------------------------- -static -int itemfrob(ZString param) -{ - ItemNameId source_id, dest_id; - - if (!extract(param, record<' '>(&source_id, &dest_id))) - { - PRINTF("You must provide the source and destination item IDs.\n"_fmt); - return 1; - } - - Packet_Fixed<0x7924> fixed_24; - fixed_24.source_item_id = source_id; - fixed_24.dest_item_id = dest_id; - send_fpacket<0x7924, 10>(login_session, fixed_24); - bytes_to_read = 1; // all logging is done to the three main servers - - return 0; -} - //-------------------------------------------- // Sub-function: Asking to modify a memo field //-------------------------------------------- @@ -1552,179 +1444,6 @@ void blockaccount(ZString param) changestatesub(name, 5, "-"_s); // state 5, no error message } -//--------------------------------------------------------------------- -// Sub-function: Add/substract time to the validity limit of an account -//--------------------------------------------------------------------- -static -void timeaddaccount(ZString param) -{ - AccountName name; - HumanTimeDiff modif {}; - - if (!qsplit(param, &name, &modif)) - { - PRINTF("Please input an account name and a modifier.\n"_fmt); - PRINTF(" <example>: timeadd testname +1m-2mn1s-6y\n"_fmt); - PRINTF(" this example adds 1 month and 1 second, and substracts 2 minutes\n"_fmt); - PRINTF(" and 6 years at the same time.\n"_fmt); - LADMIN_LOG("Incomplete parameters to modify a limit time ('timeadd' command).\n"_fmt); - return; - } - if (name.is_print()) - { - return; - } - - if (!modif) - { - PRINTF("Please give an adjustment with this command:\n"_fmt); - PRINTF(" Adjustment value (-1, 1, +1, etc...)\n"_fmt); - PRINTF(" Modified element:\n"_fmt); - PRINTF(" a or y: year\n"_fmt); - PRINTF(" m: month\n"_fmt); - PRINTF(" j or d: day\n"_fmt); - PRINTF(" h: hour\n"_fmt); - PRINTF(" mn: minute\n"_fmt); - PRINTF(" s: second\n"_fmt); - PRINTF(" <example> timeadd testname +1m-2mn1s-6y\n"_fmt); - PRINTF(" this example adds 1 month and 1 second, and substracts 2 minutes\n"_fmt); - PRINTF(" and 6 years at the same time.\n"_fmt); - LADMIN_LOG("No adjustment isn't an adjustment ('timeadd' command).\n"_fmt); - return; - } - - LADMIN_LOG("Request to login-server to modify a time limit.\n"_fmt); - - Packet_Fixed<0x7950> fixed_50; - fixed_50.account_name = name; - fixed_50.valid_add = modif; - send_fpacket<0x7950, 38>(login_session, fixed_50); - bytes_to_read = 1; -} - -//------------------------------------------------- -// Sub-function: Set a validity limit of an account -//------------------------------------------------- -static -void timesetaccount(ZString param) -{ - AccountName name; - XString date; - XString time_; - int year, month, day, hour, minute, second; - - year = month = day = hour = minute = second = 0; - - // # of seconds 1/1/1970 (timestamp): Validity limit of the account (0 = unlimited) - TimeT connect_until_time = TimeT(); - struct tm tmtime = connect_until_time; // initialize - - if (!qsplit(param, &name, &date, &time_) - && !qsplit(param, &name, &date)) - { - PRINTF("Please input an account name, a date and a hour.\n"_fmt); - PRINTF("<example>: timeset <account_name> yyyy/mm/dd [hh:mm:ss]\n"_fmt); - PRINTF(" timeset <account_name> 0 (0 = unlimited)\n"_fmt); - PRINTF(" Default time [hh:mm:ss]: 23:59:59.\n"_fmt); - LADMIN_LOG("Incomplete parameters to set a limit time ('timeset' command).\n"_fmt); - return; - } - if (!name.is_print()) - return; - - if (!time_) - time_ = "23:59:59"_s; - - if (date != "0"_s - && ((!extract(date, record<'/'>(&year, &month, &day)) - && !extract(date, record<'-'>(&year, &month, &day)) - && !extract(date, record<'.'>(&year, &month, &day))) - || !extract(time_, record<':'>(&hour, &minute, &second)))) - { - PRINTF("Please input 0 or a date and a time (format: 0 or yyyy/mm/dd hh:mm:ss).\n"_fmt); - LADMIN_LOG("Invalid format for the date/time ('timeset' command).\n"_fmt); - return; - } - - if (date == "0"_s) - { - connect_until_time = TimeT(); - } - else - { - if (year < 70) - { - year = year + 100; - } - if (year >= 1900) - { - year = year - 1900; - } - if (month < 1 || month > 12) - { - PRINTF("Please give a correct value for the month (from 1 to 12).\n"_fmt); - LADMIN_LOG("Invalid month for the date ('timeset' command).\n"_fmt); - return; - } - month = month - 1; - if (day < 1 || day > 31) - { - PRINTF("Please give a correct value for the day (from 1 to 31).\n"_fmt); - LADMIN_LOG("Invalid day for the date ('timeset' command).\n"_fmt); - return; - } - if (((month == 3 || month == 5 || month == 8 || month == 10) - && day > 30) ||(month == 1 && day > 29)) - { - PRINTF("Please give a correct value for a day of this month (%d).\n"_fmt, - month); - LADMIN_LOG("Invalid day for this month ('timeset' command).\n"_fmt); - return; - } - if (hour < 0 || hour > 23) - { - PRINTF("Please give a correct value for the hour (from 0 to 23).\n"_fmt); - LADMIN_LOG("Invalid hour for the time ('timeset' command).\n"_fmt); - return; - } - if (minute < 0 || minute > 59) - { - PRINTF("Please give a correct value for the minutes (from 0 to 59).\n"_fmt); - LADMIN_LOG("Invalid minute for the time ('timeset' command).\n"_fmt); - return; - } - if (second < 0 || second > 59) - { - PRINTF("Please give a correct value for the seconds (from 0 to 59).\n"_fmt); - LADMIN_LOG("Invalid second for the time ('timeset' command).\n"_fmt); - return; - } - tmtime.tm_year = year; - tmtime.tm_mon = month; - tmtime.tm_mday = day; - tmtime.tm_hour = hour; - tmtime.tm_min = minute; - tmtime.tm_sec = second; - tmtime.tm_isdst = -1; // -1: no winter/summer time modification - connect_until_time = tmtime; - if (connect_until_time.error()) - { - PRINTF("Invalid date.\n"_fmt); - PRINTF("Please add 0 or a date and a time (format: 0 or yyyy/mm/dd hh:mm:ss).\n"_fmt); - LADMIN_LOG("Invalid date. ('timeset' command).\n"_fmt); - return; - } - } - - LADMIN_LOG("Request to login-server to set a time limit.\n"_fmt); - - Packet_Fixed<0x7948> fixed_48; - fixed_48.account_name = name; - fixed_48.valid_until = connect_until_time; - send_fpacket<0x7948, 30>(login_session, fixed_48); - bytes_to_read = 1; -} - //------------------------------------------------------------------------------ // Sub-function: Asking to displaying information about an account (by its name) //------------------------------------------------------------------------------ @@ -1874,8 +1593,6 @@ void prompt(void) infoaccount(wrap<AccountId>(static_cast<uint32_t>(atoi(parameters.c_str())))); else if (command == "kami"_s) sendbroadcast(parameters); // flag for normal - else if (command == "itemfrob"_s) - itemfrob(parameters); // 0: to list all else if (command == "list"_s) listaccount(parameters, 0); // 0: to list all else if (command == "listban"_s) @@ -1898,10 +1615,6 @@ void prompt(void) changesex(parameters); else if (command == "state"_s) changestate(parameters); - else if (command == "timeadd"_s) - timeaddaccount(parameters); - else if (command == "timeset"_s) - timesetaccount(parameters); else if (command == "unban"_s) unbanaccount(parameters); else if (command == "unblock"_s) @@ -1974,7 +1687,7 @@ void parse_fromlogin(Session *s) break; Iprintf(" Login-Server [%s:%d]\n"_fmt, - login_ip, login_port); + admin_conf.login_ip, admin_conf.login_port); Version version = fixed.version; Iprintf(" tmwA version %hhu.%hhu.%hhu (dev? %hhu) (flags %hhx) (which %hhx) (vend %hu)\n"_fmt, version.major, version.minor, version.patch, @@ -1986,17 +1699,6 @@ void parse_fromlogin(Session *s) break; } - case 0x7925: // Itemfrob-OK - { - Packet_Fixed<0x7925> fixed; - rv = recv_fpacket<0x7925, 2>(s, fixed); - if (rv != RecvResult::Complete) - break; - - bytes_to_read = 0; - break; - } - case 0x7921: // Displaying of the list of accounts { std::vector<Packet_Repeat<0x7921>> repeat; @@ -2487,47 +2189,6 @@ void parse_fromlogin(Session *s) break; } - case 0x7949: // answer of an account validity limit set - { - Packet_Fixed<0x7949> fixed; - rv = recv_fpacket<0x7949, 34>(s, fixed); - if (rv != RecvResult::Complete) - break; - - AccountId account_id = fixed.account_id; - AccountName name = fixed.account_name; - if (!account_id) - { - PRINTF("Account [%s] validity limit changing failed. Account doesn't exist.\n"_fmt, - name); - LADMIN_LOG("Account [%s] validity limit changing failed. Account doesn't exist.\n"_fmt, - name); - } - else - { - TimeT timestamp = fixed.valid_until; - if (!timestamp) - { - PRINTF("Validity Limit of the account [%s][id: %d] successfully changed to [unlimited].\n"_fmt, - name, account_id); - LADMIN_LOG("Validity Limit of the account [%s][id: %d] successfully changed to [unlimited].\n"_fmt, - name, account_id); - } - else - { - timestamp_seconds_buffer tmpstr; - stamp_time(tmpstr, ×tamp); - PRINTF("Validity Limit of the account [%s][id: %d] successfully changed to be until %s.\n"_fmt, - name, account_id, tmpstr); - LADMIN_LOG("Validity Limit of the account [%s][id: %d] successfully changed to be until %s.\n"_fmt, - name, account_id, - tmpstr); - } - } - bytes_to_read = 0; - break; - } - case 0x794b: // answer of an account ban set { Packet_Fixed<0x794b> fixed; @@ -2632,50 +2293,6 @@ void parse_fromlogin(Session *s) break; } - case 0x7951: // answer of an account validity limit changing - { - Packet_Fixed<0x7951> fixed; - rv = recv_fpacket<0x7951, 34>(s, fixed); - if (rv != RecvResult::Complete) - break; - - AccountId account_id = fixed.account_id; - AccountName name = fixed.account_name; - if (!account_id) - { - PRINTF("Account [%s] validity limit changing failed. Account doesn't exist.\n"_fmt, - name); - LADMIN_LOG("Account [%s] validity limit changing failed. Account doesn't exist.\n"_fmt, - name); - } - else - { - TimeT timestamp = fixed.valid_until; - if (!timestamp) - { - PRINTF("Validity limit of the account [%s][id: %d] unchanged.\n"_fmt, - name, account_id); - PRINTF("The account have an unlimited validity limit or\n"_fmt); - PRINTF("the changing is impossible with the proposed adjustments.\n"_fmt); - LADMIN_LOG("Validity limit of the account [%s][id: %d] unchanged. The account have an unlimited validity limit or the changing is impossible with the proposed adjustments.\n"_fmt, - name, account_id); - } - else - { - timestamp_seconds_buffer tmpstr; - stamp_time(tmpstr, ×tamp); - PRINTF("Validity limit of the account [%s][id: %d] successfully changed to be until %s.\n"_fmt, - name, account_id, - tmpstr); - LADMIN_LOG("Validity limit of the account [%s][id: %d] successfully changed to be until %s.\n"_fmt, - name, account_id, - tmpstr); - } - } - bytes_to_read = 0; - break; - } - case 0x7953: // answer of a request about informations of an account (by account name/id) { Packet_Head<0x7953> head; @@ -2696,7 +2313,6 @@ void parse_fromlogin(Session *s) timestamp_milliseconds_buffer lastlogin = head.last_login_string; VString<15> last_ip_ = head.ip_string; AccountEmail email = head.email; - TimeT connect_until_time = head.connect_until; TimeT ban_until_time = head.ban_until; AString& memo = repeat; if (!account_id) @@ -2790,17 +2406,9 @@ void parse_fromlogin(Session *s) connections); PRINTF(" Last connection at: %s (ip: %s)\n"_fmt, lastlogin, last_ip_); - if (!connect_until_time) { PRINTF(" Validity limit: unlimited.\n"_fmt); } - else - { - timestamp_seconds_buffer tmpstr; - stamp_time(tmpstr, &connect_until_time); - PRINTF(" Validity limit: until %s.\n"_fmt, - tmpstr); - } PRINTF(" Memo: '%s'\n"_fmt, memo); } } @@ -2836,12 +2444,12 @@ void parse_fromlogin(Session *s) // Function to connect to login-server //------------------------------------ static -int Connect_login_server(void) +int connect_login_server(void) { Iprintf("Attempt to connect to login-server...\n"_fmt); LADMIN_LOG("Attempt to connect to login-server...\n"_fmt); - login_session = make_connection(login_ip, login_port, SessionParsers{.func_parse= parse_fromlogin, .func_delete= delete_fromlogin}); + login_session = make_connection(admin_conf.login_ip, admin_conf.login_port, SessionParsers{.func_parse= parse_fromlogin, .func_delete= delete_fromlogin}); if (!login_session) return 0; @@ -2849,7 +2457,7 @@ int Connect_login_server(void) { Packet_Fixed<0x7918> fixed_18; fixed_18.encryption_zero = 0; - fixed_18.account_pass = admin_pass; + fixed_18.account_pass = admin_conf.admin_pass; send_fpacket<0x7918, 28>(login_session, fixed_18); bytes_to_read = 1; @@ -2861,59 +2469,36 @@ int Connect_login_server(void) } static -bool admin_confs(XString w1, ZString w2) +bool admin_config(io::Spanned<XString> key, io::Spanned<ZString> value) { + return parse_admin_conf(admin_conf, key, value); +} + +static +bool admin_confs(io::Spanned<XString> key, io::Spanned<ZString> value) +{ + if (key.data == "admin_conf"_s) { - if (w1 == "login_ip"_s) - { - struct hostent *h = gethostbyname(w2.c_str()); - if (h != nullptr) - { - Iprintf("Login server IP address: %s -> %s\n"_fmt, - w2, login_ip); - login_ip = IP4Address({ - static_cast<uint8_t>(h->h_addr[0]), - static_cast<uint8_t>(h->h_addr[1]), - static_cast<uint8_t>(h->h_addr[2]), - static_cast<uint8_t>(h->h_addr[3]), - }); - } - } - else if (w1 == "login_port"_s) - { - login_port = atoi(w2.c_str()); - } - else if (w1 == "admin_pass"_s) - { - admin_pass = stringish<AccountPass>(w2); - } - else if (w1 == "ladmin_log_filename"_s) - { - ladmin_log_filename = w2; - } - else - { - PRINTF("WARNING: unknown ladmin config key: %s\n"_fmt, AString(w1)); - return false; - } + return load_config_file(value.data, admin_config); } - return true; + key.span.error("Unknown meta-key for admin nonserver"_s); + return false; } +} // namespace admin //-------------------------------------- // Function called at exit of the server //-------------------------------------- void term_func(void) { - - if (already_exit_function == 0) + if (admin::already_exit_function == 0) { - delete_session(login_session); + delete_session(admin::login_session); Iprintf(SGR_RESET "----End of Ladmin (normal end with closing of all files).\n"_fmt); LADMIN_LOG("----End of Ladmin (normal end with closing of all files).\n"_fmt); - already_exit_function = 1; + admin::already_exit_function = 1; } } @@ -2949,14 +2534,14 @@ int do_init(Slice<ZString> argv) else { loaded_config_yet = true; - runflag &= load_config_file(argvi, admin_confs); + runflag &= load_config_file(argvi, admin::admin_confs); } } if (!loaded_config_yet) - runflag &= load_config_file("conf/tmwa-admin.conf"_s, admin_confs); + runflag &= load_config_file("conf/tmwa-admin.conf"_s, admin::admin_confs); - eathena_interactive_session = isatty(0); + admin::eathena_interactive_session = isatty(0); LADMIN_LOG(""_fmt); LADMIN_LOG("Configuration file readed.\n"_fmt); @@ -2973,8 +2558,9 @@ int do_init(Slice<ZString> argv) LADMIN_LOG("Ladmin is ready.\n"_fmt); Iprintf("Ladmin is " SGR_BOLD SGR_GREEN "ready" SGR_RESET ".\n\n"_fmt); - Connect_login_server(); + admin::connect_login_server(); return 0; } +// namespace admin ends before term_func and do_init } // namespace tmwa |