summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changelog.txt5
-rw-r--r--conf-tmpl/char_athena.conf4
-rw-r--r--conf-tmpl/login_athena.conf4
-rw-r--r--conf-tmpl/map_athena.conf4
-rw-r--r--src/char/char.c16
-rw-r--r--src/char_sql/char.c15
-rw-r--r--src/login/login.c23
-rw-r--r--src/login_sql/login.c20
-rw-r--r--src/map/clif.c10
-rw-r--r--src/map/map.c1
10 files changed, 81 insertions, 21 deletions
diff --git a/Changelog.txt b/Changelog.txt
index 9b3c33647..87bfe1245 100644
--- a/Changelog.txt
+++ b/Changelog.txt
@@ -1,6 +1,11 @@
Date Added
02/05
+ * Changed interface binding to use a bind_ip instead of using
+ the login_ip, char_ip, or map_ip. This lets you still be
+ able to set your WAN IP seperate from what interface you
+ wish to bind to. Also, the default is back to binding to
+ all interfaces on the machine. [1045: MouseJstr]
* optimizing OnTouch event name generation [Shinomori]
* fixing Celests Sharp Shooting [Shinomori]
* Updated Sharp Shooting AoE code, thanks to Neodis / k-Athena [celest]
diff --git a/conf-tmpl/char_athena.conf b/conf-tmpl/char_athena.conf
index 221815c4a..e23be8de9 100644
--- a/conf-tmpl/char_athena.conf
+++ b/conf-tmpl/char_athena.conf
@@ -18,6 +18,10 @@ wisp_server_name: Server
//
// login_ip:127.0.0.1
+// What interface should we bind to.. if you have multiple IP's on one
+// machine, this lets you put multiple servers on the same ports
+// bind_ip:127.0.0.1
+
// Login Server Port
login_port: 6900
diff --git a/conf-tmpl/login_athena.conf b/conf-tmpl/login_athena.conf
index 2cabd0953..b4dabade4 100644
--- a/conf-tmpl/login_athena.conf
+++ b/conf-tmpl/login_athena.conf
@@ -8,6 +8,10 @@
// you need to specify the IP address you wish to export to the entire world.
//
//login_ip:127.0.0.1
+
+// What interface should we bind to.. if you have multiple IP's on one
+// machine, this lets you put multiple servers on the same ports
+// bind_ip:127.0.0.1
// Login Server Port
login_port: 6900
diff --git a/conf-tmpl/map_athena.conf b/conf-tmpl/map_athena.conf
index d32e16ba6..b5c772b6e 100644
--- a/conf-tmpl/map_athena.conf
+++ b/conf-tmpl/map_athena.conf
@@ -30,6 +30,10 @@ passwd: p1
//
//char_ip:127.0.0.1
+// What interface should we bind to.. if you have multiple IP's on one
+// machine, this lets you put multiple servers on the same ports
+// bind_ip:127.0.0.1
+
// Character Server Port
char_port: 6121
diff --git a/src/char/char.c b/src/char/char.c
index 70bf4aeb7..038000aab 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -54,6 +54,8 @@ in_addr_t login_ip;
int login_port = 6900;
int char_ip_set_ = 0;
char char_ip_str[16];
+int bind_ip_set_ = 0;
+char bind_ip_str[16];
in_addr_t char_ip;
int char_port = 6121;
int char_maintenance;
@@ -3219,6 +3221,14 @@ int char_config_read(const char *cfgName) {
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);
+ } else if (strcmpi(w1, "bind_ip") == 0) {
+ bind_ip_set_ = 1;
+ h = gethostbyname(w2);
+ if (h != NULL) {
+ printf("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);
} else if (strcmpi(w1, "char_port") == 0) {
char_port = atoi(w2);
} else if (strcmpi(w1, "char_maintenance") == 0) {
@@ -3436,8 +3446,10 @@ int do_init(int argc, char **argv) {
set_termfunc(do_final);
set_defaultparse(parse_char);
- //char_fd = make_listen_port(char_port);
- char_fd = make_listen_bind(char_ip,char_port);
+ 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);
add_timer_func_list(check_connect_login_server, "check_connect_login_server");
add_timer_func_list(send_users_tologin, "send_users_tologin");
diff --git a/src/char_sql/char.c b/src/char_sql/char.c
index 22e1f78e1..a6c8d60b3 100644
--- a/src/char_sql/char.c
+++ b/src/char_sql/char.c
@@ -93,6 +93,8 @@ in_addr_t login_ip;
int login_port = 6900;
int char_ip_set_ = 0;
char char_ip_str[128];
+int bind_ip_set_ = 0;
+char bind_ip_str[128];
in_addr_t char_ip;
int char_port = 6121;
int char_maintenance;
@@ -3174,6 +3176,14 @@ int char_config_read(const char *cfgName) {
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);
+ } else if (strcmpi(w1, "bind_ip") == 0) {
+ bind_ip_set_ = 1;
+ h = gethostbyname (w2);
+ if(h != NULL) {
+ printf("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);
} else if (strcmpi(w1, "char_port") == 0) {
char_port = atoi(w2);
} else if (strcmpi(w1, "char_maintenance") == 0) {
@@ -3330,7 +3340,10 @@ int do_init(int argc, char **argv){
printf("open port %d.....\n",char_port);
//char_fd = make_listen_port(char_port);
- char_fd = make_listen_bind(char_ip,char_port);
+ 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);
// send ALIVE PING to login server.
printf("add interval tic (check_connect_login_server)....\n");
diff --git a/src/login/login.c b/src/login/login.c
index 5c3888bd4..187111f1a 100644
--- a/src/login/login.c
+++ b/src/login/login.c
@@ -55,8 +55,8 @@ void Gettimeofday(struct timeval *timenow)
int account_id_count = START_ACCOUNT_NUM;
int server_num;
int new_account_flag = 0;
-char login_ip_str[16];
-in_addr_t login_ip;
+char bind_ip_str[16];
+in_addr_t bind_ip;
int login_port = 6900;
char lan_char_ip[16];
int subneti[4];
@@ -3367,6 +3367,8 @@ int login_config_read(const char *cfgName) {
FILE *fp;
struct hostent *h = NULL;
+ bind_ip_str[0] = '\0';
+
if ((fp = fopen(cfgName, "r")) == NULL) {
printf("Configuration file (%s) not found.\n", cfgName);
return 1;
@@ -3421,14 +3423,14 @@ int login_config_read(const char *cfgName) {
level_new_gm = atoi(w2);
} else if (strcmpi(w1, "new_account") == 0) {
new_account_flag = config_switch(w2);
- } else if (strcmpi(w1, "login_ip") == 0) {
- //login_ip_set_ = 1;
+ } else if (strcmpi(w1, "bind_ip") == 0) {
+ //bind_ip_set_ = 1;
h = gethostbyname (w2);
if (h != NULL) {
printf("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]);
+ 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(login_ip_str,w2,16);
+ memcpy(bind_ip_str,w2,16);
} else if (strcmpi(w1, "login_port") == 0) {
login_port = atoi(w2);
} else if (strcmpi(w1, "account_filename") == 0) {
@@ -3955,9 +3957,14 @@ int do_init(int argc, char **argv) {
read_gm_account();
// set_termfunc(mmo_auth_sync);
set_defaultparse(parse_login);
- login_ip = inet_addr(login_ip_str);
+
+ if (bind_ip_str[0] != '\0')
+ bind_ip = inet_addr(bind_ip_str);
+ else
+ bind_ip = INADDR_ANY;
+
//login_fd = make_listen_port(login_port);
- login_fd = make_listen_bind(login_ip,login_port);
+ login_fd = make_listen_bind(bind_ip,login_port);
if(anti_freeze_enable > 0) {
add_timer_func_list(char_anti_freeze_system, "char_anti_freeze_system");
diff --git a/src/login_sql/login.c b/src/login_sql/login.c
index 7d457b138..97e25a3a3 100644
--- a/src/login_sql/login.c
+++ b/src/login_sql/login.c
@@ -82,8 +82,8 @@ void Gettimeofday(struct timeval *timenow)
int account_id_count = START_ACCOUNT_NUM;
int server_num;
int new_account_flag = 0;
-char login_ip_str[16];
-in_addr_t login_ip;
+char bind_ip_str[16];
+in_addr_t bind_ip;
int login_port = 6900;
char lan_char_ip[128]; // Lan char ip added by kashy
int subnetmaski[4]; // Subnetmask added by kashy
@@ -1580,6 +1580,8 @@ int login_config_read(const char *cfgName){
FILE *fp;
struct hostent *h = NULL;
+ bind_ip_str[0] = '\0';
+
fp=fopen(cfgName,"r");
if(fp==NULL){
@@ -1594,15 +1596,14 @@ int login_config_read(const char *cfgName){
i=sscanf(line,"%[^:]: %[^\r\n]",w1,w2);
if(i!=2)
continue;
-
- else if (strcmpi(w1, "login_ip") == 0) {
+ else if (strcmpi(w1, "bind_ip") == 0) {
//login_ip_set_ = 1;
h = gethostbyname (w2);
if (h != NULL) {
printf("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]);
+ 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(login_ip_str,w2,16);
+ memcpy(bind_ip_str,w2,16);
} else if(strcmpi(w1,"login_port")==0){
login_port=atoi(w2);
printf ("set login_port : %s\n",w2);
@@ -1816,10 +1817,13 @@ int do_init(int argc,char **argv){
printf ("set max servers complete\n");
//server port open & binding
- login_ip = inet_addr(login_ip_str);
+ if (bind_ip_str[0] != '\0')
+ bind_ip = inet_addr(bind_ip_str);
+ else
+ bind_ip = INADDR_ANY;
//login_fd=make_listen_port(login_port);
- login_fd=make_listen_bind(login_ip,login_port);
+ login_fd=make_listen_bind(bind_ip,login_port);
//Auth start
printf ("Running mmo_auth_sqldb_init()\n");
diff --git a/src/map/clif.c b/src/map/clif.c
index 16c3b4589..b6044c166 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -153,6 +153,7 @@ enum {
static char map_ip_str[16];
static in_addr_t map_ip;
+static in_addr_t bind_ip = INADDR_ANY;
static int map_port = 5121;
int map_fd;
char talkie_mes[80];
@@ -167,6 +168,11 @@ void clif_setip(char *ip)
map_ip = inet_addr(map_ip_str);
}
+void clif_setbindip(char *ip)
+{
+ bind_ip = inet_addr(ip);
+}
+
/*==========================================
* mapŽI‚ÌportÝ’è
*------------------------------------------
@@ -11357,14 +11363,14 @@ int do_init_clif(void) {
set_defaultparse(clif_parse);
#ifdef __WIN32
//if (!make_listen_port(map_port)) {
- if (!make_listen_bind(map_ip,map_port)) {
+ if (!make_listen_bind(bind_ip,map_port)) {
printf("cant bind game port\n");
exit(1);
}
#else
for(i = 0; i < 10; i++) {
//if (make_listen_port(map_port))
- if (make_listen_bind(map_ip,map_port))
+ if (make_listen_bind(bind_ip,map_port))
break;
sleep(20);
}
diff --git a/src/map/map.c b/src/map/map.c
index c0f3aa046..d7c7cd2aa 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -2132,6 +2132,7 @@ int map_delmap(char *mapname) {
}
static int map_ip_set_ = 0;
+static int bind_ip_set_ = 0;
static int char_ip_set_ = 0;
/*==========================================