[REL] RCON[v1.0.1] - Control your plugin with any telnet client!

Started by Kirollos, Sep 21, 2015, 01:55 AM

Previous topic - Next topic

Kirollos

RCON v1.0.1
Control your server with any telnet client!
RCON v1.0.1 is released!

+ Introduction
Hi there, I'm new to this community, and so far I've been enjoying the new version (0.4), so I decided to try and write a plugin. I started thinking about important things that would come in handy for a server administrator, when I was told that VC-MP no longer has RCON functionality. So I started working on this plugin. I'm not too experienced in C/++ and the development/improvement of the plugin is in progress, as there may be some issues which I will work to fix if they are found.

+ About Plugin
I started working on this plugin around 10 days ago, I have been too excited to get this plugin working asap. So far, it's been mostly stable! Even though I didn't test the plugin as much as it deserves, but I hope it runs well. Please report bugs whenever you discover them!
This plugin creates a TCP socket and binds on a configured port, then it accepts client connections, which will need to identify to the server with a password to be able to control the server. Everything will be documented below.

+ Source Code
The source code can be found here

Note: Pull requests are welcomed!

+ Downloads
Plugin binaries (compiled on both Windows and Linux) can be found here

+ Configuration
On the first installation, you need to run the server with the plugin, then you can shut down the server.
This plugin's configuration entries can be found in server.cfg as the following:
rcon_enabled false
rcon_port 1337
rcon_bindip 0.0.0.0
rcon_password plschange
  • rcon_enabled [true/false]
  • rcon_port [integer]
  • rcon_bindip [IPv4] - Binds the RCON socket to a specific IP address. Set it to "0.0.0.0" to bind it on all IP addresses
  • rcon_password [string] - The RCON password

+ How-to compile
  - Windows: Just load the visual studio solution file and compile. All should work with no problems.
  - Linux: running "make" in the main directory shall do everything needed.
Note that you need to run "make release32" for x86 server and "make release64" for x64 server!

+ How-to use
This plugin can be accessed with almost any telnet client. PuTTY can work in Raw/Telnet mode as well.

Some clients that are written by me can be found here.

+ Built-in commands
All the commands can be found type sending "help".

+ Squirrel related stuff
This plugin gives you more ability to control it through your scripts, adding your own commands, etc.

This plugin sends a callback to squirrel if the input command is not defined in the main plugin commands, which is:

function RCON_OnCommand(clientid, ip, command, params)
  • integer clientid - The ID of the client that requested the command (Note: clientid is not usually unique!)
  • string ip - The client's IPv4 address
  • string command - The requested command
  • string params - The requested parameters

The plugin also provides the following functions:
RCON_Send(int clientid, string text);
RCON_Broadcast(string text);
RCON_GetClients();
/*
This function returns an array which looks like this:
[
// [string IP, bool IDENTIFIED]
["127.0.0.1", true], // first client
["192.168.1.2", false], // second client
... // etc..
]
*/

+ Thanks to
- VC-MP team for their SDK header.
- Whoever has written the plugin SDK introduction page on the wiki.
- Castagna - Motivated me to start working on my plugin.
- SLC - Introduced me to SQImports and stuff..
- Sachiko - Helped w/ testing the plugin and catching some bugs.
- Many others helped me w/ the testing.

* This topic will be updated regularly and will be more organised!

Castagna


Sachiko

Yup. Good one, bruh. Can't wait for the progress it makes.

Xmair


Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

KAKAN

oh no


DizzasTeR

Console ftw! but still the effort here cannot be neglected! ;)

.

Mmm... A small suggestion. Remove the Squirrel library as it's not needed. All the squirrel function pointers are shared by the main Squirrel module through the HSQAPI structure pointer declared in `main.h` and then defined and initialized in `main.cpp` Therefore, instead of having to include Squirrel source in your project. Whenever you see any Squirrel API functions that start with something like `sq_(name)`, you should replace that with `sqapi->(name)` Thus, `sq_pushroottable(...)` will become `sqapi->pushroottable(...)`. Doing that will not need the Squirrel source to be included in the project. Just make sure you include `main.h` whenever you want to use the Squirrel API. And keep only `squirrel.h` and `sqconfig.h` from the squirrel source.

This could have recursions when the squirrel version that you're using doesn't match with the Squirrel version of the plugin.
.

