Any way to make this faster? -
MafiaOink - 26.11.2015
So this is my Range Banning code:
Код:
stock BanRange(l1)
{
printf("[BanRange] Banning Range Starting from: %d", l1);
new docmd[128], ipttl[128];
for(new i=1;i<256;i++)
{
for(new b=0;b<256;b++)
{
for(new c=0;c<256;c++)
{
format(ipttl, sizeof(ipttl), "%d.%d.%d.%d", l1, i, b, c);
format(docmd, 128, "banip %s", ipttl);
SendRconCommand(docmd);
}
}
}
return 1;
}
Its slow and it would take hours to ban one range..
Anyway to make it more faster? or optimize it?
Re: Any way to make this faster? -
jamesbond007 - 26.11.2015
cant u do 123.*.*.* and it bans all?
Re: Any way to make this faster? -
iKarim - 26.11.2015
This would ban all ips lol, you're looping through 256 ip part inside a 256 loop both inside 256 loop which loops through: 16777216 ip part. impossible to do this, and your code isn't a range ban code, it bans each n every ip.
Re: Any way to make this faster? -
cawfee - 26.11.2015
Provided you're using sscanf and zcmd, you could always use this:
Код:
CMD:banip(playerid, params[])
{
new given_ip[16];
if(sscanf(params, "s[16]", given_ip))
{
// Invalid input...
return false;
}
new str[25];
str = "banip ";
strcat(str, given_ip);
SendRconCommand(str);
return true;
}
Re: Any way to make this faster? -
MafiaOink - 26.11.2015
Quote:
Originally Posted by PawnHunter
This would ban all ips lol, you're looping through 256 ip part inside a 256 loop both inside 256 loop which loops through: 16777216 ip part. impossible to do this, and your code isn't a range ban code, it bans each n every ip.
|
It dosent ban each and every IP..
It will ban all the IPs under the first line e.g. 192
and cawfee
You cant directly set a string, You have to format it.
So that would return errors
+ The hell? ip isn't even declared on that command so it would basically send this: "banip " with no parameters.
Re: Any way to make this faster? -
iKarim - 26.11.2015
You can't ban IPs like that, can you explain me your code?
All I can see this loops banning 11.*.*.*
{11.1.1.1, 11.1.1.2, 11.1.1.3, etc etc etc, 11.255.255.255}
and you're looping through 16777216 ip part.
Re: Any way to make this faster? -
cawfee - 26.11.2015
Quote:
Originally Posted by MafiaOink
It dosent ban each and every IP..
It will ban all the IPs under the first line e.g. 192
and cawfee
You cant directly set a string, You have to format it.
So that would return errors
+ The hell? ip isn't even declared on that command so it would basically send this: "banip " with no parameters.
|
My bad. Try it now. And by the way, format is not required in this case. Eliminating the need for format actually makes it slightly faster too.
Re: Any way to make this faster? -
iKarim - 26.11.2015
If you can't make your own range ban system, use RCON.
Use: /rcon banip 11.*.*.*, and none of this range will be able to access server.
Re: Any way to make this faster? -
Vince - 26.11.2015
An entire class A range should never be range banned as that is way too broad. A class A range is in most cases shared by several different countries.
The 192 class A range (192.0.0.0 through 192.255.255.255) is in fact shared - and I'm not making this up - by no less than 104 different countries. Here's the top 5:
Country | Numer of IP addresses |
United States | 11247369 |
Canada | 924255 |
Finland | 488406 |
Japan | 392666 |
Sweden | 337251 |
Re: Any way to make this faster? -
Jefff - 26.11.2015
Loled
pawn Код:
stock BanRange(l1)
{
new str[16];
printf("[BanRange] Banning Range Starting from: %d", l1);
format(str, sizeof(str), "banip %d.*.*.*", l1);
SendRconCommand(str);
return 1;
}
? xD