|
@@ -2,20 +2,13 @@
|
|
// For more information, see LICENCE in the main folder
|
|
// For more information, see LICENCE in the main folder
|
|
|
|
|
|
#include <sys/types.h>
|
|
#include <sys/types.h>
|
|
-#include <stdio.h>
|
|
|
|
-#include <stdlib.h>
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
#ifdef _WIN32
|
|
#include <winsock.h>
|
|
#include <winsock.h>
|
|
-typedef long in_addr_t;
|
|
|
|
#else
|
|
#else
|
|
#include <sys/socket.h>
|
|
#include <sys/socket.h>
|
|
-#include <netinet/in.h>
|
|
|
|
|
|
+#include <netinet/in.h>
|
|
#include <arpa/inet.h>
|
|
#include <arpa/inet.h>
|
|
-#include <netdb.h>
|
|
|
|
-#include <sys/ioctl.h>
|
|
|
|
-#include <sys/time.h>
|
|
|
|
-#include <unistd.h>
|
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
#include <time.h>
|
|
#include <time.h>
|
|
@@ -23,6 +16,8 @@ typedef long in_addr_t;
|
|
#include <fcntl.h>
|
|
#include <fcntl.h>
|
|
#include <string.h>
|
|
#include <string.h>
|
|
#include <stdarg.h>
|
|
#include <stdarg.h>
|
|
|
|
+#include <stdio.h>
|
|
|
|
+#include <stdlib.h>
|
|
#include <limits.h>
|
|
#include <limits.h>
|
|
|
|
|
|
#include "../common/strlib.h"
|
|
#include "../common/strlib.h"
|
|
@@ -54,15 +49,13 @@ char userid[24];
|
|
char passwd[24];
|
|
char passwd[24];
|
|
char server_name[20];
|
|
char server_name[20];
|
|
char wisp_server_name[NAME_LENGTH] = "Server";
|
|
char wisp_server_name[NAME_LENGTH] = "Server";
|
|
-int login_ip_set_ = 0;
|
|
|
|
char login_ip_str[16];
|
|
char login_ip_str[16];
|
|
in_addr_t login_ip;
|
|
in_addr_t login_ip;
|
|
int login_port = 6900;
|
|
int login_port = 6900;
|
|
-int char_ip_set_ = 0;
|
|
|
|
char char_ip_str[16];
|
|
char char_ip_str[16];
|
|
-int bind_ip_set_ = 0;
|
|
|
|
-char bind_ip_str[16];
|
|
|
|
in_addr_t char_ip;
|
|
in_addr_t char_ip;
|
|
|
|
+char bind_ip_str[16];
|
|
|
|
+in_addr_t bind_ip;
|
|
int char_port = 6121;
|
|
int char_port = 6121;
|
|
int char_maintenance;
|
|
int char_maintenance;
|
|
int char_new;
|
|
int char_new;
|
|
@@ -1798,7 +1791,6 @@ static int char_delete(struct mmo_charstatus *cs) {
|
|
int parse_tologin(int fd) {
|
|
int parse_tologin(int fd) {
|
|
int i;
|
|
int i;
|
|
struct char_session_data *sd;
|
|
struct char_session_data *sd;
|
|
- struct hostent *h;
|
|
|
|
RFIFOHEAD(fd);
|
|
RFIFOHEAD(fd);
|
|
|
|
|
|
// only login-server can have an access to here.
|
|
// only login-server can have an access to here.
|
|
@@ -2296,14 +2288,16 @@ int parse_tologin(int fd) {
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
case 0x2735:
|
|
case 0x2735:
|
|
|
|
+ {
|
|
|
|
+ unsigned char ip[4];
|
|
ShowInfo("IP Sync in progress...\n");
|
|
ShowInfo("IP Sync in progress...\n");
|
|
- h = char_server_dns?gethostbyname(char_server_dns):NULL;
|
|
|
|
- if(h){
|
|
|
|
|
|
+ if (char_server_dns && resolve_hostbyname(char_server_dns, ip, NULL))
|
|
|
|
+ {
|
|
WFIFOW(fd,0) = 0x2736;
|
|
WFIFOW(fd,0) = 0x2736;
|
|
- WFIFOB(fd,2) = h->h_addr[0];
|
|
|
|
- WFIFOB(fd,3) = h->h_addr[1];
|
|
|
|
- WFIFOB(fd,4) = h->h_addr[2];
|
|
|
|
- WFIFOB(fd,5) = h->h_addr[3];
|
|
|
|
|
|
+ WFIFOB(fd,2) = ip[0];
|
|
|
|
+ WFIFOB(fd,3) = ip[1];
|
|
|
|
+ WFIFOB(fd,4) = ip[2];
|
|
|
|
+ WFIFOB(fd,5) = ip[3];
|
|
WFIFOSET(fd, 6);
|
|
WFIFOSET(fd, 6);
|
|
}
|
|
}
|
|
for(i = 0; i < MAX_MAP_SERVERS; i++){
|
|
for(i = 0; i < MAX_MAP_SERVERS; i++){
|
|
@@ -2314,6 +2308,7 @@ int parse_tologin(int fd) {
|
|
}
|
|
}
|
|
RFIFOSKIP(fd,2);
|
|
RFIFOSKIP(fd,2);
|
|
break;
|
|
break;
|
|
|
|
+ }
|
|
default:
|
|
default:
|
|
ShowWarning("Unknown packet 0x%04x received from login-server, disconnecting.\n", RFIFOW(fd,0));
|
|
ShowWarning("Unknown packet 0x%04x received from login-server, disconnecting.\n", RFIFOW(fd,0));
|
|
session[fd]->eof = 1;
|
|
session[fd]->eof = 1;
|
|
@@ -3954,7 +3949,6 @@ int char_lan_config_read(const char *lancfgName) {
|
|
}
|
|
}
|
|
|
|
|
|
int char_config_read(const char *cfgName) {
|
|
int char_config_read(const char *cfgName) {
|
|
- struct hostent *h = NULL;
|
|
|
|
char line[1024], w1[1024], w2[1024];
|
|
char line[1024], w1[1024], w2[1024];
|
|
FILE *fp = fopen(cfgName, "r");
|
|
FILE *fp = fopen(cfgName, "r");
|
|
|
|
|
|
@@ -3994,35 +3988,24 @@ int char_config_read(const char *cfgName) {
|
|
wisp_server_name[sizeof(wisp_server_name) - 1] = '\0';
|
|
wisp_server_name[sizeof(wisp_server_name) - 1] = '\0';
|
|
}
|
|
}
|
|
} else if (strcmpi(w1, "login_ip") == 0) {
|
|
} else if (strcmpi(w1, "login_ip") == 0) {
|
|
- login_ip_set_ = 1;
|
|
|
|
- h = gethostbyname(w2);
|
|
|
|
- if(char_server_dns)
|
|
|
|
- aFree(char_server_dns);
|
|
|
|
- char_server_dns = (char *)aCalloc(strlen(w2)+1, 1);
|
|
|
|
- strcpy(char_server_dns, w2);
|
|
|
|
- if (h != NULL) {
|
|
|
|
- ShowStatus("Login server IP address : %s -> %d.%d.%d.%d\n", w2, (unsigned char)h->h_addr[0], (unsigned char)h->h_addr[1], (unsigned char)h->h_addr[2], (unsigned char)h->h_addr[3]);
|
|
|
|
- sprintf(login_ip_str, "%d.%d.%d.%d", (unsigned char)h->h_addr[0], (unsigned char)h->h_addr[1], (unsigned char)h->h_addr[2], (unsigned char)h->h_addr[3]);
|
|
|
|
- } else
|
|
|
|
- memcpy(login_ip_str, w2, 16);
|
|
|
|
|
|
+ login_ip = resolve_hostbyname(w2, NULL, login_ip_str);
|
|
|
|
+ if (login_ip) {
|
|
|
|
+ if(char_server_dns)
|
|
|
|
+ aFree(char_server_dns);
|
|
|
|
+ char_server_dns = (char *)aCalloc(strlen(w2)+1, 1);
|
|
|
|
+ strcpy(char_server_dns, w2);
|
|
|
|
+ ShowStatus("Login server IP address : %s -> %s\n", w2, login_ip_str);
|
|
|
|
+ }
|
|
} else if (strcmpi(w1, "login_port") == 0) {
|
|
} else if (strcmpi(w1, "login_port") == 0) {
|
|
login_port = atoi(w2);
|
|
login_port = atoi(w2);
|
|
} else if (strcmpi(w1, "char_ip") == 0) {
|
|
} else if (strcmpi(w1, "char_ip") == 0) {
|
|
- char_ip_set_ = 1;
|
|
|
|
- h = gethostbyname(w2);
|
|
|
|
- if (h != NULL) {
|
|
|
|
- ShowStatus("Character server IP address : %s -> %d.%d.%d.%d\n", w2, (unsigned char)h->h_addr[0], (unsigned char)h->h_addr[1], (unsigned char)h->h_addr[2], (unsigned char)h->h_addr[3]);
|
|
|
|
- sprintf(char_ip_str, "%d.%d.%d.%d", (unsigned char)h->h_addr[0], (unsigned char)h->h_addr[1], (unsigned char)h->h_addr[2], (unsigned char)h->h_addr[3]);
|
|
|
|
- } else
|
|
|
|
- memcpy(char_ip_str, w2, 16);
|
|
|
|
|
|
+ char_ip = resolve_hostbyname(w2, NULL, char_ip_str);
|
|
|
|
+ if (char_ip)
|
|
|
|
+ ShowStatus("Character server IP address : %s -> %s\n", w2, char_ip_str);
|
|
} else if (strcmpi(w1, "bind_ip") == 0) {
|
|
} else if (strcmpi(w1, "bind_ip") == 0) {
|
|
- bind_ip_set_ = 1;
|
|
|
|
- h = gethostbyname(w2);
|
|
|
|
- if (h != NULL) {
|
|
|
|
- ShowStatus("Character server binding IP address : %s -> %d.%d.%d.%d\n", w2, (unsigned char)h->h_addr[0], (unsigned char)h->h_addr[1], (unsigned char)h->h_addr[2], (unsigned char)h->h_addr[3]);
|
|
|
|
- sprintf(bind_ip_str, "%d.%d.%d.%d", (unsigned char)h->h_addr[0], (unsigned char)h->h_addr[1], (unsigned char)h->h_addr[2], (unsigned char)h->h_addr[3]);
|
|
|
|
- } else
|
|
|
|
- memcpy(bind_ip_str, w2, 16);
|
|
|
|
|
|
+ bind_ip = resolve_hostbyname(w2, NULL, bind_ip_str);
|
|
|
|
+ if (bind_ip)
|
|
|
|
+ ShowStatus("Character server binding IP address : %s -> %s\n", w2, bind_ip_str);
|
|
} else if (strcmpi(w1, "char_port") == 0) {
|
|
} else if (strcmpi(w1, "char_port") == 0) {
|
|
char_port = atoi(w2);
|
|
char_port = atoi(w2);
|
|
} else if (strcmpi(w1, "char_maintenance") == 0) {
|
|
} else if (strcmpi(w1, "char_maintenance") == 0) {
|
|
@@ -4225,7 +4208,7 @@ int do_init(int argc, char **argv) {
|
|
// moved behind char_config_read in case we changed the filename [celest]
|
|
// moved behind char_config_read in case we changed the filename [celest]
|
|
char_log("The char-server starting..." RETCODE);
|
|
char_log("The char-server starting..." RETCODE);
|
|
|
|
|
|
- if ((naddr_ != 0) && (login_ip_set_ == 0 || char_ip_set_ == 0)) {
|
|
|
|
|
|
+ if ((naddr_ != 0) && (!login_ip || !char_ip)) {
|
|
// The char server should know what IP address it is running on
|
|
// The char server should know what IP address it is running on
|
|
// - MouseJstr
|
|
// - MouseJstr
|
|
int localaddr = ntohl(addr_[0]);
|
|
int localaddr = ntohl(addr_[0]);
|
|
@@ -4236,18 +4219,19 @@ int do_init(int argc, char **argv) {
|
|
ShowStatus("Multiple interfaces detected.. using %s as our IP address\n", buf);
|
|
ShowStatus("Multiple interfaces detected.. using %s as our IP address\n", buf);
|
|
else
|
|
else
|
|
ShowStatus("Defaulting to %s as our IP address\n", buf);
|
|
ShowStatus("Defaulting to %s as our IP address\n", buf);
|
|
- if (login_ip_set_ == 0)
|
|
|
|
|
|
+ if (!login_ip) {
|
|
strcpy(login_ip_str, buf);
|
|
strcpy(login_ip_str, buf);
|
|
- if (char_ip_set_ == 0)
|
|
|
|
|
|
+ login_ip = inet_addr(login_ip_str);
|
|
|
|
+ }
|
|
|
|
+ if (!char_ip) {
|
|
strcpy(char_ip_str, buf);
|
|
strcpy(char_ip_str, buf);
|
|
|
|
+ char_ip = inet_addr(char_ip_str);
|
|
|
|
+ }
|
|
|
|
|
|
if (ptr[0] == 192 && ptr[1] == 168)
|
|
if (ptr[0] == 192 && ptr[1] == 168)
|
|
ShowWarning("Firewall detected.. edit subnet_athena.conf and char_athena.conf\n");
|
|
ShowWarning("Firewall detected.. edit subnet_athena.conf and char_athena.conf\n");
|
|
}
|
|
}
|
|
|
|
|
|
- login_ip = inet_addr(login_ip_str);
|
|
|
|
- char_ip = inet_addr(char_ip_str);
|
|
|
|
-
|
|
|
|
for(i = 0; i < MAX_MAP_SERVERS; i++) {
|
|
for(i = 0; i < MAX_MAP_SERVERS; i++) {
|
|
memset(&server[i], 0, sizeof(struct mmo_map_server));
|
|
memset(&server[i], 0, sizeof(struct mmo_map_server));
|
|
server_fd[i] = -1;
|
|
server_fd[i] = -1;
|
|
@@ -4266,10 +4250,7 @@ int do_init(int argc, char **argv) {
|
|
|
|
|
|
set_defaultparse(parse_char);
|
|
set_defaultparse(parse_char);
|
|
|
|
|
|
- if (bind_ip_set_)
|
|
|
|
- char_fd = make_listen_bind(inet_addr(bind_ip_str),char_port);
|
|
|
|
- else
|
|
|
|
- char_fd = make_listen_bind(INADDR_ANY,char_port);
|
|
|
|
|
|
+ char_fd = make_listen_bind(bind_ip?bind_ip:INADDR_ANY,char_port);
|
|
|
|
|
|
add_timer_func_list(check_connect_login_server, "check_connect_login_server");
|
|
add_timer_func_list(check_connect_login_server, "check_connect_login_server");
|
|
add_timer_func_list(send_users_tologin, "send_users_tologin");
|
|
add_timer_func_list(send_users_tologin, "send_users_tologin");
|