Raised This Month: $75 Target: $400
 18% 

Block IP Pattern (With Spaces)


Post New Thread Reply   
 
Thread Tools Display Modes
Fuck For Fun
Veteran Member
Join Date: Nov 2013
Location: Derbent, Caucasian
Old 08-05-2019 , 12:41   Re: Block IP Pattern (With Spaces)
Reply With Quote #11

Quote:
Originally Posted by Relaxing View Post
Code:
#include <amxmodx> #include <regex> #define PATTERN "(\d.*){8}" new whitelist[][] = {     "123.456.789.101:27099",     "123.456.789.101",     "yeah" } new Regex:re, ret; public plugin_init(){     register_clcmd("say", "clcmd_say");     register_clcmd("say_team", "clcmd_say");         new err[32];     re = regex_compile(PATTERN, ret, err, 31, "i");     if (re!=REGEX_OK) log_amx("Error: %s (%d)", err, ret); } public plugin_end() {     regex_free(re);    } public clcmd_say(id){     new arg[64], bool: whitestlist;     read_args(arg, charsmax(arg));         remove_quotes(arg);     trim(arg);         for (new i = 0; i < sizeof(whitelist); i++){         if (contain(arg, whitelist[i])){             whitestlist = true;             break;         }     }         if (strlen(arg) > 7 && !whitestlist){         new match = regex_match_c(arg, re, ret);         if (match > 0){             client_print(id, print_chat, "More digits are not allowed in a single message to avoid IP spam.")             return PLUGIN_HANDLED;         }     }     return PLUGIN_CONTINUE; }
I was either looking for or planning to do something like that but if you already send then you better do
Testing the system
Quote:
identifies USER with an IP address
of over X digits so that will simply give KICK
And preferably without a checklist for the following reasons:
Because you have to write something there every time to block it is better to do a test for a user who enters the server \ who changes there and writes in chat.

I would love you to


EDIT:
Quote:
For other players who want to use this code: Block 7 numbers is pretty bad, because for example there are SERVERS who use a particular EVENT that has a name to type X numbers in chat for winning and that will block them

Last edited by Fuck For Fun; 08-05-2019 at 12:43.
Fuck For Fun is offline
Relaxing
Veteran Member
Join Date: Jun 2016
Location: Catlands
Old 08-05-2019 , 12:56   Re: Block IP Pattern (With Spaces)
Reply With Quote #12

Spamming is super hard to avoid.
Well you could add a whitelist but I can bypass it typing in chat:
<whitelist text> connect to my server 123.456.789.101
__________________
Relaxing is offline
thEsp
Veteran Member
Join Date: Aug 2017
Location: Gjilan, Albania
Old 08-05-2019 , 13:37   Re: Block IP Pattern (With Spaces)
Reply With Quote #13

Replace every item from whitelist in a loop.
__________________
thEsp is online now
Alber9091
Senior Member
Join Date: Jun 2014
Location: Some Where On Earth
Old 08-05-2019 , 16:35   Re: Block IP Pattern (With Spaces)
Reply With Quote #14

Quote:
Originally Posted by Relaxing View Post
Code:
#include <amxmodx> #include <regex> #define PATTERN "(\d.*){8}" new whitelist[][] = {     "123.456.789.101:27099",     "123.456.789.101",     "yeah" } new Regex:re, ret; public plugin_init(){     register_clcmd("say", "clcmd_say");     register_clcmd("say_team", "clcmd_say");         new err[32];     re = regex_compile(PATTERN, ret, err, 31, "i");     if (re!=REGEX_OK) log_amx("Error: %s (%d)", err, ret); } public plugin_end() {     regex_free(re);    } public clcmd_say(id){     new arg[64], bool: whitestlist;     read_args(arg, charsmax(arg));         remove_quotes(arg);     trim(arg);         for (new i = 0; i < sizeof(whitelist); i++){         if (contain(arg, whitelist[i])){             whitestlist = true;             break;         }     }         if (strlen(arg) > 7 && !whitestlist){         new match = regex_match_c(arg, re, ret);         if (match > 0){             client_print(id, print_chat, "More digits are not allowed in a single message to avoid IP spam.")             return PLUGIN_HANDLED;         }     }     return PLUGIN_CONTINUE; }
Compiled Successfully, No Error Logs But Plugin Not Working, I can still write ips with space, 88 99 88 91 etc.
__________________

Last edited by Alber9091; 08-05-2019 at 16:47.
Alber9091 is online now
bad_boy
Junior Member
Join Date: Oct 2018
Old 08-05-2019 , 19:26   Re: Block IP Pattern (With Spaces)
Reply With Quote #15

Can you please give mines a try, it should block the spaces.
I'm sure the plugin can be improved so test it and give me some feedback.
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <regex>

new const BlockIps[ ] = "\b(?:\d{1,3}\s)\d{1,3}\b"

new ret,error]
new 
Regex:Spam

