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

Kirollos

  • Newbie
  • Posts: 21
[REL] RCON[v1.0.1] - Control your plugin with any telnet client!
« on September 21st, 2015, 02:55 AM »Last edited on December 31st, 2015, 08:13 PM
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:
Code: [Select]
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:

Code: [Select]
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:
Code: [Select]
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

  • VC:MP Beta Tester
  • Posts: 40

Sachiko

  • Newbie
  • Posts: 4

Xmair

  • Wiki Contributor
  • Posts: 881
VU Full Member | VCCNR Developer | KTB Developer | EAD Ex-Scripter

KAKAN

  • Wiki Contributor
  • Posts: 3,346
You can contact me using Discord, at Developers.CPP( check off-board to find the invite link )
Github: https://github.com/theKAKAN

Zeeshan.Bhatti

  • Full Member
  • Posts: 213

Doom_Kill3R

  • VC:MP Beta Tester
  • Infinite loops defy infinity by overflowing memory
  • Posts: 1,107

.

  • VC:MP Beta Tester
  • .
  • Posts: 1,804
[WIP] Re: RCON - Control your plugin with any telnet client!
« Reply #7, on September 21st, 2015, 06:51 PM »
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

  • Newbie
  • Posts: 21
[WIP] Re: RCON - Control your plugin with any telnet client!
« Reply #8, on September 21st, 2015, 10:50 PM »Last edited on September 21st, 2015, 10:56 PM
Thanks all for your comments! I hope it is running smoothly for you.

Quote from S.L.C on September 21st, 2015, 06:51 PM
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.
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! :)
[WIP] Re: RCON - Control your plugin with any telnet client!
« Reply #9, on September 23rd, 2015, 02:46 PM »
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

  • Wiki Contributor
  • Posts: 3,346
[REL] Re: RCON - Control your plugin with any telnet client!
« Reply #10, on December 25th, 2015, 05:20 PM »Last edited on December 25th, 2015, 05:23 PM
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
[/list]

Text param:-
Well, I was trying to execute this command:-
Code: [Select]
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.
You can contact me using Discord, at Developers.CPP( check off-board to find the invite link )
Github: https://github.com/theKAKAN

Kirollos

  • Newbie
  • Posts: 21
[REL] Re: RCON[v1.0.1] - Control your plugin with any telnet client!
« Reply #11, on December 31st, 2015, 08:14 PM »
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

  • VC:MP Beta Tester
  • Posts: 620
[REL] Re: RCON[v1.0.1] - Control your plugin with any telnet client!
« Reply #12, on January 1st, 2016, 04:11 AM »
Quote from Kirollos on December 31st, 2015, 08:14 PM
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!
I think it's better to use it through WebSocket!

Kirollos

  • Newbie
  • Posts: 21
[REL] Re: RCON[v1.0.1] - Control your plugin with any telnet client!
« Reply #13, on January 12th, 2016, 08:33 PM »
Quote from ysc3839 on January 1st, 2016, 04:11 AM
Quote from Kirollos on December 31st, 2015, 08:14 PM
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!
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

  • Wiki Contributor
  • Posts: 3,346
You can contact me using Discord, at Developers.CPP( check off-board to find the invite link )
Github: https://github.com/theKAKAN