summaryrefslogtreecommitdiff
path: root/src/login
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-11-29 15:16:44 +0300
committerAndrei Karas <akaras@inbox.ru>2014-11-29 15:16:44 +0300
commitaa3110d092a545c027a4c568a9158e7c1210d547 (patch)
tree43de0da3044881dee26ff9af4de47c1c925e5282 /src/login
parent33dd27e7025553d3635dc06200c1189901243ede (diff)
downloadevol-hercules-aa3110d092a545c027a4c568a9158e7c1210d547.tar.gz
evol-hercules-aa3110d092a545c027a4c568a9158e7c1210d547.tar.bz2
evol-hercules-aa3110d092a545c027a4c568a9158e7c1210d547.tar.xz
evol-hercules-aa3110d092a545c027a4c568a9158e7c1210d547.zip
login: add ability to filter inter servers connections by ip
New config option: inter_server_ip Example: inter_server_ip 127.0.0.1,127.0.0.2
Diffstat (limited to 'src/login')
-rw-r--r--src/login/config.c16
-rw-r--r--src/login/config.h2
-rw-r--r--src/login/init.c2
-rw-r--r--src/login/parse.c13
-rw-r--r--src/login/parse.h1
5 files changed, 34 insertions, 0 deletions
diff --git a/src/login/config.c b/src/login/config.c
index d53cd17..d6ea4bd 100644
--- a/src/login/config.c
+++ b/src/login/config.c
@@ -14,14 +14,30 @@
#include "login/config.h"
char *update_server = NULL;
+char *inter_server_ip = NULL;
void config_update_server(const char *val)
{
update_server = aStrdup(val);
}
+void config_inter_server_ip(const char *val)
+{
+ char buf[1000];
+
+ if (strlen(val) > 900)
+ return;
+
+ strcpy(buf, ",");
+ strcat(buf, val);
+ strcat(buf, ",");
+ inter_server_ip = aStrdup(buf);
+}
+
void config_final(void)
{
if (update_server)
aFree(update_server);
+ if (inter_server_ip)
+ aFree(inter_server_ip);
}
diff --git a/src/login/config.h b/src/login/config.h
index a491e1e..ad63371 100644
--- a/src/login/config.h
+++ b/src/login/config.h
@@ -6,7 +6,9 @@
void config_update_server(const char *val);
void config_final(void);
+void config_inter_server_ip(const char *val);
extern char *update_server;
+extern char *inter_server_ip;
#endif // EVOL_LOGIN_CONFIG
diff --git a/src/login/init.c b/src/login/init.c
index 30cce3a..c781588 100644
--- a/src/login/init.c
+++ b/src/login/init.c
@@ -35,12 +35,14 @@ HPExport void plugin_init (void)
addPacket(0x7530, 22, login_parse_version, hpParse_Login);
addPacket(0x027c, 95, elogin_parse_client_login2, hpParse_Login);
addHookPre("login->parse_client_login", elogin_parse_client_login_pre);
+ addHookPre("login->parse_request_connection", elogin_parse_request_connection);
}
HPExport void server_preinit (void)
{
iMalloc = GET_SYMBOL("iMalloc");
addLoginConf("update_server", config_update_server);
+ addLoginConf("inter_server_ip", config_inter_server_ip);
}
HPExport void server_online (void)
diff --git a/src/login/parse.c b/src/login/parse.c
index ba4efbd..9f1ffcb 100644
--- a/src/login/parse.c
+++ b/src/login/parse.c
@@ -13,6 +13,7 @@
#include "../../../login/account.h"
#include "../../../login/login.h"
+#include "login/config.h"
#include "login/parse.h"
#include "login/send.h"
@@ -134,3 +135,15 @@ void elogin_parse_client_login2(int fd)
return;
}
+
+void elogin_parse_request_connection(int *fd, struct login_session_data* sd, const char *const ip)
+{
+ if (!inter_server_ip || !ip)
+ return;
+ if (!strstr(inter_server_ip, ip))
+ {
+ hookStop();
+ login->char_server_connection_status(*fd, sd, 3);
+ ShowNotice("Connection of the char-server from ip %s REFUSED.\n", ip);
+ }
+}
diff --git a/src/login/parse.h b/src/login/parse.h
index 01a584a..44cb1b1 100644
--- a/src/login/parse.h
+++ b/src/login/parse.h
@@ -7,5 +7,6 @@
void login_parse_version(int fd);
int elogin_parse_client_login_pre(int *fd, struct login_session_data* sd, const char *const ip);
void elogin_parse_client_login2(int fd);
+void elogin_parse_request_connection(int *fd, struct login_session_data* sd, const char *const ip);
#endif // EVOL_LOGIN_PARSE