RemoteRCON - Managing external RCON packets! -
Abagail - 18.03.2015
RemoteRCON - Managing External RCON Packets!
This include simply takes advantage of the OnRemoteRCONPacket callback in YSF r11(kurta999). It allows you to enable / disable the RCON system completely, whitelist IP addresses, log detailed access attempts, drop RCON packets and more.
This include solely depends on rcon being set to 1 in server.cfg so make sure it's enabled. You can simply use ToggleRCON with the include to disable it. The functions and their uses can be found below:
Functions:
pawn Код:
WhitelistIPAddress(ipaddr[])
Used to whitelist an IP address. This is useless if the whitelisting system isn't enabled with ToggleRemoteWhitelist.
pawn Код:
UnwhitelistIPAddress(ipaddr[])
Used to unwhitelist an IP address. This is useless if the whitelisting system isn't enabled with ToggleRemoteWhitelist.
pawn Код:
ToggleRemoteRCON(bool: toggle)
Used to toggle if the RCON system is activated or not. If disabled, all remote RCON packets are dropped.
pawn Код:
ToggleRemoteWhitelist(bool: toggle)
Used to toggle if the whitelist system is activated or not. If disabled, IP related requests aren't filtered.
pawn Код:
IsIPWhitelisted(ipaddr[])
Used to check if an IP is whitelisted or not.
pawn Код:
ToggleLogging(bool: toggle)
Used for important logs. It is not recommended to disable this, however if used correctly there should be no reason you can't disable it.
Callbacks:
pawn Код:
forward OnRemoteRCONFail(ipaddr[], port, password[], command[], reason);
Called when a remote RCON request fails. There are currently only two reasons as seen below.
Reasons:
0 - Never called, ever(unless the callback is called outside of the include)
1 - Unwhitelisted IP address
2 - Unsuccessful login / request.
3 - RCON system is disabled.
pawn Код:
forward OnRemoteRCONExecuted(ipaddr[], port, password[], command[]);
Called when a remote RCON request is successful. If 0 is returned in this callback, the RCON packet is dropped. If 1 is returned(or anything other than 0 for that matter), the packet is executed and not dropped.
REQUIREMENTS
Ofcourse this needs YSF r11 or above by Kurta999. It should be noted that this has only been tested on a local windows machine within a 20 minute testing session. This has never been tested on any linux machines although it should be identical to a windows system.
DOWNLOAD
The include can be found on github:
https://github.com/Abagail/RemoteRCON/
An example can additionally be found in the git repository. I have also written a tutorial about how you can use this include here:
http://forum.sa-mp.com/showthread.ph...wpost&t=568062
Re: RemoteRCON - Managing external RCON packets! -
kurta999 - 20.03.2015
Nice
Re: RemoteRCON - Managing external RCON packets! -
Abagail - 20.03.2015
Quote:
Originally Posted by kurta999
Nice ![Cheesy](images/smilies/biggrin.png)
|
Thanks! I appreciate it
Re: RemoteRCON - Managing external RCON packets! -
MafiaOink - 20.03.2015
cool
Re: RemoteRCON - Managing external RCON packets! -
FunnyBear - 21.03.2015
Quote:
Originally Posted by ******
|
There's a missing closing curly bracket for OnFilterScriptInit
Re: RemoteRCON - Managing external RCON packets! -
Abagail - 21.03.2015
My apologizes, that was from a recent addition I guess that didn't save properly. It should be fixed now.
Re: RemoteRCON - Managing external RCON packets! -
Abagail - 24.08.2015
Updated & optimized it a small bit - most of the code is quite old.
Re: RemoteRCON - Managing external RCON packets! -
Variable™ - 24.08.2015
Very nice o.o
Re: RemoteRCON - Managing external RCON packets! -
IDarkness - 26.08.2015
Nice Luff!
Re: RemoteRCON - Managing external RCON packets! -
Lordzy - 29.08.2015
If your command system is in progress, you can simply comment out the "g_icommanddata" array defined in your enumerator. Also, using format function to copy strings is a bad practice! Use
strcpy instead.
Re: RemoteRCON - Managing external RCON packets! -
Abagail - 29.08.2015
Quote:
Originally Posted by Lordzy
If your command system is in progress, you can simply comment out the "g_icommanddata" array defined in your enumerator. Also, using format function to copy strings is a bad practice! Use strcpy instead.
|
Thanks for the feedback! This was done a while ago(around maybe a year or so) where I wasn't as aware of the best practice - I'd love any further insight you have.
I've updated it to use your strcpy function. It will be automatically included into the script if INCLUDE_STRCPY_FALSE is not defined. If it is however defined it will simply be placed in as a static stock so it doesn't input itself throughout the rest of the script outside of the include. I have also added three functions to detect the status of the primary functions:
- stock bool: RCON_IsWhitelistingEnabled()
- stock bool: RCON_IsRemoteRCONEnabled()
- stock bool: RCON_IsLoggingEnabled()
Re: RemoteRCON - Managing external RCON packets! -
Lordzy - 29.08.2015
Quote:
Originally Posted by Abagail
Thanks for the feedback! This was done a while ago(around maybe a year or so) where I wasn't as aware of the best practice - I'd love any further insight you have.
I've updated it to use your strcpy function. It will be automatically included into the script if INCLUDE_STRCPY_FALSE is not defined. If it is however defined it will simply be placed in as a static stock so it doesn't input itself throughout the rest of the script outside of the include. I have also added three functions to detect the status of the primary functions: - stock bool: RCON_IsWhitelistingEnabled()
- stock bool: RCON_IsRemoteRCONEnabled()
- stock bool: RCON_IsLoggingEnabled()
|
It's nice that you've updated using strcpy function, however you forgot to edit your "WhitelistIP" function. I've to also note that instead of declaring normal variables for the functions you mentioned above, it's better to use booleans since the only values they hold are 0 and 1. For further optimization I suggest you to use bit flagging method.
Re: RemoteRCON - Managing external RCON packets! -
Variable™ - 04.09.2015
Nice one