HamletEagle |
04-17-2015 05:52 |
Re: limit rcon server access
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(HandlePath, charsmax(HandlePath)) format(HandlePath, charsmax(HandlePath), "%s/%s", HandlePath, FileName) new FilePointer = fopen(HandlePath, "rt") if(FilePointer) { new FileData[40] while(!feof(FilePointer)) { fgets(FilePointer, FileData, charsmax(FileData)) trim(FileData) if(!FileData[0] || FileData[0] == '#' || FileData[0] == '/') { continue } TrieSetCell(HandleIpTrie, FileData, 0) } } OrpheuRegisterHook(OrpheuGetFunction("SV_Rcon"), "OnSV_Rcon", OrpheuHookPre) }
public OrpheuHookReturn:OnSV_Rcon(Pointer) { new LocalIp[10] OrpheuGetBytesAtAddress(Pointer, LocalIp, charsmax(LocalIp)) if(LocalIp[0] == 3) { formatex(HandleUserIp, charsmax(HandleUserIp), "%i.%i.%i.%i", LocalIp[4], LocalIp[5], LocalIp[6], LocalIp[7]) if(!TrieKeyExists(HandleIpTrie, HandleUserIp)) { 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.
|