Kirollos

Thanks all for your comments! I hope it is running smoothly for you.


Quote from: S.L.C on Sep 21, 2015, 05:51 PMMmm... A small suggestion. Remove the Squirrel library as it's not needed. All the squirrel function pointers are shared by the main Squirrel module through the HSQAPI structure pointer declared in `main.h` and then defined and initialized in `main.cpp` Therefore, instead of having to include Squirrel source in your project. Whenever you see any Squirrel API functions that start with something like `sq_(name)`, you should replace that with `sqapi->(name)` Thus, `sq_pushroottable(...)` will become `sqapi->pushroottable(...)`. Doing that will not need the Squirrel source to be included in the project. Just make sure you include `main.h` whenever you want to use the Squirrel API. And keep only `squirrel.h` and `sqconfig.h` from the squirrel source.

This could have recursions when the squirrel version that you're using doesn't match with the Squirrel version of the plugin.

I don't know why I haven't taken that into consideration. In fact, I used that method in a part of my code, but didn't think it would actually work without linking to squirrel library. Thanks! :)

Kirollos

I've written a node.js client for this plugin :D. It creates a minimal webserver on a specific port (with optional SSL) and launches a terminal-like webpage where you can control your server with it. This client can be found here.

KAKAN

Here's a list of bugs which I had told you in IRC, just in-case to remind you :P
  • When I press enter in Putty without any text in it, the server crashes.
  • You should disable the callbacks for everything, the reason is: One day, someone registered in my server, and I was able to see his pass because it showed the command in the RCON client along with the text in it, and I like my custom text for any callback too.
  • The ID is not getting back to 0. for ex:- I joined the RCON with my PC, which ID was 0, I quitted from it, then joined from my laptop, it's ID was 1 instead of 0
  • The text param in your function callback will call the command instead of the text in it. For ex see the last

Text param:-
Well, I was trying to execute this command:-
function RCON_OnCommand(id, ip,cmd, text){
    if ( cmd == "exec" )
    {
        if( !text ) RCON_Send(id,">> Error - Syntax: exec <Squirrel code>");
        else
        {
            try
            {
                local script = compilestring( text );
                script();
        RCON_Send(id,">> Succesfully excecuted.");
            }
            catch(e) RCON_Send(id,">> Error: " + e);
        }
    }
}
Now when I type 'exec' without quotes in my RCON client( putty, raw mode ) then it shows:- "Successfully executed" instead of showing the syntax error.
I need to use GetTok( text, " ", 1 ) instead of text to make it work.
oh no

Kirollos

RCON v1.0.1.0 is released!

You can find the new version here.
Changelog:

  • Fixed a crash when you only send \r\n to server
  • Added the ability to toggle builtin server events
  • Clients were not removed from client-vector on disconnection
  • Pushing null instead of an empty string if no parameter was sent
  • Plugin version shows @ console on server startup

Thank you all for your support!

ysc3839

Quote from: Kirollos on Dec 31, 2015, 08:14 PMRCON v1.0.1.0 is released!

You can find the new version here.
Changelog:

  • Fixed a crash when you only send \r\n to server
  • Added the ability to toggle builtin server events
  • Clients were not removed from client-vector on disconnection
  • Pushing null instead of an empty string if no parameter was sent
  • Plugin version shows @ console on server startup

Thank you all for your support!
I think it's better to use it through WebSocket!

Kirollos

Quote from: ysc3839 on Jan 01, 2016, 04:11 AM
Quote from: Kirollos on Dec 31, 2015, 08:14 PMRCON v1.0.1.0 is released!

You can find the new version here.
Changelog:

  • Fixed a crash when you only send \r\n to server
  • Added the ability to toggle builtin server events
  • Clients were not removed from client-vector on disconnection
  • Pushing null instead of an empty string if no parameter was sent
  • Plugin version shows @ console on server startup

Thank you all for your support!
I think it's better to use it through WebSocket!

At first I was thinking about just using any known socketing library and save myself from headache, but I've found myself writing my own one a better idea in terms of practising since I'm practising C/++ by writing projects. I appreciate your suggestion though :).

KAKAN

*BUMP*
Update the SDK. I need this plugin beri much
:edit: Just checked the source, you didn't tell us about RCON_KickClient :D
oh no