[Include] RemoteRCON - Managing external RCON packets!
#1

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
Reply
#2

Nice
Reply
#3

Quote:
Originally Posted by kurta999
Посмотреть сообщение
Nice
Thanks! I appreciate it
Reply
#4

cool
Reply
#5

Quote:
Originally Posted by ******
Посмотреть сообщение
I had a quick look at your code:

https://github.com/Abagail/RemoteRCO...on.inc#L22-L39

I'm not sure what's going on there - that won't compile...
There's a missing closing curly bracket for OnFilterScriptInit
Reply
#6

My apologizes, that was from a recent addition I guess that didn't save properly. It should be fixed now.
Reply
#7

Updated & optimized it a small bit - most of the code is quite old.
Reply
#8

Very nice o.o
Reply
#9

Nice Luff!
Reply
#10

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.
Reply
#11

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()
Reply
#12

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.
Reply
#13

Nice one
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)