[PHP] Rcon class

Hi folks

I’ve tried a couple of libraries but it seems that the rust rcon protocol and the source ds rcon protocol still use different implementations. This annoyed me so I went to write the rcon class myself up to the point where it worked.

Example use:
http://pastebin.com/TY1H3mTh

This class is quickly hacked together. I expect this to break with every other Rust update or even fail to handle certain commands.

I use this class to send announcements to my vanilla server, to call airdrops every n minutes with a minimum amount of players and to announce when admins joined the server.

NOTE that this script should not be used for user interaction (it’s slow and it sucks, but it does the job).
Edit: It’s a lot faster now, pretty sure this can be used for user interaction.

To see a live use of this script, join rust.bloodisgood.org:28200

Download:
http://pastebin.com/vQqmx6bR (v 1.1)

License:
Creative Commons BY-NC-SA 4.0

Talkback
http://forum.rustoxide.com/threads/php-rcon-class.2811/

php sockets = sux.

  1. Ur script was laggy if online >70 players due buffer bug (u dont fix this)
  2. Backend software on Go/C/C#/C++ etc more better then php.

Some statistics: PHP RCON load page with 100 online ~6-12 seconds.
My backend on go - 0.2 sec.

P.S. U regex sux :smiley:

my page: http://rust.ttyh.ru/rcon/online
my parsing script: http://pastebin.com/VUfL2cQx

also i use dynamic VAC status check for profile, but this is another story :slight_smile:
also this is txt with chat for site :slight_smile: http://rust.ttyh.ru/rcon/chat (use codepage utf8 for see it)

Haha ooh you funny troll. PHP sucks in general. There’s no need to say that php sockets suck.

Obviously, as this script is only hacked together, neither performance nor bugs are relevant. This script works perfectly fine if you want to automate rcon commands from cron or through other services (where no front-end is involved). That’s why there’s absolutely no proper buffering or handling of the stream.
Deal with it.

Also, if there is any open source php script that works better than this one please go ahead and link it. I couldn’t find any. Most choose to make one but never release the code.

edit: maybe I should write that this class is not for anything a user comes in contact with…

Amazon give free servers u can use it for cron or backend with low load… :slight_smile:

[editline]10th April 2014[/editline]

http://yadi.sk/d/1Iw3jxzdMC6Wj my admin centre :smiley:

care to share the source so others can use it too? Because that is exactly the issue I’m having. It seems everybody has written their own rust management tool that is SOOO GOOD AND FAST but is too self-absorbed to care and share their work with those who need it.

thanks for sharing

You can ping me at monday in steam - fresh code on “work” machine :slight_smile:

[editline]11th April 2014[/editline]

also u can use this https://github.com/james4k/rcon
but u need bugfix for buffer size.

I appreciate your offer but I’d find it much easier if I could jut clone some git repo and use it from there. Is there any reason why you don’t put this up on git?

Coz i’am lazy :smiley: anyway sources in office and i cant give u it now.

I’m currently modifying this version to make a more performant one. Still not planning to fix the double buffer bug as that is not really a problem with packet ids.
The changes will be:

  • Don’t Read when Sending, the reading and packet assignment has to be done manually (speed up sending commands)
  • Don’t Read when Authing, authentication errors will be thrown with the first couple of Reads (speed up connecting)
  • Responses (Reading) come in a class RustRconResponse now to keep response body and id

I will also put up a lite version of the server extension I wrote for the rcon class. It will have cron and commands just to demonstrate the capabilities of this class.

Currently, this class in in use on my server to make it a modded vanilla server. There are static and dynamic announcements, join and quit messages (and first welcome), automated airdrops and commands (help, kit, admin, …). This works very well and, with the new version of the class, runs fairly fast and does not drop player commands.

The class and server extension is rewritten but untested, I will put these changes up once they are tested (and fixed) in around 4-6 hours.

New version up. It’s much faster now.

Is this still working?

Sure, I use it on my server and run a lot of traffic through this class.

I made this now in C#, only better and more stable. It also seems to get rid of the split package bug completely, which is great for servers with more than 42 players or big ban lists.

http://forum.facepunch.com/showthread.php?t=1398702