Raised This Month: $32 Target: $400
 8% 

Block IP Pattern (With Spaces)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Alber9091
Veteran Member
Join Date: Jun 2014
Location: Karachi, Pakistan
Old 08-04-2019 , 18:38   Block IP Pattern (With Spaces)
Reply With Quote #1

Is there any way to block ips shared like this.

91 87 88 92
OR
91 87 88 92 27015

I saw this in Alka Code, will this be helpful?

PHP Code:
if(digits && periods 2)
 {
  
server_cmd("amx_kick ^"%s^" %s"szNamereason); 
By the way this is just idea, I would like, Replace Text instead of kick, Replace Text: Stop Advertising !! or plugin made by any means, protects server from such kind of ip sharing, like: Regex if it helps, etc, anything, would be appreciated.

Last edited by Alber9091; 08-04-2019 at 18:55.
Alber9091 is offline
Relaxing
AlliedModders Donor
Join Date: Jun 2016
Location: White Plains
Old 08-04-2019 , 18:55   Re: Block IP Pattern (With Spaces)
Reply With Quote #2

#define PATTERN "(\d.*){9}"
I would recommend you this. It turns true when you've typed 9 or more numbers on chat.
The order doesn't matter.
__________________

Last edited by Relaxing; 08-04-2019 at 19:08.
Relaxing is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-05-2019 , 06:23   Re: Block IP Pattern (With Spaces)
Reply With Quote #3

I don't know about Regex but both of these ideas will return false positives sometimes.

Idea #1: If someone writes 123.. the code will think he's advertising an IP, but he isn't.
Idea #2: If someone writes 123456789 , the code will also think he's advertising, but in fact he isn't.
__________________

Last edited by edon1337; 08-05-2019 at 06:24.
edon1337 is offline
Alber9091
Veteran Member
Join Date: Jun 2014
Location: Karachi, Pakistan
Old 08-05-2019 , 06:24   Re: Block IP Pattern (With Spaces)
Reply With Quote #4

Quote:
Originally Posted by Relaxing View Post
#define PATTERN "(\d.*){9}"
I would recommend you this. It turns true when you've typed 9 or more numbers on chat.
The order doesn't matter.
Ah I appreciate the method but friend, again I have to remind you its request section, not scripting help :p I can't make plugins and it would be better if it turns true after 8 or more, instead of 9 or more.
Alber9091 is offline
thEsp
BANNED
Join Date: Aug 2017
Old 08-05-2019 , 06:34   Re: Block IP Pattern (With Spaces)
Reply With Quote #5

It's more like of both, anyway the best way for checking regex patterns is using a web-tool called RegexR.
thEsp is offline
Relaxing
AlliedModders Donor
Join Date: Jun 2016
Location: White Plains
Old 08-05-2019 , 09:16   Re: Block IP Pattern (With Spaces)
Reply With Quote #6

A quick search: https://forums.alliedmods.net/showpo...17&postcount=3
Code:
#include <amxmodx> #include <regex> #define PATTERN "(\d.*){8}" 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];     read_args(arg, charsmax(arg));         remove_quotes(arg);     trim(arg);         if (strlen(arg) > 7){         new match = regex_match_c(arg, re, ret);         if (match > 0){             return PLUGIN_HANDLED;         }     }     return PLUGIN_CONTINUE; }
__________________

Last edited by Relaxing; 08-05-2019 at 09:18.
Relaxing is offline
Alber9091
Veteran Member
Join Date: Jun 2014
Location: Karachi, Pakistan
Old 08-05-2019 , 11:37   Re: Block IP Pattern (With Spaces)
Reply With Quote #7

Quote:
Originally Posted by edon1337 View Post
I don't know about Regex but both of these ideas will return false positives sometimes.

Idea #1: If someone writes 123.. the code will think he's advertising an IP, but he isn't.
Idea #2: If someone writes 123456789 , the code will also think he's advertising, but in fact he isn't.
Sorry, just saw your message, yes that's true, but there is no another solution to avoid this !! If you have any idea, please share.
Alber9091 is offline
Alber9091
Veteran Member
Join Date: Jun 2014
Location: Karachi, Pakistan
Old 08-05-2019 , 11:39   Re: Block IP Pattern (With Spaces)
Reply With Quote #8

Quote:
Originally Posted by thEsp View Post
It's more like of both, anyway the best way for checking regex patterns is using a web-tool called RegexR.
Can you make one? With good idea? So, IPs with spaces can be avoided. Thanks.
Alber9091 is offline
Alber9091
Veteran Member
Join Date: Jun 2014
Location: Karachi, Pakistan
Old 08-05-2019 , 11:42   Re: Block IP Pattern (With Spaces)
Reply With Quote #9

Quote:
Originally Posted by Relaxing View Post
A quick search: https://forums.alliedmods.net/showpo...17&postcount=3
Code:
#include <amxmodx> #include <regex> #define PATTERN "(\d.*){8}" 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];     read_args(arg, charsmax(arg));         remove_quotes(arg);     trim(arg);         if (strlen(arg) > 7){         new match = regex_match_c(arg, re, ret);         if (match > 0){             return PLUGIN_HANDLED;         }     }     return PLUGIN_CONTINUE; }
I will use it, till yet any other ideas are shared, between can you add message, If IP Pattern found, say: 8 or More digits are not allowed in a single message to avoid IP spam.
+ Can you add Whitelist, so I can whitelist my servers own IPs?

Last edited by Alber9091; 08-05-2019 at 12:02.
Alber9091 is offline
Relaxing
AlliedModders Donor
Join Date: Jun 2016
Location: White Plains
Old 08-05-2019 , 12:15   Re: Block IP Pattern (With Spaces)
Reply With Quote #10

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; }
__________________

Last edited by Relaxing; 08-05-2019 at 12:17.
Relaxing is offline
Old 08-05-2019, 12:18
Alber9091
This message has been deleted by Alber9091. Reason: NVM
Reply



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 23:35.


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