Git Product home page Git Product logo

tsclientlib's Introduction

TsClientlib Build status

TsClientlib is a library that enables you to write voip clients and bots using the TeamSpeak protocol.

TeamSpeak is a proprietary voice-over-Internet Protocol (VoIP) application for audio communication between users on a chat channel, much like a telephone conference call. Users typically use headphones with a microphone. The client software connects to a TeamSpeak server of the user's choice, from which the user may join chat channels. – Wikipedia

The various libraries in this repository are currently a work in progress so don‘t expect everything to work. Many things you would expect from a library are working, like connecting, getting events, writing and receiving messages, etc. Some features like automatic reconnects are not yet there.

If you are searching for a usable client instead of a library, Qint will be a cross-platform TeamSpeak client, which is based on this library (but it is not ready yet).

Dependencies

Getting Started

An example of a simple chat bot can be found here.

Clone

This repository embeds the declarations as submodule. You can clone with

git clone https://github.com/ReSpeak/tsclientlib.git --recurse-submodules

or download the submodule afterwards with

git clone https://github.com/ReSpeak/tsclientlib.git
cd tsclientlib
git submodule update --init --recursive

Build and run the example client

The code can be found here.

cd tsclientlib
cargo run --example simple

Build and run the example audio client

The code can be found here.

cd tsclientlib
cargo run --example audio

Projects

You probably want to use tsclientlib, it builds upon all other projects. This list shows what each library does and it may be useful if you want to help developing.

  • tsclientlib: This is the main product of this repository, a simple to use TeamSpeak library
  • tsproto: The low level library that does the network part. You probably don't want to use that, but a higher level library like tsclientlib.

Utils

The utils folder contains smaller building blocks for the library.

  • ts-bookkeeping: This crates keeps book of the currently connected clients and channels of a server.
  • tsproto-packets: Parse packets and commands.
  • tsproto-structs: Contains parsed versions of the tsdeclarations.
  • tsproto-types: Contains basic types for TeamSpeak, e.g. versions and error codes.

How this works

tsproto implements the basic TeamSpeak protocol stuff (uh, who would have expected that), which comes down to creating a connection, make sure that udp packets are delivered, encrypt and compress the communication and give access to all these low-level things.

The convenient client library on top is tsclientlib. It uses all the versions, messages, structures and errors which are written down in a machine readable format and provides a nice and safe api.

Performance

For benchmarks, a TeamSpeak server has to run at localhost. Run

cd tsproto
cargo bench -- <name>

where <name> is connect or message.

On a i7-5280K with 6 cores/12 threads @3.6 GHz, which uses more or less only one thread because we only test a single connection, we get:

  • 199 ms for creating one connection, which means 6.5 connections per second. This comes down to solving the RSA puzzle at the beginning of a connection, not much else plays a role. Be sure to run the benchmark with --features rug to get an efficient big integer implementation, otherwise it will fall back to a slower implementation.
  • 189 µs for sending a message, which means 5300 messages per second. The benchmark is not perfectly accurate as it does not wait for all packets to be sent.

Miscellaneous

This project is not an official TeamSpeak project. We started to write an own client for fun and because we want some features (and bugfixes) which are not available in the official client.

That said, we do not want to harm the company behind TeamSpeak because we like their product. Otherwise we would just use something else and not write our own client 😉. As TeamSpeak earns its money with selling servers and thus their existence depends on it, we will not publish any server related code and we encourage you to do the same (this may change with the new licensing system, introduced in the 3.1 server).

Thanks TeamSpeak for your software!

License

Licensed under either of

at your option.

tsclientlib's People

Contributors

0xpr03 avatar bluscream avatar flakebi avatar jokler avatar splamy avatar tyranron avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

tsclientlib's Issues

0.2 release

Hi, guys! 👋
It's almost a year since I'm succesfully using this library. Thank you so much for it, and for the all effort!

Would it be possible to release some intermediate 0.2 version? It's really a bit hard to catch up with you by raw commits.

Thanks!

Build fails on latest after removal of utils/ffigen

Hello, it's annoying me again!

Building the lib from scratch fails as tsclientlib-ffi is always built but it has a broken build dependency (utils/ffigen) which has been removed recently (40f5f3b).

For now i'm falling back to the previous commit :)

Normalization of channel streams to same out level

Hey all!

In regular Teamspeak client, there is an option to specify the volume per each client. It's helpful when speakers use different microphones.

I'm curious how it's possible to achieve some normalization to a specified level across all clients in the channel. I know that each client is a separate stream, and we pass relevant data to AudioHandler::handle_packet. But currently have no idea how to normalize this data. Do you have some ideas? Thanks!

Cannot properly add tsclientlib as a dependency