public plugin_init() 
{
    
register_plugin"Block IP""1.0""Allied")

    
register_clcmd"say""spamming" )
    
register_clcmd"say_team""spamming" )

    
Spam regex_compile BlockIpsreterrorcharsmax error ) )
}

public 
spammingid 
{
    new 
text128 ], ret
    read_args
textcharsmaxtext ) )

    new 
Check regex_match_ctextSpamret )
        
    if( 
Check 
    {
        
client_printidprint_chat"Stop Advertising !!" )
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_CONTINUE


Last edited by bad_boy; 08-05-2019 at 21:02.
bad_boy is offline
Alber9091
Senior Member
Join Date: Jun 2014
Location: Some Where On Earth
Old 08-06-2019 , 01:41   Re: Block IP Pattern (With Spaces)
Reply With Quote #16

Quote:
Originally Posted by bad_boy View Post
Can you please give mines a try, it should block the spaces.
I'm sure the plugin can be improved so test it and give me some feedback.
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <regex>

new const BlockIps[ ] = "\b(?:\d{1,3}\s)\d{1,3}\b"

new ret,error]
new 
Regex:Spam

public plugin_init() 
{
    
register_plugin"Block IP""1.0""Allied")

    
register_clcmd"say""spamming" )
    
register_clcmd"say_team""spamming" )

    
Spam regex_compile BlockIpsreterrorcharsmax error ) )
}

public 
spammingid 
{
    new 
text128 ], ret
    read_args
textcharsmaxtext ) )

    new 
Check regex_match_ctextSpamret )
        
    if( 
Check 
    {
        
client_printidprint_chat"Stop Advertising !!" )
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_CONTINUE

Will give it a try, when at home.
Till yet as said by you, may be someone improve it too?
__________________
Alber9091 is online now
Alber9091
Senior Member
Join Date: Jun 2014
Location: Some Where On Earth
Old 08-10-2019 , 09:53   Re: Block IP Pattern (With Spaces)
Reply With Quote #17

Sorry for being late !! I had exams and some personal problems !!
Ah, bad_boy, your code also compiled but didn't work. I kept plugin at top in plugins.ini
__________________
Alber9091 is online now
bad_boy
Junior Member
Join Date: Oct 2018
Old 08-10-2019 , 12:59   Re: Block IP Pattern (With Spaces)
Reply With Quote #18

I tested the previous code and it worked. However it will only block 1 space between the numbers.
This one will block up to 4 spaces between the numbers. If they use 5 spaces or more this will not work.


PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <regex>

new const BlockIps[ ] = "\d{1,3}\s{1,4}\d{1,3}\s{1,4}\d{1,3}\s{1,4}\d{1,3}"

new ret,error]
new 
Regex:Spam

public plugin_init() 
{
    
register_plugin"Block IP""1.0""Allied")

    
register_clcmd"say""spamming" )
    
register_clcmd"say_team""spamming" )

    
Spam regex_compile BlockIpsreterrorcharsmax error ) )
}

public 
spammingid 
{
    new 
text128 ], ret
    read_args
textcharsmaxtext ) )

    new 
Check regex_match_ctextSpamret )
        
    if( 
Check 
    {
        
client_printidprint_chat"Stop Advertising !!" )
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_CONTINUE

bad_boy is offline
Relaxing
Veteran Member
Join Date: Jun 2016
Location: Catlands
Old 08-10-2019 , 15:40   Re: Block IP Pattern (With Spaces)
Reply With Quote #19

Quote:
Originally Posted by bad_boy View Post
I tested the previous code and it worked. However it will only block 1 space between the numbers.
This one will block up to 4 spaces between the numbers. If they use 5 spaces or more this will not work.


PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <regex>

new const BlockIps[ ] = "\d{1,3}\s{1,4}\d{1,3}\s{1,4}\d{1,3}\s{1,4}\d{1,3}"

new ret,error]
new 
Regex:Spam

public plugin_init() 
{
    
register_plugin"Block IP""1.0""Allied")

    
register_clcmd"say""spamming" )
    
register_clcmd"say_team""spamming" )

    
Spam regex_compile BlockIpsreterrorcharsmax error ) )
}

public 
spammingid 
{
    new 
text128 ], ret
    read_args
textcharsmaxtext ) )

    new 
Check regex_match_ctextSpamret )
        
    if( 
Check 
    {
        
client_printidprint_chat"Stop Advertising !!" )
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_CONTINUE

https://regexr.com
No match: 123.456.789.123:27015
__________________
Relaxing is offline
bad_boy
Junior Member
Join Date: Oct 2018
Old 08-10-2019 , 15:58   Re: Block IP Pattern (With Spaces)
Reply With Quote #20

Quote:
Originally Posted by Relaxing View Post
https://regexr.com
No match: 123.456.789.123:27015
It's not supposed to match 123.456.789.123:27015
But it will match 123 456 789 123:27015

He asked for it to block Ips with spaces between the numbers.
bad_boy is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:36.


Powered by vBulletin®
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Theme made by Freecode