hello,
title simply says it all but i'm going to elaborate a bit. i'm trying to make an anti proxy system and so far it works. however i want to whitelist ips like 192.168.1.1 until 192.168.1.255. however, it seems like i dont know how, even though i tried so many times with different approaches such as strfind, strlen, strdel but these didnt help me out either probably because the way i did it didn't work. well here's the code:
much appreciated if anyone could help, ive been trying to fix this issue for like hours.
edit: i could do it the worst way which is: then 192.168.1.2 and so on but it sucks
title simply says it all but i'm going to elaborate a bit. i'm trying to make an anti proxy system and so far it works. however i want to whitelist ips like 192.168.1.1 until 192.168.1.255. however, it seems like i dont know how, even though i tried so many times with different approaches such as strfind, strlen, strdel but these didnt help me out either probably because the way i did it didn't work. well here's the code:
Code:
forward httpResponse(playerid, response_code, data[]);
public httpResponse(playerid, response_code, data[])
{
new name[MAX_PLAYERS], string[192], ipstring[64];
new ip[16];
GetPlayerName(playerid, name, sizeof(name));
GetPlayerIp(playerid, ip, sizeof(ip));
format(ipstring, sizeof(string), "192.168.1.%d", strlen(ip) - 13);
if(strcmp(ip, "127.0.0.1", true) == 0 || strcmp(ip, ipstring, true) == 0)
{
printf("%s(%d) IP(%s) is a LAN type, therefore able to enter the server.", name, playerid, ip);
return 1;
}
// If the site sends an OK message
if(response_code == 200)
{
// If a player is using VPN
if(data[0] == 'Y')
{
format(string, sizeof(string), "ANTI VPN: %s(%d) has been kicked from the server due to VPN usage.", name, playerid);
SendClientMessageToAll(COLOR_RED, string);
printf("%s(%d) IP(%s) is not legit, therefore not able to enter the server.", name, playerid, ip);
//SetTimerEx("DelayKick", 100, false, "i", playerid);
}
// If not
if(data[0] == 'N')
{
printf("%s(%d) IP(%s) is legit, therefore able to enter the server.", name, playerid, ip);
// OnPlayerConnect welcome messages should handle this
}
// Failsafe. Should not trigger
if(data[0] == 'X')
{
printf("From the site: Wrong IP format!");
}
} else {
printf("The request failed! The response code was: %d", response_code);
}
return 1;
}
much appreciated if anyone could help, ive been trying to fix this issue for like hours.
edit: i could do it the worst way which is:
Code:
if(strcmp(ip, "192.168.1.1", true) == 0)