summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am8
-rw-r--r--src/char/char.c3
-rw-r--r--src/common/ip.c25
-rw-r--r--src/common/ip.h9
-rw-r--r--src/login/parse.c3
5 files changed, 44 insertions, 4 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 896fb9b..29984a5 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -6,7 +6,9 @@ CHAR_SRC = char/char.c \
char/config.h \
char/init.c \
common/interfaces.c \
- common/interfaces.h
+ common/interfaces.h \
+ common/ip.c \
+ common/ip.h
LOGIN_SRC = login/config.c \
login/config.h \
@@ -16,7 +18,9 @@ LOGIN_SRC = login/config.c \
login/send.c \
login/send.h \
common/interfaces.c \
- common/interfaces.h
+ common/interfaces.h \
+ common/ip.c \
+ common/ip.h
MAP_SRC = map/clif.c \
map/clif.h \
diff --git a/src/char/char.c b/src/char/char.c
index fc9dd2d..d852f21 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -12,6 +12,7 @@
#include "../../../common/strlib.h"
#include "../../../char/char.h"
+#include "common/ip.h"
#include "char/char.h"
#include "char/config.h"
@@ -23,7 +24,7 @@ void echar_parse_char_login_map_server(int *fd)
const uint32 ipl = session[*fd]->client_addr;
const char *const ip = ip2str(ipl, NULL);
- if (!strstr(inter_server_ip, ip))
+ if (!checkAllowedIp(inter_server_ip, ip))
{
hookStop();
ShowNotice("Connection of the map-server from ip %s REFUSED.\n", ip);
diff --git a/src/common/ip.c b/src/common/ip.c
new file mode 100644
index 0000000..bad4b61
--- /dev/null
+++ b/src/common/ip.c
@@ -0,0 +1,25 @@
+// Copyright (c) Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// Copyright (c) 2014 Evol developers
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "../../../common/HPMi.h"
+#include "../../../common/malloc.h"
+#include "../../../common/mmo.h"
+#include "../../../common/socket.h"
+#include "../../../common/strlib.h"
+
+#include "common/ip.h"
+
+bool checkAllowedIp(const char* const mask, const char* const ip)
+{
+ char buf[1000];
+
+ strcpy(buf, ",");
+ strcat(buf, ip);
+ strcat(buf, ",");
+
+ return strstr(mask, buf) != NULL;
+}
diff --git a/src/common/ip.h b/src/common/ip.h
new file mode 100644
index 0000000..1b0ba18
--- /dev/null
+++ b/src/common/ip.h
@@ -0,0 +1,9 @@
+// Copyright (c) Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// Copyright (c) 2014 Evol developers
+
+#ifndef EVOL_COMMON_IP
+#define EVOL_COMMON_IP
+
+bool checkAllowedIp(const char* const mask, const char* const ip);
+
+#endif // EVOL_COMMON_IP
diff --git a/src/login/parse.c b/src/login/parse.c
index 9f1ffcb..7aa31e9 100644
--- a/src/login/parse.c
+++ b/src/login/parse.c
@@ -13,6 +13,7 @@
#include "../../../login/account.h"
#include "../../../login/login.h"
+#include "common/ip.h"
#include "login/config.h"
#include "login/parse.h"
#include "login/send.h"
@@ -140,7 +141,7 @@ void elogin_parse_request_connection(int *fd, struct login_session_data* sd, con
{
if (!inter_server_ip || !ip)
return;
- if (!strstr(inter_server_ip, ip))
+ if (!checkAllowedIp(inter_server_ip, ip))
{
hookStop();
login->char_server_connection_status(*fd, sd, 3);