Hello!
In first place i'm sorry if i'm gonna say anything weird. I'm a rust super-noob, in fact this is the first time i'm approaching it.

I'm in need to use this library with the audio feature on in my project, so my cargo.toml looks like this

[dependencies.tsclientlib]
git = "https://github.com/ReSpeak/tsclientlib.git"
branch = "master"
features = ["audio"]

Now cargo is crying about tsclientlib having no feature called audio, however i can run cargo build --features audio just fine so i'm super confused.

error: failed to select a version for `tsclientlib`.
    ... required by package `myprj v0.1.0 (/home/jury/Documents/dev/myprj)`
versions that meet the requirements `= 0.1.0` are: 0.1.0

the package `myprj` depends on `tsclientlib`, with features: `audio` but `tsclientlib` does not have these features.

So what is the right way of including this project into my project?
Also if i'd manage to get it to work, what format/encoding does the audio client expects the data to be?

Many many thanks,
Jury :)

Are ClientIds static?

I want to identify clients over a long amount of time. Do you know if it is possible to use ClientIds for this or should I use Uids to be certain that I don't misidentify a client?

Change license from OSL to MIT/Apache

Hi,
I think it might be a good idea to license these crates under the MIT/Apache 2.0 licenses, as these are widely used throughout the Rust library ecosystem.
To do so, I need your agreement to use/relicense your contributions under MIT/Apache 2.0, as you contributed to this project under OSL.

Are you ok with this change?

Copyright & Teamspeak

Hello,
I'd like to use this lib as I'm currently sandboxing teamspeak in docker for a music-bot application I'm developing with some other people, which is really painful in terms of overhead and performance.
But I've to ask about the big elephant in the room: How lawyer proof is this reverse engineering of teamspeaks client API ? Specifically as the official SDK can't be used on teamspeaks on servers.

Listing available files in channels?

When calling
channel.file_list("","")
It returns OutFileListRequestedPart.

I'm wanting to list all available files to download inside of the respective channel and this doesn't seem to be the right function.

No audio feature in tsclientlib

Running the audio example returns that there's no feature. Not sure if I'm doing something wrong?

[matthew@laptop tsclientlib]$ cargo run --features audio --example audio
error: Package `tsclientlib v0.1.0 (/home/matthew/Projects/tsbot/tsclientlib/tsclientlib)` does not have these features: `audio`

Get the voice of a single person

Hi Guys,

I wanted to ask if this crate allows to process the voice of the persons in a channel.
So if the bot is in a channel with 3 persons, than he should get the voice of each person separately without mixing them.
Is that possible?

T

Document buffer size expected by AudioQueue/AudioHandler

I'm using cubeb for audio playback which doesn't seem to let me specify the exact amount of samples per callback. I don't really understand how the amount of samples requested from the AudioQueues would affect the audio which is played back so I assumed that setting the desired samples in the example was not relevant. After hours of testing I tried requesting 1920 samples from the AudioQueues and that fixed my issues.

I think it would be nice if the expected size could be documented so that the next person trying to do something similar doesn't have to struggle (unless this is a bug of course).
I would have expected something like that to be documented here:
https://docs.rs/tsclientlib/latest/tsclientlib/audio/struct.AudioHandler.html#method.fill_buffer
https://docs.rs/tsclientlib/latest/tsclientlib/audio/struct.AudioQueue.html#method.get_next_data

tsclientlib with WebAssembly on the web

Hey @Flakebi! I'm checking possibilities of creating a small subset of the TS client for the web. Seems using a tsclientlib and WebAssembly for that should be a good way to go. I'm curious, have you tried to compile it for the web? Do you see some limitations in achieving such scenario? Thanks

Release on crates.io

Are there any plans to release this to crates.io ?
Would make it more convenient to embed in cargo.toml

Problems with sending a message

Hi,
Firstly, I would like to mention that I am fairly new to Rust and using this library, so please bear with me if I have overlooked something obvious.

I tried using this library to send a message back to my client or the channel, like a simple help command. I anticipated this to be a straightforward process, but I'm having difficulty making it work.

Here's what my code looks like:

let state = con.get_state().unwrap_or_else(|e| {
   error!("Unable to get state: {}", e);
   exit(-1);
});

match state.send_message(MessageTarget::Channel, "test").send(&mut con) {
  Ok(_) => info!("Message sent"),
  Err(e) => error!("Message sending error: {}", e),
};

The connection appears to be functional, as I can successfully change the bot's username. Additionally, the "Message sent" line is printed, suggesting that no errors were returned.

I also tried cloning the SimpleBot repository to see if it works, but it doesn't respond to any commands I issue. As a result, I am unsure whether the issue lies with my Teamspeak Server or the library itself.

