felixms / arma-rcon-class-php

A lightweight client for sending commands easily to a BattlEye server.
MIT License
46 stars 22 forks source link

RCON Login Spam #23

Closed WASasquatch closed 7 years ago

WASasquatch commented 7 years ago

When I run a simple script to connect, and get users and bans, In my RTP the RCON script will login multiple times. Usually between 3-6 but sometimes more. I used to have a heartbeat script which checked the online status once every 2 minutes, and that would cause excessive RCON login spam. I have followed the construct of your class, and am disconnecting from the server, and PHP Access logs only say the server is running the script once, yet I get numerous logins from my servers RCON class.

13:39:30 BattlEye Server: RCon admin #0 (*:58854) logged in
13:39:31 BattlEye Server: RCon admin #1 (*:52640) logged in
13:39:31 BattlEye Server: RCon admin #2 (*:40464) logged in
13:39:32 BattlEye Server: RCon admin #3 (*:58214) logged in
13:39:32 BattlEye Server: RCon admin #4 (*:41285) logged in
13:39:33 BattlEye Server: RCon admin #0 (*:41024) logged in
13:39:33 BattlEye Server: RCon admin #1 (*:51242) logged in

the connection script

<?php

    require_once('arc.php');

    use \Nizarii\ARC;

    try {
        $rcon = new ARC('*', '*', 2309);
    } catch(Exception $e) {
        print 'Waiting for server...' . "\n";
        exit;
    }

The Stats script

<?php

    require_once('rconnect.php');

    try {
        $online = $rcon->getPlayersArray();
        $bans = $rcon->getBans();
        $rcon->disconnect();
        echo '<span style="color:#3e97b2;">' . count($online) . '</span> User(s) Online | <span style="color:#3e97b2;">' . (count($bans)-1) . '</span> User(s) Banned';
    } catch (Exception $e) {
        echo 'Waiting for Server...';
    }
felixms commented 7 years ago

I am currently not at home, I am going to take a look at it tomorrow.

felixms commented 7 years ago

The login spam is caused by a reconnect which is done after getting players or bans from the server. This reconnect is a workaround for various bugs, so I won't remove it. Basically every time you get the players from the server, a new admin will login. However I stumbled across a little mistake I made some months ago while I was fixing a bug. After receiving the players, the reconnect method got called twice. So I removed this line in the latest version. This might reduce the login spam a bit, but it does not completely stop it.

WASasquatch commented 7 years ago

Thanks, the explanation and looking into the code, it makes sense.