Script Multi Instance on single IP

Mr-Malone

You risk and you will win
Sep 11, 2015
69
25
108
Hello. I'm looking for a script to ban users who connect to the TeamSpeak server multiple times from a single IP. (those who connect with multiple identities on the server)
 

Norvik

Retired Staff
Contributor
Jul 18, 2015
635
588
157
Just get a list of all clients, loop through them and put their IP into an array. Check if the array already contains that IP address before adding it and ban him if it does.
 

Norvik

Retired Staff
Contributor
Jul 18, 2015
635
588
157
I just made a little example for you. Replace line 17 with the code below depending on what you want you want.

Kick all clients with the same IP: $suspect->kick(TeamSpeak3::KICK_SERVER, 'Violation of the multiple connection rule!');
Ban all clients with the same IP: $suspect->ban(0 ,'Violation of the multiple connection rule!');

PHP:
<?php
    require_once("libraries/TeamSpeak3/TeamSpeak3.php");
    $tsHandle = TeamSpeak3::factory("serverquery://serveradmin:[email protected]:10011/?server_port=9987");

    $whitelist = array('127.0.0.3', '127.0.0.2');
    $clientIPs = array();

    foreach($tsHandle->clientList(array("client_type" => 0)) as $client)
    {
        if(in_array($client->connection_client_ip, $clientIPs))
        {
            if(!in_array($client->connection_client_ip, $whitelist))
            {
                foreach($tsHandle->clientList(array("connection_client_ip" => $client->connection_client_ip)) as $suspect)
                {
                    try {
                        // Replace this line with the code above
                    } catch(TeamSpeak3_Exception $e) {
                        echo "Error ".$e->getCode().": ".$e->getMessage();
                    }
                }
            }
        } else {
            array_push($clientIPs, $client->connection_client_ip);
        }
    }
 

Bluscream

Retired Staff
Contributor
May 8, 2015
967
934
211
Isnt that exactly what you ask for?


EzX7pkA.png
 

Bluscream

Retired Staff
Contributor
May 8, 2015
967
934
211
He didn't mean server instances, he meant multiple instances in a way to mention multiple identities/clients with the same IP address.
serverinstance_pending_connections_per_ip is not about servers, it's about clients. The only difference is that it checks over the whole instance so you can't be on two servers of the same time if that's set to 1
 

Norvik

Retired Staff
Contributor
Jul 18, 2015
635
588
157
@AnonymousSV asked me for a version of the script that allows you to accept a specific amount of duplicate IPs.

PHP:
<?php
    require_once("libraries/TeamSpeak3/TeamSpeak3.php");
    $tsHandle = TeamSpeak3::factory("serverquery://serveradmin:[email protected]:10011/?server_port=9987");
    
    $whitelist = array('127.0.0.3', '127.0.0.2');
    $maxConnections = 2;
    $clientIPs = array();

    foreach($tsHandle->clientList(array("client_type" => 0)) as $client)
    {
        if(in_array(strval($client->connection_client_ip), $clientIPs) && array_count_values($clientIPs)[strval($client->connection_client_ip)] >= $maxConnections)
        {
            if(!in_array($client->connection_client_ip, $whitelist))
            {
                foreach($tsHandle->clientList(array("connection_client_ip" => $client->connection_client_ip)) as $suspect)
                {
                    try {
                        // Replace this line with the code above
                    } catch(TeamSpeak3_Exception $e) {
                        echo "Error ".$e->getCode().": ".$e->getMessage();
                    }
                }
            }
        } else {
            array_push($clientIPs, strval($client->connection_client_ip));
        }
    }
 

Etex

Member
Sep 23, 2015
26
5
35
I just made a little example for you. Replace line 17 with the code below depending on what you want you want.

Kick all clients with the same IP: $suspect->kick(TeamSpeak3::KICK_SERVER, 'Violation of the multiple connection rule!');
Ban all clients with the same IP: $suspect->ban(0 ,'Violation of the multiple connection rule!');

PHP:
<?php
    require_once("libraries/TeamSpeak3/TeamSpeak3.php");
    $tsHandle = TeamSpeak3::factory("serverquery://serveradmin:[email protected]:10011/?server_port=9987");

    $whitelist = array('127.0.0.3', '127.0.0.2');
    $clientIPs = array();

    foreach($tsHandle->clientList(array("client_type" => 0)) as $client)
    {
        if(in_array($client->connection_client_ip, $clientIPs))
        {
            if(!in_array($client->connection_client_ip, $whitelist))
            {
                foreach($tsHandle->clientList(array("connection_client_ip" => $client->connection_client_ip)) as $suspect)
                {
                    try {
                        // Replace this line with the code above
                    } catch(TeamSpeak3_Exception $e) {
                        echo "Error ".$e->getCode().": ".$e->getMessage();
                    }
                }
            }
        } else {
            array_push($clientIPs, $client->connection_client_ip);
        }
    }


How can I make this always active? So I don't have to exec this script everytime I see someone connecting multiple times? I would like this to be active 24/7 and "taking care" of server
 

Norvik

Retired Staff
Contributor
Jul 18, 2015
635
588
157
How can I make this always active? So I don't have to exec this script everytime I see someone connecting multiple times? I would like this to be active 24/7 and "taking care" of server
Just use an infinite loop or use an event listener that get's triggered when somebody joins your server.
 

Etex

Member
Sep 23, 2015
26
5
35
I can't block this anyway with any permission or server config, the problem that bothers me is "TS Godzilla".
 

Bluscream

Retired Staff
Contributor
May 8, 2015
967
934
211
You can't or couldn't?

In case you can't find it, here's a step by step tutorial:

G808o5O.png
 
Last edited:
Top