Script Multi Instance on single IP

Mr-Malone

You risk and you will win
Joined
Sep 11, 2015
Messages
69
Reaction score
25
Points
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
Joined
Jul 18, 2015
Messages
635
Reaction score
588
Points
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
Joined
Jul 18, 2015
Messages
635
Reaction score
588
Points
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
Joined
May 8, 2015
Messages
967
Reaction score
934
Points
211
Isnt that exactly what you ask for?


EzX7pkA.png
 

Mr-Malone

You risk and you will win
Joined
Sep 11, 2015
Messages
69
Reaction score
25
Points
108
Thanks very much man, i luv u
 

Bluscream

Retired Staff
Contributor
Joined
May 8, 2015
Messages
967
Reaction score
934
Points
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
Joined
Jul 18, 2015
Messages
635
Reaction score
588
Points
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
Joined
Sep 23, 2015
Messages
26
Reaction score
5
Points
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
Joined
Jul 18, 2015
Messages
635
Reaction score
588
Points
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
Joined
Sep 23, 2015
Messages
26
Reaction score
5
Points
35
Can you help me with this? I'm not so experienced with PHP and that stuff.
 

KappaJoe

New Member
Joined
Jul 6, 2017
Messages
6
Reaction score
1
Points
18
Can you help me with this? I'm not so experienced with PHP and that stuff.

Just use the permissions system and limit multiple connections, it seems like it'd nail your goal in a heartbeat.
 

Etex

Member
Joined
Sep 23, 2015
Messages
26
Reaction score
5
Points
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
Joined
May 8, 2015
Messages
967
Reaction score
934
Points
211
I showed how to block this with yatqa
 

Bluscream

Retired Staff
Contributor
Joined
May 8, 2015
Messages
967
Reaction score
934
Points
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