From 8867d978d868f6856cf0dd9eccbe1022c2814856 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 29 Nov 2014 16:16:48 +0300 Subject: Improve inter server ip limit checks. Also move this check into common. --- src/common/ip.c | 25 +++++++++++++++++++++++++ src/common/ip.h | 9 +++++++++ 2 files changed, 34 insertions(+) create mode 100644 src/common/ip.c create mode 100644 src/common/ip.h (limited to 'src/common') 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 +#include +#include + +#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 -- cgit v1.2.3-70-g09d2