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

limit rcon server access


Post New Thread Reply   
 
Thread Tools Display Modes
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 04-17-2015 , 05:52   Re: limit rcon server access
Reply With Quote #11

Not a module, but a pawn plugin. See this as an experimental plugin and test by yourself.

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

new HandleUserIp[35]

new 
Trie:HandleIpTrie

public plugin_precache()
{
    
HandleIpTrie TrieCreate()
    if(
HandleIpTrie == Invalid_Trie)
    {
        
set_fail_state("Failed to create trie")
    }

    new const 
FileName[] = "rcon_ip_acces.ini"
    
new HandlePath[95]; get_configsdir(HandlePathcharsmax(HandlePath))
    
format(HandlePathcharsmax(HandlePath), "%s/%s"HandlePathFileName)
    
    new 
FilePointer fopen(HandlePath"rt")
    if(
FilePointer)
    {
        new 
FileData[40]
        while(!
feof(FilePointer))
        {
            
fgets(FilePointerFileDatacharsmax(FileData))
            
trim(FileData)
            
            if(!
FileData[0] || FileData[0] == '#' || FileData[0] == '/')
            {
                continue
            }
            
            
TrieSetCell(HandleIpTrieFileData0)
        }
    }
    
    
OrpheuRegisterHook(OrpheuGetFunction("SV_Rcon"), "OnSV_Rcon"OrpheuHookPre)
}

public 
OrpheuHookReturn:OnSV_Rcon(Pointer)
{
    new 
LocalIp[10]
    
OrpheuGetBytesAtAddress(PointerLocalIpcharsmax(LocalIp))
    
    if(
LocalIp[0] == 3)
    {
        
formatex(HandleUserIpcharsmax(HandleUserIp), "%i.%i.%i.%i"LocalIp[4], LocalIp[5], LocalIp[6], LocalIp[7])
        if(!
TrieKeyExists(HandleIpTrieHandleUserIp))
        {
            
log_amx("Blocked rcon attemp from: %s"HandleUserIp)
            return 
OrpheuSupercede
        
}
        
        
log_amx("Allowed rcon attemp from: %s"HandleUserIp)
        return 
OrpheuIgnored
    
}
    return 
OrpheuIgnored
    
    
}

public 
plugin_end()
{
    
TrieDestroy(HandleIpTrie)

Signature(put into addons/amxmodx/configs/orpheu/functions)
Code:
{
	"name" : "SV_Rcon",
	"library" : "engine",
	"arguments" :
	[
		{
			"type" : "pointer"
		}
	],
	"identifiers":
	[
		{
			"os" : "windows",
			"value" : [0x55,0x8B,0xEC,0x81,0xEC,0x04,0x06,0x00,0x00,0x53,0x56,0x57]
		},
		{
			"os" : "linux",
			"value" : "SV_Rcon"
		}
	]
}
Create in addons/amxmodx/configs a file called rcon_ip_acces.ini. Write there the ip that can acces rcon, without port.
__________________

Last edited by HamletEagle; 07-18-2016 at 05:27.
HamletEagle is offline
Green0Turtle
Member
Join Date: Nov 2012
Old 04-21-2015 , 02:57   Re: limit rcon server access
Reply With Quote #12

Great job
Can you add a feature to prevent flooding? (max blocked rcon attempt)

Last edited by Green0Turtle; 04-21-2015 at 02:58.
Green0Turtle is offline
Green0Turtle
Member
Join Date: Nov 2012
Old 11-05-2015 , 15:06   Re: limit rcon server access
Reply With Quote #13

Quote:
Originally Posted by Green0Turtle View Post
Great job
Can you add a feature to prevent flooding? (max blocked rcon attempt)
@HamletEagle
Green0Turtle is offline
KORD_12.7
Senior Member
Join Date: Aug 2009
Location: Russia, Vladivostok
Old 11-07-2015 , 04:25   Re: limit rcon server access
Reply With Quote #14

HamletEagle, dear plugin approver, there is no need to destroy arrays/tries on plugin end
__________________

Vi Veri Veniversum Vivus Vici
Russian Half-Life and Adrenaline Gamer community
KORD_12.7 is offline
Send a message via ICQ to KORD_12.7
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 11-07-2015 , 06:07   Re: limit rcon server access
Reply With Quote #15

Quote:
Originally Posted by KORD_12.7 View Post
HamletEagle, dear plugin approver, there is no need to destroy arrays/tries on plugin end
KORD_12.7, dear user, there is no problem in destroying them, and it's a good practice(not only about tries, but about all handles). You should always free what you used when you no longer need it, and given that memory is reused after map change you can waste memory(at least in amxx < 183). Ask Arkshine if you want to know about the changes in the dev versions.
__________________

Last edited by HamletEagle; 11-07-2015 at 06:09.
HamletEagle is offline
KORD_12.7
Senior Member
Join Date: Aug 2009
Location: Russia, Vladivostok
Old 11-07-2015 , 09:08   Re: limit rcon server access
Reply With Quote #16

HamletEagle, dear plugin approver, pls sorry, i'm just a newbie.
__________________

Vi Veri Veniversum Vivus Vici
Russian Half-Life and Adrenaline Gamer community
KORD_12.7 is offline
Send a message via ICQ to KORD_12.7
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 09:32.


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