I would greatly appreciate any assistance in debugging this further.

Thanks!

Server Password authentication doesn't work

Environment

  • TS3 Server: 3.12.0 Linux
  • tsclientlib: cab105e

Steps to reproduce

  • Add password setting:
diff --git a/tsclientlib/examples/audio.rs b/tsclientlib/examples/audio.rs
index dc134ce..1f4385c 100644
--- a/tsclientlib/examples/audio.rs
+++ b/tsclientlib/examples/audio.rs
@@ -16,6 +16,9 @@ struct ConnectionId(u64);
 #[derive(StructOpt, Debug)]
 #[structopt(author, about)]
 struct Args {
+	/// The address of the server to connect to
+	#[structopt(short = "p", long, default_value = "")]
+	password: String,
 	/// The address of the server to connect to
 	#[structopt(short = "a", long, default_value = "localhost")]
 	address: String,
@@ -54,7 +57,8 @@ async fn real_main() -> Result<()> {
 	let con_config = Connection::build(args.address)
 		.log_commands(args.verbose >= 1)
 		.log_packets(args.verbose >= 2)
-		.log_udp_packets(args.verbose >= 3);
+		.log_udp_packets(args.verbose >= 3)
+                .password(args.password);

 	// Optionally set the key of this client, otherwise a new key is generated.
 	let id = Identity::new_from_str(
  • Run: cargo run --example audio -- -v -a <server> -p <password>

Expected result

Audio example runs.

Actual result

    dir: OUT
     Dec 29 15:23:16.069 DEBG Command, content: clientek ek=T1KOHxMK8XmEuKKpVxsgwzi2kZJjHJ0vEgjlLZlzsQw= proof=MEUCIDjfKrUREPPhXEdJtLNZKq++EBp\/hxgO8pE56Q9vXcbDAiEAt+UmvfcwaOZ8ycLlFRmoifDiUt11I+Des4f8Qdl9l0Q=
     Dec 29 15:23:16.088 DEBG Command, content: clientinit client_nickname=TeamSpeakUser client_version=3.?.?\s[Build:\s5680278000] client_platform=Windows client_input_hardware=1 client_output_hardware=1 client_default_channel client_default_channel_password client_server_password=<password> client_meta_data client_version_sign=DX5NIYLvfJEUjuIbCidnoeozxIDRRkpq3I9vVMBmE9L2qnekOoBzSenkzsg2lC9CMv8K5hkEzhr2TYUYSwUXCg== client_key_offset=354 client_nickname_phonetic client_default_token hwid=923f136fb1e22ae6ce95e60255529c00,d13231b1bc33edfecfb9169cc7a63bcc
    dir: IN
     Dec 29 15:23:16.108 DEBG Command, content: error id=1028 msg=invalid\sserver\spassword

Error: Server refused connection: ServerInvalidPassword

Remarks

I tested with multiple servers (another one at 3.12.1), and the password supplied is verified correct (TS3 Client connects).
I don't think it's a tsclientlib issue per se, as ts3j has the same problem, maybe the protocol has changed slightly?
Seeing as server password is a relatively recent addition to the lib, maybe I'm just using it wrong?
I haven't checked with TS3Hook yet how the password is presented in the regular client, might that be helpful?

How to subscribe to new channels?

I saw that tsclientlib::data::Server has a set_subscribed method but it seems overkill to call that every time a channel is created.

Is another such subscribe method missing from tsclientlib::data::Channel or did I just miss it?

Failed to deserialize license: invalid utf-8

Hello,

ive getting a the error Failed to deserialize license: invalid utf-8 when trying to connect to a specific ts host. the client refuses to do any further actions after this error.

Jun 11 20:48:17.534 INFO Connecting failed, trying next address, error: Failed to connect: Failed to parse license: Failed to deserialize license: invalid utf-8 sequence of 1 bytes from index 10

its an self hosted teamspeak server with a "gamer license" bought directly from teamspeak.com

Create Identity with exported TeamSpeak identity

Hi guys!

I'm curious where you get actually Identity Key. I've tried to get it from TeamSpeak by exporting through GUI and pass identity property from *.ini file.

I'm getting the error Any known methods to decode the key failed with this:

Identity::new_from_str("42VeP4pQAky4r+nmCrlGAUCReG3ZW5zE3lAcHEDfiUae3oBcHJ1ekRvUyR1DS9fKXtIBmF8U1VxSR9UWm0ie2l0Q1NoVnZVVn58LBdjUDYJTixnZgZFIHtCN0IHfHxWNVx1JkZzeEJPTnJLUUloQUxSVlFqNjlDeWRnS0Y5UE5rdVJqMXdLczU2OXdnUHpwZTUyeFhERHVBTDk=")

In your In the example key it is different though. But It's not cleaner is it possible to get this key from TS identity or not.

Thanks!

UPD

Actually, with your key, it doesn't work either. Maybe need to try the latest version

Cannot join TeaSpeak server

Using git url in Cargo.toml:
tsclientlib = { git = "https://github.com/ReSpeak/tsclientlib", default-features = false }
With simple example the bot connects (can be seen in the server) but immidieltly crashes and times out.

Log:

May 10 21:07:32.341 INFO TsClientlib, tsproto-version: 0.1.0+135 (5facf71ad 2020-04-25) dirty 1 modification, profile: Debug, version: 0.1.0+135 (5facf71ad 2020-04-25) dirty 1 modification
addr: 213.232.x.x:8600
 module: resolver
  May 10 21:07:32.381 DEBG Starting resolve, address: 213.232.x.x:8600
 May 10 21:07:32.383 DEBG Connecting, address: 213.232.x.x:8600
 local_addr: 0.0.0.0:62709
  remote_addr: 213.232.x.x:8600
   May 10 21:07:32.500 INFO Solve RSA puzzle, y: 8723936990881646971634718538142609102355251916986973944432589766401949068486423461886395290859036201612429790782526491046960631694579471096541769720493184, n: 11123400745562958910244492490827953852572440103989553562167402963531575601608560797501435186671157100790399862727380181776554078832306932328534646034810183, x: 2734392063954191350664097231331798576250127772103965844421157207037545396495144005205222611970307297540547386323150397440565322634966676290871737460374830, level: 1000
   name: Solve RSA puzzle
    May 10 21:07:32.508 INFO time report, : 0.066709387
   May 10 21:07:32.676 WARN Out of order command packet, expected: 11, got: 12
 May 10 21:07:32.770 INFO Connecting failed, trying next address, error: Parameter PermissionId not found in PermList
Error: Failed to connect to server, address Other("213.232.x.x:8600") did not work

Full backtrace: gist

Tested with:
TeaSpeak 1.4.12
TeaSpeak 1.3.25
TeamSpeak 3.12.1 (works fine)

Should I give you access to the server or provide more info? thanks.

Building failed, tokio2 missing 'tokio02::io::AsyncWriteExt' and 'tokio02::io::AsyncWriteExt'

Hi,
the build failed with the following error:

$ cargo build
   Compiling tsclientlib v0.1.0 (/home/jnk/projects/tsclientlib/tsclientlib)
error[E0432]: unresolved import "tokio02::net::TcpStream"
  --> tsclientlib/src/lib.rs:30:5
   |
30 | use tokio02::net::TcpStream;
   |     ^^^^^^^^^^^^^^^^^^^^^^^ no "TcpStream" in "net"

error[E0432]: unresolved import "tokio02::io::AsyncWriteExt"
  --> tsclientlib/src/lib.rs:31:5
   |
31 | use tokio02::io::AsyncWriteExt;
   |     ^^^^^^^^^^^^^-------------
   |     |            |
   |     |            help: a similar name exists in the module: "AsyncWrite"
   |     no "AsyncWriteExt" in "io"

error: aborting due to 2 previous errors

For more information about this error, try "rustc --explain E0432".
error: could not compile "tsclientlib".

To learn more, run the command again with --verbose. 

For me personally it was resolved by adding features = ["full"] to tokio2 declaration in tsclientlib/Cargo.toml

Is that the correct way to handle it, or am i overseeing something else? (Relatively new to Rust)

Edit 1: Formatting

Build errors

error[E0432]: unresolved import `tsproto::errors`
  --> tsproto-commands/src/codec.rs:10:14
   |
10 | use tsproto::errors::Error;
   |              ^^^^^^ Could not find `errors` in `tsproto`

warning: unreachable statement
  --> tsproto-commands/src/codec.rs:57:4
   |
57 |    let header = Header::new(PacketType::Command);
   |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: #[warn(unreachable_code)] on by default

error: aborting due to previous error

error: Could not compile `tsproto-commands`.

How to play a wav file?

I want to build a simple bot to play some sound in my ts server.
I noticed that there is a ts3client_playWaveFile api in ts SDK, but i didn't see the same api in tsclientlib.
So how to do that ?

Please update self_cell to v0.10

Hi, I'm the author of self_cell and I've recently released a new version and yanked all previous versions due to serious soundness bugs (see https://github.com/Voultapher/self_cell/releases/tag/v0.10.0 for details). These have been addressed and as far as I can tell your project was not directly affected. Regardless I've taken the precaution of yanking all previously affected versions and am now going through reverse dependents.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.