Vice City: Multiplayer

Server Development => Community Plugins => Topic started by: Kirollos on September 21st, 2015, 02:55 AM

Title: [REL] RCON[v1.0.1] - Control your plugin with any telnet client!
Post by: Kirollos on September 21st, 2015, 02:55 AM
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(https://github.com/Kirollos/VCMP_RCON)

Note: Pull requests are welcomed!

+ Downloads
Plugin binaries (compiled on both Windows and Linux) can be found here(https://github.com/Kirollos/VCMP_RCON/releases)

+ 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

+ 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(https://github.com/Kirollos/VCMP_RCON/tree/master/clients).

+ 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)


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!
Title: Re: [WIP] RCON - Control your plugin with any telnet client!
Post by: Castagna on September 21st, 2015, 03:01 AM
Good one Kiro :D
Title: Re: [WIP] RCON - Control your plugin with any telnet client!
Post by: Sachiko on September 21st, 2015, 03:27 AM
Yup. Good one, bruh. Can't wait for the progress it makes.
Title: Re: [WIP] RCON - Control your plugin with any telnet client!
Post by: Xmair on September 21st, 2015, 06:49 AM
Nice work :D
Title: Re: [WIP] RCON - Control your plugin with any telnet client!
Post by: KAKAN on September 21st, 2015, 09:12 AM
Nice work!
Title: Re: [WIP] RCON - Control your plugin with any telnet client!
Post by: Zeeshan.Bhatti on September 21st, 2015, 01:42 PM
Quote from Castagna on September 21st, 2015, 03:01 AM
Good one Kiro :D
Title: Re: [WIP] RCON - Control your plugin with any telnet client!
Post by: Doom_Kill3R on September 21st, 2015, 01:43 PM
Console ftw! but still the effort here cannot be neglected! ;)
Title: Re: [WIP] RCON - Control your plugin with any telnet client!
Post by: . 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(https://github.com/Kirollos/VCMP_RCON/blob/master/RCON/inc/SQModule.h#L193) structure pointer declared (https://github.com/Kirollos/VCMP_RCON/blob/master/RCON/src/main.h#L47) in `main.h` and then defined(https://github.com/Kirollos/VCMP_RCON/blob/master/RCON/src/main.cpp#L27) and initialized(https://github.com/Kirollos/VCMP_RCON/blob/master/RCON/src/main.cpp#L134) 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.
Title: Re: [WIP] RCON - Control your plugin with any telnet client!
Post by: Kirollos on September 21st, 2015, 10:50 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(https://github.com/Kirollos/VCMP_RCON/blob/master/RCON/inc/SQModule.h#L193) structure pointer declared (https://github.com/Kirollos/VCMP_RCON/blob/master/RCON/src/main.h#L47) in `main.h` and then defined(https://github.com/Kirollos/VCMP_RCON/blob/master/RCON/src/main.cpp#L27) and initialized(https://github.com/Kirollos/VCMP_RCON/blob/master/RCON/src/main.cpp#L134) 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!(https://github.com/Kirollos/VCMP_RCON/commit/e93c9eed0762fb112c4362a5f76c700878ec019b) :)
Title: Re: [WIP] RCON - Control your plugin with any telnet client!
Post by: Kirollos 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(https://github.com/Kirollos/VCMP_RCON/tree/master/clients/node.js).
Title: Re: [REL] RCON - Control your plugin with any telnet client!
Post by: KAKAN on December 25th, 2015, 05:20 PM
Here's a list of bugs which I had told you in IRC, just in-case to remind you :P

[/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.
Title: Re: [REL] RCON[v1.0.1] - Control your plugin with any telnet client!
Post by: Kirollos on December 31st, 2015, 08:14 PM
RCON v1.0.1.0 is released!

You can find the new version here(https://github.com/Kirollos/VCMP_RCON/releases/tag/1.0.1.0).
Changelog:


Thank you all for your support!
Title: Re: [REL] RCON[v1.0.1] - Control your plugin with any telnet client!
Post by: 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(https://github.com/Kirollos/VCMP_RCON/releases/tag/1.0.1.0).
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!
Title: Re: [REL] RCON[v1.0.1] - Control your plugin with any telnet client!
Post by: Kirollos 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(https://github.com/Kirollos/VCMP_RCON/releases/tag/1.0.1.0).
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 :).
Title: Re: [REL] RCON[v1.0.1] - Control your plugin with any telnet client!
Post by: KAKAN on May 3rd, 2016, 02:18 PM
*BUMP*
Update the SDK. I need this plugin beri much
:edit: Just checked the source, you didn't tell us about RCON_KickClient :D
Title: Re: [REL] RCON[v1.0.1] - Control your plugin with any telnet client!
Post by: Thijn on May 3rd, 2016, 06:08 PM
https://github.com/Thijn/VCMP_RCON/commit/80175e772c50b700c7fb52b42023e0c6a35a4548

Currently compiling. Will edit this when done.

:edit: Builds up at http://thijn.ovh/vcmp/builds/
Make sure you install the 2015 c++ redistributable(https://www.microsoft.com/en-us/download/details.aspx?id=48145) if you're using it on windows.
Title: Re: [REL] RCON[v1.0.1] - Control your plugin with any telnet client!
Post by: Kirollos on May 4th, 2016, 08:25 PM
Quote from Thijn on May 3rd, 2016, 06:08 PM
https://github.com/Thijn/VCMP_RCON/commit/80175e772c50b700c7fb52b42023e0c6a35a4548

Currently compiling. Will edit this when done.

:edit: Builds up at http://thijn.ovh/vcmp/builds/
Make sure you install the 2015 c++ redistributable(https://www.microsoft.com/en-us/download/details.aspx?id=48145) if you're using it on windows.
Thank you! Appreciated :)
Quote from KAKAN on May 3rd, 2016, 02:18 PM
*BUMP*
Update the SDK. I need this plugin beri much
:edit: Just checked the source, you didn't tell us about RCON_KickClient :D
I added RCON_KickClient to github repo but I've never released binaries of that version, been busy with school and exams :(.
Title: Re: [REL] RCON[v1.0.1] - Control your plugin with any telnet client!
Post by: KAKAN on May 17th, 2016, 04:13 AM
Just ran the server, when I connected a telnet client and typed something, the server crashed :(
Title: Re: [REL] RCON[v1.0.1] - Control your plugin with any telnet client!
Post by: Kirollos on August 8th, 2016, 12:29 AM
Quote from KAKAN on May 17th, 2016, 04:13 AM
Just ran the server, when I connected a telnet client and typed something, the server crashed :(
I'm sorry, I'm not able to replicate that issue. Can you please help?