Raised This Month: $51 Target: $400
 12% 

restrict players with specific client ports


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
lqlqlq
Senior Member
Join Date: Jan 2008
Old 12-22-2012 , 09:19   restrict players with specific client ports
Reply With Quote #1

I want a metamod method, to drop all clients with specific client ports on connect to server.
I want to add a some ports on file, like ports.ini to can connect in server.

PP: I need module for windows and linux.
Thanks.

Last edited by lqlqlq; 12-23-2012 at 05:20.
lqlqlq is offline
DjOptimuS
Senior Member
Join Date: Jan 2009
Old 12-22-2012 , 09:53   Re: [metamod]restrict players with specific client ports
Reply With Quote #2

What's the point of using a metamod module for this ? It's much easier with a plugin. Here it is.

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

#define PLUGIN    "OptimuS Forbidden Ports Blocker"
#define AUTHOR    "OptimuS"
#define VERSION    "0.1"

new g_ForbiddenPorts[][] = {
    
"65535",
    
"65534",
    
"65533",
    
"27015"
}

new 
g_iSizeForbiddenPorts 0;

static 
userip[32];

static 
pos 0;

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
g_iSizeForbiddenPorts sizeof (g_ForbiddenPorts);
}

public 
client_connect(id)
{
    if(
is_user_hltv(id) || is_user_bot(id))
        return 
PLUGIN_CONTINUE
    
    get_user_ip
(0useripsizeof (userip) - 1);
    
    
pos contain(userip":");
    
    
pos += 1;
    
    if(
is_forbidden_port(userip[pos]))
    {
        new 
uid get_user_userid(id);
        
server_cmd("kick #%d Forbidden Port (%s)"uiduserip[pos]);
    }
    
    return 
PLUGIN_CONTINUE
}

stock bool:is_forbidden_port(port[])
{
    
//server_print(" >> %s", port);
    
    
for(new i=0;i<g_iSizeForbiddenPorts;i++)
    {
        if(
equal(portg_ForbiddenPorts[i]))
        {
            return 
true;
        } else {
            continue;
        }
    }
    
    return 
false;


Last edited by DjOptimuS; 12-22-2012 at 09:53.
DjOptimuS is offline
lqlqlq
Senior Member
Join Date: Jan 2008
Old 12-22-2012 , 10:05   Re: [metamod]restrict players with specific client ports
Reply With Quote #3

it doesn't work and i need a version, allowing entry only from ports that I allow, not to block the ports that I do not want.

Maybe can and plugin based on orpheu.

Last edited by lqlqlq; 12-22-2012 at 10:22.
lqlqlq is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-22-2012 , 14:22   Re: [metamod]restrict players with specific client ports
Reply With Quote #4

Why do you want something like this?
__________________
fysiks is offline
DjOptimuS
Senior Member
Join Date: Jan 2009
Old 12-22-2012 , 21:05   Re: [metamod]restrict players with specific client ports
Reply With Quote #5

My code works, you can put the ports in this section

PHP Code:
new g_ForbiddenPorts[][] = {
    
"65535",
    
"65534",
    
"65533",
    
"27015"

Or code your own file reading function. It's simple.
DjOptimuS is offline
Neeeeeeeeeel.-
Some Guy Yellin'
Join Date: Jul 2010
Location: Argentina
Old 12-22-2012 , 22:28   Re: [metamod]restrict players with specific client ports
Reply With Quote #6

He said that wants a "white list" not a "black list".
__________________
Neeeeeeeeeel.- is offline
Send a message via Skype™ to Neeeeeeeeeel.-
lqlqlq
Senior Member
Join Date: Jan 2008
Old 12-23-2012 , 03:43   Re: [metamod]restrict players with specific client ports
Reply With Quote #7

Quote:
Originally Posted by Neeeeeeeeeel.- View Post
He said that wants a "white list" not a "black list".
yes.

Optimus,
with server kick function, you cant add a reason.
server_cmd("kick #%d Forbidden Port (%s)", uid, userip[pos]); - look
lqlqlq is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 12-23-2012 , 03:50   Re: [metamod]restrict players with specific client ports
Reply With Quote #8

Why do you need that, and why do you need a module (and not a pawn plugin) ?
__________________

Last edited by Arkshine; 12-23-2012 at 03:50.
Arkshine is offline
lqlqlq
Senior Member
Join Date: Jan 2008
Old 12-23-2012 , 03:54   Re: [metamod]restrict players with specific client ports
Reply With Quote #9

To protect against future exploits, udp flood (to port 27005) and Fake players.
I have iptables in which only 27005 can connect to 27015:27050.
So I want a module (for me it's probably a module as a plugin) to drop players with different port than 27005 (and some that i allow).

Last edited by lqlqlq; 12-23-2012 at 03:59.
lqlqlq is offline
DjOptimuS
Senior Member
Join Date: Jan 2009
Old 12-23-2012 , 04:13   Re: [metamod]restrict players with specific client ports
Reply With Quote #10

Here you go

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

#define PLUGIN    "OptimuS Forbidden Ports Blocker"
#define AUTHOR    "OptimuS"
#define VERSION    "0.1"

new g_WhiteListPorts[][] = {
    
"65535",
    
"65534",
    
"65533",
    
"27015",
    
"27005"
}

new 
g_iSizeWhiteListPorts 0;

static 
userip[32];

static 
pos 0;

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
g_iSizeWhiteListPorts sizeof (g_WhiteListPorts);
}

public 
client_connect(id)
{
    if(
is_user_hltv(id) || is_user_bot(id))
        return 
PLUGIN_CONTINUE
    
    get_user_ip
(0useripsizeof (userip) - 1);
    
    
pos contain(userip":");
    
    
pos += 1;
    
    if(!
is_port_allowed(userip[pos]))
    {
        new 
uid get_user_userid(id);
        
server_cmd("kick #%d Forbidden Port (%s)"uiduserip[pos]);
    }
    
    return 
PLUGIN_CONTINUE
}

stock bool:is_port_allowed(port[])
{
    
//server_print(" >> %s", port);
    
    
for(new i=0;i<g_iSizeWhiteListPorts;i++)
    {
        if(
equal(portg_WhiteListPorts[i]))
        {
            return 
true;
        } else {
            continue;
        }
    }
    
    return 
false;

DjOptimuS is offline
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 04:17.


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