Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clientlist filter not working for me #12

Closed
ghost opened this issue Jun 21, 2018 · 9 comments
Closed

clientlist filter not working for me #12

ghost opened this issue Jun 21, 2018 · 9 comments

Comments

@ghost
Copy link

ghost commented Jun 21, 2018

Hi guys, i tryed use

function parseList(data) {
    return data.raw()
      .split('|')
      .map(TeamspeakQuery.parse)
      .map(entry => entry.params);
  }

query.send('clientlist', { 'client_type': 0, 'connection_client_ip': ip })
.then((result) => {
var data = parseList(result)
conole.log(data)
})

where ip is some ip
and it's return me list of all users, instead of 1 user with that ip
Also i noticed it's returns users with client_type 1.
So for some reason for me filter not working.
Or i make something wrong?
Pls can some help me?

@schroffl
Copy link
Owner

schroffl commented Jun 22, 2018

Looking at the documentation of clientlist I can't see anything about the options you specify. Neither client_type nor connection_client_ip are mentioned as arguments.

What you could try is to filter out your desired client after getting the list. However, you can't get the ip of the client this way so you will have to obtain it via other commands. This has the disadvantage that you need to send a single command for each client, which could lead to throttling problems if you don't have unrestricted access and many connected clients.
Edit: It is possible, but not documented in the manual.

Here is a small example that uses the Array.prototype.find method and will return the first client with client_type 1. Alas, I could not get the ip-filtering working right now, but I will retry later today.

query.send('clientlist')
  .then(parseList)
  .then(list => list.find(client => client.client_type == 1))
  .then(console.log);

When running it:

$ node abc.js
{ clid: '6',
  cid: '1',
  client_database_id: '1',
  client_nickname: 'serveradmin',
  client_type: '1',
  raw: [Function] }

@ghost
Copy link
Author

ghost commented Jun 22, 2018

I just have an php example on ts3-framework, where ip filtering is working, will be nice if we will have this in teamspeak-query (sorry for english)

@schroffl
Copy link
Owner

Hey, can you send me a link to that example? No worries about your english, at least for me it is totally understandable :)

@ghost
Copy link
Author

ghost commented Jun 22, 2018

https://gitlab.com/NOFEAR/TS3-Client-Verifired/blob/master/index.php#L53
Russian in text, but i think you can understand code.
It's working :O

@schroffl
Copy link
Owner

I need to sign in to view the repo, is it private? If yes, you could post only the relevant code without revealing too much (I suppose it's private for a reason :p).

@ghost
Copy link
Author

ghost commented Jun 22, 2018

@schroffl
Copy link
Owner

schroffl commented Jun 22, 2018

Oh I know why, the -ip option actually lists the connection_client_ip of all connected clients, but this doesn't work for ServerQuery clients, which is why I couldn't see it.
Edit: This actually was a bug. The server sends a connection_client_ip for ServerQuery clients, but without a value. So instead of …client_type=0 connection_client_ip=x.x.x.x… it responds with …client_type=1 connection_client_ip…. However, this doesn't change the fact that you cannot get the ip of such clients, you just can see that their connection_client_ip is undefined. Fixed in Version 2.1.1

So this should work (out of my head, I'm in a hurry):

query.send('clientlist', '-ip')
  .then(parseList)
  .then(list => list.find(client => client.client_type == 0 && client.connection_client_ip == ip))
  .then(console.log);

@ghost
Copy link
Author

ghost commented Jun 22, 2018

it's working :O
Thx man!

@schroffl
Copy link
Owner

Nice, I'm glad I could help :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant