diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 6 | ||||
-rw-r--r-- | src/char/char.c | 32 | ||||
-rw-r--r-- | src/char/char.h | 9 | ||||
-rw-r--r-- | src/char/config.c | 35 | ||||
-rw-r--r-- | src/char/config.h | 12 | ||||
-rw-r--r-- | src/char/init.c | 9 |
6 files changed, 100 insertions, 3 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 7ed1330..896fb9b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,6 +1,10 @@ AUTOMAKE_OPTIONS = subdir-objects -CHAR_SRC = char/init.c \ +CHAR_SRC = char/char.c \ + char/char.h \ + char/config.c \ + char/config.h \ + char/init.c \ common/interfaces.c \ common/interfaces.h diff --git a/src/char/char.c b/src/char/char.c new file mode 100644 index 0000000..fc9dd2d --- /dev/null +++ b/src/char/char.c @@ -0,0 +1,32 @@ +// 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 "../../../char/char.h" + +#include "char/char.h" +#include "char/config.h" + +void echar_parse_char_login_map_server(int *fd) +{ + if (!inter_server_ip) + return; + + const uint32 ipl = session[*fd]->client_addr; + + const char *const ip = ip2str(ipl, NULL); + if (!strstr(inter_server_ip, ip)) + { + hookStop(); + ShowNotice("Connection of the map-server from ip %s REFUSED.\n", ip); + chr->login_map_server_ack(*fd, 3); + } +} diff --git a/src/char/char.h b/src/char/char.h new file mode 100644 index 0000000..f1be161 --- /dev/null +++ b/src/char/char.h @@ -0,0 +1,9 @@ +// Copyright (c) Copyright (c) Hercules Dev Team, licensed under GNU GPL. +// Copyright (c) 2014 Evol developers + +#ifndef EVOL_CHAR_CHAR +#define EVOL_CHAR_CHAR + +void echar_parse_char_login_map_server(int *fd); + +#endif // EVOL_CHAR_CHAR diff --git a/src/char/config.c b/src/char/config.c new file mode 100644 index 0000000..5eefbc1 --- /dev/null +++ b/src/char/config.c @@ -0,0 +1,35 @@ +// 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 "char/config.h" + +char *inter_server_ip = NULL; + +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 (inter_server_ip) + aFree(inter_server_ip); +} diff --git a/src/char/config.h b/src/char/config.h new file mode 100644 index 0000000..930c293 --- /dev/null +++ b/src/char/config.h @@ -0,0 +1,12 @@ +// Copyright (c) Copyright (c) Hercules Dev Team, licensed under GNU GPL. +// Copyright (c) 2014 Evol developers + +#ifndef EVOL_CHAR_CONFIG +#define EVOL_CHAR_CONFIG + +void config_final(void); +void config_inter_server_ip(const char *val); + +extern char *inter_server_ip; + +#endif // EVOL_CHAR_CONFIG diff --git a/src/char/init.c b/src/char/init.c index bfe7097..639c19b 100644 --- a/src/char/init.c +++ b/src/char/init.c @@ -27,6 +27,8 @@ #include "../../../char/mapif.h" #include "common/interfaces.h" +#include "char/char.h" +#include "char/config.h" #include "../../../common/HPMDataCheck.h" /* should always be the last file included! (if you don't make it last, it'll intentionally break compile time) */ @@ -40,8 +42,6 @@ HPExport struct hplugin_info pinfo = HPExport void plugin_init (void) { - interfaces_init_common(); - chr = GET_SYMBOL("chr"); geoip = GET_SYMBOL("geoip"); inter_auction = GET_SYMBOL("inter_auction"); @@ -57,10 +57,15 @@ HPExport void plugin_init (void) inter = GET_SYMBOL("inter"); loginif = GET_SYMBOL("loginif"); mapif = GET_SYMBOL("mapif"); + + addHookPre("chr->parse_char_login_map_server", echar_parse_char_login_map_server); } HPExport void server_preinit (void) { + interfaces_init_common(); + + addCharInterConf("inter_server_ip", config_inter_server_ip); } HPExport void server_online (void) |