From a5861a4c81bb616b7fba2028cf9ee31f890357c5 Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Sun, 8 Sep 2013 19:43:28 -0700 Subject: Use IP4 classes and rename conf variables --- src/ladmin/ladmin.cpp | 45 ++++++++++++++++++--------------------------- 1 file changed, 18 insertions(+), 27 deletions(-) (limited to 'src/ladmin/ladmin.cpp') diff --git a/src/ladmin/ladmin.cpp b/src/ladmin/ladmin.cpp index 12d9390..e0860b2 100644 --- a/src/ladmin/ladmin.cpp +++ b/src/ladmin/ladmin.cpp @@ -36,11 +36,11 @@ int eathena_interactive_session; // (see login_athena.conf, 'admin_state' parameter) //------------------------------------------------------------------------- static -IP_String loginserverip = stringish("127.0.0.1"); // IP of login-server +IP4Address login_ip = IP4_LOCALHOST; // IP of login-server static -int loginserverport = 6900; // Port of login-server +int login_port = 6900; // Port of login-server static -AccountPass loginserveradminpassword = stringish("admin"); // Administration password +AccountPass admin_pass = stringish("admin"); // Administration password static FString ladmin_log_filename = "log/ladmin.log"; //------------------------------------------------------------------------- @@ -226,8 +226,6 @@ FString ladmin_log_filename = "log/ladmin.log"; static int login_fd; static -int login_ip; -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 @@ -1903,9 +1901,9 @@ void parse_fromlogin(int fd) if (session[fd]->eof) { PRINTF("Impossible to have a connection with the login-server [%s:%d] !\n", - loginserverip, loginserverport); + login_ip, login_port); LADMIN_LOG("Impossible to have a connection with the login-server [%s:%d] !\n", - loginserverip, loginserverport); + login_ip, login_port); delete_session(fd); exit(0); } @@ -1945,8 +1943,8 @@ void parse_fromlogin(int fd) if (RFIFOREST(fd) < 10) return; { - Iprintf(" Login-Server [%s:%d]\n", loginserverip, - loginserverport); + Iprintf(" Login-Server [%s:%d]\n", + login_ip, login_port); Version version; RFIFO_STRUCT(login_fd, 2, version); Iprintf(" tmwA version %hhu.%hhu.%hhu (dev? %hhu) (flags %hhx) (which %hhx) (vend %hu)\n", @@ -2608,7 +2606,7 @@ void parse_fromlogin(int fd) int state = RFIFOL(fd, 36); timestamp_seconds_buffer error_message = stringish(RFIFO_STRING<20>(fd, 40)); timestamp_milliseconds_buffer lastlogin = stringish(RFIFO_STRING<24>(fd, 60)); - IP_String last_ip = stringish(RFIFO_STRING<16>(fd, 84)); + VString<15> last_ip_ = RFIFO_STRING<16>(fd, 84); AccountEmail email = stringish(RFIFO_STRING<40>(fd, 100)); TimeT connect_until_time = static_cast(RFIFOL(fd, 140)); TimeT ban_until_time = static_cast(RFIFOL(fd, 144)); @@ -2703,7 +2701,7 @@ void parse_fromlogin(int fd) PRINTF(" Count: %d connection.\n", connections); PRINTF(" Last connection at: %s (ip: %s)\n", - lastlogin, last_ip); + lastlogin, last_ip_); if (!connect_until_time) { PRINTF(" Validity limit: unlimited.\n"); @@ -2743,13 +2741,13 @@ int Connect_login_server(void) Iprintf("Attempt to connect to login-server...\n"); LADMIN_LOG("Attempt to connect to login-server...\n"); - if ((login_fd = make_connection(login_ip, loginserverport)) < 0) + if ((login_fd = make_connection(login_ip, login_port)) < 0) return 0; { WFIFOW(login_fd, 0) = 0x7918; // Request for administation login WFIFOW(login_fd, 2) = 0; // no encrypted - WFIFO_STRING(login_fd, 4, loginserveradminpassword, 24); + WFIFO_STRING(login_fd, 4, admin_pass, 24); WFIFOSET(login_fd, 28); bytes_to_read = 1; @@ -2788,28 +2786,23 @@ int ladmin_config_read(ZString cfgName) struct hostent *h = gethostbyname(w2.c_str()); if (h != NULL) { - Iprintf("Login server IP address: %s -> %d.%d.%d.%d\n", - w2, + Iprintf("Login server IP address: %s -> %s\n", + w2, login_ip); + login_ip = IP4Address({ static_cast(h->h_addr[0]), static_cast(h->h_addr[1]), static_cast(h->h_addr[2]), - static_cast(h->h_addr[3])); - SNPRINTF(loginserverip, 16, "%d.%d.%d.%d", - static_cast(h->h_addr[0]), - static_cast(h->h_addr[1]), - static_cast(h->h_addr[2]), - static_cast(h->h_addr[3])); + static_cast(h->h_addr[3]), + }); } - else - loginserverip = stringish(w2); } else if (w1 == "login_port") { - loginserverport = atoi(w2.c_str()); + login_port = atoi(w2.c_str()); } else if (w1 == "admin_pass") { - loginserveradminpassword = stringish(w2); + admin_pass = stringish(w2); } else if (w1 == "ladmin_log_filename") { @@ -2825,8 +2818,6 @@ int ladmin_config_read(ZString cfgName) } } - login_ip = inet_addr(loginserverip.c_str()); - Iprintf("---End reading of Ladmin configuration file.\n"); return 0; -- cgit v1.2.3-70-g09d2