From 7b6959c4ccfe7d91519bb75466edf5c19679f7fe Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 25 Sep 2026 12:46:11 +0000 Subject: [PATCH] vendor: import ReSpeak/tsclientlib@ee3bc6f Unmodified copy of the tsclientlib workspace crates (MIT OR Apache-2.0) with the tsdeclarations submodule (83cb8a9) flattened into plain files. See crates/proto/UPSTREAM.md for the path mapping. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G --- crates/proto/.rustfmt.toml | 15 + crates/proto/CHANGELOG.md | 61 + crates/proto/LICENSE-APACHE | 201 ++ crates/proto/LICENSE-MIT | 21 + crates/proto/README.upstream.md | 115 + crates/proto/UPSTREAM.md | 33 + crates/proto/clippy.toml | 1 + crates/proto/ts-bookkeeping/Cargo.toml | 44 + crates/proto/ts-bookkeeping/README.md | 21 + crates/proto/ts-bookkeeping/README.tpl | 10 + .../proto/ts-bookkeeping/benches/command.rs | 44 + .../ts-bookkeeping/build/BookDeclarations.tt | 14 + .../ts-bookkeeping/build/BookToMessages.tt | 232 ++ crates/proto/ts-bookkeeping/build/Events.tt | 88 + .../build/MessageDeclarations.tt | 340 +++ .../ts-bookkeeping/build/MessagesToBook.tt | 439 ++++ .../proto/ts-bookkeeping/build/Properties.tt | 55 + .../proto/ts-bookkeeping/build/book_parser.rs | 13 + .../build/book_to_messages_parser.rs | 71 + crates/proto/ts-bookkeeping/build/build.rs | 52 + crates/proto/ts-bookkeeping/build/events.rs | 20 + .../ts-bookkeeping/build/message_parser.rs | 299 +++ .../build/messages_to_book_parser.rs | 28 + .../proto/ts-bookkeeping/build/properties.rs | 43 + crates/proto/ts-bookkeeping/src/data.rs | 1051 +++++++++ crates/proto/ts-bookkeeping/src/events.rs | 79 + crates/proto/ts-bookkeeping/src/lib.rs | 246 ++ crates/proto/ts-bookkeeping/src/messages.rs | 80 + crates/proto/tsclientlib/Cargo.toml | 64 + crates/proto/tsclientlib/README.md | 21 + crates/proto/tsclientlib/README.tpl | 10 + .../tsclientlib/examples/audio-latency.rs | 66 + crates/proto/tsclientlib/examples/audio.rs | 127 + .../examples/audio_utils/audio_to_ts.rs | 184 ++ .../tsclientlib/examples/audio_utils/mod.rs | 37 + .../examples/audio_utils/ts_to_audio.rs | 138 ++ .../proto/tsclientlib/examples/channeltree.rs | 129 ++ crates/proto/tsclientlib/examples/many.rs | 86 + .../proto/tsclientlib/examples/simple-sync.rs | 78 + crates/proto/tsclientlib/examples/simple.rs | 85 + crates/proto/tsclientlib/examples/sync.rs | 77 + crates/proto/tsclientlib/src/audio.rs | 876 +++++++ crates/proto/tsclientlib/src/lib.rs | 2042 +++++++++++++++++ crates/proto/tsclientlib/src/prelude.rs | 4 + crates/proto/tsclientlib/src/resolver.rs | 514 +++++ crates/proto/tsclientlib/src/sync.rs | 470 ++++ crates/proto/tsclientlib/src/tests.rs | 37 + crates/proto/tsproto-packets/Cargo.toml | 25 + crates/proto/tsproto-packets/README.md | 10 + crates/proto/tsproto-packets/README.tpl | 10 + crates/proto/tsproto-packets/src/commands.rs | 293 +++ crates/proto/tsproto-packets/src/lib.rs | 62 + crates/proto/tsproto-packets/src/packets.rs | 1251 ++++++++++ crates/proto/tsproto-structs/Cargo.toml | 31 + crates/proto/tsproto-structs/README.md | 13 + crates/proto/tsproto-structs/README.tpl | 10 + .../tsproto-structs/declarations/.gitignore | 67 + .../tsproto-structs/declarations/Badges.csv | 83 + .../tsproto-structs/declarations/Book.toml | 327 +++ .../declarations/BookToMessages.toml | 393 ++++ .../tsproto-structs/declarations/Enums.toml | 172 ++ .../tsproto-structs/declarations/Errors.csv | 197 ++ .../declarations/LICENSE-APACHE | 201 ++ .../tsproto-structs/declarations/LICENSE-MIT | 21 + .../declarations/Messages.toml | 1028 +++++++++ .../declarations/MessagesToBook.toml | 268 +++ .../tsproto-structs/declarations/Packets.txt | 151 ++ .../declarations/Permissions.csv | 250 ++ .../tsproto-structs/declarations/README.md | 26 + .../tsproto-structs/declarations/Versions.csv | 1417 ++++++++++++ .../declarations/ts3protocol.md | 864 +++++++ crates/proto/tsproto-structs/src/book.rs | 207 ++ .../tsproto-structs/src/book_to_messages.rs | 344 +++ crates/proto/tsproto-structs/src/enums.rs | 52 + crates/proto/tsproto-structs/src/errors.rs | 20 + crates/proto/tsproto-structs/src/lib.rs | 398 ++++ crates/proto/tsproto-structs/src/messages.rs | 115 + .../tsproto-structs/src/messages_to_book.rs | 263 +++ .../proto/tsproto-structs/src/permissions.rs | 26 + crates/proto/tsproto-structs/src/versions.rs | 94 + crates/proto/tsproto-types/Cargo.toml | 40 + crates/proto/tsproto-types/README.md | 10 + crates/proto/tsproto-types/README.tpl | 10 + crates/proto/tsproto-types/build/Enums.tt | 30 + crates/proto/tsproto-types/build/Errors.tt | 13 + crates/proto/tsproto-types/build/Versions.tt | 41 + crates/proto/tsproto-types/build/build.rs | 30 + crates/proto/tsproto-types/build/enums.rs | 17 + crates/proto/tsproto-types/build/errors.rs | 17 + crates/proto/tsproto-types/build/versions.rs | 14 + crates/proto/tsproto-types/src/crypto.rs | 609 +++++ crates/proto/tsproto-types/src/errors.rs | 13 + crates/proto/tsproto-types/src/lib.rs | 173 ++ crates/proto/tsproto-types/src/versions.rs | 9 + crates/proto/tsproto/Cargo.toml | 67 + crates/proto/tsproto/README.md | 21 + crates/proto/tsproto/README.tpl | 10 + crates/proto/tsproto/benches/connect.rs | 77 + crates/proto/tsproto/benches/license.rs | 58 + crates/proto/tsproto/benches/message.rs | 69 + crates/proto/tsproto/benches/modpow.rs | 42 + crates/proto/tsproto/benches/utils/mod.rs | 112 + crates/proto/tsproto/examples/client.rs | 67 + crates/proto/tsproto/examples/decompress.rs | 21 + crates/proto/tsproto/examples/many-tsproto.rs | 71 + .../proto/tsproto/examples/parse-license.rs | 19 + crates/proto/tsproto/examples/test-decrypt.rs | 52 + crates/proto/tsproto/examples/test-ed25519.rs | 39 + crates/proto/tsproto/examples/test-proofs.rs | 35 + crates/proto/tsproto/examples/utils/mod.rs | 101 + crates/proto/tsproto/src/algorithms.rs | 452 ++++ crates/proto/tsproto/src/client.rs | 1213 ++++++++++ crates/proto/tsproto/src/connection.rs | 449 ++++ crates/proto/tsproto/src/lib.rs | 253 ++ crates/proto/tsproto/src/license.rs | 932 ++++++++ crates/proto/tsproto/src/log.rs | 111 + crates/proto/tsproto/src/packet_codec.rs | 461 ++++ crates/proto/tsproto/src/resend.rs | 1067 +++++++++ crates/proto/tsproto/src/utils.rs | 47 + 119 files changed, 24322 insertions(+) create mode 100644 crates/proto/.rustfmt.toml create mode 100644 crates/proto/CHANGELOG.md create mode 100644 crates/proto/LICENSE-APACHE create mode 100644 crates/proto/LICENSE-MIT create mode 100644 crates/proto/README.upstream.md create mode 100644 crates/proto/UPSTREAM.md create mode 100644 crates/proto/clippy.toml create mode 100644 crates/proto/ts-bookkeeping/Cargo.toml create mode 100644 crates/proto/ts-bookkeeping/README.md create mode 100644 crates/proto/ts-bookkeeping/README.tpl create mode 100644 crates/proto/ts-bookkeeping/benches/command.rs create mode 100644 crates/proto/ts-bookkeeping/build/BookDeclarations.tt create mode 100644 crates/proto/ts-bookkeeping/build/BookToMessages.tt create mode 100644 crates/proto/ts-bookkeeping/build/Events.tt create mode 100644 crates/proto/ts-bookkeeping/build/MessageDeclarations.tt create mode 100644 crates/proto/ts-bookkeeping/build/MessagesToBook.tt create mode 100644 crates/proto/ts-bookkeeping/build/Properties.tt create mode 100644 crates/proto/ts-bookkeeping/build/book_parser.rs create mode 100644 crates/proto/ts-bookkeeping/build/book_to_messages_parser.rs create mode 100644 crates/proto/ts-bookkeeping/build/build.rs create mode 100644 crates/proto/ts-bookkeeping/build/events.rs create mode 100644 crates/proto/ts-bookkeeping/build/message_parser.rs create mode 100644 crates/proto/ts-bookkeeping/build/messages_to_book_parser.rs create mode 100644 crates/proto/ts-bookkeeping/build/properties.rs create mode 100644 crates/proto/ts-bookkeeping/src/data.rs create mode 100644 crates/proto/ts-bookkeeping/src/events.rs create mode 100644 crates/proto/ts-bookkeeping/src/lib.rs create mode 100644 crates/proto/ts-bookkeeping/src/messages.rs create mode 100644 crates/proto/tsclientlib/Cargo.toml create mode 100644 crates/proto/tsclientlib/README.md create mode 100644 crates/proto/tsclientlib/README.tpl create mode 100644 crates/proto/tsclientlib/examples/audio-latency.rs create mode 100644 crates/proto/tsclientlib/examples/audio.rs create mode 100644 crates/proto/tsclientlib/examples/audio_utils/audio_to_ts.rs create mode 100644 crates/proto/tsclientlib/examples/audio_utils/mod.rs create mode 100644 crates/proto/tsclientlib/examples/audio_utils/ts_to_audio.rs create mode 100644 crates/proto/tsclientlib/examples/channeltree.rs create mode 100644 crates/proto/tsclientlib/examples/many.rs create mode 100644 crates/proto/tsclientlib/examples/simple-sync.rs create mode 100644 crates/proto/tsclientlib/examples/simple.rs create mode 100644 crates/proto/tsclientlib/examples/sync.rs create mode 100644 crates/proto/tsclientlib/src/audio.rs create mode 100644 crates/proto/tsclientlib/src/lib.rs create mode 100644 crates/proto/tsclientlib/src/prelude.rs create mode 100644 crates/proto/tsclientlib/src/resolver.rs create mode 100644 crates/proto/tsclientlib/src/sync.rs create mode 100644 crates/proto/tsclientlib/src/tests.rs create mode 100644 crates/proto/tsproto-packets/Cargo.toml create mode 100644 crates/proto/tsproto-packets/README.md create mode 100644 crates/proto/tsproto-packets/README.tpl create mode 100644 crates/proto/tsproto-packets/src/commands.rs create mode 100644 crates/proto/tsproto-packets/src/lib.rs create mode 100644 crates/proto/tsproto-packets/src/packets.rs create mode 100644 crates/proto/tsproto-structs/Cargo.toml create mode 100644 crates/proto/tsproto-structs/README.md create mode 100644 crates/proto/tsproto-structs/README.tpl create mode 100644 crates/proto/tsproto-structs/declarations/.gitignore create mode 100644 crates/proto/tsproto-structs/declarations/Badges.csv create mode 100644 crates/proto/tsproto-structs/declarations/Book.toml create mode 100644 crates/proto/tsproto-structs/declarations/BookToMessages.toml create mode 100644 crates/proto/tsproto-structs/declarations/Enums.toml create mode 100644 crates/proto/tsproto-structs/declarations/Errors.csv create mode 100644 crates/proto/tsproto-structs/declarations/LICENSE-APACHE create mode 100644 crates/proto/tsproto-structs/declarations/LICENSE-MIT create mode 100644 crates/proto/tsproto-structs/declarations/Messages.toml create mode 100644 crates/proto/tsproto-structs/declarations/MessagesToBook.toml create mode 100644 crates/proto/tsproto-structs/declarations/Packets.txt create mode 100644 crates/proto/tsproto-structs/declarations/Permissions.csv create mode 100644 crates/proto/tsproto-structs/declarations/README.md create mode 100644 crates/proto/tsproto-structs/declarations/Versions.csv create mode 100644 crates/proto/tsproto-structs/declarations/ts3protocol.md create mode 100644 crates/proto/tsproto-structs/src/book.rs create mode 100644 crates/proto/tsproto-structs/src/book_to_messages.rs create mode 100644 crates/proto/tsproto-structs/src/enums.rs create mode 100644 crates/proto/tsproto-structs/src/errors.rs create mode 100644 crates/proto/tsproto-structs/src/lib.rs create mode 100644 crates/proto/tsproto-structs/src/messages.rs create mode 100644 crates/proto/tsproto-structs/src/messages_to_book.rs create mode 100644 crates/proto/tsproto-structs/src/permissions.rs create mode 100644 crates/proto/tsproto-structs/src/versions.rs create mode 100644 crates/proto/tsproto-types/Cargo.toml create mode 100644 crates/proto/tsproto-types/README.md create mode 100644 crates/proto/tsproto-types/README.tpl create mode 100644 crates/proto/tsproto-types/build/Enums.tt create mode 100644 crates/proto/tsproto-types/build/Errors.tt create mode 100644 crates/proto/tsproto-types/build/Versions.tt create mode 100644 crates/proto/tsproto-types/build/build.rs create mode 100644 crates/proto/tsproto-types/build/enums.rs create mode 100644 crates/proto/tsproto-types/build/errors.rs create mode 100644 crates/proto/tsproto-types/build/versions.rs create mode 100644 crates/proto/tsproto-types/src/crypto.rs create mode 100644 crates/proto/tsproto-types/src/errors.rs create mode 100644 crates/proto/tsproto-types/src/lib.rs create mode 100644 crates/proto/tsproto-types/src/versions.rs create mode 100644 crates/proto/tsproto/Cargo.toml create mode 100644 crates/proto/tsproto/README.md create mode 100644 crates/proto/tsproto/README.tpl create mode 100644 crates/proto/tsproto/benches/connect.rs create mode 100644 crates/proto/tsproto/benches/license.rs create mode 100644 crates/proto/tsproto/benches/message.rs create mode 100644 crates/proto/tsproto/benches/modpow.rs create mode 100644 crates/proto/tsproto/benches/utils/mod.rs create mode 100644 crates/proto/tsproto/examples/client.rs create mode 100644 crates/proto/tsproto/examples/decompress.rs create mode 100644 crates/proto/tsproto/examples/many-tsproto.rs create mode 100644 crates/proto/tsproto/examples/parse-license.rs create mode 100644 crates/proto/tsproto/examples/test-decrypt.rs create mode 100644 crates/proto/tsproto/examples/test-ed25519.rs create mode 100644 crates/proto/tsproto/examples/test-proofs.rs create mode 100644 crates/proto/tsproto/examples/utils/mod.rs create mode 100644 crates/proto/tsproto/src/algorithms.rs create mode 100644 crates/proto/tsproto/src/client.rs create mode 100644 crates/proto/tsproto/src/connection.rs create mode 100644 crates/proto/tsproto/src/lib.rs create mode 100644 crates/proto/tsproto/src/license.rs create mode 100644 crates/proto/tsproto/src/log.rs create mode 100644 crates/proto/tsproto/src/packet_codec.rs create mode 100644 crates/proto/tsproto/src/resend.rs create mode 100644 crates/proto/tsproto/src/utils.rs diff --git a/crates/proto/.rustfmt.toml b/crates/proto/.rustfmt.toml new file mode 100644 index 0000000..09509fd --- /dev/null +++ b/crates/proto/.rustfmt.toml @@ -0,0 +1,15 @@ +version = "Two" +edition = "2018" +newline_style = "Unix" + +hard_tabs = true +use_small_heuristics = "Max" +use_try_shorthand = true + +# Unstable + +where_single_line = true +fn_params_layout = "Compressed" +fn_single_line = true +format_strings = true +overflow_delimited_expr = true diff --git a/crates/proto/CHANGELOG.md b/crates/proto/CHANGELOG.md new file mode 100644 index 0000000..a8e7fcb --- /dev/null +++ b/crates/proto/CHANGELOG.md @@ -0,0 +1,61 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] +### ℹ Changed +- Switched from `slog` to `tracing` for logging +- Update dependencies (updates some exposed types) + +## [0.2.0] - 2021-05-12 +### ✨ Added +- 🎵 An audio queue that automatically sort, decode and handle lost audio packets +- Audio example for `tsclientlib` +- Send audio packets with `Connection::send_audio` +- ⏫ Automatically improve identity level if it is not high enough +- 🔓 Add `channel`, `channel_password` and (server-)`password` to `ConnectOptions` +- 📂 Filetransfer: Download and upload files from and to TeamSpeak servers +- Most structs can be serialized with `serde` now +- `Reason` to events that support it, that allows distinguishing between client joins and subscription events +- Add ability to check server identity when connecting as `ConnectOptions::server` +- `StreamItem::MessageEvent` for non-book events + +### ℹ Changed +- ➠ Upgrade from `futures` 0.1 to 0.3 and `tokio` 0.1 to 1.0 for `async`/`await` support +- 🔒 Rewrite `tsproto` and `tsclientlib` to be a single, non-cloneable object. This removes all locks +- 🚀 Many performance improvements + - New command parser, 2–2.5× faster than the old one + - New command serializer, 2× faster than the old one +- Switched error handling library from `failure` to `thiserror` +- Now licensed under MIT/Apache 2.0 (previously under OSL 2.0) +- Commands are now sent with `command.send(&mut connection)?` +- A new connection should now be created with `ConnectOptions::connect` instead of `Connection::new` +- Multiple renamings in the book +- Rename `StreamItem::ConEvents` to `StreamItem::BookEvents` +- Rename `UidRef` to `Uid` and make it a dynamically sized type. The previously owned `Uid` type is now called `UidBuf` +- Replace `ring` with RustCrypto crates to get rid of the `flakebi-ring` crate + +### ❌ Removed +- The `ConnectionManager` in `tsproto` was removed + +### 🐛 Fixed +- Hashcash implementation counts leading zeroes from lsb instead of msb +- Use `3.?.?` version by default to allow connecting to newer TeamSpeak servers +- Fix channel order handling +- Use `git-testament` instead of `built`, this removes building libgit +- Fix encoding newlines in commands +- The last `Ack` packet is sent reliably now, previously it was lost sometimes +- Fix connecting to servers behind certain protections by restart sending init packets +- Try to reconnect infinitely after a timeout +- Keep channel and muted state when reconnecting +- Automatically subscribe to new channels when the server is subscribed + +## [0.1.0] - 2019-04-14 +### Added +- First release on crates.io for + - tsclientlib + - tsproto + - tsproto-commands + - tsproto-structs diff --git a/crates/proto/LICENSE-APACHE b/crates/proto/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/crates/proto/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/crates/proto/LICENSE-MIT b/crates/proto/LICENSE-MIT new file mode 100644 index 0000000..fa2904d --- /dev/null +++ b/crates/proto/LICENSE-MIT @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2017-2020 tsclientlib contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/crates/proto/README.upstream.md b/crates/proto/README.upstream.md new file mode 100644 index 0000000..a470f1d --- /dev/null +++ b/crates/proto/README.upstream.md @@ -0,0 +1,115 @@ +# TsClientlib [![Build status](https://ci.appveyor.com/api/projects/status/ylne3ku7265xa22j/branch/master?svg=true)](https://ci.appveyor.com/project/Flakebi/tsclientlib/branch/master) +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](https://en.wikipedia.org/wiki/Teamspeak) + +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](https://github.com/ReSpeak/Qint) will be a cross-platform TeamSpeak +client, which is based on this library (but it is not ready yet). + +## Dependencies +- [Rust](https://rust-lang.org) (preferred installation method is [rustup](https://rustup.rs)) +- [OpenSSL](https://www.openssl.org) 1.1 (linux only) + +## Getting Started +An example of a simple chat bot can be found [here](https://github.com/ReSpeak/SimpleBot). + +## Clone +This repository embeds the [declarations](https://github.com/ReSpeak/tsdeclarations) 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](tsclientlib/examples/simple.rs). +``` +cd tsclientlib +cargo run --example simple +``` + +## Build and run the example audio client +The code can be found [here](tsclientlib/examples/audio.rs). +``` +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](https://github.com/ReSpeak/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](https://github.com/ReSpeak/tsdeclarations) and +provides a nice and safe api. + +## Performance +For benchmarks, a TeamSpeak server has to run at localhost. Run +``` +cd tsproto +cargo bench -- +``` +where `` 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 + + * [Apache License, Version 2.0](LICENSE-APACHE) + * [MIT license](LICENSE-MIT) + +at your option. diff --git a/crates/proto/UPSTREAM.md b/crates/proto/UPSTREAM.md new file mode 100644 index 0000000..13cb801 --- /dev/null +++ b/crates/proto/UPSTREAM.md @@ -0,0 +1,33 @@ +# Vendored upstream: ReSpeak/tsclientlib + +The crates in this directory are a vendored fork of +[ReSpeak/tsclientlib](https://github.com/ReSpeak/tsclientlib), licensed +`MIT OR Apache-2.0` (see `LICENSE-MIT` and `LICENSE-APACHE` in this directory). + +| Item | Source | +|---|---| +| tsclientlib | `ee3bc6f45a7137db7793ba5593a321df400d53e5` (master) | +| `tsproto-structs/declarations` (was a git submodule) | [ReSpeak/tsdeclarations](https://github.com/ReSpeak/tsdeclarations) `83cb8a94b65021bb8ec4beb339e5bfbdd93df60f` (MIT OR Apache-2.0, own `LICENSE-*` kept inside the directory) | + +## Layout mapping + +| Upstream path | Here | +|---|---| +| `tsclientlib/` | `crates/proto/tsclientlib/` | +| `tsproto/` | `crates/proto/tsproto/` | +| `utils/ts-bookkeeping/` | `crates/proto/ts-bookkeeping/` | +| `utils/tsproto-packets/` | `crates/proto/tsproto-packets/` | +| `utils/tsproto-structs/` | `crates/proto/tsproto-structs/` (submodule flattened into plain files) | +| `utils/tsproto-types/` | `crates/proto/tsproto-types/` | +| `README.md`, `CHANGELOG.md`, `.rustfmt.toml`, `clippy.toml` | `crates/proto/README.upstream.md`, `CHANGELOG.md`, `.rustfmt.toml`, `clippy.toml` | + +Not vendored: `.appveyor/`, `tools/measure-latency.sh`, `tslientlib.code-workspace`, +the upstream root `Cargo.toml` (replaced by this repository's workspace). + +## Local patches + +The import commit contains the upstream files unmodified. Every later change to +files in this directory is listed here, newest last, so it can be diffed +against or offered back to upstream. + + diff --git a/crates/proto/clippy.toml b/crates/proto/clippy.toml new file mode 100644 index 0000000..c6c2413 --- /dev/null +++ b/crates/proto/clippy.toml @@ -0,0 +1 @@ +doc-valid-idents = ["MiB", "GiB", "TiB", "PiB", "EiB", "TeamSpeak", "TeamSpeak3", "PRIME256v1"] diff --git a/crates/proto/ts-bookkeeping/Cargo.toml b/crates/proto/ts-bookkeeping/Cargo.toml new file mode 100644 index 0000000..155fe46 --- /dev/null +++ b/crates/proto/ts-bookkeeping/Cargo.toml @@ -0,0 +1,44 @@ +[package] +name = "ts-bookkeeping" +version = "0.1.0" +authors = ["Flakebi "] +description = "Structs to store the state of a TeamSpeak server, with its clients and channels." +repository = "https://github.com/ReSpeak/tsclientlib/tree/master/utils/ts-bookkeeping" +readme = "README.md" +keywords = ["teamspeak3", "ts3"] +license = "MIT OR Apache-2.0" +build = "build/build.rs" +edition = "2018" +autobenches = false +include = [ + "/Cargo.toml", + "/README.md", + "**/*.rs", + "**/*.tt", +] + +[dependencies] +base64 = "0.22" +num-traits = "0.2" +num-derive = "0.4" +serde = { version = "1", features = ["derive"] } +thiserror = "2" +time = { version = "0.3", features = ["serde"] } +tracing = "0.1" +tsproto-packets = { path = "../tsproto-packets", version = "0.1" } +tsproto-types = { path = "../tsproto-types", version = "0.1" } + +[build-dependencies] +heck = "0.5" +itertools = "0.14" +t4rust-derive = "0.3" +tsproto-structs = { path = "../tsproto-structs", version = "0.2" } + +[dev-dependencies] +criterion = "0.8" +once_cell = "1" +tracing-subscriber = "0.3" + +[[bench]] +name = "command" +harness = false diff --git a/crates/proto/ts-bookkeeping/README.md b/crates/proto/ts-bookkeeping/README.md new file mode 100644 index 0000000..54d6fcc --- /dev/null +++ b/crates/proto/ts-bookkeeping/README.md @@ -0,0 +1,21 @@ +# ts-bookkeeping [![docs.rs](https://docs.rs/ts-bookkeeping/badge.svg)](https://docs.rs/ts-bookkeeping) +`ts-bookkeeping` contains structs to store the state of a TeamSpeak server, with its clients and +channels. + +The crate can be used to keep track of the state on a server by processing all incoming +commands, which is why it is called “bookkeeping”. It also contains generated structs for all +TeamSpeak commands. + +Incoming commands can be applied to the state and generate [`events`]. The main struct is +[`data::Connection`]. + +The structs have methods to create packets for various actions. The generated packets can be +sent to a server. + +## License +Licensed under either of + + * [Apache License, Version 2.0](../../LICENSE-APACHE) + * [MIT license](../../LICENSE-MIT) + +at your option. diff --git a/crates/proto/ts-bookkeeping/README.tpl b/crates/proto/ts-bookkeeping/README.tpl new file mode 100644 index 0000000..d79d809 --- /dev/null +++ b/crates/proto/ts-bookkeeping/README.tpl @@ -0,0 +1,10 @@ +# ts-bookkeeping [![docs.rs](https://docs.rs/ts-bookkeeping/badge.svg)](https://docs.rs/ts-bookkeeping) +{{readme}} + +## License +Licensed under either of + + * [Apache License, Version 2.0](../../LICENSE-APACHE) + * [MIT license](../../LICENSE-MIT) + +at your option. diff --git a/crates/proto/ts-bookkeeping/benches/command.rs b/crates/proto/ts-bookkeeping/benches/command.rs new file mode 100644 index 0000000..0f9843f --- /dev/null +++ b/crates/proto/ts-bookkeeping/benches/command.rs @@ -0,0 +1,44 @@ +use std::iter; + +use criterion::{criterion_group, criterion_main, Bencher, Criterion}; +use once_cell::sync::Lazy; +use ts_bookkeeping::messages::s2c::{self, InMessage}; +use tsproto_packets::packets::{Direction, Flags, OutPacket, PacketType}; + +const SHORT_CMD: &[u8] = b"notifyclientleftview cfid=1 ctid=0 clid=61"; +const LONG_CMD: &[u8] = b"channellist cid=2 cpid=0 channel_name=Trusted\\sChannel channel_topic channel_codec=0 channel_codec_quality=0 channel_maxclients=0 channel_maxfamilyclients=-1 channel_order=1 channel_flag_permanent=1 channel_flag_semi_permanent=0 channel_flag_default=0 channel_flag_password=0 channel_codec_latency_factor=1 channel_codec_is_unencrypted=1 channel_delete_delay=0 channel_flag_maxclients_unlimited=0 channel_flag_maxfamilyclients_unlimited=0 channel_flag_maxfamilyclients_inherited=1 channel_needed_talk_power=0 channel_forced_silence=0 channel_name_phonetic channel_icon_id=0 channel_flag_private=0|cid=4 cpid=2 channel_name=Ding\\s\xe2\x80\xa2\\s1\\s\\p\\sSplamy\xc2\xb4s\\sBett channel_topic channel_codec=4 channel_codec_quality=7 channel_maxclients=-1 channel_maxfamilyclients=-1 channel_order=0 channel_flag_permanent=1 channel_flag_semi_permanent=0 channel_flag_default=0 channel_flag_password=0 channel_codec_latency_factor=1 channel_codec_is_unencrypted=1 channel_delete_delay=0 channel_flag_maxclients_unlimited=1 channel_flag_maxfamilyclients_unlimited=0 channel_flag_maxfamilyclients_inherited=1 channel_needed_talk_power=0 channel_forced_silence=0 channel_name_phonetic=Neo\\sSeebi\\sEvangelion channel_icon_id=0 channel_flag_private=0|cid=6 cpid=2 channel_name=Ding\\s\xe2\x80\xa2\\s2\\s\\p\\sThe\\sBook\\sof\\sHeavy\\sMetal channel_topic channel_codec=2 channel_codec_quality=7 channel_maxclients=-1 channel_maxfamilyclients=-1 channel_order=4 channel_flag_permanent=1 channel_flag_semi_permanent=0 channel_flag_default=0 channel_flag_password=0 channel_codec_latency_factor=1 channel_codec_is_unencrypted=1 channel_delete_delay=0 channel_flag_maxclients_unlimited=1 channel_flag_maxfamilyclients_unlimited=0 channel_flag_maxfamilyclients_inherited=1 channel_needed_talk_power=0 channel_forced_silence=0 channel_name_phonetic=Not\\senought\\sChannels channel_icon_id=0 channel_flag_private=0|cid=30 cpid=2 channel_name=Ding\\s\xe2\x80\xa2\\s3\\s\\p\\sSenpai\\sGef\xc3\xa4hrlich channel_topic channel_codec=2 channel_codec_quality=7 channel_maxclients=-1 channel_maxfamilyclients=-1 channel_order=6 channel_flag_permanent=1 channel_flag_semi_permanent=0 channel_flag_default=0 channel_flag_password=0 channel_codec_latency_factor=1 channel_codec_is_unencrypted=1 channel_delete_delay=0 channel_flag_maxclients_unlimited=1 channel_flag_maxfamilyclients_unlimited=0 channel_flag_maxfamilyclients_inherited=1 channel_needed_talk_power=0 channel_forced_silence=0 channel_name_phonetic=The\\strashcan\\shas\\sthe\\strash channel_icon_id=0 channel_flag_private=0"; + +static TRACING: Lazy<()> = Lazy::new(|| tracing_subscriber::fmt().with_test_writer().init()); + +fn parse(b: &mut Bencher, cmd: &[u8]) { + Lazy::force(&TRACING); + let header = OutPacket::new_with_dir(Direction::S2C, Flags::empty(), PacketType::Command); + + b.iter(|| InMessage::new(&header.header(), cmd).unwrap()); +} + +fn write(b: &mut Bencher, cmd: &[u8]) { + Lazy::force(&TRACING); + let header = OutPacket::new_with_dir(Direction::S2C, Flags::empty(), PacketType::Command); + let msg = InMessage::new(&header.header(), cmd).unwrap(); + match msg { + InMessage::ClientLeftView(msg) => { + let out_part = msg.iter().next().unwrap().as_out(); + b.iter(|| s2c::OutClientLeftViewMessage::new(&mut iter::once(out_part.clone()))); + } + InMessage::ChannelList(msg) => { + let out_part = msg.iter().next().unwrap().as_out(); + b.iter(|| s2c::OutChannelListMessage::new(&mut iter::once(out_part.clone()))); + } + _ => unreachable!("This command type is not supported in this test"), + } +} + +fn parse_short(c: &mut Criterion) { c.bench_function("parse short", |b| parse(b, SHORT_CMD)); } +fn parse_long(c: &mut Criterion) { c.bench_function("parse long", |b| parse(b, LONG_CMD)); } + +fn write_short(c: &mut Criterion) { c.bench_function("write short", |b| write(b, SHORT_CMD)); } +fn write_long(c: &mut Criterion) { c.bench_function("write long", |b| write(b, LONG_CMD)); } + +criterion_group!(benches, parse_short, parse_long, write_short, write_long); +criterion_main!(benches); diff --git a/crates/proto/ts-bookkeeping/build/BookDeclarations.tt b/crates/proto/ts-bookkeeping/build/BookDeclarations.tt new file mode 100644 index 0000000..58085e7 --- /dev/null +++ b/crates/proto/ts-bookkeeping/build/BookDeclarations.tt @@ -0,0 +1,14 @@ +<#@ template cleanws="true" #> +<# for struc in &self.0.structs { #> +<#= doc_comment(&struc.doc) #> +#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] +pub struct <#= struc.name #> { +<# for p in struc.get_all_properties() { + if let Some(ref doc) = p.get_doc() { #> +<#= indent(doc_comment(doc), 1) #> +<# } #> + pub <#= p.get_attr_name(&struc) #>: <#= p.get_type(&self.0.structs)? #>, +<# } #> +} + +<# } #> diff --git a/crates/proto/ts-bookkeeping/build/BookToMessages.tt b/crates/proto/ts-bookkeeping/build/BookToMessages.tt new file mode 100644 index 0000000..ed83c62 --- /dev/null +++ b/crates/proto/ts-bookkeeping/build/BookToMessages.tt @@ -0,0 +1,232 @@ +<#@ template cleanws="true" #> +<# +use std::{fmt, iter}; + +use tsproto_structs::messages::{MessageDeclarations, MessageGroup}; + +fn get_all_arguments<'a>(e: &'a Event<'a>, r: Option<&'a RuleKind<'a>>) -> String { + let mut args = String::new(); + for r in e.ids.iter().chain(r.iter().cloned()) { + match r { + RuleKind::ArgumentMap { .. } | + RuleKind::ArgumentFunction { .. } => { + let arg = r.get_argument(); + if !arg.is_empty() { + args.push_str(", "); + args.push_str(&arg); + } + } + _ => {} + } + } + args +} + +fn get_all_id_arguments<'a>(e: &'a Event<'a>) -> String { + let mut args = String::new(); + for r in &e.ids { + match r { + RuleKind::ArgumentMap { .. } | + RuleKind::ArgumentFunction { .. } => { + let arg = r.get_argument(); + if !arg.is_empty() { + args.push_str(&arg); + args.push_str(", "); + } + } + _ => {} + } + } + args +} + +fn create_message( + _fmt: &mut fmt::Formatter, e: &Event, rule: Option<&RuleKind>, + msg_group: &MessageGroup, messages: &MessageDeclarations, +) -> fmt::Result { + for r in e.ids.iter().chain(rule.iter().cloned()) { + call_func(_fmt, r)?; + } + #> + c2s::Out<#= e.msg.name #>Part { + <# + for a in &e.msg.attributes { + let field = messages.get_field(a); + + let (from_rule, found) = find_rule(e, rule, field); + let from = match found { + Some(RuleKind::Map { from, .. }) => { + let from_self = if from_rule { "" } else { "self." }; + Some(format!("{}{}", from_self, from.name.to_snake_case())) + } + Some(found@RuleKind::ArgumentMap { .. }) => Some(found.from_name().to_snake_case()), + Some(RuleKind::Function { .. }) + | Some(RuleKind::ArgumentFunction { .. }) => Some(field.get_rust_name()), + None => None, + }; + + if let Some(from) = from { + if field.is_opt(&e.msg) { #> + <#= field.get_rust_name() #>: Some(<#= from #>.into()), + <# } else { #> + <#= field.get_rust_name() #>: <#= from #>.into(), + <# } + } else { #> + <#= field.get_rust_name() #>: None, + <# } + } #> + } + <# + Ok(()) +} + +/// Calls function if it is one, otherwise does nothing. +fn call_func(_fmt: &mut fmt::Formatter, r: &RuleKind) -> fmt::Result { + match r { + RuleKind::Function { name, to, .. } => { #> + let <#= get_to_list(to.as_slice()) #> = self.<#= name.to_snake_case() #>(); + <# } + RuleKind::ArgumentFunction { from, to, name, .. } => { #> + let <#= get_to_list(to.as_slice()) + #> = self.<#= name.to_snake_case() #>(<#= from.to_snake_case() #>); + <# } + _ => {} + } + Ok(()) +} + +/// Calls function if it is one, otherwise does nothing. +fn call_func2(_fmt: &mut fmt::Formatter, struct_name: &str, r: &RuleKind) -> fmt::Result { + match r { + RuleKind::Function { name, to, .. } => { #> + let <#= get_to_list(to.as_slice()) #> = <#= struct_name #>::<#= name.to_snake_case() #>(); + <# } + RuleKind::ArgumentFunction { from, to, name, .. } => { #> + let <#= get_to_list(to.as_slice()) + #> = <#= struct_name #>::<#= name.to_snake_case() #>(<#= from.to_snake_case() #>); + <# } + _ => {} + } + Ok(()) +} + +for e in &self.decls { + let msg_group = self.messages.get_message_group(&e.msg); + let uses_lifetime = self.messages.uses_lifetime(&e.msg); + // Update + if e.op == RuleOp::Update { + let small_change_name = e.get_small_name(); + let change_name = e.get_change_name(); + #> + +impl <#= e.book_struct.name #> { + pub fn <#= change_name.to_snake_case() #><# if uses_lifetime { #><'a><# } #>(&self, <#= + get_all_id_arguments(e).replace('&', "&'a ") #> + <# if e.msg.attributes.is_empty() { #> + ) -> OutCommand + <# } else { #> + ) -> c2s::Out<#= e.msg.name #>Part<# if uses_lifetime { #><'a><# } #> + <# } #> + { + <# if e.msg.attributes.is_empty() { #> + c2s::Out<#= e.msg.name #>Message::new() + <# } else { #> + <# create_message(_fmt, e, None, msg_group, &self.messages)?; #> + <# } #> + } +} + +<# if !e.rules.is_empty() { #> +pub trait M2B<#= e.msg.name #>Ext<# if uses_lifetime { #><'a><# } #> { +<# for r in &e.rules { + let name = r.from_name(); + #> + fn set_<#= name.to_snake_case() #>(self, <#= r.get_argument_no_option() + .replace('&', "&'a ") #>) -> Self; +<# } #> +} + +impl<# if uses_lifetime { #><'a><# } #> M2B<#= e.msg.name #>Ext<# if uses_lifetime { #><'a><# } #> for c2s::Out<#= e.msg.name #>Part<# if uses_lifetime { #><'a><# } #> { +<# for r in &e.rules { + let name = r.from_name(); + let from_name; + match r { + RuleKind::Map { from, .. } => { + from_name = format!("self.{}", from.name.to_snake_case()); + } + RuleKind::ArgumentMap { .. } => from_name = r.from_name().to_snake_case(), + RuleKind::Function { .. } + | RuleKind::ArgumentFunction { .. } => from_name = r.from_name().to_snake_case(), + } + #> + fn set_<#= name.to_snake_case() #>(mut self, <#= r.get_argument_no_option() + .replace('&', "&'a ") #>) -> Self { + <# call_func2(_fmt, &e.book_struct.name, r)?; #> + <# match r { + RuleKind::Map { to, .. } + | RuleKind::ArgumentMap { to, .. } => { #> + self.<#= to.get_rust_name() #> = Some(<#= r.from_name().to_snake_case() #>.into()); + <# } + RuleKind::Function { to, .. } + | RuleKind::ArgumentFunction { to, .. } => { + for t in to { #> + self.<#= t.get_rust_name() #> = Some(<#= t.get_rust_name() #>.into()); + <# } + } + } #> + self + } +<# } #> +} +<# } #> +<# + } else if e.op == RuleOp::Remove { + if e.rules.is_empty() { + let args = get_all_arguments(e, None); + let name_add = if !args.is_empty() { + format!("_{}", &args[2..args.find(':').unwrap()]) + } else { + "".into() + }; #> + +impl <#= e.book_struct.name #> { + pub fn remove<#= name_add #>(&self<#= args #>) -> OutCommand { + c2s::Out<#= e.msg.name #>Message::new(&mut std::iter::once({ + <# create_message(_fmt, e, None, msg_group, &self.messages)?; #> + })<# if msg_group.default.response { #>, None<# } #>) + } +} +<# } else { + // Remove the property + for r in &e.rules { + let args = get_all_arguments(e, Some(r)); + let name_add = if !args.is_empty() { + format!("_{}", &args[2..args.find(':').unwrap()]) + } else { + "".into() + }; #> + +impl <#= e.book_struct.name #> { + pub fn remove<#= name_add #>(&self<#= args #>) -> OutCommand { + c2s::Out<#= e.msg.name #>Message::new(&mut std::iter::once({ + <# create_message(_fmt, e, Some(r), msg_group, &self.messages)?; #> + })<# if msg_group.default.response { #>, None<# } #>) + } +} + <# } + } + } else if e.op == RuleOp::Add { + for r in &e.rules { + let name = r.from_name_singular(); + #> + +impl <#= e.book_struct.name #> { + pub fn add_<#= name.to_snake_case() #>(&self<#= get_all_arguments(e, Some(r)) #>) -> OutCommand { + c2s::Out<#= e.msg.name #>Message::new(&mut std::iter::once({ + <# create_message(_fmt, e, Some(r), msg_group, &self.messages)?; #> + })<# if msg_group.default.response { #>, None<# } #>) + } +} + <# } + } +} #> diff --git a/crates/proto/ts-bookkeeping/build/Events.tt b/crates/proto/ts-bookkeeping/build/Events.tt new file mode 100644 index 0000000..bd7b93a --- /dev/null +++ b/crates/proto/ts-bookkeeping/build/Events.tt @@ -0,0 +1,88 @@ +<#@ template cleanws="true" #> +/// A `PropertyId` identifies a single attribute in the data structure of a +/// connection. +#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] +#[non_exhaustive] +pub enum PropertyId { +<# for struc in &self.structs { #> + <#= struc.name #><#= struc.get_ids(&self.structs) #>, +<# } #> + +<# for struc in self.structs.iter().filter(|s| !s.opt) { + for p in struc.get_properties(&self.structs) { #> + <#= struc.name #><#= p.get_name() #><#= p.get_ids(&self.structs, struc) #>, +<# } +} #> +} + +/// A `PropertyValue` contains the value of an attribute in the data structures. +#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] +#[non_exhaustive] +pub enum PropertyValue { +<# for struc in &self.structs { #> + <#= struc.name #>(<#= struc.get_type()? #>), +<# } #> + +<# +let mut done = HashSet::new(); +for struc in self.structs.iter().filter(|s| !s.opt) { + for p in struc.get_properties(&self.structs) { + let type_s = p.get_inner_type()?; + if !done.insert(type_s.to_string()) { + continue; + } + #> + <#= p.get_inner_type_as_name()? #>(<#= type_s #>), +<# } +} #> +} + +/// A `PropertyValueRef` contains a reference to the value of an attribute in +/// the data structures. +/// +/// See [`PropertyValue`] for the owned variant. +#[derive(Clone, Debug, PartialEq)] +#[non_exhaustive] +pub enum PropertyValueRef<'a> { +<# for struc in &self.structs { #> + <#= struc.name #>(<#= struc.get_type()?.lifetime(true).to_ref(true) #>), +<# } #> + +<# +let mut done = HashSet::new(); +for struc in self.structs.iter().filter(|s| !s.opt) { + for p in struc.get_properties(&self.structs) { + let type_s = p.get_inner_type()?; + if !done.insert(type_s.to_string()) { + continue; + } + #> + <#= p.get_inner_type_as_name()? #>(<#= p.get_inner_type()?.lifetime(true).to_ref(true) #>), +<# } +} #> +} + +impl PropertyValue { + pub fn as_ref(&self) -> PropertyValueRef<'_> { + match self { +<# for struc in &self.structs { #> + PropertyValue::<#= struc.name #>(s) => PropertyValueRef::<#= struc.name #>(<#= struc.get_type()?.code_as_ref("s").trim_start_matches('&') #>), +<# } #> + +<# +let mut done = HashSet::new(); +for struc in self.structs.iter().filter(|s| !s.opt) { + for p in struc.get_properties(&self.structs) { + let inner_type = p.get_inner_type()?; + if !done.insert(inner_type.to_string()) { + continue; + } + let name = inner_type.to_name(); + let has_ref = inner_type.lifetime(true).to_ref(true).uses_lifetime(); + #> + PropertyValue::<#= name #>(s) => PropertyValueRef::<#= name #>(<#= inner_type.wrap_ref().code_as_ref("s").trim_start_matches('&') #>), +<# } +} #> + } + } +} diff --git a/crates/proto/ts-bookkeeping/build/MessageDeclarations.tt b/crates/proto/ts-bookkeeping/build/MessageDeclarations.tt new file mode 100644 index 0000000..873f577 --- /dev/null +++ b/crates/proto/ts-bookkeeping/build/MessageDeclarations.tt @@ -0,0 +1,340 @@ +<#@ template cleanws="true" #> +use std::borrow::Cow; +// Needed for vector serialization +#[allow(unused_imports)] +use std::fmt::Write as _; +use std::str; + +use base64::prelude::*; +use num_traits::{FromPrimitive, ToPrimitive}; +use tracing::{instrument, warn}; +use tsproto_packets::commands::{CommandItem, CommandParser}; +use tsproto_packets::packets::*; + +#[derive(Clone, Debug)] +#[non_exhaustive] +pub enum InMessage { +<# for msg_group in &self.0.msg_group { + for msg in &msg_group.msg { #> + <#= msg.name #>(In<#= msg.name #>), +<# } +} #> +} + +impl InMessage { + /// Parse a message into a struct. + pub fn new(header: &InHeader, cmd: &[u8]) -> Result { + let (name, args) = CommandParser::new(cmd); + match name { + <# + let mut msgs: Vec<_> = self.0.msg_group.iter() + .flat_map(|g| g.msg.iter()) + .filter(|m| m.notify.is_some()) + .collect(); + msgs.sort_unstable_by_key(|m| m.notify.as_ref().map(|s| s.as_str()).unwrap()); + for (notify, group) in &msgs.iter().group_by(|m| m.notify.as_ref().map(|s| s.as_str()).unwrap()) { + let group: Vec<_> = group.collect(); + let (msg, group) = group.split_last().unwrap(); + #> + b"<#= notify #>" => <# for msg in group { + #>if let Ok(r) = In<#= msg.name #>::new(header, args.clone()) { + Ok(InMessage::<#= msg.name #>(r)) + } else <# + } #>{ + Ok(InMessage::<#= msg.name #>(In<#= msg.name #>::new(header, args)?)) + } + <# } #> + s => Err(ParseError::UnknownCommand(str::from_utf8(s)?.to_string())), + } + } + + pub fn get_command_name(&self) -> &'static str { + match self { + <# for msg_group in &self.0.msg_group { + for msg in &msg_group.msg { #> + InMessage::<#= msg.name #>(_) => "<#= if let Some(s) = &msg.notify { s } else { &msg.name } #>", + <# } + } #> + } + } +} + +<# for msg_group in &self.0.msg_group { + for msg in &msg_group.msg { + let has_attributes = !msg.attributes.is_empty(); #> +#[derive(Clone, Debug)] +pub struct In<#= msg.name #> { + <# if msg_group.default.response { #> + pub return_code: Option, + <# } + if has_attributes { #> + list: VecPart>, + <# } #> +} +<# if has_attributes { #> + +#[derive(Clone, Debug)] +pub struct In<#= msg.name #>Part { + <# for a in &msg.attributes { + let field = self.0.get_field(a); + if field.get_rust_name() != field.ts { #> + /// `<#= field.ts #>` in TeamSpeak + <# } #> + pub <#= field.get_rust_name() #>: <#= field.get_type(a)? #>, + <# } #> +} +<# } #> + +impl InMessageTrait for In<#= msg.name #> { + #[instrument(name = "parse_message", skip(header, <# if !has_attributes { #>_<# } #>args))] + fn new(header: &InHeader, <# if !has_attributes { #>_<# } #>args: CommandParser) -> Result { + // TODO newprotocol + //if <#= if msg_group.default.np { "!" } else { "" } #>header.flags().contains(Flags::NEWPROTOCOL) { return Err(ParseError::WrongNewprotocol(<#= if msg_group.default.np { "false" } else { "true" } #>)); } + if header.packet_type() != PacketType::Command<#= if msg_group.default.low { "Low" } else { "" } #> { return Err(ParseError::WrongPacketType(header.packet_type())); } + <# if !msg_group.default.s2c { #> + if header.direction() == Direction::S2C { return Err(ParseError::WrongDirection(header.direction())); } + <# } #> + <# if !msg_group.default.c2s { #> + if header.direction() == Direction::C2S { return Err(ParseError::WrongDirection(header.direction())); } + <# } #> + + <# if msg_group.default.response { #> + let mut return_code = None; + <# } #> + <# for a in &msg.attributes { #> + let mut <#= self.0.get_field(a).get_rust_name() #> = None; + <# } #> + + <# if !has_attributes { #> + Ok(In<#= msg.name #> {<# if msg_group.default.response { #> return_code <# } #>}) + <# } else { #> + let mut list = Vec::Part>::new(); + for item in args.chain(std::iter::once(CommandItem::NextCommand)) { + match item { + CommandItem::NextCommand => { + // Build command + let new = In<#= msg.name #>Part { + <# for a in &msg.attributes { + let field = self.0.get_field(a); + let transform_func = if !field.get_type(a)?.is_primitive() { + ".clone()" + } else { + "" + }; #> + <#= field.get_rust_name() #>: <#= field.get_rust_name() #> + <# if !a.ends_with('?') { /* is not optional */ #> + .take() + .or_else(|| list.first().map(|p| p.<#= field.get_rust_name() #><#= transform_func #>)) + .ok_or(ParseError::ParameterNotFound { arg: "<#= field.pretty #>", name: "<#= msg.name #>", })?, + <# } else { #> + .take() + .or_else(|| list.first().and_then(|p| p.<#= field.get_rust_name() #><#= transform_func #>)), + <# } #> + <# } #> + }; + list.push(new); + } + CommandItem::Argument(arg) => { + match arg.name() { + <# for a in &msg.attributes { + let field = self.0.get_field(a); #> + b"<#= field.ts #>" => { + let val = arg.value().get_str()?; + let val = val.as_ref(); + <#= field.get_rust_name() #> = Some({ + <# #><#= generate_deserializer(field) #> + }); + } + <# } #> + <# if msg_group.default.response { #> + b"return_code" => { + if return_code.is_some() { + warn!(command = "<#= msg.name #>", "Got multiple return codes"); + } + return_code = Some(arg.value().get_str()?.into_owned()); + } + <# } #> + s => warn!(command = "<#= msg.name #>", argument = ?str::from_utf8(s), + "Unknown argument"), + } + } + } + } + + Ok(In<#= msg.name #> {<# if msg_group.default.response { #> return_code,<# } #> list }) + <# } #> + } +} + +<# if has_attributes { #> +impl In<#= msg.name #> { + #[inline] + pub fn iter(&self) -> InMessageIteratorPart> { self.into_iter() } +} + +impl<'a> IntoIterator for &'a In<#= msg.name #> { + type Item = &'a In<#= msg.name #>Part; + type IntoIter = InMessageIterator<'a, In<#= msg.name #>Part>; + #[inline] + fn into_iter(self) -> Self::IntoIter { InMessageIterator(&self.list, 0) } +} + +impl In<#= msg.name #>Part { + pub fn get_invoker(&self) -> Option { + <# + let mut has_invoker_id = false; + let mut has_invoker_name = false; + let mut has_invoker_uid = false; + let mut invoker_optional = true; + + for a in &msg.attributes { + let field = self.0.get_field(a); + match field.ts.as_str() { + "invokerid" => { + has_invoker_id = true; + invoker_optional = a.ends_with('?'); + } + "invokername" => has_invoker_name = true, + "invokeruid" => has_invoker_uid = true, + _ => {} + } + } + + if has_invoker_id && has_invoker_name && has_invoker_uid { #> + <# if invoker_optional { #> + let id = self.invoker_id?; + let name = self.invoker_name.clone()?; + let uid = self.invoker_uid.clone(); + <# } else { #> + let id = self.invoker_id; + let name = self.invoker_name.clone(); + let uid = self.invoker_uid.clone(); + <# } #> + Some(Invoker { + id, + name, + uid, + }) + <# } else { #> + None + <# } #> + } + + pub fn as_out(&self) -> Out<#= msg.name #>Part { + Out<#= msg.name #>Part { + <# + let mut uses_lifetime = false; + for a in &msg.attributes { + let field = self.0.get_field(a); + let ty = field.get_type(a)?; + let mut from = ty + .code_as_ref("field") + .replacen("field", &format!("self.{}", field.get_rust_name()), 1); + if ty.to_cow().is_cow() { + if ty.is_opt() { + from.push_str(".map(Cow::Borrowed)"); + } else { + from = format!("Cow::Borrowed({})", from); + } + } #> + <#= field.get_rust_name() #>: <#= from #>, + <# } #> + } + } +} +<# } #> + +<# } +} #> + +/// The iterator is guaranteed to output at least one part. +pub struct InMessageIterator<'a, T>(&'a [T], usize); +impl<'a, T> Iterator for InMessageIterator<'a, T> { + type Item = &'a T; + fn next(&mut self) -> Option { + let i = self.1; + self.1 += 1; + self.0.get(i) + } +} + +<# for msg_group in &self.0.msg_group { + let defs = &msg_group.default; + for msg in &msg_group.msg { + let uses_lifetime = self.0.uses_lifetime(msg); + let has_attributes = msg_group.default.response || !msg.attributes.is_empty(); #> + +<# if has_attributes { #> +#[derive(Clone, Debug)] +pub struct Out<#= msg.name #>Part<# if uses_lifetime { #><'a><# } #> { +<# for a in &msg.attributes { + let field = self.0.get_field(a); + if field.get_rust_name() != field.ts { #> + /// `<#= field.ts #>` in TeamSpeak + <# } #> + pub <#= field.get_rust_name() #>: <#= field.get_type(a)?.to_cow().lifetime(true) #>, +<# } #> +} + +<# +let part_name = format!("Out{}Part{}", msg.name, if uses_lifetime { "<'a>" } else { "" }); +#> +impl<<# if uses_lifetime { #>'a, <# } #>> OutMessage<# if msg_group.default.response { #>WithReturn<# } #>Trait for &mut dyn Iterator> { + fn to_packet(self<# + if msg_group.default.response { #>, return_code: Option<&str><# } #>) -> OutCommand + where Self: Sized { + Out<#= msg.name #>Message::new(self<# + if msg_group.default.response { #>, return_code<# } #>) + } +} + +impl<<# if uses_lifetime { #>'a, <# } #>> OutMessage<# if msg_group.default.response { #>WithReturn<# } #>Trait for <#= part_name #> { + fn to_packet(self<# + if msg_group.default.response { #>, return_code: Option<&str><# } #>) -> OutCommand + where Self: Sized { + Out<#= msg.name #>Message::new(&mut std::iter::once(self)<# + if msg_group.default.response { #>, return_code<# } #>) + } +} + +<# } #> +pub struct Out<#= msg.name #>Message; +impl Out<#= msg.name #>Message { + #[allow(clippy::let_and_return, clippy::new_ret_no_self)] + pub fn new(<# if has_attributes { #>parts: &mut dyn IteratorPart><# + if msg_group.default.response { #>, return_code: Option<&str><# } } #>) -> OutCommand { + let<# if has_attributes { #> mut<# } #> packet = OutCommand::new( + Direction::<#= if msg_group.default.s2c { "S2C" } else { "C2S" } #>, + Flags::<#= if msg_group.default.np { "NEWPROTOCOL" } else { "empty()" } #>, + PacketType::Command<# if msg_group.default.low { #>Low<# } #>, + "<#= msg.notify.as_ref().map(|s| s.as_str()).unwrap_or("") #>", + ); + <# if msg_group.default.response { #> + if let Some(r) = return_code { + packet.write_arg("return_code", &r); + } + <# } #> + <# if !msg.attributes.is_empty() { #> + let mut first = true; + for p in parts { + if first { + first = false; + } else { + packet.start_new_part(); + } + <# for a in &msg.attributes { + let field = self.0.get_field(a); + if a.ends_with('?') { #> + if let Some(val) = p.<#= field.get_rust_name() #> { packet.write_arg("<#= field.ts #>", <#= generate_serializer(field, "val") #>); } + <# } else { #> + packet.write_arg("<#= field.ts #>", <#= generate_serializer(field, &format!("p.{}", field.get_rust_name())) #>); + <# } #> + <# } #> + } + <# } #> + + packet + } +} +<# } +} #> diff --git a/crates/proto/ts-bookkeeping/build/MessagesToBook.tt b/crates/proto/ts-bookkeeping/build/MessagesToBook.tt new file mode 100644 index 0000000..359c749 --- /dev/null +++ b/crates/proto/ts-bookkeeping/build/MessagesToBook.tt @@ -0,0 +1,439 @@ +<#@ template cleanws="true" #> +<# +/// Push into events the difference between two arrays. +/// +/// The old value is stored in `old`, the `new` in the book. +fn diff(_fmt: &mut std::fmt::Formatter, new: &str, event: &Event, p: &Property, from: &Field) -> std::fmt::Result { + let mut ids = event.get_id_args("m"); + let type_s = p.get_inner_type_as_name()?; + let added; + let removed; + let modifier = from.modifier.as_ref().unwrap(); + if modifier == "array" { + added = format!("iter().filter(|n| !old.contains(n))"); + removed = format!("into_iter().filter(|o| !{}.contains(o))", new); + } else if modifier == "set" { + added = format!("difference(&old)"); + removed = format!("difference(&{})", new); + } else { + panic!("Unsupported modifier {}", modifier); + } +#> + // Added + for i in <#= new #>.<#= added #> { + events.push(Event::PropertyAdded { + id: PropertyId::<#= event.book_struct.name #><#= p.get_name() #>(<#= ids #>, *i), + invoker: invoker.clone(), + extra: ExtraInfo { + reason, + }, + }); + } + + // Removed + for i in old.<#= removed #> { + events.push(Event::PropertyRemoved { + id: PropertyId::<#= event.book_struct.name #><#= p.get_name() #>(<#= ids #>, i), + old: PropertyValue::<#= type_s #>(i), + invoker: invoker.clone(), + extra: ExtraInfo { + reason, + }, + }); + } +<# + Ok(()) +} + +fn create_event(_fmt: &mut std::fmt::Formatter, event: &Event, change: &str, old: bool) -> std::fmt::Result { + let ids = embrace(&event.get_id_args("m")); + #> + events.push(Event::Property<#= change #> { + id: PropertyId::<#= event.book_struct.name #><#= ids #>, + <# if old { #> + old: PropertyValue::<#= event.book_struct.name #>(old), + <# } #> + invoker: invoker.clone(), + extra: ExtraInfo { reason }, + }); + <# + Ok(()) +} + +fn create_add_rule(_fmt: &mut std::fmt::Formatter, event: &Event) -> std::fmt::Result { + // Create a new object + // First, call all functions + for fun in event.rules.iter().filter(|r| r.is_function()) { + if let RuleKind::Function { name, to } = fun { + let return_match = if to.len() == 1 { + to[0].name.to_snake_case() + } else { + format!("({})", to.iter().map(|p| p.name.to_snake_case()).collect::>().join(", ")) + }; #> + let <#= return_match #> = self.<#= name.to_snake_case() #>(m, &mut events)?; + <# } + } #> + let r = <#= event.book_struct.name #> { + <# + // Add ids + for (id, fld) in event.book_struct.id.iter().zip(event.id.iter()) { #> + <#= PropId::from(id).get_attr_name(&event.book_struct) #>: m.<#= fld.get_rust_name() #>.clone(), + <# } + + let v = vec![]; + // Function return values + for p in event.rules.iter() + .flat_map(|f| if let RuleKind::Function { to, .. } = f { + to + } else { + &v + }) { #> + <#= p.name.to_snake_case() #>, + <# } + for p in event.rules.iter() { + if let RuleKind::Map { from, to, op } = p { + if *op != RuleOp::Update { + panic!("Cannot add or remove when adding a new struct"); + } + let transform_func = if to.is_set() { + // Convert to set + ".iter().cloned().collect()" + } else if !to.get_type()?.is_primitive() { + ".clone()" + } else { + "" + }; + // to is optional, but from not + let from_opt = from.is_opt(&event.msg); #> + <#= to.name.to_snake_case() #>: <# + if to.opt && !from_opt { + #>Some(m.<#= from.get_rust_name() #><#= transform_func #>), + <# } else { + #>m.<#= from.get_rust_name() #><#= transform_func #>, + <# } + } + } #> + }; + <# + Ok(()) +} + +#> +impl Connection { + /// Return if the message was handled and the generated events. + fn handle_command_generated(&mut self, msg: &InMessage) -> Result<(bool, Vec)> { + let mut events = Vec::new(); + match msg { +<# +// Group events by message +let mut groups = HashMap::new(); +for event in &self.decls { + let group = groups.entry(event.msg.name.as_str()).or_insert_with(Vec::new); + group.push(event); +} + +for (msg_name, group) in groups { + let event = &group[0]; #> + InMessage::<#= msg_name #>(m) => for m in m.iter() { + #[allow(unused_variables)] + let invoker = m.get_invoker(); + #[allow(unused_variables)] + <# if event.msg.attributes.iter().any(|a| a == "reasonid") { #> + let reason = Some(m.reason); + <# } else if event.msg.attributes.iter().any(|a| a == "reasonid?") { #> + let reason = m.reason; + <# } else { #> + let reason: Option = None; + <# } #> +<# + for event in group { + let book_name = &event.book_struct.name; +#> + + <# if event.op == RuleOp::Remove { + let function_name = format!("remove_{}", book_name.to_snake_case()); + let mut ids = event.get_id_args("m"); + if !ids.is_empty() { ids.push_str(", "); } + if !event.book_struct.opt { #> + let old = self.<#= function_name #>(<#= ids #>&mut events)? + .ok_or(Error::RemoveNotFound("<#= book_name #>"))?; + <# } else { #> + let old = self.<#= function_name #>(<#= ids #>&mut events)?; + <# } + create_event(_fmt, event, "Removed", true)?; + } else if event.op == RuleOp::Update && !event.book_struct.opt { + // Update the object + // Functions first + let mut rule_count = event.rules.len(); + for rule in &event.rules { + if let RuleKind::Function { name, to } = rule { + rule_count -= 1; #> + self.<#= name.to_snake_case() #>(<#= event.get_id_args("m") #>, m, &mut events)?; + <# } + } + let function_name = format!("get_mut_{}", book_name.to_snake_case()); + + // Only print if necessary + if rule_count > 0 { #> + let r = self.<#= function_name #>(<#= event.get_id_args("m") #>)?; + <# } + for rule in &event.rules { + match rule { + RuleKind::Map { from, to, op } => { + // Put field from packet into bookkeeping struct + match op { + RuleOp::Update => { + let from_opt = from.is_opt(&event.msg); + // to/book is optional, but from/message not + if to.opt && !from_opt { #> + let old = mem::replace(&mut r.<#= to.name.to_snake_case() #>, Some(m.<#= from.get_rust_name() #><# if !to.get_type()?.is_primitive() { #>.clone()<# } #>)); + events.push(Event::PropertyChanged { + id: <#= event.get_property_id(to, from, "m") #>, + old: <#= get_property(to, "old") #>, + invoker: invoker.clone(), + extra: ExtraInfo { reason }, + }); + <# } else if from_opt { + let mut prefix = ""; + let transform_func = if to.is_set() { + ".iter().cloned().collect()" + } else if !to.get_type()?.is_primitive() { + ".clone()" + } else { + prefix = "*"; + "" + }; #> + if let Some(val) = &m.<#= from.get_rust_name() #> { + <# if to.opt { #> + let old = mem::replace(&mut r.<#= to.name.to_snake_case() #>, Some(<#= prefix #>val<#= transform_func #>)); + <# } else { #> + let old = mem::replace(&mut r.<#= to.name.to_snake_case() #>, <#= prefix #>val<#= transform_func #>); + <# } #> + <# if from.modifier.as_ref().map(|s| s == "array" || s == "set").unwrap_or(false) { + diff(_fmt, &format!("r.{}", to.name.to_snake_case()), event, to, from)?; + } else { #> + events.push(Event::PropertyChanged { + id: <#= event.get_property_id(to, from, "m") #>, + old: <#= get_property(to, "old") #>, + invoker: invoker.clone(), + extra: ExtraInfo { reason }, + }); + <# } #> + } + <# } else { + // Nothing is optional + #> + let old = mem::replace(&mut r.<#= to.name.to_snake_case() #>, m.<#= from.get_rust_name() #>.clone()); + events.push(Event::PropertyChanged { + id: <#= event.get_property_id(to, from, "m") #>, + old: <#= get_property(to, "old") #>, + invoker: invoker.clone(), + extra: ExtraInfo { reason }, + }); + <# } + } + // The field in the struct is a vector + RuleOp::Add => { + if to.is_set() { #> + r.<#= to.name.to_snake_case() #>.insert(m.<#= from.get_rust_name() #>.clone()); + <# } else { #> + r.<#= to.name.to_snake_case() #>.push(m.<#= from.get_rust_name() #>.clone()); + <# } #> + events.push(Event::PropertyAdded { + id: <#= event.get_property_id(to, from, "m") #>, + invoker: invoker.clone(), + extra: ExtraInfo { reason }, + }); + <# } + RuleOp::Remove => { + if to.is_set() { #> + if r.<#= to.name.to_snake_case() #>.remove(&m.<#= from.get_rust_name() #>) { + let old = m.<#= from.get_rust_name() #>; + <# } else { #> + // Find index and remove + if let Some(i) = r.<#= to.name.to_snake_case() #>.iter().position(|i| *i == m.<#= from.get_rust_name() #>) { + let old = r.<#= to.name.to_snake_case() #>.remove(i); + <# } #> + events.push(Event::PropertyRemoved { + id: <#= event.get_property_id(to, from, "m") #>, + old: <#= get_property(to, "old") #>, + invoker: invoker.clone(), + extra: ExtraInfo { reason }, + }); + } + <# } + } + } + + RuleKind::Function { to, .. } => {} + } + } + } else if event.op == RuleOp::Update && event.book_struct.opt { + // Optional structs that get only updated as a whole + + // Create a new object + // First, call all functions + for fun in event.rules.iter().filter(|r| r.is_function()) { + if let RuleKind::Function { name, to } = fun { + let return_match = if to.len() == 1 { + to[0].name.to_snake_case() + } else { + format!("({})", to.iter().map(|p| p.name.to_snake_case()).collect::>().join(", ")) + }; #> + let <#= return_match #> = self.<#= name.to_snake_case() #>(m, &mut events)?; + <# } + } + + // Check if all required data are available + // Pairs of (property, string to get the property) + let mut opt_props = Vec::new(); + let mut props = Vec::new(); + let v = Vec::new(); + // Function return values + for p in event.rules.iter() + .flat_map(|f| if let RuleKind::Function { to, .. } = f { + to + } else { + &v + }) { + opt_props.push((p.name.to_snake_case(), p.name.to_snake_case())); + } + + for p in event.rules.iter() { + if let RuleKind::Map { from, to, op } = p { + if *op != RuleOp::Update { + panic!("Cannot add or remove when adding a new struct"); + } + let transform_func = if to.is_set() { + // Convert to set + ".iter().cloned().collect()" + } else if !to.get_type()?.is_primitive() { + ".clone()" + } else { + "" + }; + let from_opt = from.is_opt(&event.msg); + if to.opt && !from_opt { + // to is optional, but from not + let getter = format!("Some(m.{}{})", from.get_rust_name(), transform_func); + props.push((to.name.to_snake_case(), getter)); + } else { + let getter = format!("m.{}{}", from.get_rust_name(), transform_func); + if from_opt && !to.opt { + opt_props.push((to.name.to_snake_case(), getter)); + } else { + props.push((to.name.to_snake_case(), getter)); + } + } + } + } + + if !opt_props.is_empty() { + let mut matcher = opt_props.iter().map(|(p, _)| format!("Some({})", p)).collect::>().join(", "); + let mut getter = opt_props.iter().map(|(_, p)| p.as_str()).collect::>().join(", "); + if opt_props.len() > 1 { + matcher = format!("({})", matcher); + getter = format!("({})", getter); + } + #> + if let <#= matcher #> = <#= getter #> { + <# } #> + let r = <#= event.book_struct.name #> { + <# + // Add ids + for (id, fld) in event.book_struct.id.iter().zip(event.id.iter()) { #> + <#= PropId::from(id).get_attr_name(&event.book_struct) #>: m.<#= fld.get_rust_name() #>.clone(), + <# } + for (p, _) in &opt_props { #> + <#= p #>, + <# } + for (p, g) in &props { + if p != g { #> + <#= p #>: <#= g #>, + <# } else { #> + <#= p #>, + <# } + } #> + }; + <# + let function_name = format!("replace_{}", book_name.to_snake_case()); + let ids = event.get_id_args("m"); + let comma = if ids.is_empty() { "" } else { ", " }; + #> + let old = self.<#= function_name #>(<#= ids #><#= comma #>r, &mut events)?; + <# create_event(_fmt, event, "Changed", true)?; + if !opt_props.is_empty() { #> + } + <# } + } else if event.op == RuleOp::Add { + // Create a new object + // First, call all functions + for fun in event.rules.iter().filter(|r| r.is_function()) { + if let RuleKind::Function { name, to } = fun { + let return_match = if to.len() == 1 { + to[0].name.to_snake_case() + } else { + format!("({})", to.iter().map(|p| p.name.to_snake_case()).collect::>().join(", ")) + }; #> + let <#= return_match #> = self.<#= name.to_snake_case() #>(m, &mut events)?; + <# } + } #> + let r = <#= event.book_struct.name #> { + <# + // Add ids + for (id, fld) in event.book_struct.id.iter().zip(event.id.iter()) { #> + <#= PropId::from(id).get_attr_name(&event.book_struct) #>: m.<#= fld.get_rust_name() #><# if !id.find_property(&self.book.structs).get_type()?.is_primitive() { #>.clone()<# } #>, + <# } + + let v = vec![]; + // Function return values + for p in event.rules.iter() + .flat_map(|f| if let RuleKind::Function { to, .. } = f { + to + } else { + &v + }) { #> + <#= p.name.to_snake_case() #>, + <# } + for p in event.rules.iter() { + if let RuleKind::Map { from, to, op } = p { + if *op != RuleOp::Update { + panic!("Cannot add or remove when adding a new struct"); + } + let transform_func = if to.is_set() { + // Convert to set + ".iter().cloned().collect()" + } else if !to.get_type()?.is_primitive() { + ".clone()" + } else { + "" + }; + // to is optional, but from not + let from_opt = from.is_opt(&event.msg); #> + <#= to.name.to_snake_case() #>: <# + if to.opt && !from_opt { + #>Some(m.<#= from.get_rust_name() #><#= transform_func #>), + <# } else { + #>m.<#= from.get_rust_name() #><#= transform_func #>, + <# } + } + } #> + }; + <# + // TODO Previous function end + let function_name = format!("add_{}", book_name.to_snake_case()); + let ids = event.get_id_args("m"); #> + self.<#= function_name #>(<#= ids #>, r, &mut events)?; + <# create_event(_fmt, event, "Added", false)?; + } #> +<# } #> + } +<# } #> + _ => { + // Ignore unmentioned messages + return Ok((false, events)); + } + } + Ok((true, events)) + } +} diff --git a/crates/proto/ts-bookkeeping/build/Properties.tt b/crates/proto/ts-bookkeeping/build/Properties.tt new file mode 100644 index 0000000..f0a0e1f --- /dev/null +++ b/crates/proto/ts-bookkeeping/build/Properties.tt @@ -0,0 +1,55 @@ +<#@ template cleanws="true" #> +impl Connection { + /// Get a property by its id. + pub fn get_property(&self, id: &PropertyId) -> Result> { + Ok(match id { +<# for struc in &self.0.structs { + let mut ids = embrace(&get_ids(struc)); + let mut ids2 = get_ids2(&self.0.structs, struc); + ids2 = format!("({})", ids2); #> + PropertyId::<#= struc.name #><#= ids #> => PropertyValueRef::<#= struc.name #>(self.get_<#= struc.name.to_snake_case() #><#= ids2 #>?), +<# } #> + +<# for struc in self.0.structs.iter().filter(|s| !s.opt) { + for p in struc.get_properties(&self.0.structs) { + let type_s = p.get_inner_type_as_name()?; + + let mut ids = get_ids(struc); + if p.modifier.is_some() { + if !ids.is_empty() { + ids.push_str(", "); + } + ids.push_str("m"); + } + ids = embrace(&ids); + + let mut ids2 = format!("({})", get_ids2(&self.0.structs, struc)); + #> + PropertyId::<#= struc.name #><#= p.get_name() #><#= ids + #> => PropertyValueRef::<#= type_s #>(self.get_<#= + struc.name.to_snake_case() #><#= ids2 #>?.<#= + p.name.to_snake_case() #><# + if p.modifier.as_ref().map(|s| s == "map").unwrap_or(false) { + #>.get(*m) + .ok_or_else(|| Error::NotFound("<#= p.name #>", m.to_string()))?<# + } else if p.modifier.as_ref().map(|s| s == "array").unwrap_or(false) { + #>.iter()<# + if p.type_s != "str" { #>.cloned().find(|i| i == m)<# + } else { #>.find(|i| *i == m)<# } #> + .ok_or_else(|| Error::NotFound("<#= p.name #>", m.to_string()))?<# + } else if p.modifier.as_ref().map(|s| s == "set").unwrap_or(false) { + #>.get(m)<# + if p.type_s != "str" { #>.cloned()<# } #> + .ok_or_else(|| Error::NotFound("<#= p.name #>", m.to_string()))?<# + } + + if p.opt && (p.type_s == "str" || p.type_s == "Uid") { + #>.as_ref().map(|r| r.as_ref())<# + } else if p.type_s == "str" || p.type_s == "Uid" || ["TalkPowerRequest", "EccKeyPubP256"].contains(&p.type_s.as_str()) { + #>.as_ref()<# + } #>), +<# } +} #> + }) + } +} diff --git a/crates/proto/ts-bookkeeping/build/book_parser.rs b/crates/proto/ts-bookkeeping/build/book_parser.rs new file mode 100644 index 0000000..9aec237 --- /dev/null +++ b/crates/proto/ts-bookkeeping/build/book_parser.rs @@ -0,0 +1,13 @@ +use std::default::Default; + +use t4rust_derive::Template; +use tsproto_structs::*; + +#[derive(Template)] +#[TemplatePath = "build/BookDeclarations.tt"] +#[derive(Debug)] +pub struct BookDeclarations<'a>(pub &'a book::BookDeclarations); + +impl Default for BookDeclarations<'static> { + fn default() -> Self { BookDeclarations(&tsproto_structs::book::DATA) } +} diff --git a/crates/proto/ts-bookkeeping/build/book_to_messages_parser.rs b/crates/proto/ts-bookkeeping/build/book_to_messages_parser.rs new file mode 100644 index 0000000..ac5d6c2 --- /dev/null +++ b/crates/proto/ts-bookkeeping/build/book_to_messages_parser.rs @@ -0,0 +1,71 @@ +use std::default::Default; +use std::ops::Deref; + +use heck::*; +use t4rust_derive::Template; +use tsproto_structs::book_to_messages::*; +use tsproto_structs::messages::Field; +use tsproto_structs::*; + +#[derive(Template)] +#[TemplatePath = "build/BookToMessages.tt"] +#[derive(Debug)] +pub struct BookToMessagesDeclarations<'a>(&'a book_to_messages::BookToMessagesDeclarations<'a>); + +impl<'a> Deref for BookToMessagesDeclarations<'a> { + type Target = book_to_messages::BookToMessagesDeclarations<'a>; + fn deref(&self) -> &Self::Target { self.0 } +} + +impl Default for BookToMessagesDeclarations<'static> { + fn default() -> Self { BookToMessagesDeclarations(&DATA) } +} + +fn get_to_list(to: &[&Field]) -> String { + let mut res = String::new(); + if to.len() > 1 { + res.push('('); + } + + let mut first = true; + for t in to { + if !first { + res.push_str(", "); + } else { + first = false; + } + res.push_str(&t.get_rust_name()); + } + + if to.len() > 1 { + res.push(')'); + } + res +} + +/// The prefix is written before from, if from is a mapped argument +fn rule_has_to(r: &RuleKind, field: &Field) -> bool { + match r { + RuleKind::Map { to, .. } | RuleKind::ArgumentMap { to, .. } => to == &field, + RuleKind::ArgumentFunction { to, .. } | RuleKind::Function { to, .. } => { + to.contains(&field) + } + } +} + +/// Finds a matching rule in either the event ids or the given rule. +fn find_rule<'a>( + e: &'a Event, r: Option<&'a RuleKind>, field: &Field, +) -> (bool, Option<&'a RuleKind<'a>>) { + if let Some(r) = r { + if rule_has_to(r, field) { + return (true, Some(r)); + } + } + for r in &e.ids { + if rule_has_to(r, field) { + return (false, Some(r)); + } + } + (false, None) +} diff --git a/crates/proto/ts-bookkeeping/build/build.rs b/crates/proto/ts-bookkeeping/build/build.rs new file mode 100644 index 0000000..e80cbc3 --- /dev/null +++ b/crates/proto/ts-bookkeeping/build/build.rs @@ -0,0 +1,52 @@ +use std::env; +use std::fs::File; +use std::io::prelude::*; +use std::path::Path; + +mod book_parser; +mod book_to_messages_parser; +mod events; +mod message_parser; +mod messages_to_book_parser; +mod properties; + +use crate::book_parser::BookDeclarations; +use crate::book_to_messages_parser::BookToMessagesDeclarations; +use crate::events::EventDeclarations; +use crate::message_parser::MessageDeclarations; +use crate::messages_to_book_parser::MessagesToBookDeclarations; +use crate::properties::Properties; + +fn main() { + let out_dir = env::var("OUT_DIR").unwrap(); + + // Book declarations + let path = Path::new(&out_dir); + let mut structs = File::create(path.join("structs.rs")).unwrap(); + write!(&mut structs, "{}", BookDeclarations::default()).unwrap(); + + // Messages to book + let mut structs = File::create(path.join("m2bdecls.rs")).unwrap(); + write!(&mut structs, "{}", MessagesToBookDeclarations::default()).unwrap(); + + // Write messages + let decls = MessageDeclarations::s2c(); + let mut structs = File::create(path.join("s2c_messages.rs")).unwrap(); + write!(&mut structs, "{}", MessageDeclarations(&decls)).unwrap(); + + let decls = MessageDeclarations::c2s(); + let mut structs = File::create(path.join("c2s_messages.rs")).unwrap(); + write!(&mut structs, "{}", MessageDeclarations(&decls)).unwrap(); + + // Book to messages + let mut structs = File::create(path.join("b2mdecls.rs")).unwrap(); + write!(&mut structs, "{}", BookToMessagesDeclarations::default()).unwrap(); + + // Events + let mut structs = File::create(path.join("events.rs")).unwrap(); + write!(&mut structs, "{}", EventDeclarations::default()).unwrap(); + + // Properties + let mut structs = File::create(path.join("properties.rs")).unwrap(); + write!(&mut structs, "{}", Properties::default()).unwrap(); +} diff --git a/crates/proto/ts-bookkeeping/build/events.rs b/crates/proto/ts-bookkeeping/build/events.rs new file mode 100644 index 0000000..0674fc0 --- /dev/null +++ b/crates/proto/ts-bookkeeping/build/events.rs @@ -0,0 +1,20 @@ +use std::collections::HashSet; +use std::default::Default; +use std::ops::Deref; + +use t4rust_derive::Template; +use tsproto_structs::book::*; + +#[derive(Template)] +#[TemplatePath = "build/Events.tt"] +#[derive(Debug)] +pub struct EventDeclarations<'a>(&'a BookDeclarations); + +impl<'a> Deref for EventDeclarations<'a> { + type Target = BookDeclarations; + fn deref(&self) -> &Self::Target { self.0 } +} + +impl Default for EventDeclarations<'static> { + fn default() -> Self { EventDeclarations(&DATA) } +} diff --git a/crates/proto/ts-bookkeeping/build/message_parser.rs b/crates/proto/ts-bookkeeping/build/message_parser.rs new file mode 100644 index 0000000..f1fc849 --- /dev/null +++ b/crates/proto/ts-bookkeeping/build/message_parser.rs @@ -0,0 +1,299 @@ +use std::default::Default; + +use itertools::Itertools; +use t4rust_derive::Template; +use tsproto_structs::messages::*; +use tsproto_structs::{indent, messages, InnerRustType, RustType}; + +#[derive(Template)] +#[TemplatePath = "build/MessageDeclarations.tt"] +#[derive(Debug, Clone)] +pub struct MessageDeclarations<'a>(pub &'a messages::MessageDeclarations); + +impl MessageDeclarations<'static> { + pub fn s2c() -> messages::MessageDeclarations { + let mut res = DATA.clone(); + res.msg_group.retain(|g| g.default.s2c); + res + } + + pub fn c2s() -> messages::MessageDeclarations { + let mut res = DATA.clone(); + res.msg_group.retain(|g| g.default.c2s); + res + } +} + +impl Default for MessageDeclarations<'static> { + fn default() -> Self { MessageDeclarations(&DATA) } +} + +pub fn generate_deserializer(field: &Field) -> String { + let rust_type = field.get_type("").unwrap(); + if let InnerRustType::Vec(inner) = rust_type.inner { + vector_value_deserializer(field, (*inner).into()) + } else { + single_value_deserializer(field, &rust_type.to_string()) + } +} + +pub fn single_value_deserializer(field: &Field, rust_type: &str) -> String { + let res = match rust_type { + "i8" | "u8" | "i16" | "u16" | "i32" | "u32" | "i64" | "u64" => format!( + "val.parse().map_err(|e| ParseError::ParseInt {{ + arg: \"{}\", + value: val.to_string(), + source: e, + }})?", + field.pretty + ), + "f32" | "f64" => format!( + "val.parse().map_err(|e| ParseError::ParseFloat {{ + arg: \"{}\", + value: val.to_string(), + source: e, + }})?", + field.pretty + ), + "bool" => format!( + "match val {{ \"0\" => false, \"1\" => true, _ => return Err(ParseError::ParseBool {{ + arg: \"{}\", + value: val.to_string(), + }}), }}", + field.pretty + ), + "UidBuf" => "UidBuf(if let Ok(uid) = BASE64_STANDARD.decode(val) { uid } else { \ + val.as_bytes().to_vec() })" + .into(), + "&str" => "val".into(), + "String" => "val.to_string()".into(), + "IconId" => format!( + "IconId(if val.starts_with('-') {{ + val.parse::().map(|i| i as u32) + }} else {{ + val.parse::().map(|i| i as u32) + }}.map_err(|e| ParseError::ParseInt {{ + arg: \"{}\", + value: val.to_string(), + source: e, + }})?)", + field.pretty + ), + "ClientId" | "ClientDbId" | "ChannelId" | "ServerGroupId" | "ChannelGroupId" => format!( + "{}(val.parse().map_err(|e| ParseError::ParseInt {{ + arg: \"{}\", + value: val.to_string(), + source: e, + }})?)", + rust_type, field.pretty + ), + "IpAddr" | "SocketAddr" => format!( + "val.parse().map_err(|e| ParseError::ParseAddr {{ + arg: \"{}\", + value: val.to_string(), + source: e, + }})?", + field.pretty + ), + "ClientType" => format!( + "match val {{ + \"0\" => ClientType::Normal, + \"1\" => ClientType::Query {{ admin: false }}, + _ => return Err(ParseError::InvalidValue {{ + arg: \"{}\", + value: val.to_string(), + }}), + }}", + field.pretty + ), + "TextMessageTargetMode" + | "HostMessageMode" + | "HostBannerMode" + | "LicenseType" + | "LogLevel" + | "Codec" + | "CodecEncryptionMode" + | "Reason" + | "GroupNamingMode" + | "GroupType" + | "Permission" + | "PermissionType" + | "TokenType" + | "PluginTargetMode" + | "Error" => format!( + "{}::from_u32(val.parse().map_err(|e| ParseError::ParseInt {{ + arg: \"{}\", + value: val.to_string(), + source: e, + }})?).ok_or(ParseError::InvalidValue {{ + arg: \"{1}\", + value: val.to_string(), + }})?", + rust_type, field.pretty + ), + "ChannelPermissionHint" | "ClientPermissionHint" => format!( + "{}::from_bits(val.parse().map_err(|e| ParseError::ParseInt {{ + arg: \"{}\", + value: val.to_string(), + source: e, + }})?).ok_or(ParseError::InvalidValue {{ + arg: \"{1}\", + value: val.to_string(), + }})?", + rust_type, field.pretty + ), + "Duration" => { + if field.type_s == "DurationSeconds" { + format!( + "let val = val.parse::().map_err(|e| ParseError::ParseInt {{ + arg: \"{}\", + value: val.to_string(), + source: e, + }})?; + if val.checked_mul(1000).is_some() {{ Duration::seconds(val) }} + else {{ return Err(ParseError::InvalidValue {{ + arg: \"{0}\", + value: val.to_string(), + }}); }}", + field.pretty + ) + } else if field.type_s == "DurationMilliseconds" { + format!( + "Duration::milliseconds(val.parse::().map_err(|e| ParseError::ParseInt \ + {{ + arg: \"{}\", + value: val.to_string(), + source: e, + }})?)", + field.pretty + ) + } else if field.type_s == "DurationMillisecondsFloat" { + format!( + "Duration::microseconds((1000.0 * val.parse::().map_err(|e| \ + ParseError::ParseFloat {{ + arg: \"{}\", + value: val.to_string(), + source: e, + }})?) as i64)", + field.pretty + ) + } else { + panic!("Unknown original time type {} found.", field.type_s); + } + } + "OffsetDateTime" => format!( + "OffsetDateTime::from_unix_timestamp( + val.parse().map_err(|e| ParseError::ParseInt {{ + arg: \"{}\", + value: val.to_string(), + source: e, + }})?).map_err(|e| ParseError::ParseDate {{ + arg: \"{}\", + value: val.to_string(), + source: e, + }})?", + field.pretty, field.pretty + ), + _ => panic!("Unknown type '{}' when trying to deserialize {:?}", rust_type, field), + }; + if res.contains('\n') { indent(&res, 2) } else { res } +} + +pub fn vector_value_deserializer(field: &Field, rust_type: RustType) -> String { + format!( + "val.split(',') + .filter_map(|val| {{ + let val = val.trim(); + if val.is_empty() {{ + None + }} else {{ + Some(val) + }} + }}).map(|val| {{ + let val = val.trim(); + Ok({}) + }}).collect::>>()?", + single_value_deserializer(field, &rust_type.to_string()), + rust_type, + ) +} + +pub fn generate_serializer(field: &Field, name: &str) -> String { + let rust_type = field.get_type("").unwrap(); + if let InnerRustType::Vec(inner) = rust_type.inner { + let inner_type: RustType = (*inner).into(); + vector_value_serializer(field, &inner_type.to_string(), name) + } else { + single_value_serializer(field, &rust_type.to_string(), name, false) + } +} + +pub fn single_value_serializer(field: &Field, rust_type: &str, name: &str, is_ref: bool) -> String { + let ref_amp = if is_ref { "" } else { "&" }; + let ref_star = if is_ref { "*" } else { "" }; + match rust_type { + "i8" | "u8" | "i16" | "u16" | "i32" | "u32" | "i64" | "u64" | "f32" | "f64" | "String" + | "IpAddr" | "SocketAddr" => format!("{}{}", ref_amp, name), + "bool" => format!("if {}{} {{ &\"1\" }} else {{ &\"0\" }}", ref_star, name), + "&str" => name.to_string(), + "UidBuf" | "&Uid" => format!( + "&if {0}.is_server_admin() {{ Cow::Borrowed(\"ServerAdmin\") }} + else {{ Cow::::Owned(BASE64_STANDARD.encode(&{0}.0)) }}", + name, + ), + "ClientId" | "ClientDbId" | "ChannelId" | "ServerGroupId" | "ChannelGroupId" | "IconId" => { + format!("&{}.0", name) + } + "ClientType" => format!( + "match {} {{ + ClientType::Normal => &\"0\", + ClientType::Query {{ .. }} => &\"1\", + }}", + name + ), + "TextMessageTargetMode" + | "HostMessageMode" + | "HostBannerMode" + | "LicenseType" + | "LogLevel" + | "Codec" + | "CodecEncryptionMode" + | "Reason" + | "GroupNamingMode" + | "GroupType" + | "Permission" + | "PermissionType" + | "TokenType" + | "PluginTargetMode" + | "Error" => format!("&{}.to_u32().unwrap()", name), + "ChannelPermissionHint" | "ClientPermissionHint" => format!("&{}.bits()", name), + "Duration" => { + if field.type_s == "DurationSeconds" { + format!("&{}.whole_seconds()", name) + } else if field.type_s == "DurationMilliseconds" { + format!("&{}.whole_milliseconds()", name) + } else if field.type_s == "DurationMillisecondsFloat" { + format!("&({}.whole_microseconds() as f32 / 1000.0)", name) + } else { + panic!("Unknown original time type {} found.", field.type_s); + } + } + "OffsetDateTime" => format!("&{}.unix_timestamp()", name), + _ => panic!("Unknown type '{}'", rust_type), + } +} + +pub fn vector_value_serializer(field: &Field, inner_type: &str, name: &str) -> String { + // TODO Vector serialization creates an intermediate string which is not necessary + format!( + "&{{ let mut s = String::new(); + for val in {}.as_ref() {{ + if !s.is_empty() {{ s += \",\" }} + write!(&mut s, \"{{}}\", {}).unwrap(); + }} + s + }}", + name, + single_value_serializer(field, inner_type, "val", true) + ) +} diff --git a/crates/proto/ts-bookkeeping/build/messages_to_book_parser.rs b/crates/proto/ts-bookkeeping/build/messages_to_book_parser.rs new file mode 100644 index 0000000..ad7a72c --- /dev/null +++ b/crates/proto/ts-bookkeeping/build/messages_to_book_parser.rs @@ -0,0 +1,28 @@ +use std::collections::HashMap; +use std::default::Default; +use std::ops::Deref; + +use heck::*; +use t4rust_derive::Template; +use tsproto_structs::book::{PropId, Property}; +use tsproto_structs::messages::Field; +use tsproto_structs::messages_to_book::*; +use tsproto_structs::*; + +#[derive(Template)] +#[TemplatePath = "build/MessagesToBook.tt"] +#[derive(Debug)] +pub struct MessagesToBookDeclarations<'a>(&'a messages_to_book::MessagesToBookDeclarations<'a>); + +impl<'a> Deref for MessagesToBookDeclarations<'a> { + type Target = messages_to_book::MessagesToBookDeclarations<'a>; + fn deref(&self) -> &Self::Target { self.0 } +} + +impl Default for MessagesToBookDeclarations<'static> { + fn default() -> Self { MessagesToBookDeclarations(&DATA) } +} + +fn get_property(p: &Property, name: &str) -> String { + format!("PropertyValue::{}({})", p.get_inner_type_as_name().unwrap(), name) +} diff --git a/crates/proto/ts-bookkeeping/build/properties.rs b/crates/proto/ts-bookkeeping/build/properties.rs new file mode 100644 index 0000000..d925d69 --- /dev/null +++ b/crates/proto/ts-bookkeeping/build/properties.rs @@ -0,0 +1,43 @@ +//! Access properties of a connection with the property structs from events. +use std::default::Default; +use std::fmt::Write; + +use heck::*; +use t4rust_derive::Template; +use tsproto_structs::book::*; +use tsproto_structs::embrace; + +#[derive(Template)] +#[TemplatePath = "build/Properties.tt"] +#[derive(Debug)] +pub struct Properties<'a>(&'a BookDeclarations); + +impl Default for Properties<'static> { + fn default() -> Self { Properties(&DATA) } +} + +fn get_ids(struc: &Struct) -> String { + let mut res = String::new(); + for i in 0..struc.id.len() { + if !res.is_empty() { + res.push_str(", "); + } + let _ = write!(res, "s{}", i); + } + res +} + +fn get_ids2(structs: &[Struct], struc: &Struct) -> String { + let mut res = String::new(); + for (i, id) in struc.id.iter().enumerate() { + let p = id.find_property(structs); + if !res.is_empty() { + res.push_str(", "); + } + if p.type_s != "str" { + res.push('*'); + } + let _ = write!(res, "s{}", i); + } + res +} diff --git a/crates/proto/ts-bookkeeping/src/data.rs b/crates/proto/ts-bookkeeping/src/data.rs new file mode 100644 index 0000000..3a5f3c2 --- /dev/null +++ b/crates/proto/ts-bookkeeping/src/data.rs @@ -0,0 +1,1051 @@ +use std::borrow::Cow; +use std::collections::{HashMap, HashSet}; +use std::net::{IpAddr, SocketAddr}; +use std::{iter, mem}; + +use serde::{Deserialize, Serialize}; +use time::{Duration, OffsetDateTime}; +use tsproto_packets::packets::OutCommand; +use tsproto_types::crypto::EccKeyPubP256; +use tsproto_types::*; + +use crate::events::{Event, ExtraInfo, PropertyId, PropertyValue, PropertyValueRef}; +use crate::messages::s2c::InMessage; +use crate::messages::{c2s, s2c}; +use crate::{Error, MessageTarget, Result}; + +include!(concat!(env!("OUT_DIR"), "/m2bdecls.rs")); +include!(concat!(env!("OUT_DIR"), "/structs.rs")); +include!(concat!(env!("OUT_DIR"), "/properties.rs")); + +pub mod exts { + use super::*; + + include!(concat!(env!("OUT_DIR"), "/b2mdecls.rs")); +} + +macro_rules! max_clients { + ($msg:ident) => {{ + if $msg.is_max_clients_unlimited.unwrap_or_default() { + Some(MaxClients::Unlimited) + } else if $msg.max_clients.map(|i| i >= 0 && i <= u16::MAX as i32).unwrap_or_default() { + Some(MaxClients::Limited($msg.max_clients.unwrap() as u16)) + } else { + // Max clients is less than zero or too high so ignore it + None + } + }}; +} + +macro_rules! copy_attrs { + ($from:ident, $to:ident; $($attr:ident),* $(,)*; $($extra:ident: $ex:expr),* $(,)*) => { + $to { + $($attr: $from.$attr.clone(),)* + $($extra: $ex,)* + } + }; +} + +impl Connection { + pub fn new(public_key: EccKeyPubP256, msg: &s2c::InInitServer) -> Self { + let packet = msg.iter().next().unwrap(); + Self { + own_client: packet.client_id, + server: copy_attrs!(packet, Server; + administrative_domain, + ask_for_privilegekey, + codec_encryption_mode, + created, + default_channel_group, + default_server_group, + hostbanner_gfx_interval, + hostbanner_gfx_url, + hostbanner_mode, + hostbanner_url, + hostbutton_gfx_url, + hostbutton_tooltip, + hostbutton_url, + hostmessage_mode, + hostmessage, + icon, + max_clients, + name, + nickname, + phonetic_name, + platform, + priority_speaker_dimm_modificator, + protocol_version, + temp_channel_default_delete_delay, + version, + welcome_message, + ; + + id: packet.virtual_server_id, + public_key: public_key, + ips: packet.ips.clone().unwrap_or_default(), + // TODO Get from license struct + license: LicenseType::NoLicense, + + optional_data: None, + connection_data: None, + ), + clients: HashMap::new(), + channels: HashMap::new(), + channel_groups: HashMap::new(), + server_groups: HashMap::new(), + } + } + + pub fn handle_command(&mut self, msg: &s2c::InMessage) -> Result<(Vec, bool)> { + // Returns if it handled the message so we can warn if a message is + // unhandled. + let (mut handled, mut events) = self.handle_command_generated(msg)?; + // Handle special messages + match msg { + InMessage::TextMessage(msg) => { + for msg in msg.iter() { + let target = match msg.target { + TextMessageTargetMode::Server => MessageTarget::Server, + TextMessageTargetMode::Channel => MessageTarget::Channel, + TextMessageTargetMode::Client => { + let client = if let Some(client) = msg.target_client_id { + client + } else { + return Err(Error::MessageWithoutTargetClientId); + }; + MessageTarget::Client(client) + } + TextMessageTargetMode::Unknown => { + return Err(Error::UnknownTextMessageTargetMode); + } + }; + events.push(Event::Message { + target, + invoker: Invoker { + name: msg.invoker_name.clone(), + id: msg.invoker_id, + uid: msg.invoker_uid.clone(), + }, + message: msg.message.to_string(), + }); + handled = true; + } + } + InMessage::ClientPoke(msg) => { + for msg in msg.iter() { + events.push(Event::Message { + target: MessageTarget::Poke(msg.invoker_id), + invoker: Invoker { + name: msg.invoker_name.clone(), + id: msg.invoker_id, + uid: msg.invoker_uid.clone(), + }, + message: msg.message.to_string(), + }); + handled = true; + } + } + InMessage::CommandError(_) => handled = true, + _ => {} + } + + if let Some(invoker) = events.first().and_then(Event::get_invoker) { + // If we know this client and the name change, adjust the name. + if let Ok(client) = self.get_mut_client(invoker.id) { + if client.name != invoker.name { + let old = mem::replace(&mut client.name, invoker.name.clone()); + events.push(Event::PropertyChanged { + id: PropertyId::ClientName(client.id), + old: PropertyValue::String(old), + invoker: None, + extra: ExtraInfo { reason: None }, + }); + } + } + } + + Ok((events, handled)) + } + + fn get_server(&self) -> Result<&Server> { Ok(&self.server) } + fn get_mut_server(&mut self) -> Result<&mut Server> { Ok(&mut self.server) } + + fn get_channel_group(&self, group: ChannelGroupId) -> Result<&ChannelGroup> { + self.channel_groups + .get(&group) + .ok_or_else(|| Error::NotFound("ChannelGroup", group.to_string())) + } + fn add_channel_group( + &mut self, group: ChannelGroupId, r: ChannelGroup, _: &mut Vec, + ) -> Result> { + Ok(self.channel_groups.insert(group, r)) + } + fn get_server_group(&self, group: ServerGroupId) -> Result<&ServerGroup> { + self.server_groups + .get(&group) + .ok_or_else(|| Error::NotFound("ServerGroup", group.to_string())) + } + fn add_server_group( + &mut self, group: ServerGroupId, r: ServerGroup, _: &mut Vec, + ) -> Result> { + Ok(self.server_groups.insert(group, r)) + } + + fn get_optional_server_data(&self) -> Result> { + Ok(self.server.optional_data.as_ref()) + } + fn replace_optional_server_data( + &mut self, r: OptionalServerData, _: &mut Vec, + ) -> Result> { + Ok(mem::replace(&mut self.server.optional_data, Some(r))) + } + fn remove_optional_server_data( + &mut self, _: &mut Vec, + ) -> Result> { + Ok(self.server.optional_data.take()) + } + + fn get_connection_server_data(&self) -> Result> { + Ok(self.server.connection_data.as_ref()) + } + fn replace_connection_server_data( + &mut self, r: ConnectionServerData, _: &mut Vec, + ) -> Result> { + Ok(mem::replace(&mut self.server.connection_data, Some(r))) + } + + fn get_connection(&self) -> Result<&Connection> { Ok(self) } + + fn get_client(&self, client: ClientId) -> Result<&Client> { + self.clients.get(&client).ok_or_else(|| Error::NotFound("Client", client.to_string())) + } + fn get_mut_client(&mut self, client: ClientId) -> Result<&mut Client> { + self.clients.get_mut(&client).ok_or_else(|| Error::NotFound("Client", client.to_string())) + } + fn add_client( + &mut self, client: ClientId, r: Client, _: &mut Vec, + ) -> Result> { + Ok(self.clients.insert(client, r)) + } + fn remove_client(&mut self, client: ClientId, _: &mut Vec) -> Result> { + Ok(self.clients.remove(&client)) + } + + fn get_connection_client_data( + &self, client: ClientId, + ) -> Result> { + if let Some(c) = self.clients.get(&client) { + Ok(c.connection_data.as_ref()) + } else { + Err(Error::NotFound("Client", client.to_string())) + } + } + fn replace_connection_client_data( + &mut self, client: ClientId, r: ConnectionClientData, _: &mut Vec, + ) -> Result> { + if let Some(client) = self.clients.get_mut(&client) { + Ok(mem::replace(&mut client.connection_data, Some(r))) + } else { + Err(Error::NotFound("Client", client.to_string())) + } + } + + fn get_optional_client_data(&self, client: ClientId) -> Result> { + if let Some(c) = self.clients.get(&client) { + Ok(c.optional_data.as_ref()) + } else { + Err(Error::NotFound("Client", client.to_string())) + } + } + fn replace_optional_client_data( + &mut self, client: ClientId, r: OptionalClientData, _: &mut Vec, + ) -> Result> { + if let Some(c) = self.clients.get_mut(&client) { + Ok(mem::replace(&mut c.optional_data, Some(r))) + } else { + Err(Error::NotFound("Client", client.to_string())) + } + } + + fn get_channel(&self, channel: ChannelId) -> Result<&Channel> { + self.channels.get(&channel).ok_or_else(|| Error::NotFound("Channel", channel.to_string())) + } + fn get_mut_channel(&mut self, channel: ChannelId) -> Result<&mut Channel> { + self.channels + .get_mut(&channel) + .ok_or_else(|| Error::NotFound("Channel", channel.to_string())) + } + fn add_channel( + &mut self, channel: ChannelId, r: Channel, events: &mut Vec, + ) -> Result> { + self.channel_order_insert(r.id, r.order, r.parent, events); + Ok(self.channels.insert(channel, r)) + } + fn remove_channel( + &mut self, channel: ChannelId, events: &mut Vec, + ) -> Result> { + let old = self.channels.remove(&channel); + if let Some(ch) = &old { + self.channel_order_remove(ch.id, ch.order, events); + } + Ok(old) + } + + fn get_optional_channel_data( + &self, channel: ChannelId, + ) -> Result> { + if let Some(c) = self.channels.get(&channel) { + Ok(c.optional_data.as_ref()) + } else { + Err(Error::NotFound("Channel", channel.to_string())) + } + } + fn replace_optional_channel_data( + &mut self, channel: ChannelId, r: OptionalChannelData, _: &mut Vec, + ) -> Result> { + if let Some(c) = self.channels.get_mut(&channel) { + Ok(mem::replace(&mut c.optional_data, Some(r))) + } else { + Err(Error::NotFound("Channel", channel.to_string())) + } + } + fn remove_optional_channel_data( + &mut self, channel: ChannelId, _: &mut Vec, + ) -> Result> { + if let Some(c) = self.channels.get_mut(&channel) { + Ok(c.optional_data.take()) + } else { + Err(Error::NotFound("Channel", channel.to_string())) + } + } + + // Backing functions for MessageToBook declarations + + fn return_false(&self, _: T, _: &mut Vec) -> Result { Ok(false) } + fn return_none(&self, _: T, _: &mut Vec) -> Result> { Ok(None) } + fn return_some_none(&self, _: T, _: &mut Vec) -> Result>> { + Ok(Some(None)) + } + fn void_fun(&self, _: T, _: U, _: V) -> Result<()> { Ok(()) } + + fn max_clients_cc_fun( + &self, msg: &s2c::InChannelCreatedPart, _: &mut Vec, + ) -> Result<(Option, Option)> { + let ch = max_clients!(msg); + let ch_fam = if msg.is_max_family_clients_unlimited.unwrap_or_default() { + Some(MaxClients::Unlimited) + } else if msg.inherits_max_family_clients.unwrap_or_default() { + Some(MaxClients::Inherited) + } else if msg.max_family_clients.map(|i| i >= 0 && i <= u16::MAX as i32).unwrap_or_default() + { + Some(MaxClients::Limited(msg.max_family_clients.unwrap() as u16)) + } else { + // Max clients is less than zero or too high so ignore it + None + }; + Ok((ch, ch_fam)) + } + fn max_clients_ce_fun( + &mut self, channel_id: ChannelId, msg: &s2c::InChannelEditedPart, events: &mut Vec, + ) -> Result<()> { + let channel = self.get_mut_channel(channel_id)?; + + let ch = max_clients!(msg); + if let Some(ch) = ch { + events.push(Event::PropertyChanged { + id: PropertyId::ChannelMaxClients(channel_id), + old: PropertyValue::OptionMaxClients(channel.max_clients.take()), + invoker: msg.get_invoker(), + extra: ExtraInfo { reason: Some(msg.reason) }, + }); + channel.max_clients = Some(ch); + } + let ch_fam = if msg.is_max_family_clients_unlimited.unwrap_or_default() { + Some(MaxClients::Unlimited) + } else if msg.inherits_max_family_clients.unwrap_or_default() { + Some(MaxClients::Inherited) + } else if msg.max_family_clients.map(|i| i >= 0 && i <= u16::MAX as i32).unwrap_or_default() + { + Some(MaxClients::Limited(msg.max_family_clients.unwrap() as u16)) + } else { + // Max clients is less than zero or too high so ignore it + None + }; + if let Some(ch_fam) = ch_fam { + events.push(Event::PropertyChanged { + id: PropertyId::ChannelMaxFamilyClients(channel_id), + old: PropertyValue::OptionMaxClients(channel.max_family_clients.take()), + invoker: msg.get_invoker(), + extra: ExtraInfo { reason: Some(msg.reason) }, + }); + channel.max_family_clients = Some(ch_fam); + } + Ok(()) + } + fn max_clients_cl_fun( + &self, msg: &s2c::InChannelListPart, _: &mut Vec, + ) -> Result<(Option, Option)> { + let max_clients: i32 = msg.max_clients; + let ch = if msg.is_max_clients_unlimited { + Some(MaxClients::Unlimited) + } else if max_clients >= 0 && max_clients <= u16::MAX as i32 { + Some(MaxClients::Limited(max_clients as u16)) + } else { + // Max clients is less than zero or too high so ignore it + None + }; + + let max_clients: i32 = msg.max_family_clients; + let ch_fam = if msg.is_max_family_clients_unlimited { + Some(MaxClients::Unlimited) + } else if msg.inherits_max_family_clients { + Some(MaxClients::Inherited) + } else if max_clients >= 0 && max_clients <= u16::MAX as i32 { + Some(MaxClients::Limited(max_clients as u16)) + } else { + // Max clients is less than zero or too high so ignore it + Some(MaxClients::Unlimited) + }; + Ok((ch, ch_fam)) + } + + fn channel_type_cc_fun( + &self, msg: &s2c::InChannelCreatedPart, _: &mut Vec, + ) -> Result { + Ok(Self::channel_flags_to_type(msg.is_permanent, msg.is_semi_permanent)) + } + + fn channel_type_ce_fun( + &mut self, channel_id: ChannelId, msg: &s2c::InChannelEditedPart, events: &mut Vec, + ) -> Result<()> { + let channel = self.get_mut_channel(channel_id)?; + + if msg.is_permanent.is_none() && msg.is_semi_permanent.is_none() { + return Ok(()); + } + + let typ = Self::channel_flags_to_type(msg.is_permanent, msg.is_semi_permanent); + events.push(Event::PropertyChanged { + id: PropertyId::ChannelChannelType(channel_id), + old: PropertyValue::ChannelType(channel.channel_type), + invoker: msg.get_invoker(), + extra: ExtraInfo { reason: Some(msg.reason) }, + }); + channel.channel_type = typ; + Ok(()) + } + + fn channel_type_cl_fun( + &self, msg: &s2c::InChannelListPart, _: &mut Vec, + ) -> Result { + Ok(Self::channel_flags_to_type(Some(msg.is_permanent), Some(msg.is_semi_permanent))) + } + + fn channel_flags_to_type(perm: Option, semi: Option) -> ChannelType { + match (perm.unwrap_or_default(), semi.unwrap_or_default()) { + (true, _) => ChannelType::Permanent, + (_, true) => ChannelType::SemiPermanent, + (false, false) => ChannelType::Temporary, + } + } + + fn channel_codec_cc_fun( + &self, msg: &s2c::InChannelCreatedPart, _: &mut Vec, + ) -> Result { + Ok(msg.codec.unwrap_or(Codec::OpusVoice)) + } + + fn away_cev_fun( + &self, msg: &s2c::InClientEnterViewPart, _: &mut Vec, + ) -> Result> { + if msg.is_away { Ok(Some(msg.away_message.clone())) } else { Ok(None) } + } + + fn client_type_cev_fun( + &self, msg: &s2c::InClientEnterViewPart, _: &mut Vec, + ) -> Result { + if msg.uid.is_server_admin() { + if let ClientType::Query { .. } = msg.client_type { + return Ok(ClientType::Query { admin: true }); + } + } + Ok(msg.client_type) + } + + fn away_cu_fun( + &mut self, client_id: ClientId, msg: &s2c::InClientUpdatedPart, events: &mut Vec, + ) -> Result<()> { + let client = self.get_mut_client(client_id)?; + + if let Some(is_away) = msg.is_away { + if is_away != client.away_message.is_some() { + let away = + if is_away { Some(msg.away_message.clone().unwrap_or_default()) } else { None }; + events.push(Event::PropertyChanged { + id: PropertyId::ClientAwayMessage(client_id), + old: PropertyValue::OptionString(client.away_message.take()), + invoker: msg.get_invoker(), + extra: ExtraInfo { reason: None }, + }); + client.away_message = away; + } + } else if let Some(away_message) = &msg.away_message { + if let Some(cur_msg) = &client.away_message { + if away_message != cur_msg { + events.push(Event::PropertyChanged { + id: PropertyId::ClientAwayMessage(client_id), + old: PropertyValue::OptionString(client.away_message.take()), + invoker: msg.get_invoker(), + extra: ExtraInfo { reason: None }, + }); + client.away_message = Some(away_message.clone()); + } + } + } + Ok(()) + } + + fn talk_power_cev_fun( + &self, msg: &s2c::InClientEnterViewPart, _: &mut Vec, + ) -> Result> { + if msg.talk_power_request_time.unix_timestamp() > 0 { + Ok(Some(TalkPowerRequest { + time: msg.talk_power_request_time, + message: msg.talk_power_request_message.clone(), + })) + } else { + Ok(None) + } + } + + fn talk_power_cu_fun( + &mut self, client_id: ClientId, msg: &s2c::InClientUpdatedPart, events: &mut Vec, + ) -> Result<()> { + if let Some(talk_request) = msg.talk_power_request_time { + let client = self.get_mut_client(client_id)?; + + let talk_request = if talk_request.unix_timestamp() > 0 { + Some(TalkPowerRequest { + time: talk_request, + message: msg.talk_power_request_message.clone().unwrap_or_default(), + }) + } else { + None + }; + events.push(Event::PropertyChanged { + id: PropertyId::ClientTalkPowerRequest(client_id), + old: PropertyValue::OptionTalkPowerRequest(client.talk_power_request.take()), + invoker: msg.get_invoker(), + extra: ExtraInfo { reason: None }, + }); + client.talk_power_request = talk_request; + } + Ok(()) + } + + fn address_fun( + &self, msg: &s2c::InClientConnectionInfoPart, _: &mut Vec, + ) -> Result>> { + if let (Some(ip), Some(port)) = (&msg.ip, &msg.port) { + if !ip.is_empty() { + return Ok(Some(Some(SocketAddr::new( + ip.trim_matches(&['[', ']'][..]).parse().map_err(Error::InvalidConnectionIp)?, + *port, + )))); + } + } + Ok(Some(None)) + } + + fn channel_subscribe_fun( + &mut self, channel_id: ChannelId, _: &s2c::InChannelSubscribedPart, events: &mut Vec, + ) -> Result<()> { + let channel = self.get_mut_channel(channel_id)?; + events.push(Event::PropertyChanged { + id: PropertyId::ChannelSubscribed(channel_id), + old: PropertyValue::Bool(channel.subscribed), + invoker: None, + extra: ExtraInfo { reason: None }, + }); + channel.subscribed = true; + Ok(()) + } + + fn channel_unsubscribe_fun( + &mut self, channel_id: ChannelId, _: &s2c::InChannelUnsubscribedPart, + events: &mut Vec, + ) -> Result<()> { + let channel = self.get_mut_channel(channel_id)?; + events.push(Event::PropertyChanged { + id: PropertyId::ChannelSubscribed(channel_id), + old: PropertyValue::Bool(channel.subscribed), + invoker: None, + extra: ExtraInfo { reason: None }, + }); + channel.subscribed = false; + + // Remove all known clients from this channel + let remove_clients = self + .clients + .values() + .filter_map(|c| if c.channel == channel_id { Some(c.id) } else { None }) + .collect::>(); + for id in remove_clients { + events.push(Event::PropertyRemoved { + id: PropertyId::Client(id), + old: PropertyValue::Client(self.clients.remove(&id).unwrap()), + invoker: None, + extra: ExtraInfo { reason: None }, + }); + } + Ok(()) + } + + fn channel_order_remove( + &mut self, channel_id: ChannelId, channel_order: ChannelId, events: &mut Vec, + ) { + // [ C:7 | O:_ ] + // [ C:5 | O:7 ] ─>X + // [ C:_ | O:5 ] (Upd: O -> 7) + self.channels.values_mut().any(|c| { + if c.order == channel_id && c.id != channel_id { + events.push(Event::PropertyChanged { + id: PropertyId::ChannelOrder(c.id), + old: PropertyValue::ChannelId(c.order), + invoker: None, + extra: ExtraInfo { reason: None }, + }); + c.order = channel_order; + true + } else { + false + } + }); + } + + fn channel_order_insert( + &mut self, channel_id: ChannelId, channel_order: ChannelId, channel_parent: ChannelId, + events: &mut Vec, + ) { + // [ C:7 | O:_ ] + // [ <── (New: C:5 | O:7) + // [ C:_ | O:7 ] (Upd: O -> 5) + // + // Also work for the first channel, the order will be 0. + self.channels.values_mut().any(|c| { + if c.order == channel_order && c.parent == channel_parent && c.id != channel_id { + events.push(Event::PropertyChanged { + id: PropertyId::ChannelOrder(c.id), + old: PropertyValue::ChannelId(c.order), + invoker: None, + extra: ExtraInfo { reason: None }, + }); + c.order = channel_id; + true + } else { + false + } + }); + } + + fn channel_order_cc_fun( + &mut self, msg: &s2c::InChannelCreatedPart, events: &mut Vec, + ) -> Result { + self.channel_order_insert(msg.channel_id, msg.order, msg.parent_id, events); + Ok(msg.order) + } + + fn channel_order_ce_fun( + &mut self, channel_id: ChannelId, msg: &s2c::InChannelEditedPart, events: &mut Vec, + ) -> Result<()> { + self.channel_order_move_fun(channel_id, msg.order, msg.parent_id, events) + } + + fn channel_order_cm_fun( + &mut self, channel_id: ChannelId, msg: &s2c::InChannelMovedPart, events: &mut Vec, + ) -> Result<()> { + self.channel_order_move_fun(channel_id, Some(msg.order), Some(msg.parent_id), events) + } + + fn channel_order_move_fun( + &mut self, channel_id: ChannelId, new_order: Option, parent: Option, + events: &mut Vec, + ) -> Result<()> { + if new_order.is_some() || parent.is_some() { + let old_order; + let new_parent; + { + let channel = self.get_mut_channel(channel_id)?; + old_order = channel.order; + new_parent = parent.unwrap_or(channel.parent); + if let Some(order) = new_order { + events.push(Event::PropertyChanged { + id: PropertyId::ChannelOrder(channel.id), + old: PropertyValue::ChannelId(channel.order), + invoker: None, + extra: ExtraInfo { reason: None }, + }); + channel.order = order; + } + } + self.channel_order_remove(channel_id, old_order, events); + self.channel_order_insert( + channel_id, + new_order.unwrap_or(old_order), + new_parent, + events, + ); + } + Ok(()) + } + + fn subscribe_channel_fun( + &mut self, client_id: ClientId, msg: &s2c::InClientMovedPart, events: &mut Vec, + ) -> Result<()> { + if client_id == self.own_client && msg.target_channel_id.0 != 0 { + let channel = self.get_mut_channel(msg.target_channel_id)?; + events.push(Event::PropertyChanged { + id: PropertyId::ChannelSubscribed(msg.target_channel_id), + old: PropertyValue::Bool(channel.subscribed), + invoker: None, + extra: ExtraInfo { reason: None }, + }); + channel.subscribed = true; + } + Ok(()) + } + + // Book to messages + fn away_fun_b2m(msg: Option<&str>) -> (bool, &str) { + if let Some(msg) = msg { (true, msg) } else { (false, "") } + } +} + +impl Client { + // Book to messages + fn password_b2m(password: &str) -> String { + tsproto_types::crypto::encode_password(password.as_bytes()) + } + fn channel_id_b2m(&self, channel: ChannelId) -> ChannelId { channel } + + pub fn send_textmessage(&self, message: &str) -> OutCommand { + c2s::OutSendTextMessageMessage::new(&mut iter::once(c2s::OutSendTextMessagePart { + target: TextMessageTargetMode::Client, + target_client_id: Some(self.id), + message: message.into(), + })) + } + + pub fn poke(&self, message: &str) -> OutCommand { + c2s::OutClientPokeRequestMessage::new(&mut iter::once(c2s::OutClientPokeRequestPart { + client_id: self.id, + message: message.into(), + })) + } +} + +impl Channel { + // Book to messages + fn password_b2m(&self, password: &str) -> String { + tsproto_types::crypto::encode_password(password.as_bytes()) + } + + fn password_b2m2(password: &str) -> String { + tsproto_types::crypto::encode_password(password.as_bytes()) + } + + fn password_flagged_b2m(password: Option<&str>) -> (bool, Cow<'static, str>) { + if let Some(password) = password { + (true, tsproto_types::crypto::encode_password(password.as_bytes()).into()) + } else { + (false, "".into()) + } + } + + fn channel_type_fun_b2m(channel_type: ChannelType) -> (bool, bool) { + match channel_type { + ChannelType::Temporary => (false, false), + ChannelType::SemiPermanent => (true, false), + ChannelType::Permanent => (false, true), + } + } + + fn max_clients_fun_b2m(max_clients: MaxClients) -> (i32, bool) { + match max_clients { + MaxClients::Inherited => (0, false), + MaxClients::Unlimited => (0, true), + MaxClients::Limited(num) => (num.into(), false), + } + } + + fn max_family_clients_fun_b2m(max_clients: MaxClients) -> (i32, bool, bool) { + match max_clients { + MaxClients::Inherited => (0, false, true), + MaxClients::Unlimited => (0, true, false), + MaxClients::Limited(num) => (num.into(), false, false), + } + } + + fn channel_id_b2m(&self, channel: ChannelId) -> ChannelId { channel } + + pub fn set_subscribed(&self, subscribed: bool) -> OutCommand { + if subscribed { + c2s::OutChannelSubscribeMessage::new(&mut iter::once(c2s::OutChannelSubscribePart { + channel_id: self.id, + })) + } else { + c2s::OutChannelUnsubscribeMessage::new(&mut iter::once( + c2s::OutChannelUnsubscribePart { channel_id: self.id }, + )) + } + } +} + +/// The `ChannelOptions` are used to set initial properties of a new channel. +/// +/// A channel can be created with [`ServerMut::add_channel`]. The only necessary +/// property of a channel is the name, all other properties will be set to their +/// default value. +#[derive(Debug, Deserialize, Eq, PartialEq, Serialize)] +pub struct ChannelOptions<'a> { + name: &'a str, + description: Option<&'a str>, + parent_id: Option, + codec: Option, + codec_quality: Option, + delete_delay: Option, + password: Option<&'a str>, + is_default: bool, + max_clients: Option, + max_family_clients: Option, + channel_type: Option, + is_unencrypted: Option, + order: Option, + phonetic_name: Option<&'a str>, + topic: Option<&'a str>, +} + +impl<'a> ChannelOptions<'a> { + /// Create new `ChannelOptions` to add a new channel to a server. + /// + /// # Arguments + /// You have to supply a name for the new channel. All other properties are + /// optional. + pub fn new(name: &'a str) -> Self { + Self { + name, + description: None, + parent_id: None, + codec: None, + codec_quality: None, + delete_delay: None, + password: None, + is_default: false, + max_clients: None, + max_family_clients: None, + channel_type: None, + is_unencrypted: None, + order: None, + phonetic_name: None, + topic: None, + } + } + + pub fn description(mut self, description: &'a str) -> Self { + self.description = Some(description); + self + } + + pub fn parent_id(mut self, parent_id: ChannelId) -> Self { + self.parent_id = Some(parent_id); + self + } + + pub fn codec(mut self, codec: Codec) -> Self { + self.codec = Some(codec); + self + } + + pub fn codec_quality(mut self, codec_quality: u8) -> Self { + self.codec_quality = Some(codec_quality); + self + } + + pub fn delete_delay(mut self, delete_delay: Duration) -> Self { + self.delete_delay = Some(delete_delay); + self + } + + pub fn password(mut self, password: &'a str) -> Self { + self.password = Some(password); + self + } + + pub fn default(mut self) -> Self { + self.is_default = true; + self + } + + pub fn max_clients(mut self, max_clients: MaxClients) -> Self { + self.max_clients = Some(max_clients); + self + } + + pub fn max_family_clients(mut self, max_family_clients: MaxClients) -> Self { + self.max_family_clients = Some(max_family_clients); + self + } + + pub fn channel_type(mut self, channel_type: ChannelType) -> Self { + self.channel_type = Some(channel_type); + self + } + + pub fn is_unencrypted(mut self, is_unencrypted: bool) -> Self { + self.is_unencrypted = Some(is_unencrypted); + self + } + + /// The previous order + pub fn order(mut self, order: ChannelId) -> Self { + self.order = Some(order); + self + } + + pub fn phonetic_name(mut self, phonetic_name: &'a str) -> Self { + self.phonetic_name = Some(phonetic_name); + self + } + + pub fn topic(mut self, topic: &'a str) -> Self { + self.topic = Some(topic); + self + } +} + +impl Server { + pub fn add_channel(&self, options: ChannelOptions) -> OutCommand { + let inherits_max_family_clients = options + .max_family_clients + .as_ref() + .and_then(|m| if let MaxClients::Inherited = m { Some(true) } else { None }); + let is_max_family_clients_unlimited = options + .max_family_clients + .as_ref() + .and_then(|m| if let MaxClients::Unlimited = m { Some(true) } else { None }); + let max_family_clients = options + .max_family_clients + .as_ref() + .and_then(|m| if let MaxClients::Limited(n) = m { Some(*n as i32) } else { None }); + let is_max_clients_unlimited = options + .max_clients + .as_ref() + .and_then(|m| if let MaxClients::Unlimited = m { Some(true) } else { None }); + let max_clients = options + .max_clients + .as_ref() + .and_then(|m| if let MaxClients::Limited(n) = m { Some(*n as i32) } else { None }); + + let is_permanent = options + .channel_type + .as_ref() + .and_then(|t| if *t == ChannelType::Permanent { Some(true) } else { None }); + let is_semi_permanent = options + .channel_type + .as_ref() + .and_then(|t| if *t == ChannelType::SemiPermanent { Some(true) } else { None }); + + c2s::OutChannelCreateMessage::new(&mut iter::once(c2s::OutChannelCreatePart { + name: options.name.into(), + description: options.description.map(Into::into), + parent_id: options.parent_id, + codec: options.codec, + codec_quality: options.codec_quality, + delete_delay: options.delete_delay, + has_password: if options.password.is_some() { Some(true) } else { None }, + is_default: if options.is_default { Some(true) } else { None }, + inherits_max_family_clients, + is_max_family_clients_unlimited, + is_max_clients_unlimited, + is_permanent, + is_semi_permanent, + max_family_clients, + max_clients, + is_unencrypted: options.is_unencrypted, + order: options.order, + password: options + .password + .map(|p| tsproto_types::crypto::encode_password(p.as_bytes()).into()), + phonetic_name: options.phonetic_name.map(Into::into), + topic: options.topic.map(Into::into), + })) + } + + pub fn send_textmessage(&self, message: &str) -> OutCommand { + c2s::OutSendTextMessageMessage::new(&mut iter::once(c2s::OutSendTextMessagePart { + target: TextMessageTargetMode::Server, + target_client_id: None, + message: message.into(), + })) + } + + /// Subscribe or unsubscribe from all channels. + pub fn set_subscribed(&self, subscribed: bool) -> OutCommand { + if subscribed { + c2s::OutChannelSubscribeAllMessage::new() + } else { + c2s::OutChannelUnsubscribeAllMessage::new() + } + } + + fn zero_channel_id(&self) -> ChannelId { ChannelId(0) } + + fn empty_string(&self) -> &'static str { "" } + + // Book to messages + fn password_b2m(password: Option<&str>) -> Cow<'static, str> { + if let Some(password) = password { + tsproto_types::crypto::encode_password(password.as_bytes()).into() + } else { + "".into() + } + } +} + +impl Connection { + pub fn send_message(&self, target: MessageTarget, message: &str) -> OutCommand { + match target { + MessageTarget::Server => { + c2s::OutSendTextMessageMessage::new(&mut iter::once(c2s::OutSendTextMessagePart { + target: TextMessageTargetMode::Server, + target_client_id: None, + message: message.into(), + })) + } + MessageTarget::Channel => { + c2s::OutSendTextMessageMessage::new(&mut iter::once(c2s::OutSendTextMessagePart { + target: TextMessageTargetMode::Channel, + target_client_id: None, + message: message.into(), + })) + } + MessageTarget::Client(id) => { + c2s::OutSendTextMessageMessage::new(&mut iter::once(c2s::OutSendTextMessagePart { + target: TextMessageTargetMode::Client, + target_client_id: Some(id), + message: message.into(), + })) + } + MessageTarget::Poke(id) => c2s::OutClientPokeRequestMessage::new(&mut iter::once( + c2s::OutClientPokeRequestPart { client_id: id, message: message.into() }, + )), + } + } + + pub fn disconnect(&self, options: crate::DisconnectOptions) -> OutCommand { + c2s::OutDisconnectMessage::new(&mut iter::once(c2s::OutDisconnectPart { + reason: options.reason, + reason_message: options.message.map(Into::into), + })) + } +} diff --git a/crates/proto/ts-bookkeeping/src/events.rs b/crates/proto/ts-bookkeeping/src/events.rs new file mode 100644 index 0000000..cc2b703 --- /dev/null +++ b/crates/proto/ts-bookkeeping/src/events.rs @@ -0,0 +1,79 @@ +use serde::{Deserialize, Serialize}; +use time::{Duration, OffsetDateTime}; +use tsproto_types::crypto::EccKeyPubP256; + +use crate::data::{ + Channel, ChannelGroup, Client, Connection, ConnectionClientData, ConnectionServerData, + OptionalChannelData, OptionalClientData, OptionalServerData, Server, ServerGroup, +}; +use crate::*; + +include!(concat!(env!("OUT_DIR"), "/events.rs")); + +/// Additional data for some events. +#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)] +pub struct ExtraInfo { + /// Set for e.g. new clients to distinguish if they joined or are made available because we + /// subscribed to a channel. + pub reason: Option, +} + +/// An event gets fired when something in the data structure of a connection +/// changes or something happens like we receive a text message or get poked. +#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] +pub enum Event { + /// The object with this id was added. + /// + /// You can find the new object inside the connection data structure. + /// + /// Like a client gets assigned a new server group or a new client joins the + /// server. + PropertyAdded { id: PropertyId, invoker: Option, extra: ExtraInfo }, + /// The attribute with this id has changed. + /// + /// The second tuple item holds the old value of the changed attribute. + /// + /// E.g. a client changes its nickname or switches to another channel. + PropertyChanged { + id: PropertyId, + old: PropertyValue, + invoker: Option, + extra: ExtraInfo, + }, + /// The object with this id was removed. + /// + /// The object is not accessible anymore in the connection data structure, + /// but the second tuple item holds the removed object. + /// + /// This happens when a client leaves the server (including our own client) + /// or a channel is removed. + PropertyRemoved { + id: PropertyId, + old: PropertyValue, + invoker: Option, + extra: ExtraInfo, + }, + + Message { + /// Where this message was sent to, in the server or channel chat or + /// directly to client. + /// + /// This is our own client for private messages from others. + target: MessageTarget, + /// The user who wrote the message. + invoker: Invoker, + /// The content of the message. + message: String, + }, +} + +impl Event { + pub fn get_invoker(&self) -> Option<&Invoker> { + match self { + Event::PropertyAdded { invoker, .. } + | Event::PropertyChanged { invoker, .. } + | Event::PropertyRemoved { invoker, .. } => invoker.as_ref(), + Event::Message { invoker, .. } => Some(invoker), + } + } +} diff --git a/crates/proto/ts-bookkeeping/src/lib.rs b/crates/proto/ts-bookkeeping/src/lib.rs new file mode 100644 index 0000000..6051de8 --- /dev/null +++ b/crates/proto/ts-bookkeeping/src/lib.rs @@ -0,0 +1,246 @@ +//! `ts-bookkeeping` contains structs to store the state of a TeamSpeak server, with its clients and +//! channels. +//! +//! The crate can be used to keep track of the state on a server by processing all incoming +//! commands, which is why it is called “bookkeeping”. It also contains generated structs for all +//! TeamSpeak commands. +//! +//! Incoming commands can be applied to the state and generate [`events`]. The main struct is +//! [`data::Connection`]. +//! +//! The structs have methods to create packets for various actions. The generated packets can be +//! sent to a server. + +use std::fmt; +use std::net::{IpAddr, SocketAddr}; + +use serde::{Deserialize, Serialize}; +use thiserror::Error; + +pub mod data; +pub mod events; +pub mod messages; + +// Reexports +pub use tsproto_types::errors::Error as TsError; +pub use tsproto_types::versions::Version; +pub use tsproto_types::{ + ChannelGroupId, ChannelId, ChannelPermissionHint, ChannelType, ClientDbId, ClientId, + ClientPermissionHint, ClientType, Codec, CodecEncryptionMode, GroupNamingMode, GroupType, + HostBannerMode, HostMessageMode, IconId, Invoker, InvokerRef, LicenseType, LogLevel, + MaxClients, Permission, PermissionType, PluginTargetMode, Reason, ServerGroupId, + TalkPowerRequest, TextMessageTargetMode, TokenType, Uid, UidBuf, +}; + +type Result = std::result::Result; + +#[derive(Error, Debug)] +#[non_exhaustive] +pub enum Error { + #[error("Target client id missing for a client text message")] + MessageWithoutTargetClientId, + #[error("Unknown TextMessageTargetMode")] + UnknownTextMessageTargetMode, + #[error("{0} {1} not found")] + NotFound(&'static str, String), + #[error("{0} should be removed but does not exist")] + RemoveNotFound(&'static str), + #[error("Failed to parse connection ip: {0}")] + InvalidConnectionIp(#[source] std::net::AddrParseError), +} + +#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] +pub enum ServerAddress { + SocketAddr(SocketAddr), + Other(String), +} + +impl From for ServerAddress { + fn from(addr: SocketAddr) -> Self { ServerAddress::SocketAddr(addr) } +} + +impl From for ServerAddress { + fn from(addr: String) -> Self { ServerAddress::Other(addr) } +} + +impl<'a> From<&'a str> for ServerAddress { + fn from(addr: &'a str) -> Self { ServerAddress::Other(addr.to_string()) } +} + +impl fmt::Display for ServerAddress { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + ServerAddress::SocketAddr(a) => fmt::Display::fmt(a, f), + ServerAddress::Other(a) => fmt::Display::fmt(a, f), + } + } +} + +/// All possible targets to send messages. +#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)] +pub enum MessageTarget { + Server, + Channel, + Client(ClientId), + Poke(ClientId), +} + +/// The configuration to create a new connection. +#[derive(Deserialize, Serialize)] +pub struct ConnectOptions { + address: ServerAddress, + local_address: Option, + name: String, + version: Version, + log_commands: bool, + log_packets: bool, + log_udp_packets: bool, +} + +impl ConnectOptions { + /// Start creating the configuration of a new connection. + /// + /// # Arguments + /// The address of the server has to be supplied. The address can be a + /// [`SocketAddr`](std::net::SocketAddr), a string or directly a [`ServerAddress`]. A string + /// will automatically be resolved from all formats supported by TeamSpeak. + /// For details, see [`resolver::resolve`]. + #[inline] + pub fn new>(address: A) -> Self { + Self { + address: address.into(), + local_address: None, + name: String::from("TeamSpeakUser"), + version: Version::Linux_3_2_1, + log_commands: false, + log_packets: false, + log_udp_packets: false, + } + } + + /// The address for the socket of our client + /// + /// # Default + /// The default is `0.0.0:0` when connecting to an IPv4 address and `[::]:0` + /// when connecting to an IPv6 address. + #[inline] + pub fn local_address(mut self, local_address: SocketAddr) -> Self { + self.local_address = Some(local_address); + self + } + + /// The name of the user. + /// + /// # Default + /// `TeamSpeakUser` + #[inline] + pub fn name(mut self, name: String) -> Self { + self.name = name; + self + } + + /// The displayed version of the client. + /// + /// # Default + /// `3.2.1 on Linux` + #[inline] + pub fn version(mut self, version: Version) -> Self { + self.version = version; + self + } + + /// If the content of all commands should be written to the logger. + /// + /// # Default + /// `false` + #[inline] + pub fn log_commands(mut self, log_commands: bool) -> Self { + self.log_commands = log_commands; + self + } + + /// If the content of all packets in high-level form should be written to + /// the logger. + /// + /// # Default + /// `false` + #[inline] + pub fn log_packets(mut self, log_packets: bool) -> Self { + self.log_packets = log_packets; + self + } + + /// If the content of all udp packets in byte-array form should be written + /// to the logger. + /// + /// # Default + /// `false` + #[inline] + pub fn log_udp_packets(mut self, log_udp_packets: bool) -> Self { + self.log_udp_packets = log_udp_packets; + self + } +} + +impl fmt::Debug for ConnectOptions { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + // Error if attributes are added + let ConnectOptions { + address, + local_address, + name, + version, + log_commands, + log_packets, + log_udp_packets, + } = self; + write!( + f, + "ConnectOptions {{ address: {:?}, local_address: {:?}, name: {}, version: {}, \ + log_commands: {}, log_packets: {}, log_udp_packets: {} }}", + address, local_address, name, version, log_commands, log_packets, log_udp_packets, + )?; + Ok(()) + } +} + +#[derive(Clone, Debug, Deserialize, Serialize)] +pub struct DisconnectOptions { + reason: Option, + message: Option, +} + +impl Default for DisconnectOptions { + #[inline] + fn default() -> Self { Self { reason: None, message: None } } +} + +impl DisconnectOptions { + #[inline] + pub fn new() -> Self { Self::default() } + + /// Set the reason for leaving. + /// + /// # Default + /// + /// None + #[inline] + pub fn reason(mut self, reason: Reason) -> Self { + self.reason = Some(reason); + self + } + + /// Set the leave message. + /// + /// You also have to set the reason, otherwise the message will not be + /// displayed. + /// + /// # Default + /// + /// None + #[inline] + pub fn message>(mut self, message: S) -> Self { + self.message = Some(message.into()); + self + } +} diff --git a/crates/proto/ts-bookkeeping/src/messages.rs b/crates/proto/ts-bookkeeping/src/messages.rs new file mode 100644 index 0000000..0b15cfb --- /dev/null +++ b/crates/proto/ts-bookkeeping/src/messages.rs @@ -0,0 +1,80 @@ +use std::net::IpAddr; + +use thiserror::Error; +use time::{Duration, OffsetDateTime}; +use tsproto_packets::commands::CommandParser; +use tsproto_packets::packets::{Direction, InHeader, OutCommand, PacketType}; +use tsproto_types::errors::Error; + +use crate::*; + +type Result = std::result::Result; + +#[derive(Error, Debug)] +#[non_exhaustive] +pub enum ParseError { + #[error(transparent)] + Base64(#[from] base64::DecodeError), + + #[error("Parameter {arg} not found in {name}")] + ParameterNotFound { arg: &'static str, name: &'static str }, + #[error("Parameter {arg} not found in {name}")] + ParameterNotFound2 { arg: String, name: String }, + #[error("Command {0} is unknown")] + UnknownCommand(String), + #[error(transparent)] + StringParse(#[from] std::str::Utf8Error), + #[error(transparent)] + TsProto(#[from] tsproto_packets::Error), + /// Gets thrown when parsing a specific command with the wrong input. + #[error("Command {0} is wrong")] + WrongCommand(String), + #[error("Wrong newprotocol flag ({0})")] + WrongNewprotocol(bool), + #[error("Wrong packet type {0:?}")] + WrongPacketType(PacketType), + #[error("Wrong direction {0:?}")] + WrongDirection(Direction), + #[error("Cannot parse \"{value}\" as int for parameter {arg} ({source})")] + ParseInt { arg: &'static str, value: String, source: std::num::ParseIntError }, + #[error("Cannot parse \"{value}\" as SocketAddr for parameter {arg} ({source})")] + ParseAddr { arg: &'static str, value: String, source: std::net::AddrParseError }, + #[error("Cannot parse \"{value}\" as float for parameter {arg} ({source})")] + ParseFloat { arg: &'static str, value: String, source: std::num::ParseFloatError }, + #[error("Cannot parse \"{value}\" as bool for parameter {arg}")] + ParseBool { arg: &'static str, value: String }, + #[error("Cannot parse \"{value}\" as SocketAddr for parameter {arg} ({source})")] + ParseUid { arg: &'static str, value: String, source: base64::DecodeError }, + #[error("Cannot parse \"{value}\" as DateTimeOffset for parameter {arg} ({source})")] + ParseDate { arg: &'static str, value: String, source: time::error::ComponentRange }, + #[error("Invalid value \"{value}\" for parameter {arg}")] + InvalidValue { arg: &'static str, value: String }, +} + +pub trait InMessageTrait { + fn new(header: &InHeader, args: CommandParser) -> Result + where Self: Sized; +} + +pub trait OutMessageTrait { + fn to_packet(self) -> OutCommand; +} + +pub trait OutMessageWithReturnTrait { + fn to_packet(self, return_code: Option<&str>) -> OutCommand; +} + +impl OutMessageTrait for OutCommand { + fn to_packet(self) -> OutCommand { self } +} + +pub mod s2c { + #![allow(mismatched_lifetime_syntaxes)] + use super::*; + include!(concat!(env!("OUT_DIR"), "/s2c_messages.rs")); +} +pub mod c2s { + #![allow(mismatched_lifetime_syntaxes)] + use super::*; + include!(concat!(env!("OUT_DIR"), "/c2s_messages.rs")); +} diff --git a/crates/proto/tsclientlib/Cargo.toml b/crates/proto/tsclientlib/Cargo.toml new file mode 100644 index 0000000..a58f145 --- /dev/null +++ b/crates/proto/tsclientlib/Cargo.toml @@ -0,0 +1,64 @@ +[package] +name = "tsclientlib" +version = "0.2.0" +authors = ["Flakebi "] +description = "A library to create TeamSpeak clients and bots." +repository = "https://github.com/ReSpeak/tsclientlib" +readme = "README.md" +keywords = ["teamspeak3", "ts3", "voip"] +categories = ["multimedia"] +license = "MIT OR Apache-2.0" +edition = "2018" +include = [ + "/Cargo.toml", + "/README.md", + "**/*.rs", +] + +[package.metadata.docs.rs] +features = ["unstable"] + +[features] +default = ["audio", "default-tls"] +# Enable the unstable api +unstable = [] +audio = ["audiopus"] +# Enable default reqwest features. +# Use default-features=false on tsclientlib to configure reqwest differently. +default-tls = ["reqwest/charset", "reqwest/default-tls", "reqwest/http2"] +# Use API of audiopus fork at https://github.com/Flakebi/audiopus for more features +audiopus-unstable = [] + +[dependencies] +audiopus = { version = "0.3.0-rc.0", optional = true } +base64 = "0.22" +futures = "0.3" +git-testament = "0.2" +itertools = "0.14" +num-traits = "0.2" +pin-utils = "0.1" +rand = "0.10" +reqwest = { version = "0.13", default-features = false } +thiserror = "2" +time = "0.3" +tokio = { version = "1", features = ["time"] } +tokio-stream = "0.1" +tracing = "0.1" +hickory-net = "0.26" +hickory-resolver = "0.26" +ts-bookkeeping = { path = "../utils/ts-bookkeeping", version = "0.1" } +tsproto = { path = "../tsproto", version = "0.2" } +tsproto-packets = { path = "../utils/tsproto-packets", version = "0.1" } +tsproto-types = { path = "../utils/tsproto-types", version = "0.1" } +url = "2" + +[dev-dependencies] +anyhow = "1" +audiopus = "0.3.0-rc.0" +cpal = "0.18" +once_cell = "1" +quickcheck = "1" +quickcheck_macros = "1" +clap = { version = "4", features = ["derive"] } +tokio = { version = "1", features = ["io-util", "net", "rt-multi-thread", "rt", "signal"] } +tracing-subscriber = "0.3" diff --git a/crates/proto/tsclientlib/README.md b/crates/proto/tsclientlib/README.md new file mode 100644 index 0000000..15bd30f --- /dev/null +++ b/crates/proto/tsclientlib/README.md @@ -0,0 +1,21 @@ +# TsClientlib [![docs.rs](https://docs.rs/tsclientlib/badge.svg)](https://docs.rs/tsclientlib) +tsclientlib is a library which makes it simple to create TeamSpeak clients +and bots. + +For a full client application, you might want to have a look at [Qint]. + +If more power over the internals of a connection is needed, the `unstable` feature can be +enabled. Beware that functionality behind this feature may change on any minor release. + +The base class of this library is the [`Connection`]. One instance of this +struct manages a single connection to a server. + +[Qint]: https://github.com/ReSpeak/Qint + +## License +Licensed under either of + + * [Apache License, Version 2.0](../LICENSE-APACHE) + * [MIT license](../LICENSE-MIT) + +at your option. diff --git a/crates/proto/tsclientlib/README.tpl b/crates/proto/tsclientlib/README.tpl new file mode 100644 index 0000000..da985f2 --- /dev/null +++ b/crates/proto/tsclientlib/README.tpl @@ -0,0 +1,10 @@ +# TsClientlib [![docs.rs](https://docs.rs/tsclientlib/badge.svg)](https://docs.rs/tsclientlib) +{{readme}} + +## License +Licensed under either of + + * [Apache License, Version 2.0](../LICENSE-APACHE) + * [MIT license](../LICENSE-MIT) + +at your option. diff --git a/crates/proto/tsclientlib/examples/audio-latency.rs b/crates/proto/tsclientlib/examples/audio-latency.rs new file mode 100644 index 0000000..5ca49ca --- /dev/null +++ b/crates/proto/tsclientlib/examples/audio-latency.rs @@ -0,0 +1,66 @@ +use anyhow::Result; +use clap::Parser; +use tokio::sync::mpsc; +use tokio::task::LocalSet; +use tracing::{debug, info}; + +use tsclientlib::ClientId; +use tsproto_packets::packets::{Direction, InAudioBuf}; + +mod audio_utils; + +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] +struct ConnectionId(u64); + +#[derive(Parser, Debug)] +#[command(author, about)] +struct Args { + /// The volume for the capturing + #[arg(default_value_t = 1.0)] + volume: f32, +} + +#[tokio::main] +async fn main() -> Result<()> { real_main().await } + +async fn real_main() -> Result<()> { + tracing_subscriber::fmt::init(); + + // Parse command line options + let args = Args::parse(); + + let con_id = ConnectionId(0); + let local_set = LocalSet::new(); + let audiodata = audio_utils::start(&local_set)?; + + let (send, mut recv) = mpsc::channel(1); + { + let mut a2t = audiodata.a2ts.lock().unwrap(); + a2t.set_listener(send); + a2t.set_volume(args.volume); + a2t.set_playing(true); + } + + let t2a = audiodata.ts2a.clone(); + loop { + // Wait for ctrl + c + tokio::select! { + send_audio = recv.recv() => { + if let Some(packet) = send_audio { + let from = ClientId(0); + let mut t2a = t2a.lock().unwrap(); + let in_audio = InAudioBuf::try_new(Direction::C2S, packet.into_vec()).unwrap(); + if let Err(error) = t2a.play_packet((con_id, from), in_audio) { + debug!(%error, "Failed to play packet"); + } + } else { + info!("Audio sending stream was canceled"); + break; + } + } + _ = tokio::signal::ctrl_c() => { break; } + }; + } + + Ok(()) +} diff --git a/crates/proto/tsclientlib/examples/audio.rs b/crates/proto/tsclientlib/examples/audio.rs new file mode 100644 index 0000000..94ca7e8 --- /dev/null +++ b/crates/proto/tsclientlib/examples/audio.rs @@ -0,0 +1,127 @@ +//! This example connects to a teamspeak instance and joins a channel. +//! The connected bot-identity will listen on your microphone and send everything to the current +//! channel. In parallel, the program will play back all other clients in the channel via its own +//! audio output. +//! Microphone -> Channel +//! Channel -> PC Speakers + +use anyhow::{bail, Result}; +use clap::Parser; +use futures::prelude::*; +use tokio::sync::mpsc; +use tokio::task::LocalSet; +use tracing::{debug, info}; + +use tsclientlib::{ClientId, Connection, DisconnectOptions, Identity, StreamItem}; +use tsproto_packets::packets::AudioData; + +mod audio_utils; + +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] +struct ConnectionId(u64); + +#[derive(Parser, Debug)] +#[command(author, about)] +struct Args { + /// The address of the server to connect to + #[arg(short, long, default_value = "localhost")] + address: String, + /// The volume for the capturing + #[arg(default_value_t = 1.0)] + volume: f32, + /// Print the content of all packets + /// + /// 0. Print nothing + /// 1. Print command string + /// 2. Print packets + /// 3. Print udp packets + #[arg(short, long, action = clap::ArgAction::Count)] + verbose: u8, +} + +#[tokio::main] +async fn main() -> Result<()> { real_main().await } + +async fn real_main() -> Result<()> { + tracing_subscriber::fmt::init(); + + // Parse command line options + let args = Args::parse(); + + let con_id = ConnectionId(0); + let local_set = LocalSet::new(); + let audiodata = audio_utils::start(&local_set)?; + + let con_config = Connection::build(args.address) + .log_commands(args.verbose >= 1) + .log_packets(args.verbose >= 2) + .log_udp_packets(args.verbose >= 3); + + // Optionally set the key of this client, otherwise a new key is generated. + let id = Identity::new_from_str( + "MG0DAgeAAgEgAiAIXJBlj1hQbaH0Eq0DuLlCmH8bl+veTAO2+\ + k9EQjEYSgIgNnImcmKo7ls5mExb6skfK2Tw+u54aeDr0OP1ITs\ + C/50CIA8M5nmDBnmDM/gZ//4AAAAAAAAAAAAAAAAAAAAZRzOI").unwrap(); + let con_config = con_config.identity(id); + + // Connect + let mut con = con_config.connect()?; + + let r = con + .events() + .try_filter(|e| future::ready(matches!(e, StreamItem::BookEvents(_)))) + .next() + .await; + if let Some(r) = r { + r?; + } + + let (send, mut recv) = mpsc::channel(5); + { + let mut a2t = audiodata.a2ts.lock().unwrap(); + a2t.set_listener(send); + a2t.set_volume(args.volume); + a2t.set_playing(true); + } + + loop { + let t2a = audiodata.ts2a.clone(); + let events = con.events().try_for_each(|e| async { + if let StreamItem::Audio(packet) = e { + let from = ClientId(match packet.data().data() { + AudioData::S2C { from, .. } => *from, + AudioData::S2CWhisper { from, .. } => *from, + _ => panic!("Can only handle S2C packets but got a C2S packet"), + }); + let mut t2a = t2a.lock().unwrap(); + if let Err(error) = t2a.play_packet((con_id, from), packet) { + debug!(%error, "Failed to play packet"); + } + } + Ok(()) + }); + + // Wait for ctrl + c + tokio::select! { + send_audio = recv.recv() => { + if let Some(packet) = send_audio { + con.send_audio(packet)?; + } else { + info!("Audio sending stream was canceled"); + break; + } + } + _ = tokio::signal::ctrl_c() => { break; } + r = events => { + r?; + bail!("Disconnected"); + } + }; + } + + // Disconnect + con.disconnect(DisconnectOptions::new())?; + con.events().for_each(|_| future::ready(())).await; + + Ok(()) +} diff --git a/crates/proto/tsclientlib/examples/audio_utils/audio_to_ts.rs b/crates/proto/tsclientlib/examples/audio_utils/audio_to_ts.rs new file mode 100644 index 0000000..7c61b2a --- /dev/null +++ b/crates/proto/tsclientlib/examples/audio_utils/audio_to_ts.rs @@ -0,0 +1,184 @@ +use std::sync::atomic::{AtomicU32, Ordering}; +use std::sync::{Arc, Mutex}; + +use anyhow::{Result, format_err}; +use audiopus::coder::Encoder; +use cpal::traits::{DeviceTrait, StreamTrait}; +use cpal::{Device, Stream, StreamConfig}; +use futures::prelude::*; +use tokio::sync::mpsc; +use tokio::task::LocalSet; +use tokio::time::{self, Duration}; +use tokio_stream::wrappers::IntervalStream; +use tracing::{debug, error, instrument, warn}; +use tsproto_packets::packets::{AudioData, CodecType, OutAudio, OutPacket}; + +use super::*; + +pub struct AudioToTs { + device: Device, + listener: Arc>>>, + stream: Option, + + is_playing: bool, + /// Storing an f32 + volume: Arc, +} + +struct Callback { + listener: Arc>>>, + encoder: Encoder, + /// Storing an f32 + volume: Arc, + + tmp_buffer: [f32; USUAL_FRAME_SIZE * 2], + opus_output: [u8; MAX_OPUS_FRAME_SIZE], +} + +impl AudioToTs { + pub fn new(device: Device, local_set: &LocalSet) -> Result>> { + let listener = Arc::new(Mutex::new(Default::default())); + let volume = Arc::new(AtomicU32::new(1.0_f32.to_bits())); + + let res = Arc::new(Mutex::new(Self { + device, + listener, + stream: None, + + is_playing: false, + volume, + })); + + Self::start(res.clone(), local_set); + + Ok(res) + } + + #[instrument(skip(self))] + fn open_capture(&self) -> Result { + let config = StreamConfig { + channels: 1, + sample_rate: 48000, + buffer_size: cpal::BufferSize::Fixed(USUAL_FRAME_SIZE as u32), + }; + + let encoder = Encoder::new( + audiopus::SampleRate::Hz48000, + audiopus::Channels::Mono, + audiopus::Application::Voip, + ) + .expect("Could not create encoder"); + let mut callback = Callback { + listener: self.listener.clone(), + encoder, + volume: self.volume.clone(), + + tmp_buffer: [0.0; _], + opus_output: [0; _], + }; + + self.device + .build_input_stream( + config, + move |audio_data, _| callback.callback(audio_data), + |error| error!(%error, "Error during audio capture"), + Some(Duration::from_secs(5)), + ) + .map_err(|e| format_err!("cpal error: {}", e)) + } + + pub fn set_listener(&self, sender: mpsc::Sender) { + let mut listener = self.listener.lock().unwrap(); + *listener = Some(sender); + } + + pub fn set_volume(&mut self, volume: f32) { + self.volume.store(volume.to_bits(), Ordering::Relaxed); + } + + pub fn set_playing(&mut self, playing: bool) { + if let Some(stream) = &self.stream { + if playing { + if let Err(error) = stream.play() { + error!(%error, "Failed to start stream"); + self.stream = None; + } else { + self.is_playing = true; + } + } else { + if let Err(error) = stream.pause() { + error!(%error, "Failed to pause stream"); + self.stream = None; + } + self.is_playing = false; + } + } + } + + #[instrument(skip(a2t, local_set))] + fn start(a2t: Arc>, local_set: &LocalSet) { + local_set.spawn_local( + IntervalStream::new(time::interval(Duration::from_secs(1))).for_each(move |_| { + let mut a2t = a2t.lock().unwrap(); + + if a2t.stream.is_none() { + // Try to reconnect to audio + match a2t.open_capture() { + Ok(s) => { + a2t.stream = Some(s); + debug!("Reconnected to capture device"); + if a2t.is_playing { + a2t.set_playing(true); + } + } + Err(error) => { + error!(%error, "Failed to open capture device"); + } + }; + } + + future::ready(()) + }), + ); + } +} + +impl Callback { + #[instrument(skip(self, buffer))] + fn callback<'a>(&'a mut self, mut buffer: &'a [f32]) { + // Handle volume + let volume = f32::from_bits(self.volume.load(Ordering::Relaxed)); + if volume != 1.0 { + if self.tmp_buffer.len() < buffer.len() { + warn!("tmp buffer len smaller than received capture buffer, dropping data"); + } + for (dst, src) in self.tmp_buffer.iter_mut().zip(buffer.iter()) { + *dst = *src * volume; + } + buffer = &self.tmp_buffer[..buffer.len()]; + } + + match self.encoder.encode_float(buffer, &mut self.opus_output[..]) { + Err(error) => { + error!(%error, "Failed to encode opus"); + } + Ok(len) => { + // Create packet + let packet = OutAudio::new(&AudioData::C2S { + id: 0, + codec: CodecType::OpusVoice, + data: &self.opus_output[..len], + }); + + // Write into packet sink + let mut listener = self.listener.lock().unwrap(); + if let Some(lis) = &mut *listener { + match lis.try_send(packet) { + Err(mpsc::error::TrySendError::Closed(_)) => *listener = None, + _ => {} + } + } + } + } + } +} diff --git a/crates/proto/tsclientlib/examples/audio_utils/mod.rs b/crates/proto/tsclientlib/examples/audio_utils/mod.rs new file mode 100644 index 0000000..2680be3 --- /dev/null +++ b/crates/proto/tsclientlib/examples/audio_utils/mod.rs @@ -0,0 +1,37 @@ +use std::sync::{Arc, Mutex}; + +use anyhow::Result; +use cpal::traits::HostTrait; +use tokio::task::LocalSet; + +use audio_to_ts::AudioToTs; +use ts_to_audio::TsToAudio; + +pub mod audio_to_ts; +pub mod ts_to_audio; + +/// The usual frame size. +/// +/// Use 48 kHz, 20 ms frames (50 per second) and mono data (1 channel). +/// This means 1920 samples and 7.5 kiB. +const USUAL_FRAME_SIZE: usize = 48000 / 50; + +/// The maximum size of an opus frame is 1275 as from RFC6716. +const MAX_OPUS_FRAME_SIZE: usize = 1275; + +#[derive(Clone)] +pub struct AudioData { + pub a2ts: Arc>, + pub ts2a: Arc>, +} + +pub(crate) fn start(local_set: &LocalSet) -> Result { + let host = cpal::default_host(); + let output_device = host.default_output_device().unwrap(); + let input_device = host.default_input_device().unwrap(); + + let ts2a = TsToAudio::new(output_device, local_set)?; + let a2ts = AudioToTs::new(input_device, local_set)?; + + Ok(AudioData { a2ts, ts2a }) +} diff --git a/crates/proto/tsclientlib/examples/audio_utils/ts_to_audio.rs b/crates/proto/tsclientlib/examples/audio_utils/ts_to_audio.rs new file mode 100644 index 0000000..53622ea --- /dev/null +++ b/crates/proto/tsclientlib/examples/audio_utils/ts_to_audio.rs @@ -0,0 +1,138 @@ +use std::sync::{Arc, Mutex}; + +use anyhow::{Result, format_err}; +use cpal::traits::{DeviceTrait, StreamTrait}; +use cpal::{Device, Stream, StreamConfig}; +use futures::prelude::*; +use tokio::task::LocalSet; +use tokio::time::{self, Duration}; +use tokio_stream::wrappers::IntervalStream; +use tracing::{debug, error, instrument}; +use tsclientlib::ClientId; +use tsproto_packets::packets::InAudioBuf; + +use super::*; +use crate::ConnectionId; + +type Id = (ConnectionId, ClientId); +type AudioHandler = tsclientlib::audio::AudioHandler; + +pub struct TsToAudio { + device: Device, + stream: Option, + is_playing: bool, + data: Arc>, +} + +struct Callback { + data: Arc>, +} + +impl TsToAudio { + pub fn new(device: Device, local_set: &LocalSet) -> Result>> { + let data = Arc::new(Mutex::new(AudioHandler::new())); + + let res = Arc::new(Mutex::new(Self { device, stream: None, is_playing: false, data })); + + Self::start(res.clone(), local_set); + + Ok(res) + } + + #[instrument(skip(self))] + fn open_playback(&self) -> Result { + let config = StreamConfig { + channels: 2, + sample_rate: 48000, + buffer_size: cpal::BufferSize::Fixed(USUAL_FRAME_SIZE as u32), + }; + + let mut callback = Callback { data: self.data.clone() }; + + self.device + .build_output_stream( + config, + move |audio_data, _| callback.callback(audio_data), + |error| error!(%error, "Error during audio playback"), + Some(Duration::from_secs(5)), + ) + .map_err(|e| format_err!("cpal error: {}", e)) + } + + #[instrument(skip(t2a, local_set))] + fn start(t2a: Arc>, local_set: &LocalSet) { + local_set.spawn_local( + IntervalStream::new(time::interval(Duration::from_secs(1))).for_each(move |_| { + let mut t2a = t2a.lock().unwrap(); + + if t2a.stream.is_none() { + // Try to reconnect to audio + match t2a.open_playback() { + Ok(s) => { + t2a.stream = Some(s); + t2a.is_playing = false; + debug!("Reconnected to playback device"); + } + Err(error) => { + error!(%error, "Failed to open playback device"); + } + }; + } + + if let Some(stream) = &t2a.stream { + let data_empty = t2a.data.lock().unwrap().get_queues().is_empty(); + if !t2a.is_playing && !data_empty { + debug!("Resuming playback"); + if let Err(error) = stream.play() { + error!(%error, "Failed to start stream"); + t2a.stream = None; + } else { + t2a.is_playing = true; + } + } else if t2a.is_playing && data_empty { + debug!("Pausing playback"); + if let Err(error) = stream.pause() { + error!(%error, "Failed to pause stream"); + t2a.stream = None; + } + t2a.is_playing = false; + } + } + future::ready(()) + }), + ); + } + + #[instrument(skip(self, id, packet))] + pub(crate) fn play_packet(&mut self, id: Id, packet: InAudioBuf) -> Result<()> { + { + let mut data = self.data.lock().unwrap(); + data.handle_packet(id, packet)?; + } + + if !self.is_playing { + if let Some(stream) = &self.stream { + debug!("Resuming playback"); + if let Err(error) = stream.play() { + error!(%error, "Failed to start stream"); + self.stream = None; + } else { + self.is_playing = true; + } + } + } + Ok(()) + } +} + +impl Callback { + fn callback(&mut self, buffer: &mut [f32]) { + // Clear buffer + for d in &mut *buffer { + *d = 0.0; + } + + let mut data = self.data.lock().unwrap(); + data.fill_buffer(buffer); + } +} diff --git a/crates/proto/tsclientlib/examples/channeltree.rs b/crates/proto/tsclientlib/examples/channeltree.rs new file mode 100644 index 0000000..2365ed0 --- /dev/null +++ b/crates/proto/tsclientlib/examples/channeltree.rs @@ -0,0 +1,129 @@ +use anyhow::{bail, Result}; +use clap::Parser; +use futures::prelude::*; +use tokio::time::{self, Duration}; + +use tsclientlib::data::{self, Channel, Client}; +use tsclientlib::prelude::*; +use tsclientlib::{ChannelId, Connection, DisconnectOptions, Identity, StreamItem}; + +#[derive(Parser, Debug)] +#[command(author, about)] +struct Args { + /// The address of the server to connect to + #[arg(short, long, default_value = "localhost")] + address: String, + /// Print the content of all packets + /// + /// 0. Print nothing + /// 1. Print command string + /// 2. Print packets + /// 3. Print udp packets + #[arg(short, long, action = clap::ArgAction::Count)] + verbose: u8, +} + +/// `channels` have to be ordered. +fn print_channels(clients: &[&Client], channels: &[&Channel], parent: ChannelId, depth: usize) { + let indention = " ".repeat(depth); + for channel in channels { + if channel.parent == parent { + println!("{}- {}", indention, channel.name); + // Print all clients in this channel + for client in clients { + if client.channel == channel.id { + println!("{} {}", indention, client.name); + } + } + + print_channels(clients, channels, channel.id, depth + 1); + } + } +} + +fn print_channel_tree(con: &data::Connection) { + let mut channels: Vec<_> = con.channels.values().collect(); + let mut clients: Vec<_> = con.clients.values().collect(); + // This is not the real sorting order, the order is the ChannelId of the + // channel on top of this one, but we don't care for this example. + channels.sort_by_key(|ch| ch.order.0); + clients.sort_by_key(|c| c.talk_power); + println!("{}", con.server.name); + print_channels(&clients, &channels, ChannelId(0), 0); +} + +#[tokio::main] +async fn main() -> Result<()> { real_main().await } + +async fn real_main() -> Result<()> { + tracing_subscriber::fmt::init(); + + // Parse command line options + let args = Args::parse(); + + let con_config = Connection::build(args.address) + .log_commands(args.verbose >= 1) + .log_packets(args.verbose >= 2) + .log_udp_packets(args.verbose >= 3); + + // Optionally set the key of this client, otherwise a new key is generated. + let id = Identity::new_from_str( + "MG0DAgeAAgEgAiAIXJBlj1hQbaH0Eq0DuLlCmH8bl+veTAO2+\ + k9EQjEYSgIgNnImcmKo7ls5mExb6skfK2Tw+u54aeDr0OP1ITs\ + C/50CIA8M5nmDBnmDM/gZ//4AAAAAAAAAAAAAAAAAAAAZRzOI").unwrap(); + let con_config = con_config.identity(id); + + // Connect + let mut con = con_config.connect()?; + + let r = con + .events() + .try_filter(|e| future::ready(matches!(e, StreamItem::BookEvents(_)))) + .next() + .await; + if let Some(r) = r { + r?; + } + + con.get_state().unwrap().server.set_subscribed(true).send(&mut con)?; + + // Wait some time + let mut events = con.events().try_filter(|_| future::ready(false)); + tokio::select! { + _ = time::sleep(Duration::from_secs(1)) => {} + _ = events.next() => { + bail!("Disconnected"); + } + }; + drop(events); + + // Print channel tree + print_channel_tree(con.get_state().unwrap()); + + // Change name + { + let state = con.get_state().unwrap(); + let name = state.clients[&state.own_client].name.clone(); + state + .client_update() + .set_input_muted(true) + .set_name(&format!("{}1", name)) + .send(&mut con)?; + } + + // Wait some time + let mut events = con.events().try_filter(|_| future::ready(false)); + tokio::select! { + _ = time::sleep(Duration::from_secs(3)) => {} + _ = events.next() => { + bail!("Disconnected"); + } + }; + drop(events); + + // Disconnect + con.disconnect(DisconnectOptions::new())?; + con.events().for_each(|_| future::ready(())).await; + + Ok(()) +} diff --git a/crates/proto/tsclientlib/examples/many.rs b/crates/proto/tsclientlib/examples/many.rs new file mode 100644 index 0000000..1e0f2e8 --- /dev/null +++ b/crates/proto/tsclientlib/examples/many.rs @@ -0,0 +1,86 @@ +use anyhow::Result; +use clap::Parser; +use futures::prelude::*; +use tokio::time::{self, Duration}; +use tracing::error; + +use tsclientlib::{Connection, DisconnectOptions, Identity, StreamItem}; + +#[derive(Parser, Debug)] +#[command(author, about)] +struct Args { + /// The address of the server to connect to + #[arg(short, long, default_value = "localhost")] + address: String, + /// Print the content of all packets + /// + /// 0. Print nothing + /// 1. Print command string + /// 2. Print packets + /// 3. Print udp packets + #[arg(short, long, action = clap::ArgAction::Count)] + verbose: u8, + /// How many connections + #[arg()] + count: usize, +} + +#[tokio::main] +async fn main() -> Result<()> { real_main().await } + +async fn real_main() -> Result<()> { + tracing_subscriber::fmt::init(); + + // Parse command line options + let args = Args::parse(); + + let con_config = Connection::build(args.address.as_str()) + .log_commands(args.verbose >= 1) + .log_packets(args.verbose >= 2) + .log_udp_packets(args.verbose >= 3); + + // Optionally set the key of this client, otherwise a new key is generated. + let id = Identity::new_from_str( + "MG0DAgeAAgEgAiAIXJBlj1hQbaH0Eq0DuLlCmH8bl+veTAO2+\ + k9EQjEYSgIgNnImcmKo7ls5mExb6skfK2Tw+u54aeDr0OP1ITs\ + C/50CIA8M5nmDBnmDM/gZ//4AAAAAAAAAAAAAAAAAAAAZRzOI").unwrap(); + let con_config = con_config.identity(id); + + stream::iter(0..args.count) + .for_each_concurrent(None, |_| { + let con_config = con_config.clone(); + tokio::spawn(async move { + // Connect + let mut con = con_config.connect().unwrap(); + + let r = con + .events() + .try_filter(|e| future::ready(matches!(e, StreamItem::BookEvents(_)))) + .next() + .await; + if let Some(Err(error)) = r { + error!(%error, "Connection failed"); + return; + } + + // Wait some time + let mut events = con.events().try_filter(|_| future::ready(false)); + tokio::select! { + _ = time::sleep(Duration::from_secs(15)) => {} + _ = events.next() => { + error!("Disconnected unexpectedly"); + return; + } + }; + drop(events); + + // Disconnect + let _ = con.disconnect(DisconnectOptions::new()); + con.events().for_each(|_| future::ready(())).await; + }) + .map(|_| ()) + }) + .await; + + Ok(()) +} diff --git a/crates/proto/tsclientlib/examples/simple-sync.rs b/crates/proto/tsclientlib/examples/simple-sync.rs new file mode 100644 index 0000000..c77b5e6 --- /dev/null +++ b/crates/proto/tsclientlib/examples/simple-sync.rs @@ -0,0 +1,78 @@ +use anyhow::Result; +use clap::Parser; +use futures::prelude::*; +use tokio::time::{self, Duration}; + +use tsclientlib::sync::SyncConnection; +use tsclientlib::{Connection, DisconnectOptions, Identity}; + +#[derive(Parser, Debug)] +#[command(author, about)] +struct Args { + /// The address of the server to connect to + #[arg(short, long, default_value = "localhost")] + address: String, + /// Print the content of all packets + /// + /// 0. Print nothing + /// 1. Print command string + /// 2. Print packets + /// 3. Print udp packets + #[arg(short, long, action = clap::ArgAction::Count)] + verbose: u8, +} + +#[tokio::main] +async fn main() -> Result<()> { real_main().await } + +async fn real_main() -> Result<()> { + tracing_subscriber::fmt::init(); + + // Parse command line options + let args = Args::parse(); + + let con_config = Connection::build(args.address) + .log_commands(args.verbose >= 1) + .log_packets(args.verbose >= 2) + .log_udp_packets(args.verbose >= 3); + + // Optionally set the key of this client, otherwise a new key is generated. + let id = Identity::new_from_str( + "MG0DAgeAAgEgAiAIXJBlj1hQbaH0Eq0DuLlCmH8bl+veTAO2+\ + k9EQjEYSgIgNnImcmKo7ls5mExb6skfK2Tw+u54aeDr0OP1ITs\ + C/50CIA8M5nmDBnmDM/gZ//4AAAAAAAAAAAAAAAAAAAAZRzOI").unwrap(); + let con_config = con_config.identity(id); + + // Connect + let con: SyncConnection = con_config.connect()?.into(); + let mut handle = con.get_handle(); + + // Do event handling in another thread + tokio::spawn(con.for_each(|_| future::ready(()))); + + handle.wait_until_connected().await?; + + let welcome_message = handle + .with_connection(|con| Result::<_>::Ok(con.get_state()?.server.welcome_message.clone())) + .await??; + println!("Server welcome message: {}", sanitize(&welcome_message)); + + // Wait some time + time::sleep(Duration::from_secs(1)).await; + + // Disconnect + handle.disconnect(DisconnectOptions::new()).await?; + + Ok(()) +} + +/// Only retain a certain set of characters. +fn sanitize(s: &str) -> String { + s.chars() + .filter(|c| { + c.is_alphanumeric() + || [' ', '\t', '.', ':', '-', '_', '"', '\'', '/', '(', ')', '[', ']', '{', '}'] + .contains(c) + }) + .collect() +} diff --git a/crates/proto/tsclientlib/examples/simple.rs b/crates/proto/tsclientlib/examples/simple.rs new file mode 100644 index 0000000..ce6384d --- /dev/null +++ b/crates/proto/tsclientlib/examples/simple.rs @@ -0,0 +1,85 @@ +use anyhow::{bail, Result}; +use clap::Parser; +use futures::prelude::*; +use tokio::time::{self, Duration}; + +use tsclientlib::{Connection, DisconnectOptions, Identity, StreamItem}; + +#[derive(Parser, Debug)] +#[command(author, about)] +struct Args { + /// The address of the server to connect to + #[arg(short, long, default_value = "localhost")] + address: String, + /// Print the content of all packets + /// + /// 0. Print nothing + /// 1. Print command string + /// 2. Print packets + /// 3. Print udp packets + #[arg(short, long, action = clap::ArgAction::Count)] + verbose: u8, +} + +#[tokio::main] +async fn main() -> Result<()> { real_main().await } + +async fn real_main() -> Result<()> { + tracing_subscriber::fmt::init(); + + // Parse command line options + let args = Args::parse(); + + let con_config = Connection::build(args.address) + .log_commands(args.verbose >= 1) + .log_packets(args.verbose >= 2) + .log_udp_packets(args.verbose >= 3); + + // Optionally set the key of this client, otherwise a new key is generated. + let id = Identity::new_from_str( + "MG0DAgeAAgEgAiAIXJBlj1hQbaH0Eq0DuLlCmH8bl+veTAO2+\ + k9EQjEYSgIgNnImcmKo7ls5mExb6skfK2Tw+u54aeDr0OP1ITs\ + C/50CIA8M5nmDBnmDM/gZ//4AAAAAAAAAAAAAAAAAAAAZRzOI").unwrap(); + let con_config = con_config.identity(id); + + // Connect + let mut con = con_config.connect()?; + + let r = con + .events() + .try_filter(|e| future::ready(matches!(e, StreamItem::BookEvents(_)))) + .next() + .await; + if let Some(r) = r { + r?; + } + + println!("Server welcome message: {}", sanitize(&con.get_state()?.server.welcome_message)); + + // Wait some time + let mut events = con.events().try_filter(|_| future::ready(false)); + tokio::select! { + _ = time::sleep(Duration::from_secs(1)) => {} + _ = events.next() => { + bail!("Disconnected"); + } + }; + drop(events); + + // Disconnect + con.disconnect(DisconnectOptions::new())?; + con.events().for_each(|_| future::ready(())).await; + + Ok(()) +} + +/// Only retain a certain set of characters. +fn sanitize(s: &str) -> String { + s.chars() + .filter(|c| { + c.is_alphanumeric() + || [' ', '\t', '.', ':', '-', '_', '"', '\'', '/', '(', ')', '[', ']', '{', '}'] + .contains(c) + }) + .collect() +} diff --git a/crates/proto/tsclientlib/examples/sync.rs b/crates/proto/tsclientlib/examples/sync.rs new file mode 100644 index 0000000..0829d7d --- /dev/null +++ b/crates/proto/tsclientlib/examples/sync.rs @@ -0,0 +1,77 @@ +use anyhow::Result; +use clap::Parser; +use futures::prelude::*; +use tokio::time::{self, Duration}; + +use tsclientlib::prelude::*; +use tsclientlib::sync::SyncConnection; +use tsclientlib::{Connection, DisconnectOptions, Identity, StreamItem}; + +#[derive(Parser, Debug)] +#[command(author, about)] +struct Args { + /// The address of the server to connect to + #[arg(short, long, default_value = "localhost")] + address: String, + /// Print the content of all packets + /// + /// 0. Print nothing + /// 1. Print command string + /// 2. Print packets + /// 3. Print udp packets + #[arg(short, long, action = clap::ArgAction::Count)] + verbose: u8, +} + +#[tokio::main] +async fn main() -> Result<()> { real_main().await } + +async fn real_main() -> Result<()> { + tracing_subscriber::fmt::init(); + + // Parse command line options + let args = Args::parse(); + + let con_config = Connection::build(args.address) + .log_commands(args.verbose >= 1) + .log_packets(args.verbose >= 2) + .log_udp_packets(args.verbose >= 3); + + // Optionally set the key of this client, otherwise a new key is generated. + let id = Identity::new_from_str( + "MG0DAgeAAgEgAiAIXJBlj1hQbaH0Eq0DuLlCmH8bl+veTAO2+\ + k9EQjEYSgIgNnImcmKo7ls5mExb6skfK2Tw+u54aeDr0OP1ITs\ + C/50CIA8M5nmDBnmDM/gZ//4AAAAAAAAAAAAAAAAAAAAZRzOI").unwrap(); + let con_config = con_config.identity(id); + + // Connect + let mut con = con_config.connect()?; + let r = con + .events() + .try_filter(|e| future::ready(matches!(e, StreamItem::BookEvents(_)))) + .next() + .await; + if let Some(r) = r { + r?; + } + + let sync_con: SyncConnection = con.into(); + let mut con = sync_con.get_handle(); + + tokio::spawn(sync_con.for_each(|_| future::ready(()))); + + con.with_connection(move |mut con| { + let state = con.get_state()?; + state.server.send_textmessage("Hello there").send(&mut con)?; + Result::<_>::Ok(()) + }) + .await??; + + // Wait some time + time::sleep(Duration::from_secs(1)).await; + + // Disconnect + con.disconnect(DisconnectOptions::new()).await?; + + Ok(()) +} diff --git a/crates/proto/tsclientlib/src/audio.rs b/crates/proto/tsclientlib/src/audio.rs new file mode 100644 index 0000000..2b6fc34 --- /dev/null +++ b/crates/proto/tsclientlib/src/audio.rs @@ -0,0 +1,876 @@ +//! Handle receiving audio. +//! +//! The [`AudioHandler`] collects all incoming audio packets and queues them per +//! client. It decodes the audio, handles out-of-order packets and missing +//! packets. It automatically adjusts the queue length based on the jitter of +//! incoming packets. + +use std::cmp::Reverse; +use std::collections::{HashMap, VecDeque}; +use std::convert::TryInto; +use std::fmt::Debug; +use std::hash::Hash; + +use audiopus::coder::Decoder; +#[cfg(feature = "audiopus-unstable")] +use audiopus::coder::GenericCtl; +use audiopus::{Channels, SampleRate, packet}; +use thiserror::Error; +use tracing::{Span, debug, info_span, trace, warn}; +use tsproto_packets::packets::{AudioData, CodecType, InAudioBuf}; + +use crate::ClientId; + +const SAMPLE_RATE: SampleRate = SampleRate::Hz48000; +const CHANNELS: Channels = Channels::Stereo; +const CHANNEL_NUM: usize = 2; +/// If this amount of packets is lost consecutively, we assume the stream stopped. +const MAX_PACKET_LOSSES: usize = 3; +/// Store the buffer sizes for the last `LAST_BUFFER_SIZE_COUNT` packets. +const LAST_BUFFER_SIZE_COUNT: u8 = 255; +/// The amount of samples to maximally buffer. Equivalent to 0.5 s. +const MAX_BUFFER_SIZE: usize = 48_000 / 2; +/// Maximum number of packets in the queue. +const MAX_BUFFER_PACKETS: usize = 50; +/// Buffer for maximal 0.5 s without playing anything. +const MAX_BUFFER_TIME: usize = 48_000 / 2; +/// Duplicate or remove every `step` sample when speeding-up. +const SPEED_CHANGE_STEPS: usize = 100; +/// The usual amount of samples in a frame. +/// +/// Use 48 kHz, 20 ms frames (50 per second) and mono data (1 channel). +/// This means 1920 samples and 7.5 kiB. +const USUAL_FRAME_SIZE: usize = 48000 / 50; + +type Result = std::result::Result; + +#[derive(Debug, Error)] +#[non_exhaustive] +pub enum Error { + #[error("Failed to create opus decoder: {0}")] + CreateDecoder(#[source] audiopus::Error), + #[error("Opus decode failed: {error} (packet: {packet:?})")] + Decode { + #[source] + error: audiopus::Error, + packet: Option>, + }, + #[error("Get duplicate packet id {0}")] + Duplicate(u16), + #[error("Failed to get packet samples: {0}")] + GetPacketSample(#[source] audiopus::Error), + #[error("Audio queue is full, dropping")] + QueueFull, + #[error("Audio packet is too late, dropping (wanted {wanted}, got {got})")] + TooLate { wanted: u16, got: u16 }, + #[error("Packet has too many samples")] + TooManySamples, + #[error("Only opus audio is supported, ignoring {0:?}")] + UnsupportedCodec(CodecType), +} + +#[derive(Clone, Debug)] +struct SlidingWindowMinimum { + /// How long a value stays in the sliding window. + size: u8, + /// This is a sliding window minimum, it contains + /// `(insertion time, value)`. + /// + /// When we insert a value, we can remove all bigger sample counts, + /// thus the queue always stays sorted with the minimum at the front + /// and the maximum at the back (latest entry). + /// + /// Provides amortized O(1) minimum. + /// Source: https://people.cs.uct.ac.za/~ksmith/articles/sliding_window_minimum.html#sliding-window-minimum-algorithm + queue: VecDeque<(u8, T)>, + /// The current insertion time. + cur_time: u8, +} + +#[derive(Debug)] +struct QueuePacket { + packet: InAudioBuf, + samples: usize, + id: u16, +} + +/// A queue for audio packets for one audio stream. +pub struct AudioQueue { + span: Span, + decoder: Decoder, + pub volume: f32, + /// The id of the next packet that should be decoded. + /// + /// Used to check for packet loss. + next_id: u16, + /// If the last packet was a whisper packet. + whispering: bool, + packet_buffer: VecDeque, + /// Amount of samples in the `packet_buffer`. + packet_buffer_samples: usize, + /// Temporary buffer that contains the samples of one decoded packet. + decoded_buffer: Vec, + /// The number of samples in `decoded_buffer` that have been returned. + decoded_pos: usize, + /// The number of samples in the last packet. + last_packet_samples: usize, + /// The last `packet_loss_num` packet decodes were a loss. + packet_loss_num: usize, + /// The amount of samples to buffer until this queue is ready to play. + buffering_samples: usize, + /// The amount of packets in the buffer when a packet was decoded. + /// + /// Uses the amount of samples in the `packet_buffer` / `USUAL_PACKET_SAMPLES`. + /// Used to expand or reduce the buffer. + last_buffer_size_min: SlidingWindowMinimum, + last_buffer_size_max: SlidingWindowMinimum>, + /// Buffered for this duration. + buffered_for_samples: usize, +} + +/// Handles incoming audio, has one [`AudioQueue`] per sending client. +pub struct AudioHandler { + queues: HashMap, + /// Buffer this amount of samples for new queues before starting to play. + /// + /// Updated when a new queue gets added. + avg_buffer_samples: usize, +} + +impl SlidingWindowMinimum { + fn new(size: u8) -> Self { Self { size, queue: Default::default(), cur_time: 0 } } + + fn push(&mut self, value: T) { + while self.queue.back().map(|(_, s)| *s >= value).unwrap_or_default() { + self.queue.pop_back(); + } + let i = self.cur_time; + self.queue.push_back((i, value)); + while self + .queue + .front() + .map(|(i, _)| self.cur_time.wrapping_sub(*i) >= self.size) + .unwrap_or_default() + { + self.queue.pop_front(); + } + self.cur_time = self.cur_time.wrapping_add(1); + } + + fn get_min(&self) -> T { self.queue.front().map(|(_, s)| *s).unwrap_or_default() } +} + +impl AudioQueue { + fn new(packet: InAudioBuf) -> Result { + let data = packet.data().data(); + let opus_packet = data.data().try_into().map_err(Error::GetPacketSample)?; + let last_packet_samples = + packet::nb_samples(opus_packet, SAMPLE_RATE).map_err(Error::GetPacketSample)?; + if last_packet_samples > MAX_BUFFER_SIZE { + return Err(Error::TooManySamples); + } + + let last_packet_samples = last_packet_samples * CHANNEL_NUM; + let whispering = matches!(data, AudioData::S2CWhisper { .. }); + let decoder = Decoder::new(SAMPLE_RATE, CHANNELS).map_err(Error::CreateDecoder)?; + + // Enable DRED and NoLACE, ignore errors e.g. if unsupported + #[cfg(feature = "audiopus-unstable")] + let decoder = { + let mut decoder = decoder; + if let Err(error) = decoder.set_complexity(7) { + debug!(%error, "Failed setting opus decoder complexity, ignoring"); + } + decoder + }; + + let mut res = Self { + span: Span::current(), + decoder, + volume: 1.0, + next_id: data.id(), + whispering, + packet_buffer: Default::default(), + packet_buffer_samples: 0, + decoded_buffer: Default::default(), + decoded_pos: 0, + last_packet_samples, + packet_loss_num: 0, + buffering_samples: 0, + last_buffer_size_min: SlidingWindowMinimum::new(LAST_BUFFER_SIZE_COUNT), + last_buffer_size_max: SlidingWindowMinimum::>::new(LAST_BUFFER_SIZE_COUNT), + buffered_for_samples: 0, + }; + res.add_buffer_size(0); + res.add_packet(packet)?; + Ok(res) + } + + pub fn get_decoder(&self) -> &Decoder { &self.decoder } + pub fn is_whispering(&self) -> bool { self.whispering } + + /// Size is in samples. + fn add_buffer_size(&mut self, size: usize) { + if let Ok(size) = (size / USUAL_FRAME_SIZE).try_into() { + self.last_buffer_size_min.push(size); + self.last_buffer_size_max.push(Reverse(size)); + } else { + warn!(parent: &self.span, size, "Failed to put amount of packets into an u8"); + } + } + + /// The approximate deviation of the buffer size. + fn get_deviation(&self) -> u8 { + let min = self.last_buffer_size_min.get_min(); + let max = self.last_buffer_size_max.get_min(); + max.0 - min + } + + fn add_packet(&mut self, packet: InAudioBuf) -> Result<()> { + let _span = self.span.enter(); + if self.packet_buffer.len() >= MAX_BUFFER_PACKETS { + return Err(Error::QueueFull); + } + let samples; + if packet.data().data().data().len() <= 1 { + // End of stream + samples = 0; + } else { + let opus_packet = + packet.data().data().data().try_into().map_err(Error::GetPacketSample)?; + samples = + packet::nb_samples(opus_packet, SAMPLE_RATE).map_err(Error::GetPacketSample)?; + if samples > MAX_BUFFER_SIZE { + return Err(Error::TooManySamples); + } + } + + let id = packet.data().data().id(); + let packet = QueuePacket { packet, samples, id }; + if id.wrapping_sub(self.next_id) > MAX_BUFFER_PACKETS as u16 { + return Err(Error::TooLate { wanted: self.next_id, got: id }); + } + + // Put into first spot where the id is smaller + let i = self.packet_buffer.len() + - self + .packet_buffer + .iter() + .enumerate() + .rev() + .take_while(|(_, p)| p.id.wrapping_sub(id) <= MAX_BUFFER_PACKETS as u16) + .count(); + // Check for duplicate packet + if let Some(p) = self.packet_buffer.get(i) { + if p.id == packet.id { + return Err(Error::Duplicate(p.id)); + } + } + + trace!("Insert packet {} at {}", id, i); + let last_id = self.packet_buffer.back().map(|p| p.id.wrapping_add(1)).unwrap_or(id); + if last_id <= id { + self.buffering_samples = self.buffering_samples.saturating_sub(samples); + // Reduce buffering counter by lost packets if there are some + self.buffering_samples = self + .buffering_samples + .saturating_sub(usize::from(id - last_id) * self.last_packet_samples); + } + + self.packet_buffer_samples += packet.samples; + self.packet_buffer.insert(i, packet); + + Ok(()) + } + + fn decode_packet(&mut self, packet: Option<&QueuePacket>, fec: bool) -> Result<()> { + let _span = self.span.clone().entered(); + trace!(has_packet = packet.is_some(), fec, "Decoding packet"); + let packet_data; + let len; + if let Some(p) = packet { + packet_data = + Some(p.packet.data().data().data().try_into().map_err(Error::GetPacketSample)?); + len = p.samples; + self.whispering = matches!(p.packet.data().data(), AudioData::S2CWhisper { .. }); + } else { + packet_data = None; + len = self.last_packet_samples; + } + self.packet_loss_num += 1; + + let orig_buffer_len = self.decoded_buffer.len(); + self.decoded_buffer.resize(orig_buffer_len + len * CHANNEL_NUM, 0.0); + let len = self + .decoder + .decode_float( + packet_data, + (&mut self.decoded_buffer[orig_buffer_len..]) + .try_into() + .map_err(Error::GetPacketSample)?, + fec, + ) + .map_err(|e| Error::Decode { + error: e, + packet: packet.map(|p| p.packet.raw_data().to_vec()), + })?; + self.last_packet_samples = len; + self.decoded_buffer.truncate(orig_buffer_len + len * CHANNEL_NUM); + + // Update packet_loss_num + if packet.is_some() && !fec { + self.packet_loss_num = 0; + } + + // Update last_buffer_size + let mut count = self.packet_buffer_samples; + if let Some(last) = self.packet_buffer.back() { + // Lost packets + trace!( + last.id, + next_id = self.next_id, + first_id = self.packet_buffer.front().unwrap().id, + buffer_len = self.packet_buffer.len(), + "Ids" + ); + count += (usize::from(last.id.wrapping_sub(self.next_id)) + 1 + - self.packet_buffer.len()) + * self.last_packet_samples; + } + self.add_buffer_size(count); + + Ok(()) + } + + /// Decode data and return the requested length of buffered data. + /// + /// Returns `true` in the second return value when the stream ended, + /// `false` when it continues normally. + pub fn get_next_data(&mut self, len: usize) -> Result<(&[f32], bool)> { + let _span = self.span.clone().entered(); + if self.buffering_samples > 0 { + if self.buffered_for_samples >= MAX_BUFFER_TIME { + self.buffering_samples = 0; + self.buffered_for_samples = 0; + trace!( + buffered_for_samples = self.buffered_for_samples, + buffering_samples = self.buffering_samples, + "Buffered for too long" + ); + } else { + self.buffered_for_samples += len; + trace!( + buffered_for_samples = self.buffered_for_samples, + buffering_samples = self.buffering_samples, + "Buffering" + ); + return Ok((&[], false)); + } + } + // Need to refill buffer + self.decoded_buffer.drain(..self.decoded_pos); + + while self.decoded_buffer.len() < len { + trace!(decoded_buffer = self.decoded_buffer.len(), len, "get_next_data"); + + // Decode a packet + if let Some(packet) = self.packet_buffer.pop_front() { + if packet.packet.data().data().data().len() <= 1 { + // End of stream + return Ok((&self.decoded_buffer, true)); + } + + self.packet_buffer_samples -= packet.samples; + let cur_id = self.next_id; + self.next_id = self.next_id.wrapping_add(1); + if packet.id != cur_id { + debug_assert!( + packet.id.wrapping_sub(cur_id) < MAX_BUFFER_PACKETS as u16, + "Invalid packet queue state: {} < {}", + packet.id, + cur_id + ); + // Packet loss + debug!(need = cur_id, have = packet.id, "Audio packet loss"); + if packet.id == self.next_id { + // Can use forward-error-correction + self.decode_packet(Some(&packet), true)?; + } else { + self.decode_packet(None, false)?; + } + self.packet_buffer_samples += packet.samples; + self.packet_buffer.push_front(packet); + } else { + self.decode_packet(Some(&packet), false)?; + } + } else { + debug!("No packets in queue"); + // Packet loss or end of stream + self.decode_packet(None, false)?; + } + + if self.last_packet_samples == 0 { + break; + } + + // Check if we should speed-up playback + let min = self.last_buffer_size_min.get_min(); + let dev = self.get_deviation(); + if min > (MAX_BUFFER_SIZE / USUAL_FRAME_SIZE) as u8 { + debug!(min, "Truncating buffer"); + // Throw out all but min samples + let mut keep_samples = 0; + let keep = self + .packet_buffer + .iter() + .rev() + .take_while(|p| { + keep_samples += p.samples; + keep_samples < usize::from(min) + USUAL_FRAME_SIZE + }) + .count(); + let len = self.packet_buffer.len() - keep; + self.packet_buffer.drain(..len); + self.packet_buffer_samples = self.packet_buffer.iter().map(|p| p.samples).sum(); + if let Some(p) = self.packet_buffer.front() { + self.next_id = p.id; + } + } else if min > dev { + // Speed-up + debug!( + min, + cur_packet_count = self.packet_buffer.len(), + last_packet_samples = self.last_packet_samples, + dev, + "Speed-up buffer" + ); + let start = self.decoded_buffer.len() - self.last_packet_samples * CHANNEL_NUM; + for i in 0..(self.last_packet_samples / SPEED_CHANGE_STEPS) { + let i = start + i * (SPEED_CHANGE_STEPS - 1) * CHANNEL_NUM; + self.decoded_buffer.drain(i..(i + CHANNEL_NUM)); + } + } + } + + self.decoded_pos = len; + Ok((&self.decoded_buffer[..len], false)) + } +} + +impl Default for AudioHandler { + fn default() -> Self { Self { queues: Default::default(), avg_buffer_samples: 0 } } +} + +impl AudioHandler { + pub fn new() -> Self { Default::default() } + + /// Delete all queues + pub fn reset(&mut self) { self.queues.clear(); } + + pub fn get_queues(&self) -> &HashMap { &self.queues } + pub fn get_mut_queues(&mut self) -> &mut HashMap { &mut self.queues } + + /// `buf` is not cleared before filling it. + /// + /// Returns the clients that are not talking anymore. + pub fn fill_buffer(&mut self, buf: &mut [f32]) -> Vec { + self.fill_buffer_with_proc(buf, |_, _| {}) + } + + /// `buf` is not cleared before filling it. + /// + /// Same as [`fill_buffer`] but before merging a queue into the output buffer, a preprocessor + /// function is called. The queue volume is applied after calling the preprocessor. + /// + /// Returns the clients that are not talking anymore. + pub fn fill_buffer_with_proc( + &mut self, buf: &mut [f32], mut handle: F, + ) -> Vec { + trace!(len = buf.len(), "Filling audio buffer"); + let mut to_remove = Vec::new(); + for (id, queue) in self.queues.iter_mut() { + if queue.packet_loss_num >= MAX_PACKET_LOSSES { + debug!(packet_loss_num = queue.packet_loss_num, "Removing talker"); + to_remove.push(id.clone()); + continue; + } + + let vol = queue.volume; + match queue.get_next_data(buf.len()) { + Err(error) => { + warn!(%error, "Failed to decode audio packet"); + } + Ok((r, is_end)) => { + handle(id, r); + for i in 0..r.len() { + buf[i] += r[i] * vol; + } + if is_end { + to_remove.push(id.clone()); + } + } + } + } + + for id in &to_remove { + self.queues.remove(id); + } + to_remove + } + + /// Add a packet to the audio queue. + /// + /// If a new client started talking, returns the id of this client. + pub fn handle_packet(&mut self, id: Id, packet: InAudioBuf) -> Result> { + let empty = packet.data().data().data().len() <= 1; + let codec = packet.data().data().codec(); + if codec != CodecType::OpusMusic && codec != CodecType::OpusVoice { + return Err(Error::UnsupportedCodec(codec)); + } + + if let Some(queue) = self.queues.get_mut(&id) { + queue.add_packet(packet)?; + Ok(None) + } else { + if empty { + return Ok(None); + } + + let _span = info_span!("audio queue", client = ?id); + trace!("Adding talker"); + let mut queue = AudioQueue::new(packet)?; + if !self.queues.is_empty() { + // Update avg_buffer_samples + self.avg_buffer_samples = USUAL_FRAME_SIZE + + self + .queues + .values() + .map(|q| usize::from(q.last_buffer_size_min.get_min())) + .sum::() / self.queues.len(); + } + queue.buffering_samples = self.avg_buffer_samples; + self.queues.insert(id.clone(), queue); + Ok(Some(id)) + } + } +} + +#[cfg(test)] +mod test { + use anyhow::{Result, bail}; + use audiopus::coder::Encoder; + use tsproto_packets::packets::{Direction, OutAudio}; + + use super::*; + use crate::tests::create_logger; + + enum SimulateAction { + CreateEncoder, + /// Create packet with id. + /// + /// The `bool` is `false` if packet handling should fail. + ReceivePacket(u16, bool), + ReceiveRaw(u16, Vec), + /// Fetch audio of this sample count and expect a certain packet id. + FillBuffer(usize, Option), + /// Custom check + Check(Box)>), + } + + /// Helper function to check an audio packet. + #[allow(dead_code)] + fn check_packet(data: &[u8]) -> Result<()> { + create_logger(); + let mut handler = AudioHandler::::new(); + let id = ClientId(0); + let mut buf = vec![0.0; 48_000 / 100 * 2]; + + // Sometimes, TS sends short, non-opus packets + let packet = + OutAudio::new(&AudioData::S2C { id: 30, codec: CodecType::OpusMusic, from: 0, data }); + let input = InAudioBuf::try_new(Direction::S2C, packet.into_vec()).unwrap(); + handler.handle_packet(id, input)?; + + handler.fill_buffer(&mut buf); + handler.fill_buffer(&mut buf); + Ok(()) + } + + fn simulate(actions: Vec) -> Result<()> { + let mut encoder = None; + let mut opus_output = [0; 1275]; // Max size for an opus packet + let id = ClientId(0); + create_logger(); + let mut handler = AudioHandler::::new(); + + for a in actions { + println!("\nCurrent state"); + for q in &handler.queues { + print!("Queue {:?}:", q.0); + for p in &q.1.packet_buffer { + print!(" {:?},", p); + } + println!(); + } + + match a { + SimulateAction::CreateEncoder => { + encoder = Some(Encoder::new( + audiopus::SampleRate::Hz48000, + audiopus::Channels::Mono, + audiopus::Application::Voip, + )?); + } + SimulateAction::ReceivePacket(i, success) => { + let e = encoder.as_mut().unwrap(); + let data = vec![i as f32; USUAL_FRAME_SIZE]; + let len = e.encode_float(&data, &mut opus_output[..])?; + let packet = OutAudio::new(&AudioData::S2C { + id: i, + codec: CodecType::OpusMusic, + from: 0, + data: &opus_output[..len], + }); + let input = InAudioBuf::try_new(Direction::S2C, packet.into_vec()).unwrap(); + if handler.handle_packet(id, input).is_ok() != success { + bail!("handle_packet returned {:?} but expected {:?}", !success, success); + } + } + SimulateAction::ReceiveRaw(i, data) => { + let packet = OutAudio::new(&AudioData::S2C { + id: i, + codec: CodecType::OpusMusic, + from: 0, + data: &data, + }); + let input = InAudioBuf::try_new(Direction::S2C, packet.into_vec()).unwrap(); + let _ = handler.handle_packet(id, input); + } + SimulateAction::FillBuffer(size, expect) => { + let mut buf = vec![0.0; size * 2]; // Stereo + let cur_packet_id = + handler.queues.get(&id).and_then(|q| q.packet_buffer.front()).map(|p| p.id); + handler.fill_buffer(&mut buf); + let next_packet_id = + handler.queues.get(&id).and_then(|q| q.packet_buffer.front()).map(|p| p.id); + + if expect.is_some() { + assert_eq!(expect, cur_packet_id); + assert_ne!(cur_packet_id, next_packet_id); + } + + /*if let Some(e) = expect { + let e = *e as f32; + for b in &buf { + if (*b - e).abs() > 0.01 { + bail!("Buffer contains wrong value, \ + expected {}: {:?}", e, buf); + } + } + }*/ + } + SimulateAction::Check(f) => { + f(&handler); + } + } + } + Ok(()) + } + + #[test] + fn sliding_window_minimum() { + let data = &[ + (5, 5), + (6, 5), + (3, 3), + (4, 3), + (6, 3), + (5, 3), + (6, 3), + (6, 4), + (6, 5), + (6, 5), + (6, 6), + (7, 6), + (5, 5), + ]; + let mut window = SlidingWindowMinimum::new(5); + assert_eq!(window.get_min(), 0); + for (i, (val, min)) in data.iter().enumerate() { + println!("{:?}", window); + window.push(*val); + assert_eq!(window.get_min(), *min, "Failed in iteration {} ({:?})", i, window); + } + } + + #[test] + fn sliding_window_minimum_full() { + let mut window = SlidingWindowMinimum::new(255); + window.push(1); + assert_eq!(window.get_min(), 1); + for _ in 0..254 { + window.push(2); + } + assert_eq!(window.get_min(), 1); + window.push(2); + assert_eq!(window.get_min(), 2); + } + + #[test] + fn packets_wrapping() { + create_logger(); + let mut handler = AudioHandler::::new(); + let id = ClientId(0); + let mut buf = vec![0.0; 48_000 / 100 * 2]; + + for i in 0..100 { + let packet = OutAudio::new(&AudioData::S2C { + id: 65_500u16.wrapping_add(i), + codec: CodecType::OpusMusic, + from: 0, + data: &[0, 0, 0, 0, 0, 0, 0], + }); + let input = InAudioBuf::try_new(Direction::S2C, packet.into_vec()).unwrap(); + handler.handle_packet(id, input).unwrap(); + + if i > 5 { + handler.fill_buffer(&mut buf); + } + } + } + + #[quickcheck_macros::quickcheck] + fn short_packet_quickcheck(data: Vec>) { + create_logger(); + let mut handler = AudioHandler::::new(); + let id = ClientId(0); + let mut buf = vec![0.0; 48_000 / 100 * 2]; + + for p in data { + // Sometimes, TS sends short, non-opus packets + let packet = OutAudio::new(&AudioData::S2C { + id: 30, + codec: CodecType::OpusMusic, + from: 0, + data: &p, + }); + let input = InAudioBuf::try_new(Direction::S2C, packet.into_vec()).unwrap(); + let _ = handler.handle_packet(id, input); + + handler.fill_buffer(&mut buf); + handler.fill_buffer(&mut buf); + } + } + + #[test] + fn packets_wrapping2() -> Result<()> { + let mut a = vec![SimulateAction::CreateEncoder]; + for i in 0..100 { + let i = 65_500u16.wrapping_add(i); + a.push(SimulateAction::ReceivePacket(i, true)); + a.push(SimulateAction::FillBuffer(USUAL_FRAME_SIZE, Some(i))); + } + for _ in 0..4 { + a.push(SimulateAction::FillBuffer(USUAL_FRAME_SIZE, None)); + } + a.push(SimulateAction::Check(Box::new(|h| assert!(h.queues.is_empty())))); + simulate(a) + } + + #[test] + fn silence() -> Result<()> { + let mut a = vec![SimulateAction::CreateEncoder]; + for _ in 0..100 { + a.push(SimulateAction::FillBuffer(USUAL_FRAME_SIZE, None)); + } + simulate(a) + } + + #[test] + fn reversed() -> Result<()> { + let mut a = vec![SimulateAction::CreateEncoder]; + for i in 0..5 { + a.push(SimulateAction::ReceivePacket(i, true)); + a.push(SimulateAction::FillBuffer(USUAL_FRAME_SIZE, Some(i))); + } + a.push(SimulateAction::ReceivePacket(4, false)); + a.push(SimulateAction::ReceivePacket(3, false)); + for _ in 0..4 { + a.push(SimulateAction::FillBuffer(USUAL_FRAME_SIZE, None)); + } + a.push(SimulateAction::Check(Box::new(|h| assert!(h.queues.is_empty())))); + simulate(a) + } + + #[test] + fn duplicate() -> Result<()> { + let mut a = vec![SimulateAction::CreateEncoder]; + a.push(SimulateAction::ReceivePacket(0, true)); + a.push(SimulateAction::ReceivePacket(0, false)); + a.push(SimulateAction::FillBuffer(USUAL_FRAME_SIZE, Some(0))); + a.push(SimulateAction::FillBuffer(USUAL_FRAME_SIZE, None)); + simulate(a) + } + + #[test] + fn big_whole() -> Result<()> { + let mut a = vec![SimulateAction::CreateEncoder]; + for i in 27120..27124 { + a.push(SimulateAction::ReceivePacket(i, true)); + a.push(SimulateAction::FillBuffer(USUAL_FRAME_SIZE, Some(i))); + } + a.push(SimulateAction::ReceiveRaw(27124, vec![2])); + for _ in 0..10 { + a.push(SimulateAction::FillBuffer(USUAL_FRAME_SIZE, None)); + } + a.push(SimulateAction::Check(Box::new(|h| assert!(h.queues.is_empty())))); + for i in 27339..27349 { + a.push(SimulateAction::ReceivePacket(i, true)); + a.push(SimulateAction::FillBuffer(USUAL_FRAME_SIZE, None)); + } + for _ in 0..4 { + a.push(SimulateAction::FillBuffer(USUAL_FRAME_SIZE, None)); + } + a.push(SimulateAction::Check(Box::new(|h| assert!(h.queues.is_empty())))); + simulate(a) + } + + #[test] + fn end_packet() -> Result<()> { + let mut a = vec![SimulateAction::CreateEncoder]; + for i in 0..10 { + a.push(SimulateAction::ReceivePacket(i, true)); + a.push(SimulateAction::FillBuffer(USUAL_FRAME_SIZE, Some(i))); + } + a.push(SimulateAction::ReceiveRaw(10, vec![])); + for _ in 0..4 { + a.push(SimulateAction::FillBuffer(USUAL_FRAME_SIZE, None)); + } + a.push(SimulateAction::Check(Box::new(|h| assert!(h.queues.is_empty())))); + simulate(a) + } + + #[test] + fn packet_loss() -> Result<()> { + let mut a = vec![SimulateAction::CreateEncoder]; + a.push(SimulateAction::ReceivePacket(50, true)); + a.push(SimulateAction::ReceivePacket(53, true)); + for _ in 0..8 { + a.push(SimulateAction::FillBuffer(USUAL_FRAME_SIZE, None)); + } + a.push(SimulateAction::Check(Box::new(|h| assert!(h.queues.is_empty())))); + simulate(a) + } + + #[test] + fn packet_wrapping_loss() -> Result<()> { + let mut a = vec![SimulateAction::CreateEncoder]; + a.push(SimulateAction::ReceivePacket(65534, true)); + a.push(SimulateAction::ReceivePacket(0, true)); + for _ in 0..7 { + a.push(SimulateAction::FillBuffer(USUAL_FRAME_SIZE, None)); + } + a.push(SimulateAction::Check(Box::new(|h| assert!(h.queues.is_empty())))); + simulate(a) + } +} diff --git a/crates/proto/tsclientlib/src/lib.rs b/crates/proto/tsclientlib/src/lib.rs new file mode 100644 index 0000000..d41b601 --- /dev/null +++ b/crates/proto/tsclientlib/src/lib.rs @@ -0,0 +1,2042 @@ +//! tsclientlib is a library which makes it simple to create TeamSpeak clients +//! and bots. +//! +//! For a full client application, you might want to have a look at [Qint]. +//! +//! If more power over the internals of a connection is needed, the `unstable` feature can be +//! enabled. Beware that functionality behind this feature may change on any minor release. +//! +//! The base class of this library is the [`Connection`]. One instance of this +//! struct manages a single connection to a server. +//! +//! [Qint]: https://github.com/ReSpeak/Qint +// Needed for futures on windows. +#![recursion_limit = "128"] + +use std::borrow::Cow; +use std::collections::VecDeque; +use std::convert::TryInto; +use std::iter; +use std::mem; +use std::net::SocketAddr; +use std::pin::Pin; +use std::sync::{Arc, Mutex}; +use std::task::{Context, Poll}; +use std::time::Duration; + +use base64::prelude::*; +use futures::prelude::*; +use thiserror::Error; +use time::OffsetDateTime; +use tokio::io::AsyncWriteExt; +use tokio::net::{TcpStream, UdpSocket}; +use tokio::sync::oneshot; +use tracing::{debug, info, info_span, warn, Instrument, Span}; +use ts_bookkeeping::messages::c2s; +use ts_bookkeeping::messages::OutMessageTrait; +use tsproto::client; +use tsproto::connection::StreamItem as ProtoStreamItem; +use tsproto::resend::ResenderState; +use tsproto_packets::commands::{CommandItem, CommandParser}; +#[cfg(feature = "audio")] +use tsproto_packets::packets::InAudioBuf; +use tsproto_packets::packets::{InCommandBuf, OutCommand, OutPacket, PacketType}; + +#[cfg(feature = "audio")] +pub mod audio; +pub mod prelude; +pub mod resolver; +pub mod sync; + +// The build environment of tsclientlib. +git_testament::git_testament!(TESTAMENT); + +#[cfg(test)] +mod tests; + +// Reexports +pub use ts_bookkeeping::messages::s2c::InMessage; +// TODO This is bad because it re-exports ConnectOptions +pub use ts_bookkeeping::*; +pub use tsproto::resend::{ConnectionStats, PacketStat}; +pub use tsproto::Identity; +pub use tsproto_types::errors::Error as TsError; + +/// Wait this time for initserver, in seconds. +const INITSERVER_TIMEOUT: u64 = 5; + +type Result = std::result::Result; + +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] +pub struct MessageHandle(pub u16); +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] +pub struct FiletransferHandle(pub u16); + +#[derive(Clone, Debug, Error, Eq, Hash, PartialEq)] +#[error("{}", error)] +pub struct CommandError { + #[source] + pub error: TsError, + pub missing_permission: Option, +} + +#[derive(Debug, Error)] +#[non_exhaustive] +pub enum Error { + /// A command return an error. + #[error(transparent)] + CommandError(#[from] CommandError), + #[error("Failed to connect: {0}")] + Connect(#[source] tsproto::client::Error), + #[error("Failed to connect to server at {address:?}: {errors:?}")] + ConnectFailed { address: String, errors: Vec }, + #[error("Connection aborted: {0}")] + ConnectionFailed(#[source] tsproto::client::Error), + /// The connection was destroyed. + #[error("Connection does not exist anymore")] + ConnectionGone, + #[error("Server refused connection: {0}")] + ConnectTs(#[source] tsproto_types::errors::Error), + #[error("File transfer failed: {0}")] + FiletransferIo(#[source] std::io::Error), + #[error("Failed to create identity: {0}")] + IdentityCreate(#[source] tsproto::Error), + #[error("The server needs an identity of level {0}, please increase your identity level")] + IdentityLevel(u8), + #[error("The server requested an identity of level {needed}, but we already have level {have}")] + IdentityLevelCorrupted { needed: u8, have: u8 }, + #[error("Failed to increase identity level: Thread died")] + IdentityLevelIncreaseFailedThread, + #[error("We should be connected but the connection params do not exist")] + InitserverParamsMissing, + #[error("Failed to parse initserver: {0}")] + InitserverParse(#[source] ts_bookkeeping::messages::ParseError), + #[error("Timeout while waiting for initserver")] + InitserverTimeout, + #[error("Failed to receive initserver: {0}")] + InitserverWait(#[source] tsproto::client::Error), + #[error("Io error: {0}")] + Io(#[source] tokio::io::Error), + /// The connection is currently not connected to a server but is in the process of connecting. + #[error("Currently not connected")] + NotConnected, + #[error("Failed to resolve address: {0}")] + ResolveAddress(#[source] Box), + #[error("Failed to send clientinit: {0}")] + SendClientinit(#[source] tsproto::client::Error), + #[error("Failed to send packet: {0}")] + SendPacket(#[source] tsproto::client::Error), + #[error("The server changed its identity")] + ServerUidMismatch(UidBuf), +} + +/// The reason for a temporary disconnect. +#[derive(Clone, Copy, Debug)] +pub enum TemporaryDisconnectReason { + /// Timed out because the server did not respond to packets in time. + Timeout(&'static str), + /// The server terminated our connection because it shut down. + /// + /// This corresponds to the `Serverstop` and `ClientdisconnectServerShutdown` reasons. + /// This often happens on server restarts, so the connection will try to reconnect. + Serverstop, +} + +pub trait OutCommandExt { + /// Adds a `return_code` to the command and returns if the corresponding + /// answer is received. If an error occurs, the future will return an error. + fn send_with_result(self, con: &mut Connection) -> Result; + + /// Sends the command without asking for an answer. + fn send(self, con: &mut Connection) -> Result<()>; +} + +/// The result of a download request. +/// +/// A file download can be started by [`Connection::download_file`]. +#[derive(Debug)] +pub struct FileDownloadResult { + /// The size of the requested file. + // TODO The rest of the size when a seek_position is specified? + pub size: u64, + /// The stream where the file can be downloaded. + pub stream: TcpStream, +} + +/// The result of an upload request. +/// +/// A file upload can be started by [`Connection::upload_file`]. +#[derive(Debug)] +pub struct FileUploadResult { + /// The size of the already uploaded part when `resume` was set to `true` + /// in [`Connection::upload_file`]. + pub seek_position: u64, + /// The stream where the file can be uploaded. + pub stream: TcpStream, +} + +/// Signals audio related changes. +#[derive(Debug)] +pub enum AudioEvent { + /// If this client can send audio or is muted. + /// + /// If the client is muted, the server will drop any sent audio packets. A client counts as + /// muted if input or output is muted, he is marked away or the talk power is less than the + /// needed talk power in the current channel. Temporary disconnects also count as mutes. + /// + /// Every time the mute state changes, this event is emitted. + CanSendAudio(bool), + /// If this client can receive audio or the output is muted. + /// + /// Audio packets might still be received but should not be played. + /// + /// Every time the mute state changes, this event is emitted. + CanReceiveAudio(bool), +} + +/// An event that gets returned by the connection. +/// +/// A stream of these events is returned by [`Connection::events`]. +#[derive(Debug)] +pub enum StreamItem { + /// All the incoming book events. + /// + /// If a connection to the server was established this will contain an added event of a server. + BookEvents(Vec), + /// All incoming messages that are not related to the book. + /// + /// This contains messages like `ChannelListFinished` or `ClientChatComposing`. + /// All events related to channels or clients are returned as events in the `BookEvents` + /// variant. Other messages handled by tsclientlib, e.g. for filetransfer are also not included + /// in these events. + MessageEvent(InMessage), + /// Received an audio packet. + /// + /// Audio packets can be handled by the [`AudioHandler`](audio::AudioHandler), which builds a + /// queue per client and handles packet loss and jitter. + #[cfg(feature = "audio")] + Audio(InAudioBuf), + /// The needed level. + IdentityLevelIncreasing(u8), + /// This event may occur without an `IdentityLevelIncreasing` event before + /// if a new identity is created because no identity was supplied. + IdentityLevelIncreased, + /// The connection timed out or the server shut down. The connection will be + /// rebuilt automatically. + DisconnectedTemporarily(TemporaryDisconnectReason), + /// The result of sending a message. + /// + /// The [`MessageHandle`] is the return value of [`OutCommandExt::send_with_result`]. + MessageResult(MessageHandle, std::result::Result<(), CommandError>), + /// A file download succeeded. This event contains the `TcpStream` where the + /// file can be downloaded. + /// + /// The [`FiletransferHandle`] is the return value of [`Connection::download_file`]. + FileDownload(FiletransferHandle, FileDownloadResult), + /// A file upload succeeded. This event contains the `TcpStream` where the + /// file can be uploaded. + /// + /// The [`FiletransferHandle`] is the return value of [`Connection::upload_file`]. + FileUpload(FiletransferHandle, FileUploadResult), + /// A file download or upload failed. + /// + /// This can happen if either the TeamSpeak server denied the file transfer or the tcp + /// connection failed. + /// + /// The [`FiletransferHandle`] is the return value of [`Connection::download_file`] or + /// [`Connection::upload_file`]. + FiletransferFailed(FiletransferHandle, Error), + /// The network statistics were updated. + /// + /// This means e.g. the packet loss got a new value. Clients with audio probably want to update + /// the packet loss option of opus. + NetworkStatsUpdated, + /// A change related to audio. + AudioChange(AudioEvent), +} + +/// The `Connection` is the main interaction point with this library. +/// +/// It represents a connection to a TeamSpeak server. It will reconnect automatically when the +/// connection times out. It will not reconnect which the client is kicked or banned from the +/// server. +pub struct Connection { + state: ConnectionState, + span: Span, + options: ConnectOptions, + stream_items: VecDeque>, +} + +struct ConnectedConnection { + client: client::Client, + cur_return_code: u16, + cur_filetransfer_id: u16, + /// If we are subscribed to the server. This will automatically subscribe to new channels. + subscribed: bool, + /// If a file stream can be opened, it gets put in here until the tcp + /// connection is ready and the key is sent. + /// + /// Afterwards we can directly return a `TcpStream` in the event stream. + filetransfers: Vec>, + connection_time: time::OffsetDateTime, +} + +enum ConnectionState { + /// The future that resolves to a connection and a boolean if we should reconnect on failure. + /// + /// If the `bool` is `false`, the connection will abort on error. Otherwise it will try to + /// connect again on timeout. + Connecting(future::BoxFuture<'static, Result<(client::Client, data::Connection)>>, bool), + IdentityLevelIncreasing { + /// We get the improved identity here. + recv: oneshot::Receiver, + state: Arc>, + }, + Connected { + con: ConnectedConnection, + book: data::Connection, + }, +} + +/// A wrapper to poll events from a connection. This is used so a user can drop +/// and filter the stream of events without problems. +struct EventStream<'a>(&'a mut Connection); + +enum IdentityIncreaseLevelState { + Computing, + /// Set to this state to cancel the computation. + Canceled, +} + +/// The main type of this crate, which represents a connection to a server. +/// +/// After creating a connection with [`Connection::new`], the main way to interact with it is +/// [`get_state`](Connection::get_state). It stores currently visible clients and channels on the +/// server. The setter methods e.g. for the nickname or channel create a command that can be send +/// to the server. The send method returns a handle which can then be used to check if +/// the action succeeded or not. +/// +/// The second way of interaction is polling with [`events()`](Connection::events), which returns a +/// stream of [`StreamItem`]s. +/// +/// The connection will not do anything unless the event stream is polled. Even +/// sending packets will only happen while polling. Make sure to always wait for +/// events when awaiting other futures. +/// +/// # Examples +/// This will open a connection to the TeamSpeak server at `localhost`. +/// +/// ```no_run +/// use futures::prelude::*; +/// use tsclientlib::{Connection, StreamItem}; +/// +/// #[tokio::main] +/// async fn main() { +/// let mut con = Connection::build("localhost").connect().unwrap(); +/// // Wait until connected +/// con.events() +/// // We are connected when we receive the first BookEvents +/// .try_filter(|e| future::ready(matches!(e, StreamItem::BookEvents(_)))) +/// .next() +/// .await +/// .unwrap(); +/// } +/// ``` +impl Connection { + /// Start creating the configuration of a new connection. + /// + /// # Arguments + /// The address of the server has to be supplied. The address can be a + /// [`SocketAddr`](std::net::SocketAddr), a string or directly a [`ServerAddress`]. A string + /// will automatically be resolved from all formats supported by TeamSpeak. + /// For details, see [`resolver::resolve`]. + /// + /// # Examples + /// This will open a connection to the TeamSpeak server at `localhost`. + /// + /// ```no_run + /// # use futures::prelude::*; + /// # use tsclientlib::{Connection, StreamItem}; + /// + /// # #[tokio::main] + /// # async fn main() { + /// let mut con = Connection::build("localhost").connect().unwrap(); + /// // Wait until connected + /// con.events() + /// // We are connected when we receive the first BookEvents + /// .try_filter(|e| future::ready(matches!(e, StreamItem::BookEvents(_)))) + /// .next() + /// .await + /// .unwrap(); + /// # } + /// ``` + #[inline] + pub fn build>(address: A) -> ConnectOptions { + ConnectOptions { + address: address.into(), + local_address: None, + identity: None, + server: None, + name: "TeamSpeakUser".into(), + version: Version::Windows_3_X_X__1, + hardware_id: "923f136fb1e22ae6ce95e60255529c00,d13231b1bc33edfecfb9169cc7a63bcc".into(), + channel: None, + channel_password: None, + password: None, + input_muted: false, + output_muted: false, + input_hardware_enabled: true, + output_hardware_enabled: true, + away: None, + log_commands: false, + log_packets: false, + log_udp_packets: false, + } + } + + /// Create a connection + /// + /// This function opens a new connection to a server. The returned future + /// resolves, when the connection is established successfully. + /// + /// Settings like nickname of the user can be set using the + /// [`ConnectOptions`] parameter. + /// + /// # Examples + /// This will open a connection to the TeamSpeak server at `localhost`. + /// + /// ```no_run + /// # use futures::prelude::*; + /// # use tsclientlib::{Connection, ConnectOptions, StreamItem}; + /// + /// # #[tokio::main] + /// # async fn main() { + /// let mut con = Connection::new(ConnectOptions::new("localhost")).unwrap(); + /// // Wait until connected + /// con.events() + /// // We are connected when we receive the first BookEvents + /// .try_filter(|e| future::ready(matches!(e, StreamItem::BookEvents(_)))) + /// .next() + /// .await + /// .unwrap(); + /// # } + /// ``` + // TODO Remove + #[deprecated(since = "0.2.0", note = "ConnectOptions::connect should be used instead")] + pub fn new(options: ConnectOptions) -> Result { options.connect() } + + /// Get the options which were used to create this connection. + /// + /// The identity of the options is updated while connecting if the identity + /// level needs to be improved. + pub fn get_options(&self) -> &ConnectOptions { &self.options } + + /// Get a stream of events. The event stream needs to be polled, otherwise + /// nothing will happen in a connection, not even sending packets will work. + /// + /// The returned stream can be dropped and recreated if needed. + pub fn events(&mut self) -> impl Stream> + '_ { EventStream(self) } + + /// Connect to a server. + /// + /// If `is_reconnect` is `true`, wait 10 seconds before sending the first packet. This is to not + /// spam unnecessary packets if the internet or server is down. + async fn connect( + options: ConnectOptions, is_reconnect: bool, + ) -> Result<(client::Client, data::Connection)> { + if is_reconnect { + tokio::time::sleep(Duration::from_secs(10)).await; + } + + let resolved = match &options.address { + ServerAddress::SocketAddr(a) => stream::once(future::ok(*a)).left_stream(), + ServerAddress::Other(s) => resolver::resolve(s.into()).right_stream(), + }; + pin_utils::pin_mut!(resolved); + let mut resolved: Pin<_> = resolved; + + let mut errors = Vec::new(); + while let Some(addr) = resolved.next().await { + let addr = addr.map_err(|e| Error::ResolveAddress(Box::new(e)))?; + match Self::connect_to(&options, addr).await { + Ok(res) => return Ok(res), + Err(e @ Error::IdentityLevel(_)) | Err(e @ Error::ConnectTs(_)) => { + // Either increase identity level or the server refused us + return Err(e); + } + Err(error) => { + info!(%error, "Connecting failed, trying next address"); + errors.push(error); + } + } + } + Err(Error::ConnectFailed { address: options.address.to_string(), errors }) + } + + async fn connect_to( + options: &ConnectOptions, addr: SocketAddr, + ) -> Result<(client::Client, data::Connection)> { + let counter = options.identity.as_ref().unwrap().counter(); + let socket = Box::new( + UdpSocket::bind(options.local_address.unwrap_or_else(|| { + if addr.is_ipv4() { + "0.0.0.0:0".parse().unwrap() + } else { + "[::]:0".parse().unwrap() + } + })) + .await + .map_err(Error::Io)?, + ); + let mut client = + client::Client::new(addr, socket, options.identity.as_ref().unwrap().key().clone()); + + // Logging + tsproto::log::add_logger( + options.log_commands, + options.log_packets, + options.log_udp_packets, + &mut *client, + ); + + // Create a connection + debug!(address = %addr, "Connecting"); + client.connect().await.map_err(Error::Connect)?; + + if let Some(server_uid) = &options.server { + let params = if let Some(r) = &client.params { + r + } else { + return Err(Error::InitserverParamsMissing); + }; + let real_uid = UidBuf(params.public_key.get_uid_no_base64()); + if real_uid != *server_uid { + return Err(Error::ServerUidMismatch(real_uid)); + } + } + + // Create clientinit packet + let client_version = options.version.get_version_string(); + let client_platform = options.version.get_platform(); + let client_version_sign = BASE64_STANDARD.encode(options.version.get_signature()); + + let default_channel_password = options + .channel_password + .as_ref() + .map(|p| tsproto_types::crypto::encode_password(p.as_bytes())) + .unwrap_or_default(); + let password = options + .password + .as_ref() + .map(|p| tsproto_types::crypto::encode_password(p.as_bytes())) + .unwrap_or_default(); + let packet = c2s::OutClientInitMessage::new(&mut iter::once(c2s::OutClientInitPart { + name: Cow::Borrowed(options.name.as_ref()), + version: Cow::Borrowed(client_version), + platform: Cow::Borrowed(client_platform), + input_muted: if options.input_muted { Some(true) } else { None }, + output_muted: if options.output_muted { Some(true) } else { None }, + input_hardware_enabled: options.input_hardware_enabled, + output_hardware_enabled: options.output_hardware_enabled, + is_away: if options.away.is_some() { Some(true) } else { None }, + away_message: options.away.as_deref().map(Cow::Borrowed), + default_channel: Cow::Borrowed(options.channel.as_deref().unwrap_or_default()), + default_channel_password: Cow::Borrowed(default_channel_password.as_ref()), + password: Cow::Borrowed(password.as_ref()), + metadata: "".into(), + version_sign: Cow::Borrowed(client_version_sign.as_ref()), + client_key_offset: counter, + phonetic_name: "".into(), + default_token: "".into(), + hardware_id: Cow::Borrowed(options.hardware_id.as_ref()), + badges: None, + signed_badges: None, + integrations: None, + active_integrations_info: None, + my_team_speak_avatar: None, + my_team_speak_id: None, + security_hash: None, + })); + + client.send_packet(packet.into_packet()).map_err(Error::SendClientinit)?; + + match tokio::time::timeout( + Duration::from_secs(INITSERVER_TIMEOUT), + Self::wait_initserver(client), + ) + .await + { + Ok(r) => r, + Err(_) => Err(Error::InitserverTimeout), + } + } + + async fn wait_initserver( + mut client: client::Client, + ) -> Result<(client::Client, data::Connection)> { + // Wait until we received the initserver packet. + loop { + let cmd = client + .filter_commands(|_, cmd| Ok(Some(cmd))) + .await + .map_err(Error::InitserverWait)?; + let msg = InMessage::new(cmd.data().packet().header(), cmd.data().packet().content()) + .map_err(Error::InitserverParse); + + match msg { + Ok(InMessage::CommandError(e)) => { + let e = e.iter().next().unwrap(); + if e.id == ts_bookkeeping::TsError::ClientCouldNotValidateIdentity { + if let Some(needed) = + e.extra_message.as_ref().and_then(|m| m.parse::().ok()) + { + return Err(Error::IdentityLevel(needed)); + } + } + return Err(Error::ConnectTs(e.id)); + } + Ok(InMessage::InitServer(initserver)) => { + let public_key = { + let params = if let Some(r) = &client.params { + r + } else { + return Err(Error::InitserverParamsMissing); + }; + + params.public_key.clone() + }; + + // Create connection + let data = data::Connection::new(public_key, &initserver); + + return Ok((client, data)); + } + Ok(msg) => { + // TODO Save instead of drop + warn!(message = ?msg, "Expected initserver, dropping command"); + } + Err(error) => { + warn!(%error, "Expected initserver, failed to parse command"); + } + } + } + } + + /// If this returns `None`, the level was increased and we should try + /// connecting again. + fn increase_identity_level(&mut self, needed: u8) -> Result<()> { + if needed > 20 { + return Err(Error::IdentityLevel(needed)); + } + + let identity = self.options.identity.as_ref().unwrap().clone(); + let level = identity.level(); + if level >= needed { + return Err(Error::IdentityLevelCorrupted { needed, have: level }); + } + + // Increase identity level + let state = Arc::new(Mutex::new(IdentityIncreaseLevelState::Computing)); + let (send, recv) = oneshot::channel(); + // TODO Use tokio::blocking + // TODO Time estimate + std::thread::spawn(move || { + let mut identity = identity; + // TODO Check if canceled in between + identity.upgrade_level(needed); + let _ = send.send(identity); + }); + + self.state = ConnectionState::IdentityLevelIncreasing { recv, state }; + Ok(()) + } + + /// Adds a `return_code` to the command and returns if the corresponding + /// answer is received. If an error occurs, the future will return an error. + fn send_command_with_result(&mut self, packet: OutCommand) -> Result { + self.update_on_outgoing_command(&packet); + if let ConnectionState::Connected { con, .. } = &mut self.state { + con.send_command_with_result(packet) + } else { + Err(Error::NotConnected) + } + } + + fn send_command(&mut self, packet: OutCommand) -> Result<()> { + self.update_on_outgoing_command(&packet); + if let ConnectionState::Connected { con, .. } = &mut self.state { + con.send_command(packet) + } else { + Err(Error::NotConnected) + } + } + + /// Update for outgoing commands. + /// + /// Updates subscription and muted state. + /// + /// Muted state needs to be handled at the following places: + /// - Outgoing packet to change mute/away state: Immediately apply and add book event, update + /// CanTalk, save in ConnectOptions + /// - Incoming event to change channel/own name, edit current channel/own client permissions, + /// server settings: Update CanTalk/Play, save in ConnectOptions + /// - Incoming packet to change mute/away state: Ignore for own client + /// - Connect, temporary disconnect: Update CanTalk/Play + fn update_on_outgoing_command(&mut self, cmd: &OutCommand) { + if let ConnectionState::Connected { con, book } = &mut self.state { + let (cmd_name, parser) = CommandParser::new(cmd.0.content()); + + if cmd_name == b"channelsubscribeall" { + con.subscribed = true; + } else if cmd_name == b"channelunsubscribeall" { + con.subscribed = false; + } else if cmd_name == b"clientupdate" { + let prev_can_send = Self::intern_can_send_audio(book, &self.options); + let prev_can_receive = Self::intern_can_receive_audio(book, &self.options); + let mut own_client = book.clients.get_mut(&book.own_client); + let mut has_away_message = false; + let mut has_is_away = false; + let mut events = Vec::new(); + + for arg in parser { + if let CommandItem::Argument(arg) = arg { + macro_rules! set_prop { + ($prop:ident, $event:ident, $event_value:ident) => { + self.options.$prop = arg.value().get_raw() == b"1"; + if let Some(own_client) = &mut own_client { + if own_client.$prop != self.options.$prop { + let old = own_client.$prop; + own_client.$prop = self.options.$prop; + events.push(events::Event::PropertyChanged { + id: events::PropertyId::$event(own_client.id), + old: events::PropertyValue::$event_value(old), + invoker: None, + extra: Default::default(), + }); + } + } + }; + } + + match arg.name() { + b"client_input_muted" => { + set_prop!(input_muted, ClientInputMuted, Bool); + } + b"client_output_muted" => { + set_prop!(output_muted, ClientOutputMuted, Bool); + } + b"client_away" => { + if arg.value().get_raw() == b"1" { + if !has_away_message { + self.options.away = Some("".into()); + } + } else { + self.options.away = None; + } + has_is_away = true; + } + b"client_away_message" => { + if has_is_away && self.options.away.is_some() { + match arg.value().get_str() { + Ok(r) => self.options.away = Some(r.to_string().into()), + Err(error) => { + warn!(%error, message = ?arg.value(), + "Failed to parse sent away message"); + } + } + has_away_message = true; + } + } + b"client_input_hardware" => { + set_prop!(input_hardware_enabled, ClientInputHardwareEnabled, Bool); + } + b"client_output_hardware" => { + set_prop!( + output_hardware_enabled, + ClientOutputHardwareEnabled, + Bool + ); + } + _ => {} + } + if let Some(own_client) = &mut own_client { + if own_client.away_message.as_deref() + != self.options.away.as_ref().map(|s| s.as_ref()) + { + let old = mem::replace( + &mut own_client.away_message, + self.options.away.as_ref().map(|s| s.to_string()), + ); + events.push(events::Event::PropertyChanged { + id: events::PropertyId::ClientAwayMessage(own_client.id), + old: events::PropertyValue::OptionString(old), + invoker: None, + extra: Default::default(), + }); + } + } + } + } + + if !events.is_empty() { + self.stream_items.push_back(Ok(StreamItem::BookEvents(events))); + } + + let new_can_send = Self::intern_can_send_audio(book, &self.options); + let new_can_receive = Self::intern_can_receive_audio(book, &self.options); + if new_can_send != prev_can_send { + self.stream_items.push_back(Ok(StreamItem::AudioChange( + AudioEvent::CanSendAudio(new_can_send), + ))); + } + if new_can_receive != prev_can_receive { + self.stream_items.push_back(Ok(StreamItem::AudioChange( + AudioEvent::CanReceiveAudio(new_can_receive), + ))); + } + } + } + } + + /// Cancels the computation to increase the identity level. + /// + /// This function initiates the cancellation and immediately returns. It + /// does not wait until the background thread quits. + /// + /// Does nothing if the identity level is currently not increased. + pub fn cancel_identity_level_increase(&mut self) { + if let ConnectionState::IdentityLevelIncreasing { state, .. } = &mut self.state { + *state.lock().unwrap() = IdentityIncreaseLevelState::Canceled; + } + } + + /// Get access to the raw connection. + /// + /// Fails if the connection is currently not connected to the server. + #[cfg(feature = "unstable")] + pub fn get_tsproto_client(&self) -> Result<&client::Client> { + if let ConnectionState::Connected { con, .. } = &self.state { + Ok(&con.client) + } else { + Err(Error::NotConnected) + } + } + + /// Get access to the raw connection. + /// + /// Fails if the connection is currently not connected to the server. + #[cfg(feature = "unstable")] + pub fn get_tsproto_client_mut(&mut self) -> Result<&mut client::Client> { + if let ConnectionState::Connected { con, .. } = &mut self.state { + Ok(&mut con.client) + } else { + Err(Error::NotConnected) + } + } + + /// Returns the public key of the server, fails if disconnected. + #[cfg(feature = "unstable")] + pub fn get_server_key(&self) -> Result { + self.get_tsproto_client().and_then(|c| { + if let Some(params) = &c.params { + Ok(params.public_key.clone()) + } else { + Err(Error::NotConnected) + } + }) + } + + /// Get the current state of clients and channels of this connection. + /// + /// Fails if the connection is currently not connected to the server. + pub fn get_state(&self) -> Result<&data::Connection> { + if let ConnectionState::Connected { book, .. } = &self.state { + Ok(book) + } else { + Err(Error::NotConnected) + } + } + + /// Disconnect from the server. + /// + /// # Arguments + /// - `options`: Either `None` or `DisconnectOptions`. + /// + /// # Examples + /// + /// Use default options: + /// + /// ```no_run + /// # use futures::prelude::*; + /// # use tsclientlib::{Connection, DisconnectOptions, StreamItem}; + /// + /// # #[tokio::main] + /// # async fn main() { + /// let mut con = Connection::build("localhost").connect().unwrap(); + /// // Wait until connected + /// con.events() + /// // We are connected when we receive the first BookEvents + /// .try_filter(|e| future::ready(matches!(e, StreamItem::BookEvents(_)))) + /// .next() + /// .await + /// .unwrap(); + /// + /// // Disconnect + /// con.disconnect(DisconnectOptions::new()).unwrap(); + /// con.events().for_each(|_| future::ready(())).await; + /// # } + /// ``` + /// + /// Specify a reason and a quit message: + /// + /// ```no_run + /// # use futures::prelude::*; + /// # use tsclientlib::{Connection, DisconnectOptions, Reason, StreamItem}; + /// + /// # #[tokio::main] + /// # async fn main() { + /// let mut con = Connection::build("localhost").connect().unwrap(); + /// // Wait until connected + /// con.events() + /// // We are connected when we receive the first BookEvents + /// .try_filter(|e| future::ready(matches!(e, StreamItem::BookEvents(_)))) + /// .next() + /// .await + /// .unwrap(); + /// + /// // Disconnect + /// let options = DisconnectOptions::new() + /// .reason(Reason::Clientdisconnect) + /// .message("Away for a while"); + /// con.disconnect(options).unwrap(); + /// con.events().for_each(|_| future::ready(())).await; + /// # } + /// ``` + pub fn disconnect(&mut self, options: DisconnectOptions) -> Result<()> { + if let ConnectionState::Connected { con, book } = &mut self.state { + let packet = book.disconnect(options); + con.client.send_packet(packet.into_packet()).map_err(Error::SendPacket)?; + } + Ok(()) + } + + /// Send audio to the server. + /// + /// This function does only accept `Voice` and `VoiceWhisper` packets. Commands should be send + /// with [`command.send(&mut connection)`](OutCommandExt::send) or + /// [`command.send_with_result(&mut connection)`](OutCommandExt::send_with_result). + /// + /// # Examples + /// + /// ```no_run + /// # let con: tsclientlib::Connection = panic!(); + /// use tsproto_packets::packets::{AudioData, CodecType, OutAudio}; + /// let codec = CodecType::OpusVoice; + /// // Send an empty packet to signal audio end + /// let packet = OutAudio::new(&AudioData::C2S { id: 0, codec, data: &[] }); + /// con.send_audio(packet).unwrap(); + /// ``` + pub fn send_audio(&mut self, packet: OutPacket) -> Result<()> { + assert!( + [PacketType::Voice, PacketType::VoiceWhisper].contains(&packet.header().packet_type()), + "Can only send audio packets with send_audio" + ); + if let ConnectionState::Connected { con, book } = &mut self.state { + if !Self::intern_can_send_audio(book, &self.options) { + let span = self.span.clone(); + warn!(parent: span, "Sending audio while muted"); + } + con.client.send_packet(packet).map_err(Error::SendPacket)?; + Ok(()) + } else { + Err(Error::NotConnected) + } + } + + /// Download a file from a channel of the connected TeamSpeak server. + /// + /// Returns the size of the file and a tcp stream of the requested file. + /// + /// # Examples + /// Download an icon. + /// + /// ```no_run + /// # use tsclientlib::ChannelId; + /// # let con: tsclientlib::Connection = panic!(); + /// # let id = 0; + /// let handle_future = con.download_file(ChannelId(0), &format!("/icon_{}", id), None, None); + /// # // TODO Show rest of download + /// ``` + pub fn download_file( + &mut self, channel_id: ChannelId, path: &str, channel_password: Option<&str>, + seek_position: Option, + ) -> Result { + if let ConnectionState::Connected { con, .. } = &mut self.state { + con.download_file(channel_id, path, channel_password, seek_position) + } else { + Err(Error::NotConnected) + } + } + + /// Upload a file to a channel of the connected TeamSpeak server. + /// + /// Returns the size of the part which is already uploaded (when resume is + /// specified) and a tcp stream where the requested file should be uploaded. + /// + /// # Examples + /// Upload an avatar. + /// + /// ```no_run + /// # use tsclientlib::ChannelId; + /// # let con: tsclientlib::Connection = panic!(); + /// # let size = 0; + /// let handle_future = con.upload_file(ChannelId(0), "/avatar", None, size, true, false); + /// # // TODO Show rest of upload + /// ``` + pub fn upload_file( + &mut self, channel_id: ChannelId, path: &str, channel_password: Option<&str>, size: u64, + overwrite: bool, resume: bool, + ) -> Result { + if let ConnectionState::Connected { con, .. } = &mut self.state { + con.upload_file(channel_id, path, channel_password, size, overwrite, resume) + } else { + Err(Error::NotConnected) + } + } + + /// Get statistics about the network connection. + /// + /// # Example + /// Get the fraction of packets that are currently lost. + /// + /// ```no_run + /// # let con: tsclientlib::Connection = panic!(); + /// let loss: f32 = con.get_network_stats().unwrap().get_packetloss(); + /// ``` + /// + /// # Error + /// Returns an error if currently not connected. + pub fn get_network_stats(&self) -> Result<&ConnectionStats> { + if let ConnectionState::Connected { con, .. } = &self.state { + Ok(&con.client.resender.stats) + } else { + Err(Error::NotConnected) + } + } + + /// If this client can send audio or is muted. + /// + /// If the client is muted, the server will drop any sent audio packets. A client counts as + /// muted if input or output is muted, he is marked away or the talk power is less than the + /// needed talk power in the current channel. Temporary disconnects also count as mutes. + /// + /// If this changes, the [`AudioEvent::CanSendAudio`] event is emitted. + pub fn can_send_audio(&self) -> bool { + if let ConnectionState::Connected { book, .. } = &self.state { + Self::intern_can_send_audio(book, &self.options) + } else { + false + } + } + + fn intern_can_send_audio(book: &data::Connection, options: &ConnectOptions) -> bool { + if let Some(own_client) = book.clients.get(&book.own_client) { + if own_client.input_muted + || !own_client.input_hardware_enabled + || own_client.away_message.is_some() + || own_client.output_muted + || !own_client.output_hardware_enabled + { + return false; + } + if let Some(own_channel) = book.channels.get(&own_client.channel) { + if let Some(needed_talk_power) = own_channel.needed_talk_power { + return own_client.talk_power_granted + || own_client.talk_power >= needed_talk_power; + } + } + true + } else { + !options.input_muted + && options.input_hardware_enabled + && options.away.is_none() + && !options.output_muted + && options.output_hardware_enabled + } + } + + /// If this client can receive audio or the output is muted. + /// + /// This will return `false` if the client is currently not connected to the server. + /// Audio packets might still be received but should not be played. + /// + /// If this changes, the [`AudioEvent::CanReceiveAudio`] event is emitted. + pub fn can_receive_audio(&self) -> bool { + if let ConnectionState::Connected { book, .. } = &self.state { + Self::intern_can_receive_audio(book, &self.options) + } else { + false + } + } + + fn intern_can_receive_audio(book: &data::Connection, options: &ConnectOptions) -> bool { + if let Some(own_client) = book.clients.get(&book.own_client) { + !own_client.output_muted + && !own_client.output_only_muted + && own_client.output_hardware_enabled + } else { + !options.output_muted && options.output_hardware_enabled + } + } + + /// If the current channel (and server) allow unencrypted voice packets. + /// + /// For whisper packets, only the server setting is checked. + #[cfg(feature = "audio")] + fn intern_can_receive_unencrypted_audio(book: &data::Connection, whisper: bool) -> bool { + match book.server.codec_encryption_mode { + CodecEncryptionMode::ForcedOn => false, + CodecEncryptionMode::ForcedOff => true, + CodecEncryptionMode::PerChannel => { + if whisper { + return true; + } + if let Some(own_client) = book.clients.get(&book.own_client) { + if let Some(own_channel) = book.channels.get(&own_client.channel) { + return own_channel.is_unencrypted.unwrap_or(true); + } + } + true + } + } + } + + fn poll_next(&mut self, cx: &mut Context) -> Poll>> { + let _span = self.span.clone().entered(); + if let Some(item) = self.stream_items.pop_front() { + return Poll::Ready(Some(item)); + } + match &mut self.state { + ConnectionState::Connecting(fut, reconnect) => match fut.poll_unpin(cx) { + Poll::Pending => Poll::Pending, + Poll::Ready(Err(Error::IdentityLevel(level))) => { + if let Err(e) = self.increase_identity_level(level) { + return Poll::Ready(Some(Err(e))); + } + Poll::Ready(Some(Ok(StreamItem::IdentityLevelIncreasing(level)))) + } + Poll::Ready(Err(e)) => { + if *reconnect { + if let Error::ConnectFailed { errors, .. } = &e { + for e in errors { + if let Error::Connect(client::Error::TsProto( + tsproto::Error::Timeout(reason), + )) = e + { + debug!(timeout = reason, "Connect failed, reconnecting"); + let fut = + Self::connect(self.options.clone(), true).in_current_span(); + self.state = ConnectionState::Connecting(Box::pin(fut), true); + return self.poll_next(cx); + } + } + } + } + Poll::Ready(Some(Err(e))) + } + Poll::Ready(Ok((client, book))) => { + let con = ConnectedConnection { + client, + cur_return_code: 0, + cur_filetransfer_id: 0, + subscribed: false, + filetransfers: Default::default(), + connection_time: OffsetDateTime::now_utc(), + }; + if Self::intern_can_send_audio(&book, &self.options) { + self.stream_items + .push_back(Ok(StreamItem::AudioChange(AudioEvent::CanSendAudio(true)))); + } + if Self::intern_can_receive_audio(&book, &self.options) { + self.stream_items.push_back(Ok(StreamItem::AudioChange( + AudioEvent::CanReceiveAudio(true), + ))); + } + self.state = ConnectionState::Connected { con, book }; + Poll::Ready(Some(Ok(StreamItem::BookEvents(vec![ + events::Event::PropertyAdded { + id: events::PropertyId::Server, + invoker: None, + extra: Default::default(), + }, + ])))) + } + }, + ConnectionState::IdentityLevelIncreasing { recv, .. } => match recv.poll_unpin(cx) { + Poll::Pending => Poll::Pending, + Poll::Ready(Err(_)) => { + Poll::Ready(Some(Err(Error::IdentityLevelIncreaseFailedThread))) + } + Poll::Ready(Ok(identity)) => { + self.options.identity = Some(identity); + let fut = Self::connect(self.options.clone(), false); + self.state = + ConnectionState::Connecting(Box::pin(fut.in_current_span()), false); + Poll::Ready(Some(Ok(StreamItem::IdentityLevelIncreased))) + } + }, + ConnectionState::Connected { con, book } => match loop { + match con.client.poll_next_unpin(cx) { + Poll::Pending => break Poll::Pending, + Poll::Ready(None) => break Poll::Ready(None), + Poll::Ready(Some(Err(e))) => { + // Check if we were disconnecting + let state = con.client.resender.get_state(); + if state == ResenderState::Disconnected + || state == ResenderState::Disconnecting + { + break Poll::Ready(None); + } + + if let client::Error::TsProto(tsproto::Error::Timeout(reason)) = e { + // Reconnect on timeout + warn!(timeout = reason, "Connection failed, reconnecting"); + let fut = Self::connect(self.options.clone(), true); + self.state = + ConnectionState::Connecting(Box::pin(fut.in_current_span()), true); + return Poll::Ready(Some(Ok(StreamItem::DisconnectedTemporarily( + TemporaryDisconnectReason::Timeout(reason), + )))); + } else { + break Poll::Ready(Some(Err(Error::ConnectionFailed(e)))); + } + } + Poll::Ready(Some(Ok(item))) => match item { + ProtoStreamItem::Error(error) => { + warn!(%error, "Connection got a non-fatal error"); + } + #[cfg(feature = "audio")] + ProtoStreamItem::Audio(audio) => { + if !Self::intern_can_receive_audio(book, &self.options) { + info!("Received audio packet while output is muted, ignoring"); + } else { + let encrypted = !audio + .data() + .packet() + .header() + .flags() + .contains(tsproto_packets::packets::Flags::UNENCRYPTED); + let whisper = audio.data().packet().header().packet_type() + == PacketType::VoiceWhisper; + if encrypted + || Self::intern_can_receive_unencrypted_audio(book, whisper) + { + return Poll::Ready(Some(Ok(StreamItem::Audio(audio)))); + } else { + info!( + "Received unencrypted audio packet but only encrypted \ + packets are allowed, ignoring" + ); + } + } + } + ProtoStreamItem::Command(cmd) => { + let prev_can_send = Self::intern_can_send_audio(book, &self.options); + let prev_can_receive = + Self::intern_can_receive_audio(book, &self.options); + if let Some(reason) = con.handle_command( + book, + &mut self.stream_items, + &mut self.options, + cmd, + ) { + warn!("Server shut down, reconnecting"); + let fut = Self::connect(self.options.clone(), true); + self.state = ConnectionState::Connecting( + Box::pin(fut.in_current_span()), + true, + ); + if prev_can_send { + self.stream_items.push_back(Ok(StreamItem::AudioChange( + AudioEvent::CanSendAudio(false), + ))); + } + if prev_can_receive { + self.stream_items.push_back(Ok(StreamItem::AudioChange( + AudioEvent::CanReceiveAudio(false), + ))); + } + self.stream_items + .push_back(Ok(StreamItem::DisconnectedTemporarily(reason))); + return Poll::Ready(Some(self.stream_items.pop_front().unwrap())); + } + + let new_can_send = Self::intern_can_send_audio(book, &self.options); + let new_can_receive = + Self::intern_can_receive_audio(book, &self.options); + if new_can_send != prev_can_send { + self.stream_items.push_back(Ok(StreamItem::AudioChange( + AudioEvent::CanSendAudio(new_can_send), + ))); + } + if new_can_receive != prev_can_receive { + self.stream_items.push_back(Ok(StreamItem::AudioChange( + AudioEvent::CanReceiveAudio(new_can_receive), + ))); + } + if let Some(item) = self.stream_items.pop_front() { + break Poll::Ready(Some(item)); + } + } + ProtoStreamItem::NetworkStatsUpdated => { + return Poll::Ready(Some(Ok(StreamItem::NetworkStatsUpdated))); + } + _ => {} + }, + } + } { + Poll::Ready(r) => Poll::Ready(r), + Poll::Pending => { + // Check file transfers + let ft = con.filetransfers.iter_mut().enumerate().find_map(|(i, ft)| match ft + .poll_unpin(cx) + { + Poll::Pending => None, + Poll::Ready(r) => Some((i, r)), + }); + if let Some((i, res)) = ft { + let _ = con.filetransfers.remove(i); + Poll::Ready(Some(Ok(res))) + } else { + Poll::Pending + } + } + }, + } + } +} + +impl OutCommandExt for T { + fn send_with_result(self, con: &mut Connection) -> Result { + con.send_command_with_result(self.to_packet()) + } + + fn send(self, con: &mut Connection) -> Result<()> { con.send_command(self.to_packet()) } +} + +impl Drop for Connection { + fn drop(&mut self) { self.cancel_identity_level_increase(); } +} + +impl<'a> Stream for EventStream<'a> { + type Item = Result; + fn poll_next(mut self: Pin<&mut Self>, ctx: &mut Context) -> Poll> { + self.0.poll_next(ctx) + } +} + +impl ConnectedConnection { + fn handle_command( + &mut self, book: &mut data::Connection, stream_items: &mut VecDeque>, + options: &mut ConnectOptions, cmd: InCommandBuf, + ) -> Option { + let msg = match InMessage::new(cmd.data().packet().header(), cmd.data().packet().content()) + { + Ok(r) => r, + Err(error) => { + warn!(%error, "Failed to parse message"); + return None; + } + }; + + let mut handled = true; + if let InMessage::CommandError(msg) = &msg { + // Handle error messages + for msg in msg.iter() { + if let Some(ret_code) = msg.return_code.as_ref().and_then(|r| r.parse().ok()) { + let res = if msg.id == TsError::Ok { + Ok(()) + } else { + Err(CommandError { + error: msg.id, + missing_permission: msg.missing_permission_id, + }) + }; + stream_items + .push_back(Ok(StreamItem::MessageResult(MessageHandle(ret_code), res))); + } else { + handled = false; + } + } + } else if let InMessage::FileDownload(msg) = &msg { + for msg in msg.iter() { + let ft_id = FiletransferHandle(msg.client_filetransfer_id); + let ip = msg.ip.unwrap_or_else(|| self.client.address.ip()); + let addr = SocketAddr::new(ip, msg.port); + let key = msg.filetransfer_key.clone(); + let size = msg.size; + + let fut = Box::new(async move { + let addr = addr; + let key = key; + let mut stream = + TcpStream::connect(&addr).await.map_err(Error::FiletransferIo)?; + stream.write_all(key.as_bytes()).await.map_err(Error::FiletransferIo)?; + stream.flush().await.map_err(Error::FiletransferIo)?; + Ok(stream) + }) + .map(move |res| match res { + Ok(stream) => { + StreamItem::FileDownload(ft_id, FileDownloadResult { size, stream }) + } + Err(e) => StreamItem::FiletransferFailed(ft_id, e), + }); + + self.filetransfers.push(Box::pin(fut)); + } + } else if let InMessage::FileUpload(msg) = &msg { + for msg in msg.iter() { + let ft_id = FiletransferHandle(msg.client_filetransfer_id); + let ip = msg.ip.unwrap_or_else(|| self.client.address.ip()); + let addr = SocketAddr::new(ip, msg.port); + let key = msg.filetransfer_key.clone(); + let seek_position = msg.seek_position; + + let fut = Box::new(async move { + let addr = addr; + let key = key; + let mut stream = + TcpStream::connect(&addr).await.map_err(Error::FiletransferIo)?; + stream.write_all(key.as_bytes()).await.map_err(Error::FiletransferIo)?; + stream.flush().await.map_err(Error::FiletransferIo)?; + Ok(stream) + }) + .map(move |res| match res { + Ok(stream) => { + StreamItem::FileUpload(ft_id, FileUploadResult { seek_position, stream }) + } + Err(e) => StreamItem::FiletransferFailed(ft_id, e), + }); + + self.filetransfers.push(Box::pin(fut)); + } + } else if let InMessage::FiletransferStatus(msg) = &msg { + for msg in msg.iter() { + let ft_id = FiletransferHandle(msg.client_filetransfer_id); + let err = CommandError { error: msg.status, missing_permission: None }; + stream_items.push_back(Ok(StreamItem::FiletransferFailed(ft_id, err.into()))); + } + } else if let InMessage::ClientConnectionInfoUpdateRequest(_) = &msg { + // Answer with connection stats + let stats = &self.client.resender.stats; + let last_second_bytes = stats.get_last_second_bytes(); + let last_minute_bytes = stats.get_last_minute_bytes(); + let packet = c2s::OutSetConnectionInfoMessage::new(&mut iter::once( + c2s::OutSetConnectionInfoPart { + ping: stats.rtt.try_into().unwrap_or_else(|_| time::Duration::seconds(1)), + ping_deviation: stats + .rtt_dev + .try_into() + .unwrap_or_else(|_| time::Duration::seconds(1)), + packets_sent_speech: stats.total_packets[PacketStat::OutSpeech as usize], + packets_sent_keepalive: stats.total_packets[PacketStat::OutKeepalive as usize], + packets_sent_control: stats.total_packets[PacketStat::OutControl as usize], + bytes_sent_speech: stats.total_bytes[PacketStat::OutSpeech as usize], + bytes_sent_keepalive: stats.total_bytes[PacketStat::OutKeepalive as usize], + bytes_sent_control: stats.total_bytes[PacketStat::OutControl as usize], + packets_received_speech: stats.total_packets[PacketStat::InSpeech as usize], + packets_received_keepalive: stats.total_packets + [PacketStat::InKeepalive as usize], + packets_received_control: stats.total_packets[PacketStat::InControl as usize], + bytes_received_speech: stats.total_bytes[PacketStat::InSpeech as usize], + bytes_received_keepalive: stats.total_bytes[PacketStat::InKeepalive as usize], + bytes_received_control: stats.total_bytes[PacketStat::InControl as usize], + server_to_client_packetloss_speech: stats.get_packetloss_s2c_speech(), + server_to_client_packetloss_keepalive: stats.get_packetloss_s2c_keepalive(), + server_to_client_packetloss_control: stats.get_packetloss_s2c_control(), + server_to_client_packetloss_total: stats.get_packetloss_s2c_total(), + bandwidth_sent_last_second_speech: last_second_bytes + [PacketStat::OutSpeech as usize] + as u64, + bandwidth_sent_last_second_keepalive: last_second_bytes + [PacketStat::OutKeepalive as usize] + as u64, + bandwidth_sent_last_second_control: last_second_bytes + [PacketStat::OutControl as usize] + as u64, + bandwidth_sent_last_minute_speech: last_minute_bytes + [PacketStat::OutSpeech as usize] + / 60, + bandwidth_sent_last_minute_keepalive: last_minute_bytes + [PacketStat::OutKeepalive as usize] + / 60, + bandwidth_sent_last_minute_control: last_minute_bytes + [PacketStat::OutControl as usize] + / 60, + bandwidth_received_last_second_speech: last_second_bytes + [PacketStat::InSpeech as usize] + as u64, + bandwidth_received_last_second_keepalive: last_second_bytes + [PacketStat::InKeepalive as usize] + as u64, + bandwidth_received_last_second_control: last_second_bytes + [PacketStat::InControl as usize] + as u64, + bandwidth_received_last_minute_speech: last_minute_bytes + [PacketStat::InSpeech as usize] + / 60, + bandwidth_received_last_minute_keepalive: last_minute_bytes + [PacketStat::InKeepalive as usize] + / 60, + bandwidth_received_last_minute_control: last_minute_bytes + [PacketStat::InControl as usize] + / 60, + }, + )); + + if let Err(e) = self.client.send_packet(packet.into_packet()) { + stream_items.push_back(Err(Error::SendPacket(e))); + } + } else { + let (mut events, book_handled) = match book.handle_command(&msg) { + Ok(r) => r, + Err(error) => { + warn!(%error, "Failed to handle message"); + (Vec::new(), false) + } + }; + + if let InMessage::ClientConnectionInfo(msg) = &msg { + for msg in msg.iter() { + if msg.client_id == book.own_client && msg.connected_time.is_none() { + if let Some(own_client) = book.clients.get_mut(&book.own_client) { + if let Some(connection_data) = &mut own_client.connection_data { + connection_data.connected_time = + Some(OffsetDateTime::now_utc() - self.connection_time); + } + } + } + } + } + + handled = book_handled; + self.client.hand_back_buffer(cmd.into_buffer()); + if !events.is_empty() { + // Ignore mute state update for own client + let own_id = book.own_client; + if let Some(own_client) = book.clients.get_mut(&own_id) { + events.retain(|e| { + if let events::Event::PropertyChanged { id, old, .. } = e { + macro_rules! reset { + ($msg:ident, $obj:ident) => { + if *id == events::PropertyId::$msg(own_id) { + if let events::PropertyValue::Bool(b) = old { + own_client.$obj = *b; + } + return false; + } + }; + } + + reset!(ClientInputMuted, input_muted); + reset!(ClientOutputMuted, output_muted); + reset!(ClientInputHardwareEnabled, input_hardware_enabled); + reset!(ClientOutputHardwareEnabled, output_hardware_enabled); + reset!(ClientOutputOnlyMuted, output_only_muted); + + if *id == events::PropertyId::ClientAwayMessage(own_id) { + if let events::PropertyValue::OptionString(s) = old { + own_client.away_message = s.clone(); + } + return false; + } + } + true + }); + } + + stream_items.push_back(Ok(StreamItem::BookEvents(events))); + } + } + + if let InMessage::ChannelCreated(msg) = &msg { + // Handle subscriptions + // - If the client (server groups or permissions) change, he stays subscribed (even if he + // does not have the power anymore). + // - If the channel is edited, the subscription status gets updated. + // - If we enter a channel, we get subscribed but there is no notification that we are + // subscribed. + // - If we leave a channel, there is a notification that we unsubscribed. + // - If a new channel is created, we are not automatically subscribed. + if self.subscribed { + // Subscribe to new channels + let packet = c2s::OutChannelSubscribeMessage::new( + &mut msg + .iter() + .map(|msg| c2s::OutChannelSubscribePart { channel_id: msg.channel_id }), + ); + if let Err(error) = self.client.send_packet(packet.into_packet()) { + warn!(%error, "Failed to send channel subscribe packet"); + } + } + } else if let InMessage::ClientLeftView(msg) = &msg { + // Handle server restarts + for msg in msg.iter() { + if msg.client_id == book.own_client + && matches!( + msg.reason, + Some(Reason::Serverstop) | Some(Reason::ClientdisconnectServerShutdown) + ) { + return Some(TemporaryDisconnectReason::Serverstop); + } + } + } else if let InMessage::ClientMoved(msg) = &msg { + // Save channel switches in options + for msg in msg.iter() { + if msg.client_id == book.own_client && msg.target_channel_id.0 != 0 { + options.channel = Some(format!("/{}", msg.target_channel_id.0).into()); + break; + } + } + } else if let InMessage::ClientUpdated(msg) = &msg { + // Save name change in options + for msg in msg.iter() { + if msg.client_id == book.own_client { + if let Some(name) = &msg.name { + options.name = name.to_string().into(); + } + } + } + } + + if !handled { + stream_items.push_back(Ok(StreamItem::MessageEvent(msg))); + } + None + } + + fn send_command_with_result(&mut self, mut packet: OutCommand) -> Result { + let code = self.cur_return_code; + self.cur_return_code += 1; + packet.write_arg("return_code", &code); + + self.send_command(packet).map(|_| MessageHandle(code)) + } + + fn send_command(&mut self, packet: OutCommand) -> Result<()> { + self.client.send_packet(packet.into_packet()).map(|_| ()).map_err(Error::SendPacket) + } + + fn download_file( + &mut self, channel_id: ChannelId, path: &str, channel_password: Option<&str>, + seek_position: Option, + ) -> Result { + let ft_id = self.cur_filetransfer_id; + self.cur_filetransfer_id += 1; + let pass = channel_password + .map(|p| tsproto_types::crypto::encode_password(p.as_bytes())) + .unwrap_or_default(); + let packet = c2s::OutInitDownloadMessage::new(&mut iter::once(c2s::OutInitDownloadPart { + client_filetransfer_id: ft_id, + name: Cow::Borrowed(path), + channel_id, + channel_password: Cow::Borrowed(&pass), + seek_position: seek_position.unwrap_or_default(), + protocol: 1, + })); + + self.send_command_with_result(packet).map(|_| FiletransferHandle(ft_id)) + } + + fn upload_file( + &mut self, channel_id: ChannelId, path: &str, channel_password: Option<&str>, size: u64, + overwrite: bool, resume: bool, + ) -> Result { + let ft_id = self.cur_filetransfer_id; + self.cur_filetransfer_id += 1; + + let pass = channel_password + .map(|p| tsproto_types::crypto::encode_password(p.as_bytes())) + .unwrap_or_default(); + let packet = c2s::OutInitUploadMessage::new(&mut iter::once(c2s::OutInitUploadPart { + client_filetransfer_id: ft_id, + name: Cow::Borrowed(path), + channel_id, + channel_password: Cow::Borrowed(&pass), + overwrite, + resume, + size, + protocol: 1, + })); + + self.send_command_with_result(packet).map(|_| FiletransferHandle(ft_id)) + } +} + +/// The configuration for creating a new connection. +/// +/// # Example +/// +/// ``` +/// # use tsclientlib::Connection; +/// let config = Connection::build("localhost") +/// .name("MyUser") +/// .channel("Default Channel/Nested"); +/// +/// let con = Connection::new(config); +/// ``` +#[derive(Clone, Debug)] +pub struct ConnectOptions { + address: ServerAddress, + local_address: Option, + identity: Option, + server: Option, + name: Cow<'static, str>, + version: Version, + hardware_id: Cow<'static, str>, + channel: Option>, + channel_password: Option>, + password: Option>, + input_muted: bool, + output_muted: bool, + input_hardware_enabled: bool, + output_hardware_enabled: bool, + away: Option>, + log_commands: bool, + log_packets: bool, + log_udp_packets: bool, +} + +impl ConnectOptions { + /// Start creating the configuration of a new connection. + /// + /// # Arguments + /// The address of the server has to be supplied. The address can be a + /// [`SocketAddr`](std::net::SocketAddr), a string or directly a [`ServerAddress`]. A string + /// will automatically be resolved from all formats supported by TeamSpeak. + /// For details, see [`resolver::resolve`]. + #[inline] + // TODO Remove + #[deprecated(since = "0.2.0", note = "Connection::build should be used instead")] + pub fn new>(address: A) -> Self { Connection::build(address) } + + /// Create the connection object from these options. + /// + /// This function opens a new connection to a server. The connection needs to be polled for + /// events to do something. + /// + /// # Examples + /// This will open a connection to the TeamSpeak server at `localhost`. + /// + /// ```no_run + /// # use futures::prelude::*; + /// # use tsclientlib::{Connection, StreamItem}; + /// + /// # #[tokio::main] + /// # async fn main() { + /// let mut con = Connection::build("localhost").connect().unwrap(); + /// // Wait until connected + /// con.events() + /// // We are connected when we receive the first BookEvents + /// .try_filter(|e| future::ready(matches!(e, StreamItem::BookEvents(_)))) + /// .next() + /// .await + /// .unwrap(); + /// # } + /// ``` + pub fn connect(mut self) -> Result { + let span = info_span!("connection", addr = %self.address).entered(); + + #[cfg(debug_assertions)] + let profile = "Debug"; + #[cfg(not(debug_assertions))] + let profile = "Release"; + + info!( + version = git_testament::render_testament!(TESTAMENT).as_str(), + profile, + tsproto_version = git_testament::render_testament!(tsproto::get_testament()).as_str(), + "tsclientlib" + ); + + let mut stream_items = VecDeque::new(); + self.identity = Some(self.identity.take().unwrap_or_else(|| { + // Create new ECDH key + let id = Identity::create(); + // Send event + stream_items.push_back(Ok(StreamItem::IdentityLevelIncreased)); + id + })); + + // Try all addresses + let fut = Connection::connect(self.clone(), false); + + Ok(Connection { + state: ConnectionState::Connecting(Box::pin(fut.in_current_span()), false), + span: span.exit(), + options: self, + stream_items, + }) + } + + /// The address for the socket of our client + /// + /// # Default + /// The default is `0.0.0:0` when connecting to an IPv4 address and `[::]:0` + /// when connecting to an IPv6 address. + #[inline] + pub fn local_address(mut self, local_address: SocketAddr) -> Self { + self.local_address = Some(local_address); + self + } + + /// Set the identity of the user. + /// + /// # Default + /// A new identity is generated when connecting. + #[inline] + pub fn identity(mut self, identity: Identity) -> Self { + self.identity = Some(identity); + self + } + + /// Check the identity of the server to be equal with the given uid. + /// + /// If the public key of the server does not match this uid, the connection will be aborted. + /// + /// # Default + /// Allow the server to have any identity. + #[inline] + pub fn server(mut self, server: UidBuf) -> Self { + self.server = Some(server); + self + } + + /// The name of the user. + /// + /// # Default + /// `TeamSpeakUser` + #[inline] + pub fn name>>(mut self, name: S) -> Self { + self.name = name.into(); + self + } + + /// The displayed version of the client. + /// + /// # Default + /// `3.2.1 on Linux` + #[inline] + pub fn version(mut self, version: Version) -> Self { + self.version = version; + self + } + + /// The hardware ID (HWID) of the client. + /// + /// # Default + /// `923f136fb1e22ae6ce95e60255529c00,d13231b1bc33edfecfb9169cc7a63bcc` + #[inline] + pub fn hardware_id>>(mut self, hwid: S) -> Self { + self.hardware_id = hwid.into(); + self + } + + /// Connect to a specific channel. + /// + /// # Example + /// ``` + /// # use tsclientlib::Connection; + /// let opts = Connection::build("localhost").channel("Default Channel"); + /// ``` + /// + /// Connecting to a channel further down in the hierarchy. + /// ``` + /// # use tsclientlib::Connection; + /// let opts = Connection::build("localhost").channel("Default Channel/Nested"); + /// ``` + #[inline] + pub fn channel>>(mut self, path: S) -> Self { + self.channel = Some(path.into()); + self + } + + /// Connect to a specific channel. + /// + /// Setting the channel id is equal to connecting to the channel `/`. + /// + /// # Example + /// ``` + /// # use tsclientlib::{ChannelId, Connection}; + /// let opts = Connection::build("localhost").channel_id(ChannelId(2)); + /// ``` + #[inline] + pub fn channel_id(mut self, channel: ChannelId) -> Self { + self.channel = Some(format!("/{}", channel.0).into()); + self + } + + /// Use a password for the given channel when connecting. + /// + /// # Example + /// ``` + /// # use tsclientlib::Connection; + /// let opts = Connection::build("localhost") + /// .channel("Secret Channel") + /// .channel_password("My secret password"); + /// ``` + #[inline] + pub fn channel_password>>(mut self, pwd: S) -> Self { + self.channel_password = Some(pwd.into()); + self + } + + /// Use a server password when connecting. + /// + /// # Example + /// ``` + /// # use tsclientlib::Connection; + /// let opts = Connection::build("localhost").password("My secret password"); + /// ``` + #[inline] + pub fn password>>(mut self, pwd: S) -> Self { + self.password = Some(pwd.into()); + self + } + + /// Connect to the server in a muted state. + /// + /// # Example + /// ``` + /// # use tsclientlib::Connection; + /// let opts = Connection::build("localhost").input_muted(true); + /// ``` + #[inline] + pub fn input_muted(mut self, input_muted: bool) -> Self { + self.input_muted = input_muted; + self + } + + /// Connect to the server with the output muted. + /// + /// # Example + /// ``` + /// # use tsclientlib::Connection; + /// let opts = Connection::build("localhost").output_muted(true); + /// ``` + #[inline] + pub fn output_muted(mut self, output_muted: bool) -> Self { + self.output_muted = output_muted; + self + } + + /// Connect to the server with input hardware disabled state. + /// + /// # Example + /// ``` + /// # use tsclientlib::Connection; + /// let opts = Connection::build("localhost").input_hardware_enabled(true); + /// ``` + #[inline] + pub fn input_hardware_enabled(mut self, input_hardware_enabled: bool) -> Self { + self.input_hardware_enabled = input_hardware_enabled; + self + } + + /// Connect to the server with output hardware disabled stat. + /// + /// # Example + /// ``` + /// # use tsclientlib::Connection; + /// let opts = Connection::build("localhost").output_hardware_enabled(true); + /// ``` + #[inline] + pub fn output_hardware_enabled(mut self, output_hardware_enabled: bool) -> Self { + self.output_hardware_enabled = output_hardware_enabled; + self + } + + /// Connect to the server with an away message. + /// + /// # Example + /// ``` + /// # use tsclientlib::Connection; + /// let opts = Connection::build("localhost").away("Buying groceries"); + /// ``` + #[inline] + pub fn away>>(mut self, message: S) -> Self { + self.away = Some(message.into()); + self + } + + /// If the content of all commands should be written to the logger. + /// + /// # Default + /// `false` + #[inline] + pub fn log_commands(mut self, log_commands: bool) -> Self { + self.log_commands = log_commands; + self + } + + /// If the content of all packets in high-level form should be written to + /// the logger. + /// + /// # Default + /// `false` + #[inline] + pub fn log_packets(mut self, log_packets: bool) -> Self { + self.log_packets = log_packets; + self + } + + /// If the content of all udp packets in byte-array form should be written + /// to the logger. + /// + /// # Default + /// `false` + #[inline] + pub fn log_udp_packets(mut self, log_udp_packets: bool) -> Self { + self.log_udp_packets = log_udp_packets; + self + } + + #[inline] + pub fn get_address(&self) -> &ServerAddress { &self.address } + #[inline] + pub fn get_local_address(&self) -> Option<&SocketAddr> { self.local_address.as_ref() } + #[inline] + pub fn get_identity(&self) -> Option<&Identity> { self.identity.as_ref() } + #[inline] + pub fn get_server(&self) -> Option<&Uid> { self.server.as_deref() } + #[inline] + pub fn get_name(&self) -> &str { &self.name } + #[inline] + pub fn get_version(&self) -> &Version { &self.version } + #[inline] + pub fn get_hardware_id(&self) -> &str { &self.hardware_id } + #[inline] + pub fn get_channel(&self) -> Option<&str> { self.channel.as_ref().map(AsRef::as_ref) } + #[inline] + pub fn get_channel_password(&self) -> Option<&str> { + self.channel_password.as_ref().map(AsRef::as_ref) + } + #[inline] + pub fn get_password(&self) -> Option<&str> { self.password.as_ref().map(AsRef::as_ref) } + #[inline] + pub fn get_input_muted(&self) -> bool { self.input_muted } + #[inline] + pub fn get_output_muted(&self) -> bool { self.output_muted } + #[inline] + pub fn get_input_hardware_enabled(&self) -> bool { self.input_hardware_enabled } + #[inline] + pub fn get_output_hardware_enabled(&self) -> bool { self.output_hardware_enabled } + #[inline] + pub fn get_away(&self) -> Option<&str> { self.away.as_ref().map(AsRef::as_ref) } + #[inline] + pub fn get_log_commands(&self) -> bool { self.log_commands } + #[inline] + pub fn get_log_packets(&self) -> bool { self.log_packets } + #[inline] + pub fn get_log_udp_packets(&self) -> bool { self.log_udp_packets } +} diff --git a/crates/proto/tsclientlib/src/prelude.rs b/crates/proto/tsclientlib/src/prelude.rs new file mode 100644 index 0000000..29b9124 --- /dev/null +++ b/crates/proto/tsclientlib/src/prelude.rs @@ -0,0 +1,4 @@ +pub use ts_bookkeeping::data::exts::*; +pub use ts_bookkeeping::messages::OutMessageTrait; + +pub use crate::OutCommandExt as _; diff --git a/crates/proto/tsclientlib/src/resolver.rs b/crates/proto/tsclientlib/src/resolver.rs new file mode 100644 index 0000000..d6dea01 --- /dev/null +++ b/crates/proto/tsclientlib/src/resolver.rs @@ -0,0 +1,514 @@ +//! Resolve TeamSpeak server addresses of any kind. +// Changes with TeamSpeak client 3.1: +// https://support.teamspeakusa.com/index.php?/Knowledgebase/Article/View/332 + +use std::net::{IpAddr, Ipv6Addr, SocketAddr}; +use std::str; + +use futures::prelude::*; +use hickory_net::proto::rr::RData; +use hickory_resolver::TokioResolver; +use hickory_resolver::config::{CLOUDFLARE, ResolverConfig, ResolverOpts}; +use hickory_resolver::net::runtime::TokioRuntimeProvider; +use itertools::Itertools; +use rand::RngExt; +use thiserror::Error; +use tokio::io::{AsyncReadExt, AsyncWriteExt}; +use tokio::net::{self, TcpStream}; +use tokio::time::Duration; +use tracing::{debug, instrument, warn}; + +const DEFAULT_PORT: u16 = 9987; +const DNS_PREFIX_TCP: &str = "_tsdns._tcp."; +const DNS_PREFIX_UDP: &str = "_ts3._udp."; +const NICKNAME_LOOKUP_ADDRESS: &str = "https://named.myteamspeak.com/lookup"; +/// Wait this amount of seconds before giving up. +const TIMEOUT_SECONDS: u64 = 10; + +type Result = std::result::Result; + +#[derive(Debug, Error)] +#[non_exhaustive] +pub enum Error { + #[error("Failed to create resolver: {0}")] + CreateResolver(#[source] hickory_net::NetError), + #[error("Invalid IPv4 address")] + InvalidIp4Address, + #[error("Invalid IPv6 address")] + InvalidIp6Address, + #[error("Invalid IP address")] + InvalidIpAddress, + #[error("Not a valid nickname")] + InvalidNickname, + #[error("Failed to parse port: {0}")] + InvalidPort(#[source] std::num::ParseIntError), + #[error("Failed to contact {0} server: {1}")] + Io(&'static str, #[source] std::io::Error), + #[error("Failed to parse url: {0}")] + NicknameParseUrl(#[source] url::ParseError), + #[error("Failed to resolve nickname: {0}")] + NicknameResolve(#[source] reqwest::Error), + #[error("Failed to resolve hostname: {0}")] + ResolveHost(#[source] tokio::io::Error), + #[error("Failed to get SRV record")] + SrvLookup(#[source] hickory_net::NetError), + #[error("tsdns did not return an ip address but {0:?}")] + TsdnsAddressInvalidResponse(String), + #[error("tsdns server does not know the address")] + TsdnsAddressNotFound, + #[error("Failed to parse tsdns response: {0}")] + TsdnsParseResponse(#[source] std::str::Utf8Error), +} + +#[derive(Debug, PartialEq, Eq)] +enum ParseIpResult<'a> { + Addr(SocketAddr), + Other(&'a str, Option), +} + +/// Beware that this may be slow because it tries all available methods. +/// +/// The following methods are tried: +/// 1. If the address is an ip, the ip is returned +/// 1. Server nicknames are resolved by a http request to TeamSpeak +/// 1. The SRV record at `_ts3._udp.
` +/// 1. The SRV record at `_tsdns._tcp.address.tld` to get the address of a tsdns +/// server, e.g. when the address is `ts3.subdomain.from.com`, the SRV record +/// at `_tsdns._tcp.from.com` is requested +/// 1. Directly resolve the address to an ip address +/// +/// If a port is given with `:port`, it overwrites the automatically determined +/// port. IPv6 addresses are put in square brackets when a port is present: +/// `[::1]:9987` +#[instrument] +pub fn resolve(address: String) -> impl Stream> { + debug!("Starting resolve"); + let addr; + let port; + match parse_ip(&address) { + Ok(ParseIpResult::Addr(res)) => { + return stream::once(future::ok(res)).left_stream(); + } + Ok(ParseIpResult::Other(a, p)) => { + addr = a.to_string(); + port = p; + if let Some(port) = port { + debug!(port, "Found port"); + } + } + Err(res) => return stream::once(future::err(res)).left_stream(), + } + + // Resolve as nickname + let res = if !address.contains('.') && addr != "localhost" { + debug!("Resolving nickname"); + // Could be a server nickname + resolve_nickname(address.clone()) + .map_ok(move |mut addr| { + if let Some(port) = port { + addr.set_port(port); + } + addr + }) + .left_stream() + } else { + stream::once(future::err(Error::InvalidNickname)).right_stream() + }; + + // The system config does not yet work on android: + // https://github.com/bluejekyll/trust-dns/issues/652 + let addr2 = addr.clone(); + // TODO Move current span into stream + let res = res.chain( + stream::once(async move { + let resolver = create_resolver()?; + + // Try to get the address by an SRV record + Result::<_>::Ok(resolve_srv(resolver, format!("{DNS_PREFIX_UDP}{addr2}."))) + }) + .try_flatten(), + ); + + // Try to get the address of a tsdns server by an SRV record + let addr2 = addr.clone(); + // TODO Move current span into stream + let res = res.chain( + stream::once(async move { + let resolver = create_resolver()?; + // Trim address to two components + let name = if let Some(i) = addr2.rfind('.').and_then(|i| addr2[..i].rfind('.')) { + &addr2[i + 1..] + } else { + &addr2 + }; + // Pick the first srv record of the first server that answers + Result::<_>::Ok(resolve_srv(resolver, format!("{DNS_PREFIX_TCP}{name}.")).and_then( + move |srv| { + let address = address.clone(); + async move { + // Got tsdns server + let mut addr = resolve_tsdns(srv, &address).await?; + if let Some(port) = port { + // Overwrite port if it was specified + addr.set_port(port); + } + Ok(addr) + } + }, + )) + }) + .try_flatten(), + ); + + // Interpret as normal address and resolve with system resolver + let res = res.chain( + stream::once(async move { + let res = net::lookup_host((addr.as_str(), port.unwrap_or(DEFAULT_PORT))) + .await + .map_err(Error::ResolveHost)? + .map(Ok) + .collect::>(); + Result::<_>::Ok(stream::iter(res)) + }) + .try_flatten(), + ); + + // TODO Move current span into stream + tokio_stream::StreamExt::timeout(res, Duration::from_secs(TIMEOUT_SECONDS)) + .filter_map(move |r: std::result::Result, _>| { + future::ready(match r { + // Timeout + Err(_) => None, + // Error + Ok(Err(error)) => { + debug!(%error, "Resolver failed in one step"); + None + } + // Success + Ok(Ok(r)) => Some(Ok(r)), + }) + }) + .right_stream() +} + +// Windows for some reason automatically adds a link-local address to the dns +// resolver. These addresses are usually not reachable and should be filtered out. +// See: https://superuser.com/questions/638566/strange-value-in-dns-shown-in-ipconfig +const FILTERED_IPS: &[IpAddr] = &[ + IpAddr::V6(Ipv6Addr::new(0xfec0, 0, 0, 0xffff, 0, 0, 0, 1)), + IpAddr::V6(Ipv6Addr::new(0xfec0, 0, 0, 0xffff, 0, 0, 0, 2)), + IpAddr::V6(Ipv6Addr::new(0xfec0, 0, 0, 0xffff, 0, 0, 0, 3)), +]; + +fn create_resolver() -> Result { + let (config, options) = match hickory_resolver::system_conf::read_system_conf() { + Ok((mut config, options)) => { + config.name_servers.retain(|ns| !FILTERED_IPS.contains(&ns.ip)); + (config, options) + } + Err(error) => { + warn!(%error, "Failed to use system dns resolver config"); + // Fallback + (ResolverConfig::udp_and_tcp(&CLOUDFLARE), ResolverOpts::default()) + } + }; + let mut builder = TokioResolver::builder_with_config(config, TokioRuntimeProvider::default()); + *builder.options_mut() = options; + builder.build().map_err(Error::CreateResolver) +} + +fn parse_ip(address: &str) -> Result> { + let mut addr = address; + let mut port = None; + if let Some(pos) = address.rfind(':') { + // Either with port or IPv6 address + if address.find(':').unwrap() == pos { + // Port is appended + addr = &address[..pos]; + port = Some(&address[pos + 1..]); + if addr.chars().all(|c| c.is_ascii_digit() || c == '.') { + // IPv4 address + return Ok(ParseIpResult::Addr( + std::net::ToSocketAddrs::to_socket_addrs(address) + .map_err(|_| Error::InvalidIp4Address)? + .next() + .ok_or(Error::InvalidIp4Address)?, + )); + } + } else if let Some(pos_bracket) = address.rfind(']') { + if pos_bracket < pos { + // IPv6 address and port + return Ok(ParseIpResult::Addr( + std::net::ToSocketAddrs::to_socket_addrs(address) + .map_err(|_| Error::InvalidIp6Address)? + .next() + .ok_or(Error::InvalidIp6Address)?, + )); + } else if pos_bracket == address.len() - 1 && address.starts_with('[') { + // IPv6 address + return Ok(ParseIpResult::Addr( + std::net::ToSocketAddrs::to_socket_addrs(&( + &address[1..pos_bracket], + DEFAULT_PORT, + )) + .map_err(|_| Error::InvalidIp6Address)? + .next() + .ok_or(Error::InvalidIp6Address)?, + )); + } else { + return Err(Error::InvalidIpAddress); + } + } else { + // IPv6 address + return Ok(ParseIpResult::Addr( + std::net::ToSocketAddrs::to_socket_addrs(&(address, DEFAULT_PORT)) + .map_err(|_| Error::InvalidIp6Address)? + .next() + .ok_or(Error::InvalidIp6Address)?, + )); + } + } else if address.chars().all(|c| c.is_ascii_digit() || c == '.') { + // IPv4 address + return Ok(ParseIpResult::Addr( + std::net::ToSocketAddrs::to_socket_addrs(&(address, DEFAULT_PORT)) + .map_err(|_| Error::InvalidIp4Address)? + .next() + .ok_or(Error::InvalidIp4Address)?, + )); + } + let port = if let Some(port) = port.map(|p| p.parse().map_err(Error::InvalidPort)) { + Some(port?) + } else { + None + }; + Ok(ParseIpResult::Other(addr, port)) +} + +pub fn resolve_nickname(nickname: String) -> impl Stream> { + stream::once(async { + let nickname = nickname; + let url = + reqwest::Url::parse_with_params(NICKNAME_LOOKUP_ADDRESS, Some(("name", &nickname))) + .map_err(Error::NicknameParseUrl)?; + let body = reqwest::get(url) + .await + .map_err(Error::NicknameResolve)? + .error_for_status() + .map_err(Error::NicknameResolve)? + .text() + .await + .map_err(Error::NicknameResolve)?; + let addrs = body + .split(&['\r', '\n'][..]) + .filter(|s| !s.is_empty()) + .map(|s| Result::<_>::Ok(s.to_string())) + .collect::>(); + + Result::<_>::Ok( + stream::iter(addrs) + .and_then(|addr| async move { + match parse_ip(&addr)? { + ParseIpResult::Addr(a) => Ok(stream::once(future::ok(a)).left_stream()), + ParseIpResult::Other(a, p) => { + let addrs = net::lookup_host((a, p.unwrap_or(DEFAULT_PORT))) + .await + .map_err(Error::ResolveHost)? + .collect::>(); + Ok(stream::iter(addrs).map(Result::<_>::Ok).right_stream()) + } + } + }) + .try_flatten(), + ) + }) + .try_flatten() +} + +pub async fn resolve_tsdns(server: A, addr: &str) -> Result { + let mut stream = TcpStream::connect(server).await.map_err(|e| Error::Io("tsdns", e))?; + stream.write_all(addr.as_bytes()).await.map_err(|e| Error::Io("tsdns", e))?; + let mut data = Vec::new(); + stream.read_to_end(&mut data).await.map_err(|e| Error::Io("tsdns", e))?; + + let addr = str::from_utf8(&data).map_err(Error::TsdnsParseResponse)?; + if addr.starts_with("404") { + return Err(Error::TsdnsAddressNotFound); + } + match parse_ip(addr)? { + ParseIpResult::Addr(a) => Ok(a), + _ => Err(Error::TsdnsAddressInvalidResponse(addr.to_string())), + } +} + +fn resolve_srv(resolver: TokioResolver, addr: String) -> impl Stream> { + stream::once(async { + let lookup = resolver.srv_lookup(addr).await.map_err(Error::SrvLookup)?; + let srvs = lookup + .answers() + .iter() + .map(|r| { + let RData::SRV(srv) = &r.data else { panic!("Unexpected answer") }; + srv.clone() + }) + .collect::>(); + + let prios = srvs.iter().chunk_by(|srv| srv.priority); + let entries = prios.into_iter().sorted_by_key(|(p, _)| *p); + + // Select by weight + let mut sorted_entries = Vec::new(); + for (_, es) in entries { + let mut zero_entries = Vec::new(); + + // All non-zero entries + let mut entries = es + .filter_map(|e| { + if e.weight == 0 { + zero_entries.push(e); + None + } else { + Some(e) + } + }) + .collect::>(); + + while !entries.is_empty() { + let weight: u32 = entries.iter().map(|e| e.weight as u32).sum(); + let mut w = rand::rng().random_range(0..=weight); + if w == 0 { + // Pick the first entry with weight 0 + if let Some(i) = entries.iter().position(|e| e.weight == 0) { + sorted_entries.push(entries.remove(i)); + } + } + for i in 0..entries.len() { + let weight = entries[i].weight as u32; + if w <= weight { + sorted_entries.push(entries.remove(i)); + break; + } + w -= weight; + } + } + } + + let res = sorted_entries + .into_iter() + .map(|e| Ok((e.target.to_ascii(), e.port))) + .collect::>>(); + drop(resolver); + Ok(stream::iter(res) + .and_then(|(e, port)| async move { + let res = net::lookup_host((e.as_str(), port)) + .await + .map_err(Error::ResolveHost)? + .map(Ok) + .collect::>(); + Ok(stream::iter(res)) + }) + .try_flatten()) + }) + .try_flatten() +} + +#[cfg(test)] +mod test { + use super::*; + use crate::tests::create_logger; + + #[test] + fn parse_ip_without_port() { + let res = parse_ip("127.0.0.1"); + assert_eq!( + res.unwrap(), + ParseIpResult::Addr(format!("127.0.0.1:{}", DEFAULT_PORT).parse().unwrap()) + ); + } + + #[test] + fn parse_ip_with_port() { + let res = parse_ip("127.0.0.1:1"); + assert_eq!(res.unwrap(), ParseIpResult::Addr("127.0.0.1:1".parse().unwrap())); + } + + #[test] + fn parse_ip6_without_port() { + let res = parse_ip("::"); + assert_eq!( + res.unwrap(), + ParseIpResult::Addr(format!("[::]:{}", DEFAULT_PORT).parse().unwrap()) + ); + } + + #[test] + fn parse_ip6_without_port2() { + let res = parse_ip("[::]"); + assert_eq!( + res.unwrap(), + ParseIpResult::Addr(format!("[::]:{}", DEFAULT_PORT).parse().unwrap()) + ); + } + + #[test] + fn parse_ip6_with_port() { + let res = parse_ip("[::]:1"); + assert_eq!(res.unwrap(), ParseIpResult::Addr("[::]:1".parse().unwrap())); + } + + #[test] + fn parse_ip_address_without_port() { + assert_eq!(parse_ip("localhost").unwrap(), ParseIpResult::Other("localhost", None)); + } + + #[test] + fn parse_ip_address_with_port() { + assert_eq!(parse_ip("localhost:1").unwrap(), ParseIpResult::Other("localhost", Some(1))); + } + + #[test] + fn parse_ip_with_large_port() { + assert!(parse_ip("127.0.0.1:65536").is_err()); + } + + #[tokio::test] + async fn resolve_localhost() { + create_logger(); + let res: Vec<_> = resolve("127.0.0.1".into()).map(|r| r.unwrap()).collect().await; + let addr = format!("127.0.0.1:{}", DEFAULT_PORT).parse::().unwrap(); + assert_eq!(res.as_slice(), &[addr]); + } + + #[tokio::test] + async fn resolve_localhost2() { + create_logger(); + let res: Vec<_> = resolve("localhost".into()).map(|r| r.unwrap()).collect().await; + assert!(res.contains(&format!("127.0.0.1:{}", DEFAULT_PORT).parse().unwrap())); + } + + #[tokio::test] + async fn resolve_example() { + create_logger(); + let res: Vec<_> = resolve("example.com".into()).map(|r| r.unwrap()).collect().await; + assert!(!res.is_empty()); + } + + #[tokio::test] + async fn resolve_splamy_de() { + create_logger(); + + let res: Vec<_> = tokio::time::timeout( + Duration::from_secs(5), + resolve("splamy.de".into()).map(|r| r.unwrap()).collect(), + ) + .await + .expect("Resolve takes unacceptable long"); + assert!(res.contains(&format!("37.120.179.68:{}", DEFAULT_PORT).parse().unwrap())); + } + + #[tokio::test] + async fn resolve_loc() { + create_logger(); + let res: Vec<_> = resolve("loc".into()).map(|r| r.unwrap()).collect().await; + assert!(res.contains(&format!("127.0.0.1:{}", DEFAULT_PORT).parse().unwrap())); + } +} diff --git a/crates/proto/tsclientlib/src/sync.rs b/crates/proto/tsclientlib/src/sync.rs new file mode 100644 index 0000000..afad689 --- /dev/null +++ b/crates/proto/tsclientlib/src/sync.rs @@ -0,0 +1,470 @@ +//! The `sync` module contains an easier to use interface for a connection. +//! +//! It makes it easier to use a connection from multiple threads and use +//! `async`/`await` syntax for the cost of a little bit performance. +use std::collections::HashMap; +use std::ops::{Deref, DerefMut}; +use std::pin::Pin; +use std::task::{Context, Poll}; + +use futures::prelude::*; +use tokio::sync::{mpsc, oneshot}; +use tracing::{error, info}; +use ts_bookkeeping::ChannelId; +#[cfg(feature = "audio")] +use tsproto_packets::packets::InAudioBuf; +#[cfg(feature = "unstable")] +use tsproto_packets::packets::OutCommand; + +use crate::{ + events, AudioEvent, DisconnectOptions, Error, InMessage, Result, StreamItem, + TemporaryDisconnectReason, +}; + +enum SyncConMessage { + RunFn(Box), + #[cfg(feature = "unstable")] + SendCommand(OutCommand, oneshot::Sender>), + WaitConnected(oneshot::Sender>), + Disconnect(DisconnectOptions, oneshot::Sender>), + DownloadFile { + channel_id: ChannelId, + path: String, + channel_password: Option, + seek_position: Option, + send: oneshot::Sender>, + }, + UploadFile { + channel_id: ChannelId, + path: String, + channel_password: Option, + size: u64, + overwrite: bool, + resume: bool, + send: oneshot::Sender>, + }, +} + +/// This is a subset of [`StreamItem`](crate::StreamItem). +pub enum SyncStreamItem { + /// All the incoming book events. + /// + /// If a connection to the server was established this will contain an added event of a server. + BookEvents(Vec), + /// All incoming messages that are not related to the book. + /// + /// This contains messages like `ChannelListFinished` or `ClientChatComposing`. + /// All events related to channels or clients are returned as events in the `BookEvents` + /// variant. Other messages handled by tsclientlib, e.g. for filetransfer are also not included + /// in these events. + MessageEvent(InMessage), + /// Received an audio packet. + /// + /// Audio packets can be handled by the [`AudioHandler`](crate::audio::AudioHandler), which + /// builds a queue per client and handles packet loss and jitter. + #[cfg(feature = "audio")] + Audio(InAudioBuf), + /// The needed level. + IdentityLevelIncreasing(u8), + /// This event may occur without an `IdentityLevelIncreasing` event before + /// if a new identity is created because no identity was supplied. + IdentityLevelIncreased, + /// The connection timed out or the server shut down. The connection will be + /// rebuilt automatically. + DisconnectedTemporarily(TemporaryDisconnectReason), + /// The network statistics were updated. + /// + /// This means e.g. the packet loss got a new value. Clients with audio probably want to update + /// the packet loss option of opus. + NetworkStatsUpdated, + /// A change related to audio. + AudioChange(AudioEvent), +} + +/// A handle for a [`SyncConnection`] which can be sent across threads. +/// +/// All actions like sending messages, downloading and uploading happens through +/// a handle. +#[derive(Clone)] +pub struct SyncConnectionHandle { + send: mpsc::Sender, +} + +pub struct SyncConnection { + con: super::Connection, + recv: mpsc::Receiver, + send: mpsc::Sender, + + commands: HashMap>>, + connects: Vec>>, + disconnects: Vec>>, + downloads: + HashMap>>, + uploads: HashMap>>, +} + +impl From for SyncConnection { + fn from(con: super::Connection) -> Self { + let (send, recv) = mpsc::channel(1); + Self { + con, + recv, + send, + + commands: Default::default(), + connects: Default::default(), + disconnects: Default::default(), + downloads: Default::default(), + uploads: Default::default(), + } + } +} + +impl Deref for SyncConnection { + type Target = super::Connection; + #[inline] + fn deref(&self) -> &Self::Target { &self.con } +} + +impl DerefMut for SyncConnection { + #[inline] + fn deref_mut(&mut self) -> &mut ::Target { &mut self.con } +} + +impl Stream for SyncConnection { + type Item = Result; + fn poll_next(mut self: Pin<&mut Self>, ctx: &mut Context) -> Poll> { + let _span = self.con.span.clone().entered(); + loop { + if let Poll::Ready(msg) = self.recv.poll_recv(ctx) { + if let Some(msg) = msg { + match msg { + SyncConMessage::RunFn(f) => f(&mut self), + #[cfg(feature = "unstable")] + SyncConMessage::SendCommand(arg, send) => { + let handle = match self.con.send_command_with_result(arg) { + Ok(r) => r, + Err(e) => { + let _ = send.send(Err(e)); + continue; + } + }; + self.commands.insert(handle, send); + } + SyncConMessage::WaitConnected(send) => { + if self.con.get_state().is_ok() { + let _ = send.send(Ok(())); + } else { + self.connects.push(send); + } + } + SyncConMessage::Disconnect(arg, send) => { + match self.con.disconnect(arg) { + Ok(r) => r, + Err(e) => { + let _ = send.send(Err(e)); + continue; + } + } + self.disconnects.push(send); + } + SyncConMessage::DownloadFile { + channel_id, + path, + channel_password, + seek_position, + send, + } => { + let handle = match self.con.download_file( + channel_id, + &path, + channel_password.as_deref(), + seek_position, + ) { + Ok(r) => r, + Err(e) => { + let _ = send.send(Err(e)); + continue; + } + }; + self.downloads.insert(handle, send); + } + SyncConMessage::UploadFile { + channel_id, + path, + channel_password, + size, + overwrite, + resume, + send, + } => { + let handle = match self.con.upload_file( + channel_id, + &path, + channel_password.as_deref(), + size, + overwrite, + resume, + ) { + Ok(r) => r, + Err(e) => { + let _ = send.send(Err(e)); + continue; + } + }; + self.uploads.insert(handle, send); + } + } + continue; + } else { + error!("Message stream ended unexpectedly"); + } + } + break; + } + + loop { + break if let Poll::Ready(item) = self.con.poll_next(ctx) { + Poll::Ready(match item { + Some(Ok(item)) => Some(Ok(match item { + StreamItem::BookEvents(i) => { + self.connects.drain(..).for_each(|send| { + let _ = send.send(Ok(())); + }); + SyncStreamItem::BookEvents(i) + } + StreamItem::MessageEvent(i) => SyncStreamItem::MessageEvent(i), + #[cfg(feature = "audio")] + StreamItem::Audio(i) => SyncStreamItem::Audio(i), + StreamItem::IdentityLevelIncreasing(i) => { + SyncStreamItem::IdentityLevelIncreasing(i) + } + StreamItem::IdentityLevelIncreased => { + SyncStreamItem::IdentityLevelIncreased + } + StreamItem::DisconnectedTemporarily(reason) => { + SyncStreamItem::DisconnectedTemporarily(reason) + } + StreamItem::MessageResult(handle, res) => { + if let Some(send) = self.commands.remove(&handle) { + let _ = send.send(res.map_err(|e| e.into())); + } else { + info!("Got untracked message result"); + } + continue; + } + StreamItem::FileDownload(handle, res) => { + if let Some(send) = self.downloads.remove(&handle) { + let _ = send.send(Ok(res)); + } else { + info!("Got untracked download"); + } + continue; + } + StreamItem::FileUpload(handle, res) => { + if let Some(send) = self.uploads.remove(&handle) { + let _ = send.send(Ok(res)); + } else { + info!("Got untracked upload"); + } + continue; + } + StreamItem::FiletransferFailed(handle, res) => { + if let Some(send) = self.downloads.remove(&handle) { + let _ = send.send(Err(res)); + } else if let Some(send) = self.uploads.remove(&handle) { + let _ = send.send(Err(res)); + } else { + info!("Got untracked file transfer"); + } + continue; + } + StreamItem::NetworkStatsUpdated => SyncStreamItem::NetworkStatsUpdated, + StreamItem::AudioChange(change) => SyncStreamItem::AudioChange(change), + })), + Some(Err(e)) => Some(Err(e)), + None => { + self.disconnects.drain(..).for_each(|send| { + let _ = send.send(Ok(())); + }); + None + } + }) + } else { + Poll::Pending + }; + } + } +} + +impl SyncConnection { + /// Get a handle to the connection that can be sent across threads. + #[inline] + pub fn get_handle(&self) -> SyncConnectionHandle { + SyncConnectionHandle { send: self.send.clone() } + } +} + +impl SyncConnectionHandle { + /// Run a function on the connection. + pub async fn with_connection< + T: Send + 'static, + F: FnOnce(&mut SyncConnection) -> T + Send + 'static, + >( + &mut self, f: F, + ) -> Result { + let (send, recv) = oneshot::channel(); + self.send + .send(SyncConMessage::RunFn(Box::new(move |con| { + let _ = send.send(f(con)); + }))) + .await + .map_err(|_| Error::ConnectionGone)?; + recv.await.map_err(|_| Error::ConnectionGone) + } + + /// Adds a `return_code` to the command and returns if the corresponding + /// answer is received. If an error occurs, the future will return an error. + #[cfg(feature = "unstable")] + pub async fn send_command(&mut self, arg: OutCommand) -> Result<()> { + let (send, recv) = oneshot::channel(); + self.send + .send(SyncConMessage::SendCommand(arg, send)) + .await + .map_err(|_| Error::ConnectionGone)?; + recv.await.map_err(|_| Error::ConnectionGone)? + } + + /// This future resolves once the connection is connected to the server. + pub async fn wait_until_connected(&mut self) -> Result<()> { + let (send, recv) = oneshot::channel(); + self.send + .send(SyncConMessage::WaitConnected(send)) + .await + .map_err(|_| Error::ConnectionGone)?; + recv.await.map_err(|_| Error::ConnectionGone)? + } + + /// Disconnect from the server. + /// + /// # Arguments + /// - `options`: Either `None` or `DisconnectOptions`. + /// + /// # Examples + /// + /// Use default options: + /// + /// ```no_run + /// # use futures::prelude::*; + /// # use tsclientlib::{Connection, ConnectOptions, DisconnectOptions, StreamItem}; + /// # use tsclientlib::sync::SyncConnection; + /// + /// # #[tokio::main] + /// # async fn main() { + /// let con: SyncConnection = Connection::build("localhost").connect().unwrap().into(); + /// let mut handle = con.get_handle(); + /// tokio::spawn(con.for_each(|_| future::ready(()))); + /// // Wait until connected + /// handle.wait_until_connected().await.unwrap(); + /// + /// // Disconnect + /// handle.disconnect(DisconnectOptions::new()).await.unwrap(); + /// # } + /// ``` + /// + /// Specify a reason and a quit message: + /// + /// ```no_run + /// # use futures::prelude::*; + /// # use tsclientlib::{Connection, ConnectOptions, DisconnectOptions, Reason, StreamItem}; + /// # use tsclientlib::sync::SyncConnection; + /// + /// # #[tokio::main] + /// # async fn main() { + /// let con: SyncConnection = Connection::build("localhost").connect().unwrap().into(); + /// let mut handle = con.get_handle(); + /// tokio::spawn(con.for_each(|_| future::ready(()))); + /// // Wait until connected + /// handle.wait_until_connected().await.unwrap(); + /// + /// // Disconnect + /// let options = DisconnectOptions::new() + /// .reason(Reason::Clientdisconnect) + /// .message("Away for a while"); + /// handle.disconnect(DisconnectOptions::new()).await.unwrap(); + /// # } + /// ``` + pub async fn disconnect(&mut self, arg: DisconnectOptions) -> Result<()> { + let (send, recv) = oneshot::channel(); + self.send + .send(SyncConMessage::Disconnect(arg, send)) + .await + .map_err(|_| Error::ConnectionGone)?; + recv.await.map_err(|_| Error::ConnectionGone)? + } + + /// Download a file from a channel of the connected TeamSpeak server. + /// + /// Returns the size of the file and a tcp stream of the requested file. + /// + /// # Example + /// Download an icon. + /// + /// ```no_run + /// # use tsclientlib::ChannelId; + /// # let handle: tsclientlib::sync::SyncConnectionHandle = panic!(); + /// # let id = 0; + /// let download = handle.download_file(ChannelId(0), format!("/icon_{}", id), None, None); + /// ``` + pub async fn download_file( + &mut self, channel_id: ChannelId, path: String, channel_password: Option, + seek_position: Option, + ) -> Result { + let (send, recv) = oneshot::channel(); + self.send + .send(SyncConMessage::DownloadFile { + channel_id, + path, + channel_password, + seek_position, + send, + }) + .await + .map_err(|_| Error::ConnectionGone)?; + recv.await.map_err(|_| Error::ConnectionGone)? + } + + /// Upload a file to a channel of the connected TeamSpeak server. + /// + /// Returns the size of the part which is already uploaded (when resume is + /// specified) and a tcp stream where the requested file should be uploaded. + /// + /// # Example + /// Upload an avatar. + /// + /// ```no_run + /// # use tsclientlib::ChannelId; + /// # let handle: tsclientlib::sync::SyncConnectionHandle = panic!(); + /// # let size = 0; + /// let upload = handle.upload_file(ChannelId(0), "/avatar".to_string(), None, size, true, false); + /// ``` + pub async fn upload_file( + &mut self, channel_id: ChannelId, path: String, channel_password: Option, + size: u64, overwrite: bool, resume: bool, + ) -> Result { + let (send, recv) = oneshot::channel(); + self.send + .send(SyncConMessage::UploadFile { + channel_id, + path, + channel_password, + size, + overwrite, + resume, + send, + }) + .await + .map_err(|_| Error::ConnectionGone)?; + recv.await.map_err(|_| Error::ConnectionGone)? + } +} diff --git a/crates/proto/tsclientlib/src/tests.rs b/crates/proto/tsclientlib/src/tests.rs new file mode 100644 index 0000000..d5752e8 --- /dev/null +++ b/crates/proto/tsclientlib/src/tests.rs @@ -0,0 +1,37 @@ +use once_cell::sync::Lazy; +use ts_bookkeeping::messages::s2c::InMessage; +use tsproto_packets::packets::{Direction, Flags, OutPacket, PacketType}; + +static TRACING: Lazy<()> = Lazy::new(|| tracing_subscriber::fmt().with_test_writer().init()); + +pub(crate) fn create_logger() { Lazy::force(&TRACING); } + +fn parse_msg(msg: &str) -> InMessage { + let header = OutPacket::new_with_dir(Direction::S2C, Flags::empty(), PacketType::Command); + + InMessage::new(&header.header(), msg.as_bytes()).unwrap() +} + +fn test_iconid(input: &str, expected: u32) { + create_logger(); + + let msg = parse_msg(&format!( + r#"initserver virtualserver_name=TeamSpeak\s]I[\sServer virtualserver_welcomemessage=Welcome\sto\sTeamSpeak,\scheck\s[URL]www.teamspeak.com[\/URL]\sfor\slatest\sinformation virtualserver_platform=Linux virtualserver_version=3.11.0\s[Build:\s1578903157] virtualserver_maxclients=32 virtualserver_created=1571572631 virtualserver_codec_encryption_mode=2 virtualserver_hostmessage virtualserver_hostmessage_mode=0 virtualserver_default_server_group=8 virtualserver_default_channel_group=8 virtualserver_hostbanner_url virtualserver_hostbanner_gfx_url virtualserver_hostbanner_gfx_interval=0 virtualserver_priority_speaker_dimm_modificator=-18.0000 virtualserver_id=1 virtualserver_hostbutton_tooltip virtualserver_hostbutton_url virtualserver_hostbutton_gfx_url virtualserver_name_phonetic virtualserver_ip=0.0.0.0,\s:: virtualserver_ask_for_privilegekey=0 virtualserver_hostbanner_mode=0 virtualserver_channel_temp_delete_delay_default=0 virtualserver_nickname client_nickname=TeamSpeakUser client_version=3.?.?\s[Build:\s5680278000] client_platform=Windows client_input_muted=0 client_output_muted=0 client_outputonly_muted=0 client_input_hardware=1 client_output_hardware=1 client_default_channel client_default_channel_password client_server_password client_meta_data client_version_sign=DX5NIYLvfJEUjuIbCidnoeozxIDRRkpq3I9vVMBmE9L2qnekOoBzSenkzsg2lC9CMv8K5hkEzhr2TYUYSwUXCg== client_security_hash client_key_offset=354 client_away=0 client_away_message client_nickname_phonetic client_default_token client_badges client_myteamspeak_id client_integrations client_active_integrations_info client_myteamspeak_avatar client_signed_badges acn=TeamSpeakUser aclid=2 pv=7 client_talk_power=75 client_needed_serverquery_view_power=75 virtualserver_icon_id={}"#, + input + )); + if let InMessage::InitServer(list) = msg { + let cmd = list.iter().next().unwrap(); + assert_eq!(cmd.icon, ts_bookkeeping::IconId(expected)); + } else { + panic!("Failed to parse as initserver"); + } +} + +#[test] +fn normal_iconid() { test_iconid("96136942", 96136942); } + +#[test] +fn negative_iconid() { test_iconid("-96136942", 4198830354); } + +#[test] +fn big_iconid() { test_iconid("18446744073225738240", 3811153920); } diff --git a/crates/proto/tsproto-packets/Cargo.toml b/crates/proto/tsproto-packets/Cargo.toml new file mode 100644 index 0000000..ac30b82 --- /dev/null +++ b/crates/proto/tsproto-packets/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "tsproto-packets" +version = "0.1.0" +authors = ["Flakebi "] +description = "Parse and serialize TeamSpeak packets and commands." +repository = "https://github.com/ReSpeak/tsclientlib/tree/master/utils/tsproto-packets" +readme = "README.md" +keywords = ["teamspeak3", "ts3"] +license = "MIT OR Apache-2.0" +edition = "2018" +include = [ + "/Cargo.toml", + "/README.md", + "/src/*.rs", +] + +[dependencies] +base64 = "0.22" +bitflags = "2" +num-derive = "0.4" +num-traits = "0.2" +omnom = "3" +self_cell = "1" +serde = { version = "1", features = ["derive"] } +thiserror = "2" diff --git a/crates/proto/tsproto-packets/README.md b/crates/proto/tsproto-packets/README.md new file mode 100644 index 0000000..0934546 --- /dev/null +++ b/crates/proto/tsproto-packets/README.md @@ -0,0 +1,10 @@ +# tsproto-packets [![docs.rs](https://docs.rs/tsproto-packets/badge.svg)](https://docs.rs/tsproto-packets) +`tsproto-packets` parses and serializes TeamSpeak packets and commands. + +## License +Licensed under either of + + * [Apache License, Version 2.0](../../LICENSE-APACHE) + * [MIT license](../../LICENSE-MIT) + +at your option. diff --git a/crates/proto/tsproto-packets/README.tpl b/crates/proto/tsproto-packets/README.tpl new file mode 100644 index 0000000..fcd7655 --- /dev/null +++ b/crates/proto/tsproto-packets/README.tpl @@ -0,0 +1,10 @@ +# tsproto-packets [![docs.rs](https://docs.rs/tsproto-packets/badge.svg)](https://docs.rs/tsproto-packets) +{{readme}} + +## License +Licensed under either of + + * [Apache License, Version 2.0](../../LICENSE-APACHE) + * [MIT license](../../LICENSE-MIT) + +at your option. diff --git a/crates/proto/tsproto-packets/src/commands.rs b/crates/proto/tsproto-packets/src/commands.rs new file mode 100644 index 0000000..895ab72 --- /dev/null +++ b/crates/proto/tsproto-packets/src/commands.rs @@ -0,0 +1,293 @@ +use std::borrow::Cow; +use std::str::{self, FromStr}; + +use crate::{Error, Result}; + +/// Parses arguments of a command. +#[derive(Clone, Debug)] +pub struct CommandParser<'a> { + data: &'a [u8], + index: usize, +} + +#[derive(Clone, Debug)] +pub enum CommandItem<'a> { + Argument(CommandArgument<'a>), + /// Pipe symbol marking the start of the next command. + NextCommand, +} + +#[derive(Clone, Debug)] +pub struct CommandArgument<'a> { + name: &'a [u8], + value: CommandArgumentValue<'a>, +} + +#[derive(Clone, Debug)] +pub struct CommandArgumentValue<'a> { + raw: &'a [u8], + /// The number of escape sequences in this value. + escapes: usize, +} + +impl<'a> CommandParser<'a> { + /// Returns the name and arguments of the given command. + #[inline] + pub fn new(data: &'a [u8]) -> (&'a [u8], Self) { + let mut name_end = 0; + while name_end < data.len() { + if !data[name_end].is_ascii_alphanumeric() { + if data[name_end] == b' ' { + break; + } + // Not a command name + name_end = 0; + break; + } + name_end += 1; + } + + (&data[..name_end], Self { data, index: name_end }) + } + + fn cur(&self) -> u8 { self.data[self.index] } + fn cur_in(&self, cs: &[u8]) -> bool { cs.contains(&self.cur()) } + /// Advance + fn adv(&mut self) { self.index += 1; } + fn at_end(&self) -> bool { self.index >= self.data.len() } + + fn skip_space(&mut self) { + while !self.at_end() && self.cur_in(b"\x0b\x0c\t\r\n ") { + self.adv(); + } + } +} + +impl<'a> Iterator for CommandParser<'a> { + type Item = CommandItem<'a>; + fn next(&mut self) -> Option { + self.skip_space(); + if self.at_end() { + return None; + } + if self.cur() == b'|' { + self.adv(); + return Some(CommandItem::NextCommand); + } + + let name_start = self.index; + while !self.at_end() && !self.cur_in(b" =|") { + self.adv(); + } + let name_end = self.index; + if self.at_end() || self.cur() != b'=' { + return Some(CommandItem::Argument(CommandArgument { + name: &self.data[name_start..name_end], + value: CommandArgumentValue { raw: &[], escapes: 0 }, + })); + } + + self.adv(); + let value_start = self.index; + let mut escapes = 0; + while !self.at_end() { + if self.cur_in(b"\x0b\x0c\t\r\n| ") { + break; + } + if self.cur() == b'\\' { + escapes += 1; + self.adv(); + if self.at_end() || self.cur_in(b"\x0b\x0c\t\r\n| ") { + break; + } + } + self.adv(); + } + let value_end = self.index; + Some(CommandItem::Argument(CommandArgument { + name: &self.data[name_start..name_end], + value: CommandArgumentValue { raw: &self.data[value_start..value_end], escapes }, + })) + } +} + +impl<'a> CommandArgument<'a> { + #[inline] + pub fn name(&self) -> &'a [u8] { self.name } + #[inline] + pub fn value(&self) -> &CommandArgumentValue<'a> { &self.value } +} + +impl<'a> CommandArgumentValue<'a> { + fn unescape(&self) -> Vec { + let mut res = Vec::with_capacity(self.raw.len() - self.escapes); + let mut i = 0; + while i < self.raw.len() { + if self.raw[i] == b'\\' { + i += 1; + if i == self.raw.len() { + return res; + } + res.push(match self.raw[i] { + b'v' => b'\x0b', + b'f' => b'\x0c', + b't' => b'\t', + b'r' => b'\r', + b'n' => b'\n', + b'p' => b'|', + b's' => b' ', + c => c, + }); + } else { + res.push(self.raw[i]); + } + i += 1; + } + res + } + + #[inline] + pub fn get_raw(&self) -> &'a [u8] { self.raw } + #[inline] + pub fn get(&self) -> Cow<'a, [u8]> { + if self.escapes == 0 { Cow::Borrowed(self.raw) } else { Cow::Owned(self.unescape()) } + } + + #[inline] + pub fn get_str(&self) -> Result> { + if self.escapes == 0 { + Ok(Cow::Borrowed(str::from_utf8(self.raw)?)) + } else { + Ok(Cow::Owned(String::from_utf8(self.unescape())?)) + } + } + + #[inline] + pub fn get_parse(&self) -> std::result::Result + where + E: From<::Err>, + E: From, + { + Ok(self.get_str()?.as_ref().parse()?) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::packets::{Direction, Flags, OutCommand, PacketType}; + use std::str; + + /// Parse and write again. + fn test_loop_with_result(data: &[u8], result: &[u8]) { + let (name, parser) = CommandParser::new(data); + let name = str::from_utf8(name).unwrap(); + + let mut out_command = + OutCommand::new(Direction::S2C, Flags::empty(), PacketType::Command, name); + + println!("\nParsing {}", str::from_utf8(data).unwrap()); + for item in parser { + println!("Item: {:?}", item); + match item { + CommandItem::NextCommand => out_command.start_new_part(), + CommandItem::Argument(arg) => { + out_command.write_arg( + str::from_utf8(arg.name()).unwrap(), + &arg.value().get_str().unwrap(), + ); + } + } + } + + let packet = out_command.into_packet(); + let in_str = str::from_utf8(result).unwrap(); + let out_str = str::from_utf8(packet.content()).unwrap(); + assert_eq!(in_str, out_str); + } + + /// Parse and write again. + fn test_loop(data: &[u8]) { test_loop_with_result(data, data); } + + const TEST_COMMANDS: &[&str] = &[ + "cmd a=1 b=2 c=3", + "cmd a=\\s\\\\ b=\\p c=abc\\tdef", + "cmd a=1 c=3 b=2|b=4|b=5", + "initivexpand2 l=AQCVXTlKF+UQc0yga99dOQ9FJCwLaJqtDb1G7xYPMvHFMwIKVfKADF6zAAcAAAAgQW5vbnltb3VzAAAKQo71lhtEMbqAmtuMLlY8Snr0k2Wmymv4hnHNU6tjQCALKHewCykgcA== beta=\\/8kL8lcAYyMJovVOP6MIUC1oZASyuL\\/Y\\/qjVG06R4byuucl9oPAvR7eqZI7z8jGm9jkGmtJ6 omega=MEsDAgcAAgEgAiBxu2eCLQf8zLnuJJ6FtbVjfaOa1210xFgedoXuGzDbTgIgcGk35eqFavKxS4dROi5uKNSNsmzIL4+fyh5Z\\/+FWGxU= ot=1 proof=MEUCIQDRCP4J9e+8IxMJfCLWWI1oIbNPGcChl+3Jr2vIuyDxzAIgOrzRAFPOuJZF4CBw\\/xgbzEsgKMtEtgNobF6WXVNhfUw= tvd time=1544221457", + + "clientinitiv alpha=41Te9Ar7hMPx+A== omega=MEwDAgcAAgEgAiEAq2iCMfcijKDZ5tn2tuZcH+\\/GF+dmdxlXjDSFXLPGadACIHzUnbsPQ0FDt34Su4UXF46VFI0+4wjMDNszdoDYocu0 ip", + + // Well, that's more corrupted packet, but the parser should be robust + "initserver virtualserver_name=Server\\sder\\sVerplanten \ + virtualserver_welcomemessage=This\\sis\\sSplamys\\sWorld \ + virtualserver_platform=Linux \ + virtualserver_version=3.0.13.8\\s[Build:\\s1500452811] \ + virtualserver_maxclients=32 virtualserver_created=0 \ + virtualserver_nodec_encryption_mode=1 \ + virtualserver_hostmessage=Lé\\sServer\\sde\\sSplamy \ + virtualserver_name=Server_mode=0 virtualserver_default_server \ + group=8 virtualserver_default_channel_group=8 \ + virtualserver_hostbanner_url virtualserver_hostmessagegfx_url \ + virtualserver_hostmessagegfx_interval=2000 \ + virtualserver_priority_speaker_dimm_modificat", + + "channellist cid=2 cpid=0 channel_name=Trusted\\sChannel \ + channel_topic channel_codec=0 channel_codec_quality=0 \ + channel_maxclients=0 channel_maxfamilyclients=-1 channel_order=1 \ + channel_flag_permanent=1 channel_flag_semi_permanent=0 \ + channel_flag_default=0 channel_flag_password=0 \ + channel_codec_latency_factor=1 channel_codec_is_unencrypted=1 \ + channel_delete_delay=0 channel_flag_maxclients_unlimited=0 \ + channel_flag_maxfamilyclients_unlimited=0 \ + channel_flag_maxfamilyclients_inherited=1 \ + channel_needed_talk_power=0 channel_forced_silence=0 \ + channel_name_phonetic channel_icon_id=0 \ + channel_flag_private=0|cid=4 cpid=2 \ + channel_name=Ding\\s•\\s1\\s\\p\\sSplamy´s\\sBett channel_topic \ + channel_codec=4 channel_codec_quality=7 channel_maxclients=-1 \ + channel_maxfamilyclients=-1 channel_order=0 \ + channel_flag_permanent=1 channel_flag_semi_permanent=0 \ + channel_flag_default=0 channel_flag_password=0 \ + channel_codec_latency_factor=1 channel_codec_is_unencrypted=1 \ + channel_delete_delay=0 channel_flag_maxclients_unlimited=1 \ + channel_flag_maxfamilyclients_unlimited=0 \ + channel_flag_maxfamilyclients_inherited=1 \ + channel_needed_talk_power=0 channel_forced_silence=0 \ + channel_name_phonetic=Neo\\sSeebi\\sEvangelion channel_icon_id=0 \ + channel_flag_private=0", //|cid=6 cpid=2 channel_name=Ding\\s\xe2\x80\xa2\\s2\\s\\p\\sThe\\sBook\\sof\\sHeavy\\sMetal channel_topic channel_codec=2 channel_codec_quality=7 channel_maxclients=-1 channel_maxfamilyclients=-1 channel_order=4 channel_flag_permanent=1 channel_flag_semi_permanent=0 channel_flag_default=0 channel_flag_password=0 channel_codec_latency_factor=1 channel_codec_is_unencrypted=1 channel_delete_delay=0 channel_flag_maxclients_unlimited=1 channel_flag_maxfamilyclients_unlimited=0 channel_flag_maxfamilyclients_inherited=1 channel_needed_talk_power=0 channel_forced_silence=0 channel_name_phonetic=Not\\senought\\sChannels channel_icon_id=0 channel_flag_private=0|cid=30 cpid=2 channel_name=Ding\\s\xe2\x80\xa2\\s3\\s\\p\\sSenpai\\sGef\xc3\xa4hrlich channel_topic channel_codec=2 channel_codec_quality=7 channel_maxclients=-1 channel_maxfamilyclients=-1 channel_order=6 channel_flag_permanent=1 channel_flag_semi_permanent=0 channel_flag_default=0 channel_flag_password=0 channel_codec_latency_factor=1 channel_codec_is_unencrypted=1 channel_delete_delay=0 channel_flag_maxclients_unlimited=1 channel_flag_maxfamilyclients_unlimited=0 channel_flag_maxfamilyclients_inherited=1 channel_needed_talk_power=0 channel_forced_silence=0 channel_name_phonetic=The\\strashcan\\shas\\sthe\\strash channel_icon_id=0 channel_flag_private=0", + + "notifychannelsubscribed cid=2|cid=4 es=3867|cid=5 es=18694|cid=6 es=18694|cid=7 es=18694|cid=11 es=18694|cid=13 es=18694|cid=14 es=18694|cid=16 es=18694|cid=22 es=18694|cid=23 es=18694|cid=24 es=18694|cid=25 es=18694|cid=30 es=18694|cid=163 es=18694", + + "notifypermissionlist group_id_end=0|group_id_end=7|group_id_end=13|group_id_end=18|group_id_end=21|group_id_end=21|group_id_end=33|group_id_end=47|group_id_end=77|group_id_end=82|group_id_end=83|group_id_end=106|group_id_end=126|group_id_end=132|group_id_end=143|group_id_end=151|group_id_end=160|group_id_end=162|group_id_end=170|group_id_end=172|group_id_end=190|group_id_end=197|group_id_end=215|group_id_end=227|group_id_end=232|group_id_end=248|permname=b_serverinstance_help_view permdesc=Retrieve\\sinformation\\sabout\\sServerQuery\\scommands|permname=b_serverinstance_version_view permdesc=Retrieve\\sglobal\\sserver\\sversion\\s(including\\splatform\\sand\\sbuild\\snumber)|permname=b_serverinstance_info_view permdesc=Retrieve\\sglobal\\sserver\\sinformation|permname=b_serverinstance_virtualserver_list permdesc=List\\svirtual\\sservers\\sstored\\sin\\sthe\\sdatabase", + + // Server query + "cmd=1 cid=2", + "channellistfinished", + // With newlines + "sendtextmessage text=\\nmess\\nage\\n return_code=11", + ]; + + #[test] + fn loop_test() { + for cmd in TEST_COMMANDS { + test_loop(cmd.as_bytes()); + } + } + + #[test] + fn optional_arg() { + test_loop(b"cmd a"); + test_loop(b"cmd a b=1"); + + test_loop_with_result(b"cmd a=", b"cmd a"); + test_loop_with_result(b"cmd a= b=1", b"cmd a b=1"); + } + + #[test] + fn no_slash_escape() { + let in_cmd = "clientinitiv alpha=giGMvmfHzbY3ig== omega=MEsDAgcAAgEgAiAIXJBlj1hQbaH0Eq0DuLlCmH8bl+veTAO2+k9EQjEYSgIgNnImcmKo7ls5mExb6skfK2Tw+u54aeDr0OP1ITsC/50= ot=1 ip"; + let out_cmd = "clientinitiv alpha=giGMvmfHzbY3ig== omega=MEsDAgcAAgEgAiAIXJBlj1hQbaH0Eq0DuLlCmH8bl+veTAO2+k9EQjEYSgIgNnImcmKo7ls5mExb6skfK2Tw+u54aeDr0OP1ITsC\\/50= ot=1 ip"; + + test_loop_with_result(in_cmd.as_bytes(), out_cmd.as_bytes()); + } +} diff --git a/crates/proto/tsproto-packets/src/lib.rs b/crates/proto/tsproto-packets/src/lib.rs new file mode 100644 index 0000000..ad125fa --- /dev/null +++ b/crates/proto/tsproto-packets/src/lib.rs @@ -0,0 +1,62 @@ +//! `tsproto-packets` parses and serializes TeamSpeak packets and commands. + +use std::fmt; + +use thiserror::Error; + +pub mod commands; +pub mod packets; + +type Result = std::result::Result; + +pub const S2C_HEADER_LEN: usize = 11; +pub const C2S_HEADER_LEN: usize = 13; + +#[derive(Error, Debug)] +#[non_exhaustive] +pub enum Error { + #[error(transparent)] + Base64(#[from] base64::DecodeError), + #[error(transparent)] + Io(#[from] std::io::Error), + #[error(transparent)] + ParseInt(#[from] std::num::ParseIntError), + #[error(transparent)] + Utf8(#[from] std::str::Utf8Error), + #[error(transparent)] + StringUtf8(#[from] std::string::FromUtf8Error), + + #[error("Invalid init step {0}")] + InvalidInitStep(u8), + #[error("Invalid audio codec {0}")] + InvalidCodec(u8), + #[error("Packet content is too short (length {0})")] + PacketContentTooShort(usize), + #[error("Packet is too short (length {0})")] + PacketTooShort(usize), + #[error("Cannot parse command ({0})")] + ParseCommand(String), + #[error("Got a packet with unknown type ({0})")] + UnknownPacketType(u8), + #[error("Tried to parse a packet from the wrong direction")] + WrongDirection, + #[error("Wrong mac, expected TS3INIT1 but got {0:?}")] + WrongInitMac(Vec), + #[error("Wrong packet type ({0:?})")] + WrongPacketType(packets::PacketType), +} + +pub struct HexSlice<'a, T: fmt::LowerHex + 'a>(pub &'a [T]); + +impl<'a> fmt::Display for HexSlice<'a, u8> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "Hex[")?; + if let Some((l, m)) = self.0.split_last() { + for b in m { + write!(f, "{:02x} ", b)?; + } + write!(f, "{:02x}", l)?; + } + write!(f, "]") + } +} diff --git a/crates/proto/tsproto-packets/src/packets.rs b/crates/proto/tsproto-packets/src/packets.rs new file mode 100644 index 0000000..750d8fe --- /dev/null +++ b/crates/proto/tsproto-packets/src/packets.rs @@ -0,0 +1,1251 @@ +#![allow(clippy::new_ret_no_self)] +use std::convert::TryInto; +use std::io::prelude::*; +use std::{fmt, io, str}; + +use base64::prelude::*; +use bitflags::bitflags; +use num_derive::{FromPrimitive, ToPrimitive}; +use num_traits::{FromPrimitive as _, ToPrimitive as _}; +use omnom::{ReadExt, WriteExt}; +use serde::{Deserialize, Serialize}; + +use crate::{Error, HexSlice, Result}; + +#[derive( + Clone, Copy, Debug, Deserialize, Eq, FromPrimitive, Hash, PartialEq, ToPrimitive, Serialize, +)] +#[repr(u8)] +pub enum PacketType { + Voice, + VoiceWhisper, + Command, + CommandLow, + Ping, + Pong, + Ack, + AckLow, + Init, +} + +#[derive(Clone, Copy, Deserialize, Debug, Eq, PartialEq, Hash, Serialize)] +pub enum Direction { + /// Going from the server to the client. + S2C, + /// Going from the client to the server. + C2S, +} + +bitflags! { + #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] + pub struct Flags: u8 { + const UNENCRYPTED = 0x80; + const COMPRESSED = 0x40; + const NEWPROTOCOL = 0x20; + const FRAGMENTED = 0x10; + } +} + +impl PacketType { + pub fn is_command(self) -> bool { + self == PacketType::Command || self == PacketType::CommandLow + } + pub fn is_ack(self) -> bool { + self == PacketType::Ack || self == PacketType::AckLow || self == PacketType::Pong + } + pub fn is_voice(self) -> bool { self == PacketType::Voice || self == PacketType::VoiceWhisper } +} + +#[repr(u8)] +#[derive(Debug, PartialEq, Eq, Clone, Copy, FromPrimitive, ToPrimitive)] +pub enum CodecType { + /// Mono, 16 bit, 8 kHz, bitrate dependent on the quality setting + SpeexNarrowband, + /// Mono, 16 bit, 16 kHz, bitrate dependent on the quality setting + SpeexWideband, + /// Mono, 16 bit, 32 kHz, bitrate dependent on the quality setting + SpeexUltrawideband, + /// Mono, 16 bit, 48 kHz, bitrate dependent on the quality setting + CeltMono, + /// Mono, 16 bit, 48 kHz, bitrate dependent on the quality setting, optimized for voice + OpusVoice, + /// Stereo, 16 bit, 48 kHz, bitrate dependent on the quality setting, optimized for music + OpusMusic, +} + +macro_rules! create_buf { + ($($name:ident, $borrow_name:ident, $convert:ident);*) => { + mod rentals { + use super::*; + + $(self_cell::self_cell!( + pub struct $name { + owner: Vec, + #[covariant] + dependent: $borrow_name, + } + + impl {Debug} + );)* + } + + $( + #[derive(Debug)] + pub struct $name(rentals::$name); + + impl $name { + /// `InPacket::try_new` is not checked and must succeed. Otherwise, it + /// panics. + #[inline] + pub fn try_new(direction: Direction, data: Vec) -> Result { + Ok(Self(rentals::$name::try_new(data, |data| InPacket::new(direction, data).$convert())?)) + } + #[inline] + pub fn raw_data(&self) -> &[u8] { self.0.borrow_owner().as_slice() } + #[inline] + pub fn data(&self) -> &$borrow_name<'_> { self.0.borrow_dependent() } + #[inline] + pub fn into_buffer(self) -> Vec { self.0.into_owner() } + } + )* + } +} + +create_buf!(InAudioBuf, InAudio, into_audio; + InCommandBuf, InCommand, into_command; + InC2SInitBuf, InC2SInit, into_c2sinit; + InS2CInitBuf, InS2CInit, into_s2cinit); + +/// Used for debugging. +#[derive(Clone)] +pub struct InUdpPacket<'a>(pub InPacket<'a>); + +impl<'a> InUdpPacket<'a> { + pub fn new(packet: InPacket<'a>) -> Self { Self(packet) } +} + +#[derive(Clone)] +pub struct InHeader<'a> { + direction: Direction, + data: &'a [u8], +} + +#[derive(Clone)] +pub struct InPacket<'a> { + header: InHeader<'a>, + content: &'a [u8], +} + +#[derive(Clone, Debug)] +pub struct InCommand<'a> { + packet: InPacket<'a>, +} + +#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Hash, Serialize)] +pub struct OutUdpPacket { + generation_id: u32, + data: OutPacket, +} + +#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Hash, Serialize)] +pub struct OutPacket { + dir: Direction, + data: Vec, +} + +/// The mac has to be `b"TS3INIT1"`. +/// +/// `version` always contains the Teamspeak version as timestamp. +/// +/// `timestamp` contains a current timestamp. +#[derive(Clone)] +pub enum C2SInitData<'a> { + Init0 { + version: u32, + timestamp: u32, + random0: &'a [u8; 4], + }, + Init2 { + version: u32, + random1: &'a [u8; 16], + random0_r: &'a [u8; 4], + }, + Init4 { + version: u32, + x: &'a [u8; 64], + n: &'a [u8; 64], + level: u32, + random2: &'a [u8; 100], + /// y = x ^ (2 ^ level) % n + y: &'a [u8; 64], + /// Has to be a `clientinitiv alpha=… omega=…` command. + command: &'a [u8], + }, +} + +#[derive(Clone)] +pub enum S2CInitData<'a> { + Init1 { random1: &'a [u8; 16], random0_r: &'a [u8; 4] }, + Init3 { x: &'a [u8; 64], n: &'a [u8; 64], level: u32, random2: &'a [u8; 100] }, + Init127 {}, +} + +#[derive(Clone, Debug)] +pub struct InS2CInit<'a> { + packet: InPacket<'a>, + data: S2CInitData<'a>, +} + +#[derive(Clone, Debug)] +pub struct InC2SInit<'a> { + packet: InPacket<'a>, + data: C2SInitData<'a>, +} + +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum AudioData<'a> { + C2S { + id: u16, + codec: CodecType, + data: &'a [u8], + }, + C2SWhisper { + id: u16, + codec: CodecType, + channels: Vec, + clients: Vec, + data: &'a [u8], + }, + /// When the `Flags::NEWPROTOCOL` is set. + C2SWhisperNew { + id: u16, + codec: CodecType, + whisper_type: u8, + target: u8, + target_id: u64, + data: &'a [u8], + }, + + S2C { + id: u16, + from: u16, + codec: CodecType, + data: &'a [u8], + }, + S2CWhisper { + id: u16, + from: u16, + codec: CodecType, + data: &'a [u8], + }, +} + +#[derive(Clone)] +pub struct InAudio<'a> { + packet: InPacket<'a>, + data: AudioData<'a>, +} + +#[must_use] +pub struct OutCommand(pub OutPacket); +pub struct OutC2SInit0; +pub struct OutC2SInit2; +pub struct OutC2SInit4; +pub struct OutS2CInit1; +pub struct OutS2CInit3; +pub struct OutAck; +pub struct OutAudio; + +/// A helper to escape data while writing into a buffer. +struct EscapedWriter<'a>(&'a mut Vec); + +impl Direction { + #[inline] + pub fn reverse(self) -> Self { + match self { + Direction::S2C => Direction::C2S, + Direction::C2S => Direction::S2C, + } + } +} + +impl<'a> InPacket<'a> { + /// Do some sanity checks before creating the object. + #[inline] + pub fn try_new(direction: Direction, data: &'a [u8]) -> Result { + let header_len = + if direction == Direction::S2C { crate::S2C_HEADER_LEN } else { crate::C2S_HEADER_LEN }; + if data.len() < header_len { + return Err(Error::PacketTooShort(data.len())); + } + + // Check packet type + let p_type = data[header_len - 1] & 0xf; + if p_type > 8 { + return Err(Error::UnknownPacketType(p_type)); + } + + Ok(Self::new(direction, data)) + } + + /// This method expects that `data` holds a valid packet. + /// + /// If not, further function calls may panic. + #[inline] + pub fn new(direction: Direction, data: &'a [u8]) -> Self { + let header = InHeader::new(direction, data); + let header_len = header.data.len(); + + Self { header, content: &data[header_len..] } + } + + #[inline] + pub fn header(&self) -> &InHeader<'a> { &self.header } + #[inline] + pub fn content(&self) -> &[u8] { self.content } + + /// Get the acknowledged packet id if this is an ack packet. + #[inline] + pub fn ack_packet(&self) -> Result> { + let p_type = self.header().packet_type(); + if p_type.is_ack() { + Ok(Some( + self.content() + .read_be() + .map_err(|_| Error::PacketContentTooShort(self.content().len()))?, + )) + } else if p_type == PacketType::Init { + if self.header.direction == Direction::S2C { + Ok(Some( + self.content + .first() + .ok_or_else(|| Error::PacketContentTooShort(self.content().len())) + .and_then(|i| match u16::from(*i) { + 1 => Ok(0), + 3 => Ok(2), + 127 => Ok(2), // Have to restart sending Init0, remove Init2 anyway + _ => Err(Error::InvalidInitStep(*i)), + })?, + )) + } else { + Ok(self + .content + .get(4) + .ok_or_else(|| Error::PacketContentTooShort(self.content().len())) + .and_then(|i| match u16::from(*i) { + 0 => Ok(None), + 2 => Ok(Some(1)), + 4 => Ok(Some(3)), + _ => Err(Error::InvalidInitStep(*i)), + })?) + } + } else { + Ok(None) + } + } + + /// Parse this packet into a voice packet. + pub fn into_audio(self) -> Result> { + let p_type = self.header().packet_type(); + let newprotocol = self.header().flags().contains(Flags::NEWPROTOCOL); + let data = AudioData::parse(p_type, newprotocol, self.header.direction, self.content)?; + + Ok(InAudio { packet: self, data }) + } + + /// Put this packet into a command packet. + pub fn into_command(self) -> Result> { Ok(InCommand { packet: self }) } + + pub fn into_s2cinit(self) -> Result> { + if self.header.direction != Direction::S2C { + return Err(Error::WrongDirection); + } + let p_type = self.header().packet_type(); + if p_type != PacketType::Init { + return Err(Error::WrongPacketType(p_type)); + } + let mac = self.header().mac(); + if mac != b"TS3INIT1" { + return Err(Error::WrongInitMac(mac.to_vec())); + } + + if self.content.is_empty() { + return Err(Error::PacketContentTooShort(self.content.len())); + } + + let data; + if self.content[0] == 1 { + if self.content.len() < 21 { + return Err(Error::PacketContentTooShort(self.content.len())); + } + data = S2CInitData::Init1 { + random1: (&self.content[1..17]).try_into().unwrap(), + random0_r: (&self.content[17..21]).try_into().unwrap(), + }; + } else if self.content[0] == 3 { + if self.content.len() < 233 { + return Err(Error::PacketContentTooShort(self.content.len())); + } + data = S2CInitData::Init3 { + x: (&self.content[1..65]).try_into().unwrap(), + n: (&self.content[65..129]).try_into().unwrap(), + level: (&self.content[129..]).read_be()?, + random2: (&self.content[133..233]).try_into().unwrap(), + }; + } else if self.content[0] == 127 { + data = S2CInitData::Init127 {}; + } else { + return Err(Error::InvalidInitStep(self.content[0])); + } + + Ok(InS2CInit { packet: self, data }) + } + + pub fn into_c2sinit(self) -> Result> { + if self.header.direction != Direction::C2S { + return Err(Error::WrongDirection); + } + let p_type = self.header().packet_type(); + if p_type != PacketType::Init { + return Err(Error::WrongPacketType(p_type)); + } + let mac = self.header().mac(); + if mac != b"TS3INIT1" { + return Err(Error::WrongInitMac(mac.to_vec())); + } + + if self.content.len() < 5 { + return Err(Error::PacketContentTooShort(self.content.len())); + } + + let data; + let version = (&self.content[0..]).read_be()?; + if self.content[4] == 0 { + if self.content.len() < 13 { + return Err(Error::PacketContentTooShort(self.content.len())); + } + data = C2SInitData::Init0 { + version, + timestamp: (&self.content[5..]).read_be()?, + random0: (&self.content[9..13]).try_into().unwrap(), + }; + } else if self.content[4] == 2 { + if self.content.len() < 25 { + return Err(Error::PacketContentTooShort(self.content.len())); + } + data = C2SInitData::Init2 { + version, + random1: (&self.content[5..21]).try_into().unwrap(), + random0_r: (&self.content[21..25]).try_into().unwrap(), + }; + } else if self.content[4] == 4 { + let len = 5 + 128 + 4 + 100 + 64; + if self.content.len() < len + 20 { + return Err(Error::PacketContentTooShort(self.content.len())); + } + data = C2SInitData::Init4 { + version, + x: (&self.content[5..69]).try_into().unwrap(), + n: (&self.content[69..133]).try_into().unwrap(), + level: (&self.content[133..]).read_be()?, + random2: (&self.content[137..237]).try_into().unwrap(), + y: (&self.content[237..301]).try_into().unwrap(), + command: &self.content[len..], + }; + } else { + return Err(Error::InvalidInitStep(self.content[0])); + } + + Ok(InC2SInit { packet: self, data }) + } +} + +impl fmt::Debug for InPacket<'_> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "Packet({:?}", self.header())?; + let mut success = false; + match self.header.packet_type() { + PacketType::Voice | PacketType::VoiceWhisper => { + if let Ok(packet) = self.clone().into_audio() { + success = true; + write!(f, ", {:?}", packet)?; + } + } + PacketType::Command | PacketType::CommandLow => { + if let Ok(packet) = str::from_utf8(self.content()) { + success = true; + write!(f, ", {:?}", packet)?; + } + } + PacketType::Ping | PacketType::Pong | PacketType::Ack | PacketType::AckLow => { + success = true; + if !self.content().is_empty() { + write!(f, ", 0x")?; + } + for b in self.content() { + write!(f, "{:02x}", b)?; + } + } + PacketType::Init => { + if self.header.direction == Direction::C2S { + if let Ok(packet) = self.clone().into_c2sinit() { + success = true; + write!(f, ", {:?}", packet.data)?; + } + } else if let Ok(packet) = self.clone().into_s2cinit() { + success = true; + write!(f, ", {:?}", packet.data)?; + } + } + } + + if !success { + write!(f, ", failed to parse, content: {})", HexSlice(self.content()))?; + } + + write!(f, ")")?; + Ok(()) + } +} + +impl fmt::Debug for InUdpPacket<'_> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "Packet({:?}, content: {})", self.0.header(), HexSlice(self.0.content()))?; + Ok(()) + } +} + +impl fmt::Debug for InHeader<'_> { + #[rustfmt::skip] + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "Header(")?; + if self.mac() != &[0; 8] { + write!(f, "mac: {}, ", HexSlice(self.mac()))?; + } + write!(f, "id: {:#x}, ", self.packet_id())?; + if let Some(c_id) = self.client_id() { + write!(f, "c_id: {:#x}, ", c_id)?; + } + write!(f, "{:?}, ", self.packet_type())?; + write!(f, "")?; + let flags = self.flags(); + write!(f, "{}", if flags.contains(Flags::UNENCRYPTED) { "u" } else { "-" })?; + write!(f, "{}", if flags.contains(Flags::COMPRESSED) { "c" } else { "-" })?; + write!(f, "{}", if flags.contains(Flags::NEWPROTOCOL) { "n" } else { "-" })?; + write!(f, "{}", if flags.contains(Flags::FRAGMENTED) { "f" } else { "-" })?; + + write!(f, ")")?; + Ok(()) + } +} + +impl<'a> InHeader<'a> { + #[inline] + pub fn new(direction: Direction, data: &'a [u8]) -> Self { + let header_len = + if direction == Direction::S2C { crate::S2C_HEADER_LEN } else { crate::C2S_HEADER_LEN }; + + Self { direction, data: &data[..header_len] } + } + + /// The offset to the packet type. + #[inline] + fn get_off(&self) -> usize { if self.direction == Direction::S2C { 10 } else { 12 } } + + #[inline] + pub fn direction(&self) -> Direction { self.direction } + #[inline] + pub fn data(&self) -> &'a [u8] { self.data } + #[inline] + pub fn mac(&self) -> &'a [u8; 8] { (&self.data[..8]).try_into().unwrap() } + #[inline] + pub fn packet_id(&self) -> u16 { (&self.data[8..10]).read_be().unwrap() } + + #[inline] + pub fn client_id(&self) -> Option { + if self.direction == Direction::S2C { + None + } else { + Some((&self.data[10..12]).read_be().unwrap()) + } + } + + #[inline] + pub fn flags(&self) -> Flags { Flags::from_bits(self.data[self.get_off()] & 0xf0).unwrap() } + + #[inline] + pub fn packet_type(&self) -> PacketType { + PacketType::from_u8(self.data[self.get_off()] & 0xf).unwrap() + } + + pub fn get_meta(&self) -> &'a [u8] { &self.data[8..] } +} + +impl C2SInitData<'_> { + pub fn get_step(&self) -> u8 { + match self { + C2SInitData::Init0 { .. } => 0, + C2SInitData::Init2 { .. } => 2, + C2SInitData::Init4 { .. } => 4, + } + } +} + +impl<'a> fmt::Debug for C2SInitData<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + C2SInitData::Init0 { .. } => write!(f, "Init0"), + C2SInitData::Init2 { .. } => write!(f, "Init2"), + C2SInitData::Init4 { level, command, .. } => { + write!(f, "Init4(level: {}, ", level)?; + if let Ok(s) = str::from_utf8(command) { + write!(f, "{:?}", s)?; + } else { + write!(f, "{}", HexSlice(command))?; + } + write!(f, ")")?; + Ok(()) + } + } + } +} + +impl S2CInitData<'_> { + pub fn get_step(&self) -> u8 { + match self { + S2CInitData::Init1 { .. } => 1, + S2CInitData::Init3 { .. } => 3, + S2CInitData::Init127 { .. } => 127, + } + } +} + +impl<'a> fmt::Debug for S2CInitData<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + S2CInitData::Init1 { .. } => write!(f, "Init1"), + S2CInitData::Init3 { level, .. } => write!(f, "Init3(level: {})", level), + S2CInitData::Init127 { .. } => write!(f, "Init127"), + } + } +} + +impl<'a> InCommand<'a> { + #[inline] + pub fn packet(&self) -> &InPacket<'a> { &self.packet } +} + +impl<'a> AudioData<'a> { + pub fn parse( + p_type: PacketType, newprotocol: bool, dir: Direction, content: &'a [u8], + ) -> Result { + let id = (&content[..]).read_be()?; + if p_type == PacketType::Voice { + if dir == Direction::S2C { + if content.len() < 5 { + return Err(Error::PacketContentTooShort(content.len())); + } + Ok(AudioData::S2C { + id, + from: (&content[2..]).read_be()?, + codec: CodecType::from_u8(content[4]) + .ok_or_else(|| Error::InvalidCodec(content[4]))?, + data: &content[5..], + }) + } else { + if content.len() < 3 { + return Err(Error::PacketContentTooShort(content.len())); + } + Ok(AudioData::C2S { + id, + codec: CodecType::from_u8(content[2]) + .ok_or_else(|| Error::InvalidCodec(content[4]))?, + data: &content[3..], + }) + } + } else if dir == Direction::S2C { + if content.len() < 5 { + return Err(Error::PacketContentTooShort(content.len())); + } + Ok(AudioData::S2CWhisper { + id, + from: (&content[2..]).read_be()?, + codec: CodecType::from_u8(content[4]) + .ok_or_else(|| Error::InvalidCodec(content[4]))?, + data: &content[5..], + }) + } else { + if content.len() < 3 { + return Err(Error::PacketContentTooShort(content.len())); + } + let codec = + CodecType::from_u8(content[2]).ok_or_else(|| Error::InvalidCodec(content[4]))?; + if newprotocol { + if content.len() < 14 { + return Err(Error::PacketContentTooShort(content.len())); + } + Ok(AudioData::C2SWhisperNew { + id, + codec, + whisper_type: content[3], + target: content[4], + target_id: (&content[5..]).read_be()?, + data: &content[13..], + }) + } else { + if content.len() < 5 { + return Err(Error::PacketContentTooShort(content.len())); + } + let channel_count = content[3] as usize; + let client_count = content[4] as usize; + let channel_off = 5; + let client_off = channel_off + channel_count * 8; + let off = client_off + client_count * 2; + if content.len() < off { + return Err(Error::PacketContentTooShort(content.len())); + } + + Ok(AudioData::C2SWhisper { + id, + codec, + channels: (0..channel_count) + .map(|i| (&content[channel_off + i * 8..]).read_be()) + .collect::<::std::result::Result, _>>()?, + clients: (0..client_count) + .map(|i| (&content[client_off + i * 2..]).read_be()) + .collect::<::std::result::Result, _>>()?, + data: &content[off..], + }) + } + } + } + + #[inline] + pub fn direction(&self) -> Direction { + match self { + AudioData::C2S { .. } => Direction::C2S, + AudioData::C2SWhisper { .. } => Direction::C2S, + AudioData::C2SWhisperNew { .. } => Direction::C2S, + AudioData::S2C { .. } => Direction::S2C, + AudioData::S2CWhisper { .. } => Direction::S2C, + } + } + + #[inline] + pub fn packet_type(&self) -> PacketType { + match self { + AudioData::C2S { .. } => PacketType::Voice, + AudioData::C2SWhisper { .. } => PacketType::VoiceWhisper, + AudioData::C2SWhisperNew { .. } => PacketType::VoiceWhisper, + AudioData::S2C { .. } => PacketType::Voice, + AudioData::S2CWhisper { .. } => PacketType::VoiceWhisper, + } + } + + #[inline] + pub fn codec(&self) -> CodecType { + match self { + AudioData::C2S { codec, .. } => *codec, + AudioData::C2SWhisper { codec, .. } => *codec, + AudioData::C2SWhisperNew { codec, .. } => *codec, + AudioData::S2C { codec, .. } => *codec, + AudioData::S2CWhisper { codec, .. } => *codec, + } + } + + #[inline] + pub fn id(&self) -> u16 { + match self { + AudioData::C2S { id, .. } => *id, + AudioData::C2SWhisper { id, .. } => *id, + AudioData::C2SWhisperNew { id, .. } => *id, + AudioData::S2C { id, .. } => *id, + AudioData::S2CWhisper { id, .. } => *id, + } + } + + #[inline] + pub fn flags(&self) -> Flags { + match self { + AudioData::C2S { .. } => Flags::empty(), + AudioData::C2SWhisper { .. } => Flags::empty(), + AudioData::C2SWhisperNew { .. } => Flags::NEWPROTOCOL, + AudioData::S2C { .. } => Flags::empty(), + AudioData::S2CWhisper { .. } => Flags::empty(), + } + } + + #[inline] + pub fn data(&self) -> &[u8] { + match self { + AudioData::C2S { data, .. } => data, + AudioData::C2SWhisper { data, .. } => data, + AudioData::C2SWhisperNew { data, .. } => data, + AudioData::S2C { data, .. } => data, + AudioData::S2CWhisper { data, .. } => data, + } + } +} + +impl<'a> InS2CInit<'a> { + #[inline] + pub fn packet(&self) -> &InPacket<'a> { &self.packet } + #[inline] + pub fn data(&self) -> &S2CInitData<'a> { &self.data } +} + +impl<'a> InC2SInit<'a> { + #[inline] + pub fn packet(&self) -> &InPacket<'a> { &self.packet } + #[inline] + pub fn data(&self) -> &C2SInitData<'a> { &self.data } +} + +impl<'a> InAudio<'a> { + #[inline] + pub fn packet(&self) -> &InPacket<'a> { &self.packet } + #[inline] + pub fn data(&self) -> &AudioData<'a> { &self.data } +} + +impl fmt::Debug for InAudio<'_> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match &self.data { + AudioData::C2S { id, codec, data } => { + write!(f, "Audio(id: {}, {:?}, {})", id, codec, HexSlice(data))?; + } + AudioData::C2SWhisper { id, codec, channels, clients, data } => { + write!( + f, + "Whisper(id: {}, {:?}, channels: {:?}, clients: {:?}, {})", + id, + codec, + channels, + clients, + HexSlice(data) + )?; + } + AudioData::C2SWhisperNew { id, codec, whisper_type, target, target_id, data } => { + write!( + f, + "WhisperNew(id: {}, {:?}, type: {}, target: {}, target_id: {}, {})", + id, + codec, + whisper_type, + target, + target_id, + HexSlice(data) + )?; + } + AudioData::S2C { id, from, codec, data } => { + write!(f, "Audio(id: {}, from: {}, {:?}, {})", id, from, codec, HexSlice(data))?; + } + AudioData::S2CWhisper { id, from, codec, data } => { + write!(f, "Whisper(id: {}, from: {}, {:?}, {})", id, from, codec, HexSlice(data))?; + } + } + + Ok(()) + } +} + +impl OutPacket { + #[inline] + pub fn new( + mac: [u8; 8], packet_id: u16, client_id: Option, flags: Flags, packet_type: PacketType, + ) -> Self { + let dir = if client_id.is_some() { Direction::C2S } else { Direction::S2C }; + let mut res = Self::new_with_dir(dir, flags, packet_type); + res.data[..8].copy_from_slice(&mac); + res.packet_id(packet_id); + if let Some(cid) = client_id { + res.client_id(cid); + } + res + } + + /// Fill packet with known data. The rest gets filled by `packet_codec`. + #[inline] + pub fn new_with_dir(dir: Direction, flags: Flags, packet_type: PacketType) -> Self { + let data = + vec![ + 0; + if dir == Direction::S2C { crate::S2C_HEADER_LEN } else { crate::C2S_HEADER_LEN } + ]; + let mut res = Self { dir, data }; + res.flags(flags); + res.packet_type(packet_type); + res + } + + #[inline] + pub fn new_from_data(dir: Direction, data: Vec) -> Self { Self { dir, data } } + + #[inline] + pub fn into_vec(self) -> Vec { self.data } + + #[inline] + fn content_offset(&self) -> usize { + if self.dir == Direction::S2C { crate::S2C_HEADER_LEN } else { crate::C2S_HEADER_LEN } + } + + #[inline] + pub fn data(&self) -> &[u8] { &self.data } + #[inline] + pub fn data_mut(&mut self) -> &mut Vec { &mut self.data } + #[inline] + pub fn content(&self) -> &[u8] { &self.data[self.content_offset()..] } + #[inline] + pub fn content_mut(&mut self) -> &mut [u8] { + let off = self.content_offset(); + &mut self.data[off..] + } + #[inline] + pub fn direction(&self) -> Direction { self.dir } + #[inline] + pub fn header(&self) -> InHeader<'_> { + InHeader { direction: self.dir, data: self.header_bytes() } + } + #[inline] + pub fn header_bytes(&self) -> &[u8] { &self.data[..self.content_offset()] } + #[inline] + pub fn packet(&self) -> InPacket<'_> { InPacket::new(self.dir, &self.data) } + + #[inline] + pub fn mac(&mut self) -> &mut [u8; 8] { (&mut self.data[0..8]).try_into().unwrap() } + #[inline] + pub fn packet_id(&mut self, packet_id: u16) { + (&mut self.data[8..10]).write_be(packet_id).unwrap(); + } + #[inline] + pub fn client_id(&mut self, client_id: u16) { + assert_eq!( + self.dir, + Direction::C2S, + "Client id is only valid for client to server packets" + ); + (&mut self.data[10..12]).write_be(client_id).unwrap(); + } + #[inline] + pub fn flags(&mut self, flags: Flags) { + let off = self.header().get_off(); + self.data[off] = (self.data[off] & 0xf) | flags.bits(); + } + #[inline] + pub fn packet_type(&mut self, packet_type: PacketType) { + let off = self.header().get_off(); + self.data[off] = (self.data[off] & 0xf0) | packet_type.to_u8().unwrap(); + } +} + +impl OutUdpPacket { + #[inline] + pub fn new(generation_id: u32, data: OutPacket) -> Self { Self { generation_id, data } } + + #[inline] + pub fn generation_id(&self) -> u32 { self.generation_id } + #[inline] + pub fn data(&self) -> &OutPacket { &self.data } + + #[inline] + pub fn packet_id(&self) -> u16 { + if self.packet_type() == PacketType::Init { + if self.data.dir == Direction::S2C { + u16::from(self.data.content()[0]) + } else { + u16::from(self.data.content()[4]) + } + } else { + self.data.header().packet_id() + } + } + #[inline] + pub fn packet_type(&self) -> PacketType { self.data.header().packet_type() } +} + +impl io::Write for EscapedWriter<'_> { + fn write(&mut self, buf: &[u8]) -> io::Result { + self.0.reserve(buf.len()); + for c in buf { + match c { + b'\x0b' => self.0.extend_from_slice(b"\\v"), + b'\x0c' => self.0.extend_from_slice(b"\\f"), + b'\\' => self.0.extend_from_slice(b"\\\\"), + b'\t' => self.0.extend_from_slice(b"\\t"), + b'\r' => self.0.extend_from_slice(b"\\r"), + b'\n' => self.0.extend_from_slice(b"\\n"), + b'|' => self.0.extend_from_slice(b"\\p"), + b' ' => self.0.extend_from_slice(b"\\s"), + b'/' => self.0.extend_from_slice(b"\\/"), + c => self.0.push(*c), + } + } + Ok(buf.len()) + } + + #[inline] + fn flush(&mut self) -> io::Result<()> { Ok(()) } +} + +impl OutCommand { + #[inline] + pub fn new(dir: Direction, flags: Flags, p_type: PacketType, name: &str) -> Self { + let mut res = Self(OutPacket::new_with_dir(dir, Flags::empty(), p_type)); + res.0.flags(flags); + res.0.data.extend_from_slice(name.as_bytes()); + res + } + + /// For binary arguments. The value will still be escaped. + #[inline] + pub fn write_bin_arg(&mut self, name: &str, value: &[u8]) { + if self.0.content().last() != Some(&b'|') && !self.0.content().is_empty() { + self.0.data.push(b' '); + } + self.0.data.extend_from_slice(name.as_bytes()); + if !value.is_empty() { + self.0.data.push(b'='); + EscapedWriter(&mut self.0.data).write_all(value).unwrap(); + } + } + + /// The value will be formatted and escaped. + #[inline] + pub fn write_arg(&mut self, name: &str, value: &dyn fmt::Display) { + if self.0.content().last() != Some(&b'|') && !self.0.content().is_empty() { + self.0.data.push(b' '); + } + self.0.data.extend_from_slice(name.as_bytes()); + self.0.data.push(b'='); + let len = self.0.data.len(); + write!(EscapedWriter(&mut self.0.data), "{}", value).unwrap(); + if self.0.data.len() == len { + // Nothing was written, remove = + self.0.data.pop(); + } + } + + /// Adds a pipe symbol `|` to the command. + #[inline] + pub fn start_new_part(&mut self) { self.0.data.push(b'|'); } + #[inline] + pub fn into_packet(self) -> OutPacket { self.0 } +} + +impl OutC2SInit0 { + pub fn new(version: u32, timestamp: u32, random0: [u8; 4]) -> OutPacket { + let mut res = OutPacket::new_with_dir(Direction::C2S, Flags::empty(), PacketType::Init); + res.mac().copy_from_slice(b"TS3INIT1"); + res.packet_id(0x65); + let content = res.data_mut(); + content.write_be(version).unwrap(); + content.write_be(0u8).unwrap(); + content.write_be(timestamp).unwrap(); + content.write_all(&random0).unwrap(); + // Reserved + content.write_all(&[0u8; 8]).unwrap(); + res + } +} + +impl OutC2SInit2 { + pub fn new(version: u32, random1: &[u8; 16], random0_r: [u8; 4]) -> OutPacket { + let mut res = OutPacket::new_with_dir(Direction::C2S, Flags::empty(), PacketType::Init); + res.mac().copy_from_slice(b"TS3INIT1"); + res.packet_id(0x65); + let content = res.data_mut(); + content.write_be(version).unwrap(); + content.write_be(2u8).unwrap(); + content.write_all(random1).unwrap(); + content.write_all(&random0_r).unwrap(); + res + } +} + +impl OutC2SInit4 { + pub fn new( + version: u32, x: &[u8; 64], n: &[u8; 64], level: u32, random2: &[u8; 100], y: &[u8; 64], + alpha: &[u8], omega: &[u8], ip: &str, + ) -> OutPacket { + let mut res = OutPacket::new_with_dir(Direction::C2S, Flags::empty(), PacketType::Init); + res.mac().copy_from_slice(b"TS3INIT1"); + res.packet_id(0x65); + let content = res.data_mut(); + content.write_be(version).unwrap(); + content.write_be(4u8).unwrap(); + content.write_all(x).unwrap(); + content.write_all(n).unwrap(); + content.write_be(level).unwrap(); + content.write_all(random2).unwrap(); + content.write_all(y).unwrap(); + let ip = if ip.is_empty() { String::new() } else { format!("={}", ip) }; + content + .write_all( + format!( + "clientinitiv alpha={} omega={} ot=1 ip{}", + BASE64_STANDARD.encode(alpha), + BASE64_STANDARD.encode(omega), + ip + ) + .as_bytes(), + ) + .unwrap(); + res + } +} + +impl OutS2CInit1 { + pub fn new(random1: &[u8; 16], random0_r: [u8; 4]) -> OutPacket { + let mut res = OutPacket::new_with_dir(Direction::S2C, Flags::empty(), PacketType::Init); + res.mac().copy_from_slice(b"TS3INIT1"); + res.packet_id(0x65); + let content = res.data_mut(); + content.write_be(1u8).unwrap(); + content.write_all(random1).unwrap(); + content.write_all(&random0_r).unwrap(); + res + } +} + +impl OutS2CInit3 { + pub fn new(x: &[u8; 64], n: &[u8; 64], level: u32, random2: &[u8; 100]) -> OutPacket { + let mut res = OutPacket::new_with_dir(Direction::S2C, Flags::empty(), PacketType::Init); + res.mac().copy_from_slice(b"TS3INIT1"); + res.packet_id(0x65); + let content = res.data_mut(); + content.write_be(3u8).unwrap(); + content.write_all(x).unwrap(); + content.write_all(n).unwrap(); + content.write_be(level).unwrap(); + content.write_all(random2).unwrap(); + res + } +} + +impl OutAck { + /// `for_type` is the packet type which gets acknowledged, so e.g. `Command`. + pub fn new(dir: Direction, for_type: PacketType, packet_id: u16) -> OutPacket { + let p_type = if for_type == PacketType::Command { + PacketType::Ack + } else if for_type == PacketType::CommandLow { + PacketType::AckLow + } else if for_type == PacketType::Ping { + PacketType::Pong + } else { + panic!("Invalid packet type to create ack {:?}", for_type); + }; + + let mut res = OutPacket::new_with_dir(dir, Flags::empty(), p_type); + let content = res.data_mut(); + content.write_be(packet_id).unwrap(); + res + } +} + +impl OutAudio { + pub fn new(data: &AudioData) -> OutPacket { + let mut res = OutPacket::new_with_dir(data.direction(), data.flags(), data.packet_type()); + let content = res.data_mut(); + + content.write_be(data.id()).unwrap(); + match data { + AudioData::C2S { codec, data, .. } => { + content.write_be(codec.to_u8().unwrap()).unwrap(); + content.extend_from_slice(data); + } + AudioData::C2SWhisper { codec, channels, clients, data, .. } => { + content.write_be(codec.to_u8().unwrap()).unwrap(); + content.write_be(channels.len() as u8).unwrap(); + content.write_be(clients.len() as u8).unwrap(); + + for c in channels { + content.write_be(*c).unwrap(); + } + for c in clients { + content.write_be(*c).unwrap(); + } + content.extend_from_slice(data); + } + AudioData::C2SWhisperNew { codec, whisper_type, target, target_id, data, .. } => { + content.write_be(codec.to_u8().unwrap()).unwrap(); + content.write_be(whisper_type.to_u8().unwrap()).unwrap(); + content.write_be(*target).unwrap(); + content.write_be(*target_id).unwrap(); + content.extend_from_slice(data); + } + AudioData::S2C { from, codec, data, .. } + | AudioData::S2CWhisper { from, codec, data, .. } => { + content.write_be(*from).unwrap(); + content.write_be(codec.to_u8().unwrap()).unwrap(); + content.extend_from_slice(data); + } + } + + res + } +} + +#[cfg(test)] +mod tests { + use super::*; + + fn test_audio_roundtrip(dir: Direction, data: &AudioData) { + let out_p = OutAudio::new(data); + let in_p = InPacket::try_new(dir, out_p.data()).unwrap(); + let audio = in_p.into_audio().unwrap(); + assert_eq!(audio.data(), data); + } + + #[test] + fn test_audio_c2s() { + let data = AudioData::C2S { codec: CodecType::OpusVoice, id: 0x1234, data: &[1, 2, 3] }; + test_audio_roundtrip(Direction::C2S, &data); + } + + #[test] + fn test_audio_c2s_whisper() { + let data = AudioData::C2SWhisper { + codec: CodecType::OpusVoice, + channels: vec![4, 5, 6], + clients: vec![7, 8], + id: 0x1234, + data: &[1, 2, 3], + }; + test_audio_roundtrip(Direction::C2S, &data); + } + + #[test] + fn test_audio_c2s_whisper_new() { + let data = AudioData::C2SWhisperNew { + codec: CodecType::OpusVoice, + whisper_type: 3, + target: 4, + target_id: 5, + id: 0x1234, + data: &[1, 2, 3], + }; + test_audio_roundtrip(Direction::C2S, &data); + } + + #[test] + fn test_audio_s2c() { + let data = AudioData::S2C { + codec: CodecType::OpusVoice, + id: 0x1234, + from: 0x5678, + data: &[1, 2, 3], + }; + test_audio_roundtrip(Direction::S2C, &data); + } + + #[test] + fn test_audio_s2c_whisper() { + let data = AudioData::S2CWhisper { + codec: CodecType::OpusVoice, + id: 0x1234, + from: 0x5678, + data: &[1, 2, 3], + }; + test_audio_roundtrip(Direction::S2C, &data); + } +} diff --git a/crates/proto/tsproto-structs/Cargo.toml b/crates/proto/tsproto-structs/Cargo.toml new file mode 100644 index 0000000..e44dd2e --- /dev/null +++ b/crates/proto/tsproto-structs/Cargo.toml @@ -0,0 +1,31 @@ +[package] +name = "tsproto-structs" +version = "0.2.0" +authors = ["Flakebi ", "Splamy "] +description = "Resource files for several TeamSpeak related data." +repository = "https://github.com/ReSpeak/tsclientlib/tree/master/utils/tsproto-structs" +readme = "README.md" +keywords = ["teamspeak3", "ts3"] +license = "MIT OR Apache-2.0" +edition = "2018" +include = [ + "/Cargo.toml", + "/README.md", + "/src/*.rs", + "/declarations/Book.toml", + "/declarations/BookToMessages.toml", + "/declarations/Enums.toml", + "/declarations/Errors.csv", + "/declarations/Messages.toml", + "/declarations/MessagesToBook.toml", + "/declarations/Permissions.csv", + "/declarations/Versions.csv", +] + +[dependencies] +base64 = "0.22" +csv = "1" +heck = "0.5" +once_cell = "1" +serde = { version = "1", features = ["derive"] } +toml = "1" diff --git a/crates/proto/tsproto-structs/README.md b/crates/proto/tsproto-structs/README.md new file mode 100644 index 0000000..7644f96 --- /dev/null +++ b/crates/proto/tsproto-structs/README.md @@ -0,0 +1,13 @@ +# tsproto-structs [![docs.rs](https://docs.rs/tsproto-structs/badge.svg)](https://docs.rs/tsproto-structs) +`tsproto-structs` contains machine readable data for several TeamSpeak related topics. + +The underlying data files can be found in the +[tsdeclarations](https://github.com/ReSpeak/tsdeclarations) repository. + +## License +Licensed under either of + + * [Apache License, Version 2.0](../../LICENSE-APACHE) + * [MIT license](../../LICENSE-MIT) + +at your option. diff --git a/crates/proto/tsproto-structs/README.tpl b/crates/proto/tsproto-structs/README.tpl new file mode 100644 index 0000000..6268751 --- /dev/null +++ b/crates/proto/tsproto-structs/README.tpl @@ -0,0 +1,10 @@ +# tsproto-structs [![docs.rs](https://docs.rs/tsproto-structs/badge.svg)](https://docs.rs/tsproto-structs) +{{readme}} + +## License +Licensed under either of + + * [Apache License, Version 2.0](../../LICENSE-APACHE) + * [MIT license](../../LICENSE-MIT) + +at your option. diff --git a/crates/proto/tsproto-structs/declarations/.gitignore b/crates/proto/tsproto-structs/declarations/.gitignore new file mode 100644 index 0000000..89035df --- /dev/null +++ b/crates/proto/tsproto-structs/declarations/.gitignore @@ -0,0 +1,67 @@ +# LaTeX files +*.synctex.gz + +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* diff --git a/crates/proto/tsproto-structs/declarations/Badges.csv b/crates/proto/tsproto-structs/declarations/Badges.csv new file mode 100644 index 0000000..d498aa3 --- /dev/null +++ b/crates/proto/tsproto-structs/declarations/Badges.csv @@ -0,0 +1,83 @@ +uid,name,description,filename,codes +4b27be5a-b92a-4b30-8b2d-14b59653f427,20th Anniversary,Celebrating 20 Years of TeamSpeak,20_years, +f81ad44d-e931-47d1-a3ef-5fd160217cf8,4Netplayers,4Netplayers customer,4netplayers, +b78a0f3e-8758-4572-b102-42a79b4a0342,????,Reads between the line,hat, +2bf80270-8efe-46dc-a472-3280a0479145,Alpha Tester,Helped to test our software. THANK YOU!,Alpha, +05114019-6b46-4b13-b5a1-e5179ef69fb5,April Fools!,"Roses are red, gaming is fun, you are carrying too much to be able to run :(",rpg, +1a518885-520c-4f54-9f49-8b1acb674771,Braindance,I’m chippin’ in,Braindance,P4TEKZ80PZ +cbf5aafd-2554-4053-80bb-0cf82ec0a430,Bright Idea,TeamSpeak took my idea on board,FeatureBadge_Lightbulb, +d6062d9c-42a3-49c9-91dd-8c43a5a46805,Bug Catcher,I found a bug!,BugBadge_Splat, +dfc70674-0fd0-431e-b3a1-edc32d7b09b2,Challenge Accepted,"Unlocked at SCILL Play — Challenges, tournaments and more!",scill, +f85f7e21-753a-4566-b26a-4e3e9155d2ef,Cyberpunk,We have a city to burn,Cyberpunk, +c028298c-84ff-4e22-be4e-b8c17552b4bb,Digi,Digi joined your channel #DIGWIN,digi, +56df5ce2-6c5a-4a24-90e2-29e497e26170,Drone Champions League,I follow the Drone Champions League,DCL_Badge,DRONECHAMP +935e5a2a-954a-44ca-aa7a-55c79285b601,E3 2018 - Winner,Discovered at E3 2018,E3-2018, +61723e54-3da2-4f19-a33f-fcdc8ef5eaa0,Father's Day 2022,Not all heroes wear capes,fathersday2022, +b9c7d6ad-5b99-40fb-988c-1d02ab6cc130,Found Tim Speak,Found Tim Speak at Gamescom 2018,met_tim,XJN4WJZEJN +62444179-0d99-42ba-a45c-c6b1557d079a,Gamescom 2014,Registered at Gamescom 2014,gamescom_2014, +50bbdbc8-0f2a-46eb-9808-602225b49627,Gamescom 2016,Registered during Gamescom 2016,gamescom_2016, +534c9582-ab02-4267-aec6-2d94361daa2a,Gamescom 2017,Visited TeamSpeak at Gamescom 2017,gamescom_2017,DK9JGRJH1Q +4eef1ecf-a0ea-423d-bfd0-496543a00305,Gamescom 2018,Visited TeamSpeak at Gamescom 2018,gamescom_2018,8CXB49KPJ4 +b82a45a5-b235-4926-be77-de102222e5eb,Gamescom 2019,Visited TeamSpeak at Gamescom 2019,Gamescom19,PNKCB76VZ8 +34dbfa8f-bd27-494c-aa08-a312fc0bb240,Gamescom Hero 2017,Gaming Hero at Gamescom 2017,hero_2017, +24512806-f886-4440-b579-9e26e4219ef6,Gamescom Hero 2018,Gamescom Exclusive Gaming Hero 2018,gamescom_2018_played,BJCFQBU53C +d49fd07e-99fb-41de-8d7b-c98064713171,GommeHD.net,Your #1 Minecraft Network for over 10 years,GMHD, +c565972a-3912-457b-826f-84820c1ba6ca,Halloween 2021,Happy Halloween 2021,halloween21, +133595e7-950f-4ef2-b113-f91a68b5770d,Halloween 2021 Special,Earned by participating in our Halloween 2021 special stream,halloween21_special, +fb154277-5fe7-428a-85a4-43c0bdcdda3d,Halloween 2022,Spooky_Scary_Skeletons.mp4,halloween22, +e6679ce2-d458-493c-8ffb-5660e47ac99f,Happy Hanami,Enjoy the view,hanami2023, +de7bd960-eb02-47e1-9ce2-a44f6e255d8f,Happy Holidays 2019,Happy holidays from everyone at TeamSpeak!,Happy_Holidays, +d4ea0251-ba46-4c1a-83b7-59db3f89e52c,Happy New Year 2021,Survived the great toilet paper crisis of 2020,firework_2020, +1519e001-06a0-458c-9195-a8a6d0ec87fc,Happy New Year 2023,"Aw man, here we go again",2023_NewYear, +c68bcc52-7aeb-4868-b4d2-e7b20716f9ba,Heatwave 2022,I'm melting... help,summer_icecream, +94242c4e-6742-4540-8b66-ce951ed57159,Helping Hand,\ pushed some buttons *beep* *bop* ~ thanks!,homebase, +288a56c6-4da3-48de-9c9f-bd9eede5d832,Immortal Roleplay,This is your life.,Immortal_Roleplay, +69bfffc8-e9c0-4f70-8a37-47cb8c73fb1d,International Peace Day,"United we stand, divided we fall",peaceday2022, +9ea23c77-8755-4d82-b30c-92f4aac109ef,International Women's Day 2021,"To all the mums, sisters, aunties, nieces and beyond, Happy Women's Day!",wft, +7d9fa2b1-b6fa-47ad-9838-c239a4ddd116,MIFCOM,MIFCOM | Entered Performance,mifcom, +ed85bdff-2a2b-4bea-a1a5-4d06fcc0d776,Merry Christmas 2019,It’s the most wonderful ‘Tim’ of the Year,Christmas, +c6480fe2-ee25-4ee8-9853-243652c8ec54,Merry Christmas 2020,"Let it snow, let it snow, let it snow!",Christmas2020, +0581aa0f-8c2d-4681-bb9f-8492fec49977,Merry Christmas 2021,Look what Santa's left under the server tree!,christmas2021, +d4875b30-9908-43cb-a1eb-1a958e226078,Merry Christmas 2022,There's snow place like home,christmas2022, +87ccf9ea-67c9-45e5-adbc-77e210e6128a,Met Tim,Met Tim Speak IRL,tim_irl, +0d98391c-ecdf-4f26-931a-49bfd669cda7,Mind Egg,Found in the TeamSpeak 2020 Easter Egg Hunt,E_MindEgg, +2fdda3c6-20e0-48f1-9c12-f39239a2ed02,Mother's Day 2022,Thanks for bearing with us,rose, +c3f823eb-5d5c-40f9-9dbd-3437d59a539d,Official TeamSpeak Gamer,New myTeamSpeak member,TS-2018, +8dfa37ac-b40d-4466-b393-ff2184a9adf3,Overwatch League,I follow the Overwatch League,OWL_Badge, +4ce435d1-6ac5-4530-b81d-6d14ddaaa1ac,PGL Antwerp 2022,Watched the PGL CS:GO Major,PGLant, +fa3ece28-64df-431f-b1b3-90844bfdd2d9,Paris Games Week 2014,Registered at Paris Games Week 2014,paris_gamesweek_2014, +d95f9901-c42d-4bac-8849-7164fd9e2310,Paris Games Week 2016,Registered during Paris Games Week 2016,paris_gamesweek_2016, +0005232e-538e-4cb2-93b6-d7d83e873829,PietSmiet,Werde Snob auf PietSmiet.de ;),PietSmiet, +be932556-dfa9-4dc6-afd0-98de0ab25777,PolTeamgeist,WooOOHoohOOHooo,PolTeamgeist, +5f6d49e4-35c8-4809-8c81-6e71f7f749e9,Power Egg,Found in the TeamSpeak 2020 Easter Egg Hunt,E_PowerEgg, +ceee2445-4fbf-4f06-9421-286f0f4e875a,Pride,Never be afraid to show your colors.,pride, +1aa375e8-7207-45bf-8b80-556bafafc834,Reality Egg,Found in the TeamSpeak 2020 Easter Egg Hunt,E_RealityEgg, +f22c22f1-8e2d-4d99-8de9-f352dc26ac5b,Rocket Beans TV,Rocket Beans TV Community,rbtv,RWGE2NURJZ +2c9698c1-1fec-4baa-a28f-4845f045f42f,Soul Egg,Found in the TeamSpeak 2020 Easter Egg Hunt,E_SoulEgg, +641a4d85-2351-482c-97a1-02fc3b6abbb5,Space Egg,Found in the TeamSpeak 2020 Easter Egg Hunt,E_SpaceEgg, +63261116-4359-4842-873e-56820afbe068,SpartaTheOriginal,Olaf Toast @ twitch.tv/SpartaTheOriginal,Toast, +ef567ec5-f46e-4520-be07-6021023cf6bd,Sponsorship License,Sponsored by TeamSpeak,Sponsorship, +7a627d47-5496-4d68-83b5-2c4eafff9b30,"Stay Home, Stay Safe","Playing Apart, Staying Connected",StaySafeStayHome, +7262a528-c7df-4369-bc2c-d34bf5853d7b,TS Chat Alpha Tester,"Helped us test our new mobile app, thanks!",slim_golden, +6eee759e-b1e9-4937-b023-07fc778532a2,TS Gameday Participant,At least i tried...,silvered, +e1447b99-53b0-448a-98b7-ee7bad8bd268,TS Gameday Winner,As shiny as the golden frying pan,goldenjoystick, +1cb07348-34a4-4741-b50f-c41e584370f7,TeamSpeak Addon Author,Creator of TeamSpeak Addons,addon_author, +450f81c1-ab41-4211-a338-222fa94ed157,TeamSpeak Addon Developer (Bronze),Creator of at least 1 TeamSpeak Addon,addon_author_bronze, +94ec66de-5940-4e38-b002-970df0cf6c94,TeamSpeak Addon Developer (Gold),Creator of at least 5 TeamSpeak Addons,addon_author_gold, +c9e97536-5a2d-4c8e-a135-af404587a472,TeamSpeak Addon Developer (Silver),Creator of at least 3 TeamSpeak Addons,addon_author_silver, +9cd152a7-bf65-4ece-aeba-62d27678f79a,TeamSpeak Competition Winner Badge,TeamSpeak Competition Winner,CompWinnerBadge, +64221fd1-706c-4bb2-ba55-996c39effa79,TeamSpeak Jedi,myTeamSpeak early adopter,TS-OG, +6b187e83-873b-46b0-b2c2-a31af15e76a4,TeamSpeak Merch Badge,TeamSpeak Merch Owner - 1st Edition,cap_red, +22b9ec39-7694-453e-864c-dfc7b1b0d7c7,TeamSpeak Merch Badge 2.0,TeamSpeak Merch Owner - 2nd Edition,topper, +205916f3-a953-4754-8905-bc15069b1f91,TeamSpeak Merch Badge 3.0,TeamSpeak Merch Owner — 3rd Edition,Merch3, +c2368518-3728-4260-bcd1-8b85e9f8984c,Test,"Testing, Testing.",Testing, +4086a249-a503-4f31-9e83-8a0a8e3089bd,Tim-o'-Lantern,Mwuhaahaahaahaahaa,Tim-O-Lantern,JQGCTAQWHT +089c7295-3aa2-48b0-b2f1-2dd1bec12caf,Time Egg,Found in the TeamSpeak 2020 Easter Egg Hunt,E_TimeEgg, +904e232c-f369-44db-87f7-5142e15620cc,Time Machine,Worked like a machine to update addons in super-quick time.,time_machine, +4b0fd4f5-d456-4294-973d-853a1db5c7d8,Valentim's Day 2019,Valentim's Day 2019,Valentines_Badge, +92801833-e721-4b7e-84d4-6c02dbb332b9,Valentim's Day 2020,Valentim's Day 2020,Valentim2020, +958f904b-8260-48a4-a961-f786cbd39411,Valentine's Day 2023,Love you like my Tamagotchi,ValentinesDay23, +a676c708-da67-4784-ba7f-3fb7e8d2e865,Valentines Day 2021,"Roses are red, TS is blue, Servers are Sweet and so are you.",valentine21, +8c22fe26-30ac-4231-8b31-67d8a75c808a,Year of the Ox 2021,Only listen to the fortune cookie; disregard all other fortune telling units.,ox21, +970c70e6-00a1-41c1-ac5c-81c89a06c7a6,Year of the Rabbit 2023,Do a barrel roll!,chineseNY2023, +92356386-0451-4a97-87d9-10ff4f43260c,Year of the Tiger 2022,Rocky sends his regards,tiger, diff --git a/crates/proto/tsproto-structs/declarations/Book.toml b/crates/proto/tsproto-structs/declarations/Book.toml new file mode 100644 index 0000000..55ae61a --- /dev/null +++ b/crates/proto/tsproto-structs/declarations/Book.toml @@ -0,0 +1,327 @@ +[[struct]] +name = "ServerGroup" +id = [ + { struct="ServerGroup", prop="Id" }, +] +doc = "Get in notifyservergrouplist" +properties = [ + { name="Id", type="ServerGroupId" }, + { name="Name", type="str" }, + { name="GroupType", type="GroupType" }, + { name="Icon", type="IconId" }, + { name="IsPermanent", type="bool", doc="If the group is saved to the server database" }, + { name="SortId", type="i32" }, + { name="NamingMode", type="GroupNamingMode" }, + { name="NeededModifyPower", type="i32" }, + { name="NeededMemberAddPower", type="i32" }, + { name="NeededMemberRemovePower", type="i32", opt=true }, +] + +[[struct]] +name = "ChannelGroup" +id = [ + { struct="ChannelGroup", prop="Id" }, +] +doc = "Get in notifychannelgrouplist" +properties = [ + { name="Id", type="ChannelGroupId" }, + { name="Name", type="str" }, + { name="GroupType", type="GroupType" }, + { name="Icon", type="IconId" }, + { name="IsPermanent", type="bool", doc="If the group is saved to the server database" }, + { name="SortId", type="i32" }, + { name="NamingMode", type="GroupNamingMode" }, + { name="NeededModifyPower", type="i32" }, + { name="NeededMemberAddPower", type="i32" }, + { name="NeededMemberRemovePower", type="i32", opt=true }, +] + +[[struct]] +name = "OptionalChannelData" +opt = true +id = [ + { struct="Channel", prop="Id" }, +] +doc = "Get in notifychanneledited by channelgetdescription" +properties = [ + { name="Description", type="str" }, +] + +[[struct]] +name = "Channel" +id = [ + { struct="Channel", prop="Id" }, +] +doc = "Get in channellist" +properties = [ + { name="Id", type="ChannelId" }, + { name="Guid", type="str", opt=true }, + { name="Parent", type="ChannelId", doc="0 means root channel" }, + { name="Name", type="str" }, + { name="Topic", type="str", opt=true }, + { name="Codec", type="Codec" }, + { name="CodecQuality", type="u8", opt=true }, + { name="MaxClients", type="MaxClients", opt=true, doc="The maximum number of clients in the channel." }, + { name="MaxFamilyClients", type="MaxClients", opt=true, doc="Maximum number of clients in this and all child channels." }, + { name="Order", type="ChannelId", doc="The preceding channel id." }, + { name="ChannelType", type="ChannelType" }, + { name="IsDefault", type="bool", opt=true, doc="Whether it is the default channel" }, + { name="HasPassword", type="bool", opt=true, doc="Whether this channel has a password" }, + { name="CodecLatencyFactor", type="i32", opt=true, doc="TODO Type?" }, + { name="IsUnencrypted", type="bool", opt=true }, + { name="DeleteDelay", type="Duration", opt=true }, + { name="NeededTalkPower", type="i32", opt=true }, + { name="ForcedSilence", type="bool" }, + { name="PhoneticName", type="str", opt=true }, + { name="Icon", type="IconId", opt=true }, + { name="IsPrivate", type="bool", opt=true }, + { name="StorageQuota", type="u32", opt=true }, + { name="Subscribed", type="bool" }, + { name="PermissionHints", type="ChannelPermissionHint", opt=true }, + { name="OptionalData", type="OptionalChannelData", opt=true }, +] + +[[struct]] +name = "OptionalClientData" +opt = true +id = [ + { struct="Client", prop="Id" }, +] +doc = "Get in notifyclientupdated by clientgetvariables" +properties = [ + { name="Version", type="str" }, + { name="VersionSign", type="str", opt=true }, + { name="Platform", type="str" }, + { name="LoginName", type="str", opt=true, doc="Set only for server queries" }, + { name="Created", type="DateTime" }, + { name="LastConnected", type="DateTime" }, + { name="ConnectionsTotal", type="u32" }, + { name="BytesUploadedMonth", type="u64" }, + { name="BytesDownloadedMonth", type="u64" }, + { name="BytesUploadedTotal", type="u64" }, + { name="BytesDownloadedTotal", type="u64" }, +] + +[[struct]] +name = "ConnectionClientData" +opt = true +id = [ + { struct="Client", prop="Id" }, +] +doc = "Get in notifyconnectioninfo by getconnectioninfo" +properties = [ + { name="Ping", type="Duration", opt=true }, + { name="PingDeviation", type="Duration", opt=true }, + { name="ConnectedTime", type="Duration", opt=true }, + { name="ClientAddress", type="SocketAddr", opt=true, doc="Only available if we have the permission to view it" }, + { name="PacketsSentSpeech", type="u64", opt=true }, + { name="PacketsSentKeepalive", type="u64", opt=true }, + { name="PacketsSentControl", type="u64", opt=true }, + { name="BytesSentSpeech", type="u64", opt=true }, + { name="BytesSentKeepalive", type="u64", opt=true }, + { name="BytesSentControl", type="u64", opt=true }, + { name="PacketsReceivedSpeech", type="u64", opt=true }, + { name="PacketsReceivedKeepalive", type="u64", opt=true }, + { name="PacketsReceivedControl", type="u64", opt=true }, + { name="BytesReceivedSpeech", type="u64", opt=true }, + { name="BytesReceivedKeepalive", type="u64", opt=true }, + { name="BytesReceivedControl", type="u64", opt=true }, + { name="ServerToClientPacketlossSpeech", type="f32", opt=true }, + { name="ServerToClientPacketlossKeepalive", type="f32", opt=true }, + { name="ServerToClientPacketlossControl", type="f32", opt=true }, + { name="ServerToClientPacketlossTotal", type="f32", opt=true }, + { name="ClientToServerPacketlossSpeech", type="f32" }, + { name="ClientToServerPacketlossKeepalive", type="f32" }, + { name="ClientToServerPacketlossControl", type="f32" }, + { name="ClientToServerPacketlossTotal", type="f32" }, + { name="BandwidthSentLastSecondSpeech", type="u64", opt=true }, + { name="BandwidthSentLastSecondKeepalive", type="u64", opt=true }, + { name="BandwidthSentLastSecondControl", type="u64", opt=true }, + { name="BandwidthSentLastMinuteSpeech", type="u64", opt=true }, + { name="BandwidthSentLastMinuteKeepalive", type="u64", opt=true }, + { name="BandwidthSentLastMinuteControl", type="u64", opt=true }, + { name="BandwidthReceivedLastSecondSpeech", type="u64", opt=true }, + { name="BandwidthReceivedLastSecondKeepalive", type="u64", opt=true }, + { name="BandwidthReceivedLastSecondControl", type="u64", opt=true }, + { name="BandwidthReceivedLastMinuteSpeech", type="u64", opt=true }, + { name="BandwidthReceivedLastMinuteKeepalive", type="u64", opt=true }, + { name="BandwidthReceivedLastMinuteControl", type="u64", opt=true }, + { name="FiletransferBandwidthSent", type="u64", opt=true }, + { name="FiletransferBandwidthReceived", type="u64", opt=true }, + { name="IdleTime", type="Duration" }, +] + +[[struct]] +name = "Client" +id = [ + { struct="Client", prop="Id" }, +] +doc = "Get in notifycliententerview" +properties = [ + { name="Id", type="ClientId" }, + { name="Channel", type="ChannelId" }, + { name="Uid", type="Uid", opt=true, doc="Unique Identifier" }, + { name="Name", type="str" }, + { name="InputMuted", type="bool", doc="`true` if muted, `false` otherwise" }, + { name="OutputMuted", type="bool", doc="`true` if muted, `false` otherwise" }, + { name="OutputOnlyMuted", type="bool", doc="`true` if muted, `false` otherwise" }, + { name="InputHardwareEnabled", type="bool", doc="`true` if enabled, `false` if disabled" }, + { name="OutputHardwareEnabled", type="bool", doc="`true` if enabled, `false` if disabled" }, + { name="TalkPowerGranted", type="bool", doc="If the client is granted talk power" }, + { name="Metadata", type="str", doc="Set by client" }, + { name="IsRecording", type="bool", doc="Whether the client is recording" }, + { name="DatabaseId", type="ClientDbId" }, + { name="ChannelGroup", type="ChannelGroupId" }, + { name="ServerGroups", type="ServerGroupId", mod="set" }, + { name="AwayMessage", type="str", opt=true, doc="Contains the away message if the client is away" }, + { name="ClientType", type="ClientType", doc="If this client is a server query or not" }, + { name="AvatarHash", type="str", doc="MD5 hash of the avatar, used to retrieve the avatar" }, + { name="TalkPower", type="i32" }, + { name="TalkPowerRequest", type="TalkPowerRequest", opt=true, doc="Contains a message and timestamp from the client if he requests talk power" }, + { name="Description", type="str" }, + { name="IsPrioritySpeaker", type="bool" }, + { name="UnreadMessages", type="u32" }, + { name="PhoneticName", type="str" }, + { name="NeededServerqueryViewPower", type="i32" }, + { name="Icon", type="IconId" }, + { name="IsChannelCommander", type="bool" }, + { name="CountryCode", type="str", doc="Like US, DE" }, + { name="InheritedChannelGroupFromChannel", type="ChannelId" }, + { name="Badges", type="str" }, + { name="UserTag", type="str", opt=true }, + { name="PermissionHints", type="ClientPermissionHint", opt=true }, + { name="OptionalData", type="OptionalClientData", opt=true }, + { name="ConnectionData", type="ConnectionClientData", opt=true }, +] + +[[struct]] +name = "OptionalServerData" +opt = true +id = [ +] +doc = "Get by notifyserverupdated after requested by servergetvariables" +properties = [ + { name="Uptime", type="Duration" }, + { name="HasPassword", type="bool" }, + { name="DefaultChannelAdminGroup", type="ChannelGroupId", doc="The channel group which will be given to channel creators" }, + { name="MaxDownloadBandwidthTotal", type="u64" }, + { name="MaxUploadBandwidthTotal", type="u64" }, + { name="ComplainAutobanCount", type="u32" }, + { name="ComplainAutobanTime", type="Duration" }, + { name="ComplainRemoveTime", type="Duration" }, + { name="MinClientsInChannelBeforeForcedSilence", type="u32", doc="How many clients can be in a server before silence is forced" }, + { name="AntifloodPointsTickReduce", type="u32" }, + { name="AntifloodPointsToCommandBlock", type="u32" }, + { name="AntifloodPointsToIpBlock", type="u32" }, + { name="AntifloodPointsToPluginBlock", type="u32" }, + { name="ConnectionCountTotal", type="u64", doc="The amount of connections on this server.\n\nThis includes normal clients and server queries." }, + { name="ChannelCount", type="u64", doc="The amount of channels on the server" }, + { name="ClientCount", type="u16", doc="The amount of clients which are online on the server" }, + { name="QueryCountTotal", type="u64", doc="Amount of server queries connected to the server" }, + { name="QueryCount", type="u32", doc="Amount of server queries connected and online/visible on the server" }, + { name="DownloadQuota", type="u64" }, + { name="UploadQuota", type="u64" }, + { name="BytesDownloadedMonth", type="u64" }, + { name="BytesUploadedMonth", type="u64" }, + { name="BytesDownloadedTotal", type="u64" }, + { name="BytesUploadedTotal", type="u64" }, + { name="Port", type="u16" }, + { name="Autostart", type="bool" }, + { name="MachineId", type="str" }, + { name="NeededIdentitySecurityLevel", type="u8" }, + { name="LogClient", type="bool" }, + { name="LogQuery", type="bool" }, + { name="LogChannel", type="bool" }, + { name="LogPermissions", type="bool" }, + { name="LogServer", type="bool" }, + { name="LogFiletransfer", type="bool" }, + { name="MinClientVersion", type="DateTime" }, + { name="ReservedSlots", type="u16" }, + { name="TotalPacketlossSpeech", type="f32" }, + { name="TotalPacketlossKeepalive", type="f32" }, + { name="TotalPacketlossControl", type="f32" }, + { name="TotalPacketloss", type="f32" }, + { name="TotalPing", type="Duration" }, + { name="WeblistEnabled", type="bool" }, + { name="MinAndroidVersion", type="DateTime", doc="TODO Maybe str" }, + { name="MinIosVersion", type="DateTime" }, +] + +[[struct]] +name = "ConnectionServerData" +opt = true +id = [ +] +doc = "Get by notifyserverconnectioninfo after serverrequestconnectioninfo" +properties = [ + { name="FiletransferBandwidthSent", type="u64" }, + { name="FiletransferBandwidthReceived", type="u64" }, + { name="FiletransferBytesSentTotal", type="u64" }, + { name="FiletransferBytesReceivedTotal", type="u64" }, + { name="PacketsSentTotal", type="u64" }, + { name="BytesSentTotal", type="u64" }, + { name="PacketsReceivedTotal", type="u64" }, + { name="BytesReceivedTotal", type="u64" }, + { name="BandwidthSentLastSecondTotal", type="u64" }, + { name="BandwidthSentLastMinuteTotal", type="u64" }, + { name="BandwidthReceivedLastSecondTotal", type="u64" }, + { name="BandwidthReceivedLastMinuteTotal", type="u64" }, + { name="ConnectedTimeTotal", type="Duration" }, + { name="PacketlossTotal", type="f32" }, + { name="Ping", type="Duration" }, +] + +[[struct]] +name = "Server" +id = [ +] +doc = "Get in initserver" +properties = [ + { name="PublicKey", type="EccKeyPubP256" }, + { name="Id", type="u64", doc="The virtual server id" }, + # `Uid` is generated from public key + { name="Name", type="str" }, + { name="Nickname", type="str", opt=true }, + { name="WelcomeMessage", type="str", doc="Welcome message when connecting to a server" }, + { name="Platform", type="str" }, + { name="Version", type="str" }, + { name="MaxClients", type="u16", doc="The maximum number of clients on the server" }, + { name="Created", type="DateTime", doc="Seems to be always 0" }, + { name="CodecEncryptionMode", type="CodecEncryptionMode" }, + { name="Hostmessage", type="str" }, + { name="HostmessageMode", type="HostMessageMode" }, + { name="DefaultServerGroup", type="ServerGroupId" }, + { name="DefaultChannelGroup", type="ChannelGroupId" }, + { name="HostbannerUrl", type="str" }, + { name="HostbannerGfxUrl", type="str" }, + { name="HostbannerGfxInterval", type="Duration", doc="How often the hostbanner should be updated" }, + { name="PrioritySpeakerDimmModificator", type="f32" }, + { name="HostbuttonTooltip", type="str" }, + { name="HostbuttonUrl", type="str" }, + { name="HostbuttonGfxUrl", type="str" }, + { name="PhoneticName", type="str" }, + { name="Icon", type="IconId", doc="Should be an u32, sometimes the server sends an u64 or an i32 for reasons which has to be cut to 32 bit" }, + { name="Ips", type="IpAddr", mod="array", doc="A list of listen ips, can be empty" }, + { name="AskForPrivilegekey", type="bool" }, + { name="HostbannerMode", type="HostBannerMode" }, + { name="TempChannelDefaultDeleteDelay", type="Duration" }, + { name="ProtocolVersion", type="u16" }, + { name="License", type="LicenseType" }, + { name="AdministrativeDomain", type="str", opt=true }, + { name="OptionalData", type="OptionalServerData", opt=true }, + { name="ConnectionData", type="ConnectionServerData", opt=true }, +] + +[[struct]] +name = "Connection" +id = [ +] +doc = "A connection from our client to a server" +properties = [ + { name="OwnClient", type="ClientId", doc="The id of our own client on the server" }, + { name="Server", type="Server", doc="The server of this connection" }, + { name="Clients", type="Client", mod="map", key="ClientId", doc="All clients which are visible for us" }, + { name="Channels", type="Channel", mod="map", key="ChannelId", doc="All channels on the server" }, + { name="ServerGroups", type="ServerGroup", mod="map", key="ServerGroupId", doc="All server groups on the server" }, + { name="ChannelGroups", type="ChannelGroup", mod="map", key="ChannelGroupId", doc="All channel groups on the server" }, +] diff --git a/crates/proto/tsproto-structs/declarations/BookToMessages.toml b/crates/proto/tsproto-structs/declarations/BookToMessages.toml new file mode 100644 index 0000000..21daaff --- /dev/null +++ b/crates/proto/tsproto-structs/declarations/BookToMessages.toml @@ -0,0 +1,393 @@ +# As in M2B from/to properties can be automatically mapped when they have +# the same high-level name. + +[[rule]] +# From the Book +from = "Channel" +# Into message +to = "ChannelEdit" +operation = "update" +# The static message parameters +# Can be often empty +# Can be inferred from required message parameters +ids = [ + { from="Id", to="ChannelId" }, +] +# The dynamic message parameters +# from is the property which gets updated, to is the field in the message +properties = [ + # Function which reads a value form the book and splits it up + # into multiple message parameters + # fn bla(Channel, MaxClientChannelInherited) -> (type of asd) + #{ from="MaxClientChannelInherited", function="Bla", tolist=["asd"] }, + + { from="password", type="str?", function="PasswordFlaggedB2m", tolist=["HasPassword", "Password"] }, # 'password' is a helper + { from="ChannelType", type="ChannelType", function="ChannelTypeFunB2m", tolist=["IsSemiPermanent", "IsPermanent"] }, + { from="MaxClients", type="MaxClients", function="MaxClientsFunB2m", tolist=["MaxClients", "IsMaxClientsUnlimited"] }, + { from="MaxFamilyClients", type="MaxClients", function="MaxFamilyClientsFunB2m", tolist=["MaxFamilyClients", "IsMaxFamilyClientsUnlimited", "InheritsMaxFamilyClients"] }, + { from="Description", to="Description" }, # From optional data +] + +[[rule]] +from = "Channel" +to = "ChannelAddPerm" +operation = "update" +ids = [ + { from="Id", to="ChannelId" }, + { from="Value", to="PermissionValue" }, +] +properties = [ + { from="PermissionId", to ="PermissionId" }, + { from="PermissionName", to ="PermissionNameId" }, +] + +# Define Client-Channel-Permissions on the channel, because a channel always exists and we need to +# be able to change permissions, even if a client is not online. +[[rule]] +from = "Channel" +to = "ChannelClientAddPerm" +operation = "update" +ids = [ + { from="Id", to="ChannelId" }, + { from="ClientDbId", to="ClientDbId" }, + { from="Value", to="PermissionValue" }, +] +properties = [ + { from="PermissionId", to ="PermissionId" }, + { from="PermissionName", to ="PermissionNameId" }, +] + +[[rule]] +from = "Channel" +to = "ChannelClientDelPerm" +operation = "update" +ids = [ + { from="Id", to="ChannelId" }, + { from="ClientDbId", to="ClientDbId" }, +] +properties = [ + { from="PermissionId", to ="PermissionId" }, + { from="PermissionName", to ="PermissionNameId" }, +] + +[[rule]] +from = "Channel" +to = "ChannelClientPermListRequest" +operation = "update" +ids = [ + { from="Id", to="ChannelId" }, + { from="ClientDbId", to="ClientDbId" }, +] + +[[rule]] +from = "Channel" +to = "ChannelDelPerm" +operation = "update" +ids = [ + { from="Id", to="ChannelId" }, +] +properties = [ + { from="PermissionId", to ="PermissionId" }, + { from="PermissionName", to ="PermissionNameId" }, +] + +[[rule]] +from = "Channel" +to = "ChannelDescriptionRequest" +operation = "update" +ids = [ + { from="Id", to="ChannelId" }, +] + +[[rule]] +from = "Channel" +to = "ChannelMove" +operation = "update" +ids = [ + { from="Id", to="ChannelId" }, + { from="Parent", type="ChannelId", function="ChannelIdB2m", tolist=["ParentId"] }, + { from="Order", type="ChannelId", function="ChannelIdB2m", tolist=["Order"] }, +] + +[[rule]] +from = "Channel" +to = "ChannelPermListRequest" +operation = "update" +ids = [ + { from="Id", to="ChannelId" }, +] + +# Filetransfer stuff for Channel + +[[rule]] +from = "Channel" +to = "CreateDirectory" +operation = "update" +ids = [ + { from="Id", to="ChannelId" }, + { from="Password", type="str", function="PasswordB2m", tolist=["ChannelPassword"] }, + { from="Path", to="DirectoryName" }, +] + +[[rule]] +from = "Channel" +to = "DeleteFile" +operation = "update" +ids = [ + { from="Id", to="ChannelId" }, + { from="Password", type="str", function="PasswordB2m", tolist=["ChannelPassword"] }, + { from="Path", to="Name" }, +] + +[[rule]] +from = "Channel" +to = "FileListRequest" +operation = "update" +ids = [ + { from="Id", to="ChannelId" }, + { from="Password", type="str", function="PasswordB2m", tolist=["ChannelPassword"] }, + { from="Path", to="Path" }, +] + +[[rule]] +from = "Channel" +to = "RenameFile" +operation = "update" +ids = [ + { from="Id", to="ChannelId" }, + { from="Password", type="str", function="PasswordB2m", tolist=["ChannelPassword"] }, + { from="FromPath", to="OldName" }, + { from="ToPath", to="NewName" }, +] +properties = [ + { from="ToChannel", to="TargetChannelId" }, + { from="ToChannelPassword", type="str", function="PasswordB2m2", tolist=["TargetChannelPassword"] }, +] + + +[[rule]] +from = "Client" +to = "ClientAddPerm" +operation = "update" +ids = [ + { from="DatabaseId", to="ClientDbId" }, + { from="Value", to="PermissionValue" }, + { from="Skip", to="PermissionSkip" }, +] +properties = [ + { from="PermissionId", to ="PermissionId" }, + { from="PermissionName", to ="PermissionNameId" }, +] + +[[rule]] +from = "Client" +to = "ClientConnectionInfoRequest" +operation = "update" +ids = [ + { from="Id", to="ClientId" }, +] + +[[rule]] +from = "Client" +to = "ClientDelPerm" +operation = "update" +ids = [ + { from="DatabaseId", to="ClientDbId" }, +] +properties = [ + { from="PermissionId", to ="PermissionId" }, + { from="PermissionName", to ="PermissionNameId" }, +] + +[[rule]] +from = "Client" +to = "ClientPermListRequest" +operation = "update" +ids = [ + { from="DatabaseId", to="ClientDbId" }, +] + +[[rule]] +from = "Client" +to = "ClientVariablesRequest" +operation = "update" +ids = [ + { from="Id", to="ClientId" }, +] + +[[rule]] +from = "Client" +to = "ClientEdit" +operation = "update" +ids = [ + { from="Id", to="ClientId" }, +] + +[[rule]] +from = "Connection" +to = "ClientUpdate" +operation = "update" +properties = [ + # The original properties are on the client object, but we can only change + # our own properties, so these methods are available on the connection. + { from="Name", to="Name" }, + { from="PhoneticName", to="PhoneticName" }, + { from="InputMuted", to="InputMuted" }, + { from="OutputMuted", to="OutputMuted" }, + { from="InputHardwareEnabled", to="InputHardwareEnabled" }, + { from="OutputHardwareEnabled", to="OutputHardwareEnabled" }, + { from="IsChannelCommander", to="IsChannelCommander" }, + { from="IsRecording", to="IsRecording" }, + { from="AvatarHash", to="AvatarHash" }, + { from="Away", type="str?", function="AwayFunB2m", tolist=["IsAway", "AwayMessage"] }, + { from="TalkPowerRequest", type="str?", function="AwayFunB2m", tolist=["TalkPowerRequest", "TalkPowerRequestMessage"] }, +] + +[[rule]] +from = "Connection" +to = "Disconnect" +operation = "remove" + +[[rule]] +from = "Connection" +to = "PluginCommandRequest" +operation = "update" +ids = [ + { from="Name", to="Name" }, + { from="Data", to="Data" }, + { from="Target", to="Target" }, + # TODO optional + { from="TargetClientId", to="TargetClientId" }, +] + +[[rule]] +from = "Client" +to = "ServerGroupAddClient" +operation = "add" +ids = [ + { from="DatabaseId", to="ClientDbId" }, +] +properties = [ + { from="ServerGroup", to="ServerGroupId" }, +] + +[[rule]] +from = "Client" +to = "ServerGroupDelClient" +operation = "remove" +ids = [ + { from="DatabaseId", to="ClientDbId" }, +] +properties = [ + { from="ServerGroup", to="ServerGroupId" }, +] + +[[rule]] +from = "Client" +to = "ClientMove" +operation = "update" +ids = [ + { from="Id", to="ClientId" }, + { from="Channel", type="ChannelId", function="ChannelIdB2m", tolist=["ChannelId"] }, +] +properties = [ + { from="Password", type="str", function="PasswordB2m", tolist=["ChannelPassword"] }, +] + +[[rule]] +from = "Client" +to = "ClientKick" +operation = "update" +ids = [ + { from="Id", to="ClientId" }, + { from="Reason", to="Reason" }, +] +properties = [ + { from="ReasonMessage", to="ReasonMessage" }, +] + +[[rule]] +from = "Server" +to = "FileListRequest" +operation = "update" +ids = [ + { function="ZeroChannelId", tolist=["ChannelId"] }, + { function="EmptyString", tolist=["ChannelPassword"] }, + { from="Path", to="Path" }, +] + +[[rule]] +from = "Server" +to = "DeleteFile" +operation = "update" +ids = [ + { function="ZeroChannelId", tolist=["ChannelId"] }, + { function="EmptyString", tolist=["ChannelPassword"] }, + { from="Path", to="Name" }, +] + +[[rule]] +from = "Server" +to = "PermListRequest" +operation = "update" +ids = [ +] + +[[rule]] +from = "Server" +to = "ServerVariablesRequest" +operation = "update" +ids = [ +] + +[[rule]] +from = "Server" +to = "ServerConnectionInfoRequest" +operation = "update" +ids = [ +] + +[[rule]] +from = "Server" +to = "LogView" +operation = "update" +ids = [ +] +properties = [ + { from="Lines", to="Lines" }, + { from="Reverse", to="Reverse" }, + { from="InstanceLog", to="InstanceLog" }, + { from="Offset", to="Offset" }, +] + +[[rule]] +from = "Server" +to = "ServerEdit" +operation = "update" +ids = [ +] +properties = [ + { from="Password", type="str?", function="PasswordB2m", tolist=["Password"] }, +] + +[[rule]] +from = "ServerGroup" +to = "ServerGroupAddClient" +operation = "add" +ids = [ + { from="Id", to="ServerGroupId" }, +] +properties = [ + { from="Client", to="ClientDbId" }, +] + +[[rule]] +from = "ServerGroup" +to = "ServerGroupDelClient" +operation = "remove" +ids = [ + { from="Id", to="ServerGroupId" }, + # Not an id attribute of the server group, but we want to have it as an + # argument. + { from="Client", to="ClientDbId" }, +] diff --git a/crates/proto/tsproto-structs/declarations/Enums.toml b/crates/proto/tsproto-structs/declarations/Enums.toml new file mode 100644 index 0000000..161dd3f --- /dev/null +++ b/crates/proto/tsproto-structs/declarations/Enums.toml @@ -0,0 +1,172 @@ +[[enum]] +name = "PermissionType" +#type = "u32" +#doc = "" +variants = [ + { name="ServerGroup", doc="Server group permission. (id1: ServerGroupId, id2: 0)" }, + { name="GlobalClient", doc="Client specific permission. (id1: ClientDbId, id2: 0)" }, + { name="Channel", doc="Channel specific permission. (id1: ChannelId, id2: 0)" }, + { name="ChannelGroup", doc="Channel group permission. (id1: ChannelId, id2: ChannelGroupId)" }, + { name="ChannelClient", doc="Channel-client specific permission. (id1: ChannelId, id2: ClientDbId)" }, +] + +[[enum]] +name = "TextMessageTargetMode" +variants = [ + { name="Unknown", doc="Maybe to all servers?" }, + { name="Client", doc="Send to specific client" }, + { name="Channel", doc="Send to current channel" }, + { name="Server", doc="Send to server chat" }, +] + +[[enum]] +name = "HostMessageMode" +variants = [ + { name="None", doc="Dont display anything" }, + { name="Log", doc="Display message inside log" }, + { name="Modal", doc="Display message inside a modal dialog" }, + { name="Modalquit", doc="Display message inside a modal dialog and quit/close server/connection" }, +] + +[[enum]] +name = "HostBannerMode" +variants = [ + { name="NoAdjust", doc="Do not adjust" }, + { name="AdjustIgnoreAspect", doc="Adjust and ignore aspect ratio" }, + { name="AdjustKeepAspect", doc="Adjust and keep aspect ratio" }, +] + +[[enum]] +name = "Codec" +variants = [ + { name="SpeexNarrowband", doc="Mono, 16bit, 8kHz, bitrate dependent on the quality setting" }, + { name="SpeexWideband", doc="Mono, 16bit, 16kHz, bitrate dependent on the quality setting" }, + { name="SpeexUltrawideband", doc="Mono, 16bit, 32kHz, bitrate dependent on the quality setting" }, + { name="CeltMono", doc="Mono, 16bit, 48kHz, bitrate dependent on the quality setting" }, + { name="OpusVoice", doc="Mono, 16bit, 48kHz, bitrate dependent on the quality setting, optimized for voice" }, + { name="OpusMusic", doc="Stereo, 16bit, 48kHz, bitrate dependent on the quality setting, optimized for music" }, +] + +[[enum]] +name = "CodecEncryptionMode" +variants = [ + { name="PerChannel", doc="Voice encryption is configured per channel" }, + { name="ForcedOff", doc="Voice encryption is globally off" }, + { name="ForcedOn", doc="Voice encryption is globally on" }, +] + +[[enum]] +name = "Reason" +variants = [ + { name="None", doc="No reason data" }, + { name="Moved", doc="Has invoker" }, + { name="Subscription", doc="No reason data" }, + { name="LostConnection", doc="Timeout" }, + { name="KickChannel", doc="Has invoker" }, + { name="KickServer", doc="Has invoker" }, + { name="KickServerBan", doc="Has invoker, bantime" }, + { name="Serverstop", doc="" }, + { name="Clientdisconnect", doc="" }, + { name="Channelupdate", doc="No reason data" }, + { name="Channeledit", doc="Has invoker" }, + { name="ClientdisconnectServerShutdown", doc="" }, +] + +[[enum]] +name = "GroupNamingMode" +variants = [ + { name="None", doc="No group name is displayed." }, + { name="Before", doc="Group name is displayed before the client name." }, + { name="After", doc="Group name is displayed after the client name." }, +] + +[[enum]] +name = "GroupType" +variants = [ + { name="Template", doc="Template group (used for new virtual servers)." }, + { name="Regular", doc="Regular group (used for regular clients)." }, + { name="Query", doc="Global query group (used for server query clients)." }, +] + +[[enum]] +name = "LicenseType" +variants = [ + { name="NoLicense", doc="No licence" }, + { name="Offline", doc="Offline/LAN license" }, + { name="Sdk", doc="TeamSpeak SDK license" }, + { name="SdkOffline", doc="TeamSpeak SDK offline license" }, + { name="Npl", doc="Non-Profit License (NPL)" }, + { name="Athp", doc="Authorised TeamSpeak Host Provider License (ATHP)" }, + { name="Aal", doc="Annual activation license (AAL)" }, + { name="Default", doc="Default license with 32 slots" }, + { name="Gamer", doc="Gamer license" }, + { name="Sponsorship", doc="Licenses sponsored by TeamSpeak" }, + { name="Commercial", doc="For use inside corporates" }, +] + +[[enum]] +name = "ChannelType" +variants = [ + { name="Permanent", doc="Normal channel" }, + { name="SemiPermanent", doc="Deleted when the server restarts" }, + { name="Temporary", doc="Deleted when empty" }, +] + +[[enum]] +name = "TokenType" +variants = [ + { name="ServerGroup", doc="Server group token (`id1={groupId}, id2=0`)" }, + { name="ChannelGroup", doc="Channel group token (`id1={groupId}, id2={channelId}`)" }, +] + +[[enum]] +name = "PluginTargetMode" +variants = [ + { name="CurrentChannel", doc="Send to all clients in the current channel." }, + { name="Server", doc="Send to all clients on the server." }, + { name="Client", doc="Send to all given clients ids." }, + { name="CurrentChannelSubsribedClients", doc="Send to all given clients which are subscribed to the current channel (i.e. which see the this client)." }, +] + +[[enum]] +name = "LogLevel" +variants = [ + { name="Error", doc="Everything that is really bad.", value=1 }, + { name="Warning", doc="Everything that might be bad." }, + { name="Debug", doc="Output that might help find a problem." }, + { name="Info", doc="Informational output." }, +] + +[[bitflag]] +name = "ChannelPermissionHint" +doc = "Hints if the client has the permission to make specific actions." +variants = [ + { name="Join", doc="b_channel_join_*", value=1 }, + { name="Modify", doc="i_channel_modify_power", value=2 }, + { name="ForceDelete", doc="b_channel_delete_flag_force", value=4 }, + { name="Delete", doc="b_channel_delete_*", value=8 }, + { name="Subscribe", doc="i_channel_subscribe_power", value=16 }, + { name="ViewDescription", doc="i_channel_description_view_power", value=32 }, + { name="FileUpload", doc="i_ft_file_upload_power", value=64 }, + { name="FileDownload", doc="i_ft_needed_file_download_power", value=128 }, + { name="FileDelete", doc="i_ft_file_delete_power", value=256 }, + { name="FileRename", doc="i_ft_file_rename_power", value=512 }, + { name="FileBrowse", doc="i_ft_file_browse_power", value=1024 }, + { name="FileDirectoryCreate", doc="i_ft_directory_create_power", value=2048 }, + { name="ModifyPermissions", doc="i_channel_permission_modify_power", value=4096 }, +] + +[[bitflag]] +name = "ClientPermissionHint" +doc = "Hints if the client has the permission to make specific actions." +variants = [ + { name="KickServer", doc="i_client_kick_from_server_power", value=1 }, + { name="KickChannel", doc="i_client_kick_from_channel_power", value=2 }, + { name="Ban", doc="i_client_ban_power", value=4 }, + { name="MoveClient", doc="i_client_move_power", value=8 }, + { name="PrivateMessage", doc="i_client_private_textmessage_power", value=16 }, + { name="Poke", doc="i_client_poke_power", value=32 }, + { name="Whisper", doc="i_client_whisper_power", value=64 }, + { name="Complain", doc="i_client_complain_power", value=128 }, + { name="ModifyPermissions", doc="i_client_permission_modify_power", value=256 }, +] diff --git a/crates/proto/tsproto-structs/declarations/Errors.csv b/crates/proto/tsproto-structs/declarations/Errors.csv new file mode 100644 index 0000000..c974ed2 --- /dev/null +++ b/crates/proto/tsproto-structs/declarations/Errors.csv @@ -0,0 +1,197 @@ +name,doc,num +ok,unknown error code,0x0000 +undefined,undefined error,0x0001 +not_implemented,not implemented,0x0002 +ok_no_update,,0x0003 +dont_notify,,0x0004 +lib_time_limit_reached,library time limit reached,0x0005 +command_not_found,command not found,0x0100 +unable_to_bind_network_port,unable to bind network port,0x0101 +no_network_port_available,no network port available,0x0102 +client_invalid_id,invalid clientID,0x0200 +client_nickname_inuse,nickname is already in use,0x0201 +client_invalid_error_code,invalid error code,0x0202 +client_protocol_limit_reached,max clients protocol limit reached,0x0203 +client_invalid_type,invalid client type,0x0204 +client_already_subscribed,already subscribed,0x0205 +client_not_logged_in,not logged in,0x0206 +client_could_not_validate_identity,could not validate client identity,0x0207 +client_invalid_password,invalid loginname or password,0x0208 +client_too_many_clones_connected,too many clones already connected,0x0209 +client_version_outdated,"client version outdated, please update",0x020a +client_is_online,client is online,0x020b +client_is_flooding,client is flooding,0x020c +client_hacked,client is modified,0x020d +client_cannot_verify_now,can not verify client at this moment,0x020e +client_login_not_permitted,client is not permitted to log in,0x020f +client_not_subscribed,client is not subscribed to the channel,0x0210 +channel_invalid_id,invalid channelID,0x0300 +channel_protocol_limit_reached,max channels protocol limit reached,0x0301 +channel_already_in,already member of channel,0x0302 +channel_name_inuse,channel name is already in use,0x0303 +channel_not_empty,channel not empty,0x0304 +channel_can_not_delete_default,can not delete default channel,0x0305 +channel_default_require_permanent,default channel requires permanent,0x0306 +channel_invalid_flags,invalid channel flags,0x0307 +channel_parent_not_permanent,permanent channel can not be child of non permanent channel,0x0308 +channel_maxclients_reached,channel maxclient reached,0x0309 +channel_maxfamily_reached,channel maxfamily reached,0x030a +channel_invalid_order,invalid channel order,0x030b +channel_no_filetransfer_supported,channel does not support filetransfers,0x030c +channel_invalid_password,invalid channel password,0x030d +channel_is_private_channel,channel is private channel,0x030e +channel_invalid_security_hash,invalid security hash supplied by client,0x030f +server_invalid_id,invalid serverID,0x0400 +server_running,server is running,0x0401 +server_is_shutting_down,server is shutting down,0x0402 +server_maxclients_reached,server maxclient reached,0x0403 +server_invalid_password,invalid server password,0x0404 +server_deployment_active,deployment active,0x0405 +server_unable_to_stop_own_server,unable to stop own server in your connection class,0x0406 +server_is_virtual,server is virtual,0x0407 +server_wrong_machineid,server wrong machineID,0x0408 +server_is_not_running,server is not running,0x0409 +server_is_booting,server is booting up,0x040a +server_status_invalid,server got an invalid status for this operation,0x040b +server_modal_quit,server modal quit,0x040c +server_version_outdated,server version is too old for command,0x040d +database,database error,0x0500 +database_empty_result,database empty result set,0x0501 +database_duplicate_entry,database duplicate entry,0x0502 +database_no_modifications,database no modifications,0x0503 +database_constraint,database invalid constraint,0x0504 +database_reinvoke,database reinvoke command,0x0505 +parameter_quote,invalid quote,0x0600 +parameter_invalid_count,invalid parameter count,0x0601 +parameter_invalid,invalid parameter,0x0602 +parameter_not_found,parameter not found,0x0603 +parameter_convert,convert error,0x0604 +parameter_invalid_size,invalid parameter size,0x0605 +parameter_missing,missing required parameter,0x0606 +parameter_checksum,invalid checksum,0x0607 +vs_critical,virtual server got a critical error,0x0700 +connection_lost,Connection lost,0x0701 +not_connected,not connected,0x0702 +no_cached_connection_info,no cached connection info,0x0703 +currently_not_possible,currently not possible,0x0704 +failed_connection_initialisation,failed connection initialization,0x0705 +could_not_resolve_hostname,could not resolve hostname,0x0706 +invalid_server_connection_handler_id,invalid server connection handler ID,0x0707 +could_not_initialise_input_manager,could not initialize Input Manager,0x0708 +clientlibrary_not_initialised,client library not initialized,0x0709 +serverlibrary_not_initialised,server library not initialized,0x070a +whisper_too_many_targets,too many whisper targets,0x070b +whisper_no_targets,no whisper targets found,0x070c +file_invalid_name,invalid file name,0x0800 +file_invalid_permissions,invalid file permissions,0x0801 +file_already_exists,file already exists,0x0802 +file_not_found,file not found,0x0803 +file_io_error,file input/output error,0x0804 +file_invalid_transfer_id,invalid file transfer ID,0x0805 +file_invalid_path,invalid file path,0x0806 +file_no_files_available,no files available,0x0807 +file_overwrite_excludes_resume,overwrite excludes resume,0x0808 +file_invalid_size,invalid file size,0x0809 +file_already_in_use,file already in use,0x080a +file_could_not_open_connection,could not open file transfer connection,0x080b +file_no_space_left_on_device,no space left on device (disk full?),0x080c +file_exceeds_file_system_maximum_size,file exceeds file system's maximum file size,0x080d +file_transfer_connection_timeout,file transfer connection timeout,0x080e +file_connection_lost,lost file transfer connection,0x080f +file_exceeds_supplied_size,file exceeds supplied file size,0x0810 +file_transfer_complete,file transfer complete,0x0811 +file_transfer_canceled,file transfer canceled,0x0812 +file_transfer_interrupted,file transfer interrupted,0x0813 +file_transfer_server_quota_exceeded,file transfer server quota exceeded,0x0814 +file_transfer_client_quota_exceeded,file transfer client quota exceeded,0x0815 +file_transfer_reset,file transfer reset,0x0816 +file_transfer_limit_reached,file transfer limit reached,0x0817 +sound_preprocessor_disabled,preprocessor disabled,0x0900 +sound_internal_preprocessor,internal preprocessor,0x0901 +sound_internal_encoder,internal encoder,0x0902 +sound_internal_playback,internal playback,0x0903 +sound_no_capture_device_available,no capture device available,0x0904 +sound_no_playback_device_available,no playback device available,0x0905 +sound_could_not_open_capture_device,could not open capture device,0x0906 +sound_could_not_open_playback_device,could not open playback device,0x0907 +sound_handler_has_device,ServerConnectionHandler has a device registered,0x0908 +sound_invalid_capture_device,invalid capture device,0x0909 +sound_invalid_playback_device,invalid clayback device,0x090a +sound_invalid_wave,invalid wave file,0x090b +sound_unsupported_wave,wave file type not supported,0x090c +sound_open_wave,could not open wave file,0x090d +sound_internal_capture,internal capture,0x090e +sound_device_in_use,device still in use,0x090f +sound_device_already_registerred,device already registerred,0x0910 +sound_unknown_device,device not registered/known,0x0911 +sound_unsupported_frequency,unsupported frequency,0x0912 +sound_invalid_channel_count,invalid channel count,0x0913 +sound_read_wave,read error in wave,0x0914 +sound_need_more_data,sound need more data,0x0915 +sound_device_busy,sound device was busy,0x0916 +sound_no_data,there is no sound data for this period,0x0917 +sound_channel_mask_mismatch,Channelmask set bits count (speakers) is not the same as (count),0x0918 +permission_invalid_group_id,invalid group ID,0x0a00 +permission_duplicate_entry,duplicate entry,0x0a01 +permission_invalid_perm_id,invalid permission ID,0x0a02 +permission_empty_result,empty result set,0x0a03 +permission_default_group_forbidden,access to default group is forbidden,0x0a04 +permission_invalid_size,invalid size,0x0a05 +permission_invalid_value,invalid value,0x0a06 +permissions_group_not_empty,group is not empty,0x0a07 +permissions_client_insufficient,insufficient client permissions,0x0a08 +permissions_insufficient_group_power,insufficient group modify power,0x0a09 +permissions_insufficient_permission_power,insufficient permission modify power,0x0a0a +permission_template_group_is_used,template group is currently used,0x0a0b +permissions,permission error,0x0a0c +accounting_virtualserver_limit_reached,virtualserver limit reached,0x0b00 +accounting_slot_limit_reached,max slot limit reached,0x0b01 +accounting_license_file_not_found,license file not found,0x0b02 +accounting_license_date_not_ok,license date not ok,0x0b03 +accounting_unable_to_connect_to_server,unable to connect to accounting server,0x0b04 +accounting_unknown_error,unknown accounting error,0x0b05 +accounting_server_error,accounting server error,0x0b06 +accounting_instance_limit_reached,instance limit reached,0x0b07 +accounting_instance_check_error,instance check error,0x0b08 +accounting_license_file_invalid,license file invalid,0x0b09 +accounting_running_elsewhere,virtualserver is running elsewhere,0x0b0a +accounting_instance_duplicated,virtualserver running in same instance already,0x0b0b +accounting_already_started,virtualserver already started,0x0b0c +accounting_not_started,virtualserver not started,0x0b0d +accounting_to_many_starts,,0x0b0e +message_invalid_id,invalid message id,0x0c00 +ban_invalid_id,invalid ban id,0x0d00 +connect_failed_banned,"connection failed, you are banned",0x0d01 +rename_failed_banned,"rename failed, new name is banned",0x0d02 +ban_flooding,flood ban,0x0d03 +tts_unable_to_initialize,unable to initialize tts,0x0e00 +privilege_key_invalid,invalid privilege key,0x0f00 +voip_pjsua,,0x1000 +voip_already_initialized,,0x1001 +voip_too_many_accounts,,0x1002 +voip_invalid_account,,0x1003 +voip_internal_error,,0x1004 +voip_invalid_connectionId,,0x1005 +voip_cannot_answer_initiated_call,,0x1006 +voip_not_initialized,,0x1007 +provisioning_invalid_password,invalid password,0x1100 +provisioning_invalid_request,invalid request,0x1101 +provisioning_no_slots_available,no(more) slots available,0x1102 +provisioning_pool_missing,pool missing,0x1103 +provisioning_pool_unknown,pool unknown,0x1104 +provisioning_unknown_ip_location,unknown ip location(perhaps LAN ip?),0x1105 +provisioning_internal_tries_exceeded,internal error(tried exceeded),0x1106 +provisioning_too_many_slots_requested,too many slots requested,0x1107 +provisioning_too_many_reserved,too many reserved,0x1108 +provisioning_could_not_connect,could not connect to provisioning server,0x1109 +provisioning_auth_server_not_connected,authentication server not connected,0x1110 +provisioning_auth_data_too_large,authentication data too large,0x1111 +provisioning_already_initialized,already initialized,0x1112 +provisioning_not_initialized,not initialized,0x1113 +provisioning_connecting,already connecting,0x1114 +provisioning_already_connected,already connected,0x1115 +provisioning_not_connected,,0x1116 +provisioning_io_error,io_error,0x1117 +provisioning_invalid_timeout,,0x1118 +provisioning_ts3server_not_found,,0x1119 +provisioning_no_permission,unknown permissionID,0x111A diff --git a/crates/proto/tsproto-structs/declarations/LICENSE-APACHE b/crates/proto/tsproto-structs/declarations/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/crates/proto/tsproto-structs/declarations/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/crates/proto/tsproto-structs/declarations/LICENSE-MIT b/crates/proto/tsproto-structs/declarations/LICENSE-MIT new file mode 100644 index 0000000..00a6ce1 --- /dev/null +++ b/crates/proto/tsproto-structs/declarations/LICENSE-MIT @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Sebastian Neubauer + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/crates/proto/tsproto-structs/declarations/Messages.toml b/crates/proto/tsproto-structs/declarations/Messages.toml new file mode 100644 index 0000000..6ac049b --- /dev/null +++ b/crates/proto/tsproto-structs/declarations/Messages.toml @@ -0,0 +1,1028 @@ +# The fields array specifies command parameter. +# - "map": is a unique name for a field. This is required since teamspeak +# | sometimes reuses field names with different data or datatypes. +# | We usually use the same as "ts" unless disambiguation is needed. +# - "ts": is then field name in the command as teamspeak uses it. +# - "pretty": is a high-level name for the field which should be better readable +# | and make more sense in the object context it is used. +# - "type": Describes a primitive type or enum which can be used for this field. +# | We use the primitive type namings of the language 'Rust'. +# - "mod": Applies an additional modifier to this field. Current modifiers: +# | "array": The field is a comma-separated list and can be read as an array. + +fields = [ + { map="aclid", ts="aclid", pretty="ClientId", type="ClientId" }, + { map="acn", ts="acn", pretty="AcceptedClientName", type="str" }, + { map="alpha", ts="alpha", pretty="Alpha", type="str" }, + { map="average_speed", ts="average_speed", pretty="AverageSpeed", type="f32" }, + { map="banid", ts="banid", pretty="BanId", type="u32" }, # integer, size guessed + { map="bantime", ts="bantime", pretty="BanTime", type="DurationSeconds" }, + { map="banreason", ts="banreason", pretty="BanReason", type="str" }, + { map="begin_pos", ts="begin_pos", pretty="Offset", type="u64" }, # integer, size guessed + { map="beta", ts="beta", pretty="Beta", type="str" }, + { map="cfid", ts="cfid", pretty="SourceChannelId", type="ChannelId" }, + { map="cgi", ts="cgi", pretty="ChannelGroupIndex", type="ChannelGroupId" }, + { map="cgid", ts="cgid", pretty="ChannelGroup", type="ChannelGroupId" }, # TODO: Consider name 'ChannelGroup' for consistency + { map="channel_banner_gfx_url", ts="channel_banner_gfx_url", pretty="BannerGfxUrl", type="str" }, + { map="channel_banner_mode", ts="channel_banner_mode", pretty="BannerMode", type="str" }, # ?? Same as HostBannerMode maybe? There's no ui for this setting + { map="channel_codec", ts="channel_codec", pretty="Codec", type="Codec" }, + { map="channel_codec_is_unencrypted", ts="channel_codec_is_unencrypted", pretty="IsUnencrypted", type="bool" }, + { map="channel_codec_latency_factor", ts="channel_codec_latency_factor", pretty="CodecLatencyFactor", type="i32" }, + { map="channel_codec_quality", ts="channel_codec_quality", pretty="CodecQuality", type="u8" }, + { map="channel_delete_delay", ts="channel_delete_delay", pretty="DeleteDelay", type="DurationSeconds" }, + { map="channel_description", ts="channel_description", pretty="Description", type="str" }, + { map="channel_filepath", ts="channel_filepath", pretty="FilePath", type="str" }, + { map="channel_flag_default", ts="channel_flag_default", pretty="IsDefault", type="bool" }, + { map="channel_flag_maxclients_unlimited", ts="channel_flag_maxclients_unlimited", pretty="IsMaxClientsUnlimited", type="bool" }, + { map="channel_flag_maxfamilyclients_inherited", ts="channel_flag_maxfamilyclients_inherited", pretty="InheritsMaxFamilyClients", type="bool" }, + { map="channel_flag_maxfamilyclients_unlimited", ts="channel_flag_maxfamilyclients_unlimited", pretty="IsMaxFamilyClientsUnlimited", type="bool" }, + { map="channel_flag_password", ts="channel_flag_password", pretty="HasPassword", type="bool" }, + { map="channel_flag_permanent", ts="channel_flag_permanent", pretty="IsPermanent", type="bool" }, + { map="channel_flag_private", ts="channel_flag_private", pretty="IsPrivate", type="bool" }, + { map="channel_flag_semi_permanent", ts="channel_flag_semi_permanent", pretty="IsSemiPermanent", type="bool" }, + { map="channel_forced_silence", ts="channel_forced_silence", pretty="ForcedSilence", type="bool" }, + { map="channel_icon_id", ts="channel_icon_id", pretty="Icon", type="IconId" }, + { map="channel_maxclients", ts="channel_maxclients", pretty="MaxClients", type="i32" }, # should be u16, but teamspeak sometimes sends '-1' + { map="channel_maxfamilyclients", ts="channel_maxfamilyclients", pretty="MaxFamilyClients", type="i32" }, # should be u16, but teamspeak sometimes sends '-1' + { map="channel_name", ts="channel_name", pretty="Name", type="str" }, + { map="channel_name_phonetic", ts="channel_name_phonetic", pretty="PhoneticName", type="str" }, + { map="channel_needed_subscribe_power", ts="channel_needed_subscribe_power", pretty="NeededSubscribePower", type="i32" }, + { map="channel_needed_talk_power", ts="channel_needed_talk_power", pretty="NeededTalkPower", type="i32" }, + { map="channel_order", ts="channel_order", pretty="Order", type="ChannelId" }, + { map="channel_password", ts="channel_password", pretty="Password", type="str" }, + { map="channel_security_salt", ts="channel_security_salt", pretty="PasswordSalt", type="str" }, + { map="channel_storage_quota", ts="channel_storage_quota", pretty="StorageQuota", type="u32" }, + { map="channel_topic", ts="channel_topic", pretty="Topic", type="str" }, + { map="channel_unique_identifier", ts="channel_unique_identifier", pretty="Guid", type="str" }, + { map="cid", ts="cid", pretty="ChannelId", type="ChannelId" }, + { map="cldbid", ts="cldbid", pretty="ClientDbId", type="ClientDbId" }, + { map="clid", ts="clid", pretty="ClientId", type="ClientId" }, + { map="client_away", ts="client_away", pretty="IsAway", type="bool" }, + { map="client_away_message", ts="client_away_message", pretty="AwayMessage", type="str" }, + { map="client_badges", ts="client_badges", pretty="Badges", type="str" }, + { map="client_signed_badges", ts="client_signed_badges", pretty="SignedBadges", type="str" }, + { map="client_base64HashClientUID", ts="client_base64HashClientUID", pretty="Base64HashClientUid", type="str" }, + { map="client_channel_group_id", ts="client_channel_group_id", pretty="ChannelGroup", type="ChannelGroupId" }, + { map="client_channel_group_inherited_channel_id", ts="client_channel_group_inherited_channel_id", pretty="InheritedChannelGroupFromChannel", type="ChannelId" }, + { map="client_channel_id", ts="client_channel_id", pretty="ChannelId", type="ChannelId" }, + { map="client_country", ts="client_country", pretty="CountryCode", type="str" }, + { map="client_created", ts="client_created", pretty="Created", type="DateTime" }, + { map="client_database_id", ts="client_database_id", pretty="DatabaseId", type="ClientDbId" }, + { map="client_default_channel", ts="client_default_channel", pretty="DefaultChannel", type="str" }, + { map="client_default_channel_password", ts="client_default_channel_password", pretty="DefaultChannelPassword", type="str" }, + { map="client_default_token", ts="client_default_token", pretty="DefaultToken", type="str" }, + { map="client_description", ts="client_description", pretty="Description", type="str" }, + { map="client_estimated_location", ts="client_estimated_location", pretty="EstimatedLocation", type="str" }, + { map="client_flag_avatar", ts="client_flag_avatar", pretty="AvatarHash", type="str" }, + { map="client_flag_talking", ts="client_flag_talking", pretty="IsTalking", type="bool" }, + { map="client_icon_id", ts="client_icon_id", pretty="Icon", type="IconId" }, + { map="client_id", ts="client_id", pretty="ClientId", type="ClientId" }, + { map="client_idle_time", ts="client_idle_time", pretty="ClientIdleTime", type="DurationMilliseconds" }, + { map="client_input_hardware", ts="client_input_hardware", pretty="InputHardwareEnabled", type="bool" }, + { map="client_input_muted", ts="client_input_muted", pretty="InputMuted", type="bool" }, + { map="client_integrations", ts="client_integrations", pretty="Integrations", type="str" }, # type guessed + { map="client_active_integrations_info", ts="client_active_integrations_info", pretty="ActiveIntegrationsInfo", type="str" }, # type guessed + { map="client_is_channel_commander", ts="client_is_channel_commander", pretty="IsChannelCommander", type="bool" }, + { map="client_is_priority_speaker", ts="client_is_priority_speaker", pretty="IsPrioritySpeaker", type="bool" }, + { map="client_is_recording", ts="client_is_recording", pretty="IsRecording", type="bool" }, + { map="client_is_talker", ts="client_is_talker", pretty="TalkPowerGranted", type="bool" }, + { map="client_key_offset", ts="client_key_offset", pretty="ClientKeyOffset", type="u64" }, + { map="client_lastconnected", ts="client_lastconnected", pretty="LastConnected", type="DateTime" }, + { map="client_lastip", ts="client_lastip", pretty="LastIp", type="str" }, + { map="client_login_name", ts="client_login_name", pretty="LoginName", type="str" }, + { map="client_login_password", ts="client_login_password", pretty="LoginPassword", type="str" }, + { map="client_meta_data", ts="client_meta_data", pretty="Metadata", type="str" }, + { map="client_month_bytes_downloaded", ts="client_month_bytes_downloaded", pretty="BytesDownloadedMonth", type="u64" }, + { map="client_month_bytes_uploaded", ts="client_month_bytes_uploaded", pretty="BytesUploadedMonth", type="u64" }, + { map="client_myteamspeak_id", ts="client_myteamspeak_id", pretty="MyTeamSpeakId", type="str" }, # type guessed + { map="client_myteamspeak_avatar", ts="client_myteamspeak_avatar", pretty="MyTeamSpeakAvatar", type="str" }, # type guessed + { map="client_needed_serverquery_view_power", ts="client_needed_serverquery_view_power", pretty="NeededServerqueryViewPower", type="i32" }, + { map="client_nickname", ts="client_nickname", pretty="Name", type="str" }, + { map="client_nickname@initserver", ts="client_nickname", pretty="ClientName", type="str" }, # Mirrored + { map="client_nickname_phonetic", ts="client_nickname_phonetic", pretty="PhoneticName", type="str" }, + { map="client_nickname_phonetic@initserver", ts="client_nickname_phonetic", pretty="ClientPhoneticName", type="str" }, # Mirrored + { map="client_origin_server_id", ts="client_origin_server_id", pretty="OriginServerId", type="u64" }, + { map="client_output_hardware", ts="client_output_hardware", pretty="OutputHardwareEnabled", type="bool" }, + { map="client_output_muted", ts="client_output_muted", pretty="OutputMuted", type="bool" }, + { map="client_outputonly_muted", ts="client_outputonly_muted", pretty="OutputOnlyMuted", type="bool" }, + { map="client_platform", ts="client_platform", pretty="Platform", type="str" }, + { map="client_platform@initserver", ts="client_platform", pretty="ClientPlatform", type="str" }, # Mirrored + { map="client_security_hash", ts="client_security_hash", pretty="SecurityHash", type="str" }, + { map="client_server_password", ts="client_server_password", pretty="Password", type="str" }, + { map="client_servergroups", ts="client_servergroups", pretty="ServerGroups", type="ServerGroupId", mod="array" }, + { map="client_talk_power", ts="client_talk_power", pretty="TalkPower", type="i32" }, + { map="client_talk_request", ts="client_talk_request", pretty="TalkPowerRequestTime", type="DateTime" }, # 0 means no talk request + { map="client_talk_request@clientupdate", ts="client_talk_request", pretty="TalkPowerRequest", type="bool" }, + { map="client_talk_request_msg", ts="client_talk_request_msg", pretty="TalkPowerRequestMessage", type="str" }, + { map="client_total_bytes_downloaded", ts="client_total_bytes_downloaded", pretty="BytesDownloadedTotal", type="u64" }, + { map="client_total_bytes_uploaded", ts="client_total_bytes_uploaded", pretty="BytesUploadedTotal", type="u64" }, + { map="client_totalconnections", ts="client_totalconnections", pretty="ConnectionsTotal", type="u32" }, + { map="client_type", ts="client_type", pretty="ClientType", type="ClientType" }, + { map="client_unique_identifier", ts="client_unique_identifier", pretty="Uid", type="Uid" }, + { map="client_unread_messages", ts="client_unread_messages", pretty="UnreadMessages", type="u32" }, + { map="client_user_tag", ts="client_user_tag", pretty="UserTag", type="str" }, + { map="client_version", ts="client_version", pretty="Version", type="str" }, + { map="client_version@initserver", ts="client_version", pretty="ClientVersion", type="str" }, # Mirrored + { map="client_version_sign", ts="client_version_sign", pretty="VersionSign", type="str" }, + { map="client_version_sign@initserver", ts="client_version_sign", pretty="ClientVersionSign", type="str" }, # Mirrored + { map="clientftfid", ts="clientftfid", pretty="ClientFiletransferId", type="u16" }, + { map="cluid", ts="cluid", pretty="ClientUid", type="Uid" }, + { map="connection_bandwidth_received_last_minute_control", ts="connection_bandwidth_received_last_minute_control", pretty="BandwidthReceivedLastMinuteControl", type="u64" }, + { map="connection_bandwidth_received_last_minute_keepalive", ts="connection_bandwidth_received_last_minute_keepalive", pretty="BandwidthReceivedLastMinuteKeepalive", type="u64" }, + { map="connection_bandwidth_received_last_minute_speech", ts="connection_bandwidth_received_last_minute_speech", pretty="BandwidthReceivedLastMinuteSpeech", type="u64" }, + { map="connection_bandwidth_received_last_minute_total", ts="connection_bandwidth_received_last_minute_total", pretty="BandwidthReceivedLastMinuteTotal", type="u64" }, + { map="connection_bandwidth_received_last_second_control", ts="connection_bandwidth_received_last_second_control", pretty="BandwidthReceivedLastSecondControl", type="u64" }, + { map="connection_bandwidth_received_last_second_keepalive", ts="connection_bandwidth_received_last_second_keepalive", pretty="BandwidthReceivedLastSecondKeepalive", type="u64" }, + { map="connection_bandwidth_received_last_second_speech", ts="connection_bandwidth_received_last_second_speech", pretty="BandwidthReceivedLastSecondSpeech", type="u64" }, + { map="connection_bandwidth_received_last_second_total", ts="connection_bandwidth_received_last_second_total", pretty="BandwidthReceivedLastSecondTotal", type="u64" }, + { map="connection_bandwidth_sent_last_minute_control", ts="connection_bandwidth_sent_last_minute_control", pretty="BandwidthSentLastMinuteControl", type="u64" }, + { map="connection_bandwidth_sent_last_minute_keepalive", ts="connection_bandwidth_sent_last_minute_keepalive", pretty="BandwidthSentLastMinuteKeepalive", type="u64" }, + { map="connection_bandwidth_sent_last_minute_speech", ts="connection_bandwidth_sent_last_minute_speech", pretty="BandwidthSentLastMinuteSpeech", type="u64" }, + { map="connection_bandwidth_sent_last_minute_total", ts="connection_bandwidth_sent_last_minute_total", pretty="BandwidthSentLastMinuteTotal", type="u64" }, + { map="connection_bandwidth_sent_last_second_control", ts="connection_bandwidth_sent_last_second_control", pretty="BandwidthSentLastSecondControl", type="u64" }, + { map="connection_bandwidth_sent_last_second_keepalive", ts="connection_bandwidth_sent_last_second_keepalive", pretty="BandwidthSentLastSecondKeepalive", type="u64" }, + { map="connection_bandwidth_sent_last_second_speech", ts="connection_bandwidth_sent_last_second_speech", pretty="BandwidthSentLastSecondSpeech", type="u64" }, + { map="connection_bandwidth_sent_last_second_total", ts="connection_bandwidth_sent_last_second_total", pretty="BandwidthSentLastSecondTotal", type="u64" }, + { map="connection_bytes_received_control", ts="connection_bytes_received_control", pretty="BytesReceivedControl", type="u64" }, + { map="connection_bytes_received_keepalive", ts="connection_bytes_received_keepalive", pretty="BytesReceivedKeepalive", type="u64" }, + { map="connection_bytes_received_speech", ts="connection_bytes_received_speech", pretty="BytesReceivedSpeech", type="u64" }, + { map="connection_bytes_received_total", ts="connection_bytes_received_total", pretty="BytesReceivedTotal", type="u64" }, + { map="connection_bytes_sent_control", ts="connection_bytes_sent_control", pretty="BytesSentControl", type="u64" }, + { map="connection_bytes_sent_keepalive", ts="connection_bytes_sent_keepalive", pretty="BytesSentKeepalive", type="u64" }, + { map="connection_bytes_sent_speech", ts="connection_bytes_sent_speech", pretty="BytesSentSpeech", type="u64" }, + { map="connection_bytes_sent_total", ts="connection_bytes_sent_total", pretty="BytesSentTotal", type="u64" }, + { map="connection_client_ip", ts="connection_client_ip", pretty="Ip", type="str" }, + { map="connection_client_port", ts="connection_client_port", pretty="Port", type="u16" }, + { map="connection_client2server_packetloss_control", ts="connection_client2server_packetloss_control", pretty="ClientToServerPacketlossControl", type="f32" }, + { map="connection_client2server_packetloss_keepalive", ts="connection_client2server_packetloss_keepalive", pretty="ClientToServerPacketlossKeepalive", type="f32" }, + { map="connection_client2server_packetloss_speech", ts="connection_client2server_packetloss_speech", pretty="ClientToServerPacketlossSpeech", type="f32" }, + { map="connection_client2server_packetloss_total", ts="connection_client2server_packetloss_total", pretty="ClientToServerPacketlossTotal", type="f32" }, + { map="connection_connected_time", ts="connection_connected_time", pretty="ConnectedTime", type="DurationMilliseconds" }, + { map="connection_connected_time@server", ts="connection_connected_time", pretty="ConnectedTimeTotal", type="DurationSeconds" }, + { map="connection_filetransfer_bandwidth_received", ts="connection_filetransfer_bandwidth_received", pretty="FiletransferBandwidthReceived", type="u64" }, + { map="connection_filetransfer_bandwidth_sent", ts="connection_filetransfer_bandwidth_sent", pretty="FiletransferBandwidthSent", type="u64" }, + { map="connection_filetransfer_bytes_received_total", ts="connection_filetransfer_bytes_received_total", pretty="FiletransferBytesReceivedTotal", type="u64" }, + { map="connection_filetransfer_bytes_sent_total", ts="connection_filetransfer_bytes_sent_total", pretty="FiletransferBytesSentTotal", type="u64" }, + { map="connection_idle_time", ts="connection_idle_time", pretty="IdleTime", type="DurationMilliseconds" }, + { map="connection_packetloss_total", ts="connection_packetloss_total", pretty="PacketlossTotal", type="f32" }, + { map="connection_packets_received_control", ts="connection_packets_received_control", pretty="PacketsReceivedControl", type="u64" }, + { map="connection_packets_received_keepalive", ts="connection_packets_received_keepalive", pretty="PacketsReceivedKeepalive", type="u64" }, + { map="connection_packets_received_speech", ts="connection_packets_received_speech", pretty="PacketsReceivedSpeech", type="u64" }, + { map="connection_packets_received_total", ts="connection_packets_received_total", pretty="PacketsReceivedTotal", type="u64" }, + { map="connection_packets_sent_control", ts="connection_packets_sent_control", pretty="PacketsSentControl", type="u64" }, + { map="connection_packets_sent_keepalive", ts="connection_packets_sent_keepalive", pretty="PacketsSentKeepalive", type="u64" }, + { map="connection_packets_sent_speech", ts="connection_packets_sent_speech", pretty="PacketsSentSpeech", type="u64" }, + { map="connection_packets_sent_total", ts="connection_packets_sent_total", pretty="PacketsSentTotal", type="u64" }, + { map="connection_ping", ts="connection_ping", pretty="Ping", type="DurationMillisecondsFloat" }, + { map="connection_ping_deviation", ts="connection_ping_deviation", pretty="PingDeviation", type="DurationMillisecondsFloat" }, + { map="connection_server2client_packetloss_control", ts="connection_server2client_packetloss_control", pretty="ServerToClientPacketlossControl", type="f32" }, + { map="connection_server2client_packetloss_keepalive", ts="connection_server2client_packetloss_keepalive", pretty="ServerToClientPacketlossKeepalive", type="f32" }, + { map="connection_server2client_packetloss_speech", ts="connection_server2client_packetloss_speech", pretty="ServerToClientPacketlossSpeech", type="f32" }, + { map="connection_server2client_packetloss_total", ts="connection_server2client_packetloss_total", pretty="ServerToClientPacketlossTotal", type="f32" }, + { map="cpid", ts="cpid", pretty="ParentId", type="ChannelId" }, + { map="cpw", ts="cpw", pretty="ChannelPassword", type="str" }, + { map="created", ts="created", pretty="Created", type="DateTime" }, + { map="ctid", ts="ctid", pretty="TargetChannelId", type="ChannelId" }, + { map="current_speed", ts="current_speed", pretty="CurrentSpeed", type="f32" }, + { map="data", ts="data", pretty="Data", type="str" }, + { map="datetime", ts="datetime", pretty="DateTime", type="DateTime" }, + { map="delete", ts="delete", pretty="Delete", type="bool" }, + { map="desc", ts="desc", pretty="Description", type="str" }, + { map="dirname", ts="dirname", pretty="DirectoryName", type="str" }, + { map="duration@time", ts="duration", pretty="Duration", type="DurationSeconds" }, + { map="duration@list", ts="duration", pretty="Limit", type="u32" }, # integer, size guessed + # How often a banned client wanted to connect but was denied + { map="enforcements", ts="enforcements", pretty="Enforcements", type="u32" }, + { map="es", ts="es", pretty="EmptySince", type="DurationSeconds" }, + { map="end", ts="end", pretty="End", type="DateTime" }, + { map="event", ts="event", pretty="EventType", type="str" }, # {server|channel|textserver|textchannel|textprivate} + { map="fcldbid", ts="fcldbid", pretty="FromClientDbId", type="ClientDbId" }, + { map="file_size", ts="file_size", pretty="FileSize", type="u64" }, + { map="flag", ts="flag", pretty="IsRead", type="bool" }, + { map="flags@channel_ph", ts="flags", pretty="Flags", type="ChannelPermissionHint" }, + { map="flags@client_ph", ts="flags", pretty="Flags", type="ClientPermissionHint" }, + { map="flag_read", ts="flag_read", pretty="IsRead", type="bool" }, + { map="fname", ts="fname", pretty="FromName", type="str" }, + { map="ftkey", ts="ftkey", pretty="FiletransferKey", type="str" }, + { map="force", ts="force", pretty="Force", type="bool" }, + { map="group_id_end", ts="group_id_end", pretty="GroupIdEnd", type="PermissionId" }, # describes how permissions are grouped in the client ui + { map="hwid", ts="hwid", pretty="HardwareId", type="str" }, + { map="iconid", ts="iconid", pretty="Icon", type="IconId" }, + { map="id", ts="id", pretty="Id", type="ChannelId" }, + { map="id1", ts="id1", pretty="Id1", type="u64" }, # {ServerGroupId|ClientDbId|ChannelId} + { map="id2", ts="id2", pretty="Id2", type="u64" }, # {0|ChannelGroupId|ClientDbId} + { map="ident", ts="ident", pretty="ExternalIdentity", type="str" }, + { map="ip", ts="ip", pretty="Ip", type="IpAddr" }, + { map="instance", ts="instance", pretty="InstanceLog", type="bool" }, + { map="invokerid", ts="invokerid", pretty="InvokerId", type="ClientId" }, + { map="invokercldbid", ts="invokercldbid", pretty="InvokerDatabaseId", type="ClientDbId" }, + { map="invokername", ts="invokername", pretty="InvokerName", type="str" }, + { map="invokeruid", ts="invokeruid", pretty="InvokerUid", type="Uid" }, + { map="lastnickname", ts="lastnickname", pretty="LastNickname", type="str" }, + { map="last_pos", ts="last_pos", pretty="LastOffset", type="u64" }, # integer, size guessed + { map="lines", ts="lines", pretty="Lines", type="u32" }, # integer, size guessed + { map="log", ts="l", pretty="Log", type="str" }, # one argument per line + { map="logmsg", ts="logmsg", pretty="LogMessage", type="str" }, + { map="loglevel", ts="loglevel", pretty="LogLevel", type="LogLevel" }, + { map="lt", ts="lt", pretty="LicenseType", type="LicenseType" }, + { map="msg", ts="msg", pretty="Message", type="str" }, + { map="msgid", ts="msgid", pretty="MessageId", type="u32" }, # integer, size guessed + { map="message", ts="message", pretty="Message", type="str" }, + { map="mytsid", ts="mytsid", pretty="MyTsId", type="str" }, + { map="n", ts="n", pretty="PermissionNegated", type="bool" }, + { map="n_member_addp", ts="n_member_addp", pretty="NeededMemberAddPower", type="i32" }, + { map="n_member_removep", ts="n_member_removep", pretty="NeededMemberRemovePower", type="i32" }, + { map="n_modifyp", ts="n_modifyp", pretty="NeededModifyPower", type="i32" }, + { map="name", ts="name", pretty="Name", type="str" }, + { map="namemode", ts="namemode", pretty="NamingMode", type="GroupNamingMode" }, + { map="newname", ts="newname", pretty="NewName", type="str" }, + { map="nickname", ts="nickname", pretty="Nickname", type="str" }, + { map="oldname", ts="oldname", pretty="OldName", type="str" }, + { map="omega", ts="omega", pretty="Omega", type="str" }, + { map="order", ts="order", pretty="Order", type="ChannelId" }, + { map="overwrite", ts="overwrite", pretty="Overwrite", type="bool" }, + { map="p", ts="p", pretty="PermissionId", type="PermissionId" }, + { map="path", ts="path", pretty="Path", type="str" }, + { map="pattern", ts="pattern", pretty="Pattern", type="str" }, # sometimes Regex/SQL Wildcards + { map="permid", ts="permid", pretty="PermissionId", type="PermissionId" }, + { map="permnegated", ts="permnegated", pretty="PermissionNegated", type="bool" }, + { map="permsid", ts="permsid", pretty="PermissionNameId", type="str" }, + { map="permskip", ts="permskip", pretty="PermissionSkip", type="bool" }, + { map="permvalue", ts="permvalue", pretty="PermissionValue", type="i32" }, + { map="permname", ts="permname", pretty="PermissionName", type="str" }, + { map="permdesc", ts="permdesc", pretty="PermissionDescription", type="str" }, + { map="pid", ts="pid", pretty="ParentChannelId", type="ChannelId" }, + { map="port", ts="port", pretty="Port", type="u16" }, + { map="proto", ts="proto", pretty="Protocol", type="u8" }, + { map="pv", ts="pv", pretty="ProtocolVersion", type="u16" }, + { map="pw", ts="pw", pretty="Password", type="str" }, + # TODO maybe find better name when know what this is + { map="pw_clear", ts="pw_clear", pretty="PasswordClear", type="str" }, + { map="reasonid", ts="reasonid", pretty="Reason", type="Reason" }, + { map="reason", ts="reason", pretty="Reason", type="str" }, + { map="reasonmsg", ts="reasonmsg", pretty="ReasonMessage", type="str" }, + { map="resume", ts="resume", pretty="Resume", type="bool" }, + { map="reverse", ts="reverse", pretty="Reverse", type="bool" }, + { map="runtime", ts="runtime", pretty="Runtime", type="DurationSeconds" }, + { map="s", ts="s", pretty="PermissionSkip", type="bool" }, + { map="savedb", ts="savedb", pretty="IsPermanent", type="bool" }, + { map="scgid", ts="scgid", pretty="SourceChannelGroupId", type="ChannelGroupId" }, + { map="seconds_empty", ts="seconds_empty", pretty="DurationEmpty", type="DurationSeconds" }, + { map="seekpos", ts="seekpos", pretty="SeekPosition", type="u64" }, + # ?? type + { map="sender", ts="sender", pretty="Sender", type="u64" }, + { map="serverftfid", ts="serverftfid", pretty="ServerFiletransferId", type="u16" }, + { map="sgid", ts="sgid", pretty="ServerGroupId", type="ServerGroupId" }, + { map="sgtype", ts="sgtype", pretty="ServerGroupType", type="u32" }, # integer, size guessed + { map="sid", ts="sid", pretty="ServerId", type="u32" }, # integer, size guessed, maybe own type ServerId ? + { map="size", ts="size", pretty="Size", type="u64" }, + { map="sizedone", ts="sizedone", pretty="SizeDone", type="i64" }, + { map="sortid", ts="sortid", pretty="SortId", type="i32" }, + { map="ssgid", ts="ssgid", pretty="SourceServerGroupId", type="ServerGroupId" }, + { map="subject", ts="subject", pretty="Subject", type="str" }, + { map="subsystem", ts="subsystem", pretty="Subsystem", type="str" }, # {'voice'|'query'|'filetransfer'} + { map="status@err", ts="status", pretty="Status", type="Ts3ErrorCode" }, + { map="status@ft", ts="status", pretty="Status", type="i32" }, + { map="start@list", ts="start", pretty="Offset", type="u32" }, # integer, size guessed + { map="start@tmppw", ts="start", pretty="Start", type="DateTime" }, + { map="t", ts="t", pretty="PermissionType", type="PermissionType" }, + { map="target@msg", ts="target", pretty="TargetClientId", type="ClientId" }, + { map="target@plugin", ts="target", pretty="TargetClientId", type="ClientId" }, + { map="targetmode@msg", ts="targetmode", pretty="Target", type="TextMessageTargetMode" }, + { map="targetmode@plugin", ts="targetmode", pretty="Target", type="PluginTargetMode" }, + { map="tcgid", ts="tcgid", pretty="TargetChannelGroupId", type="ChannelGroupId" }, + { map="tcid", ts="tcid", pretty="TargetChannelId", type="ChannelId" }, + { map="tcpw", ts="tcpw", pretty="TargetChannelPassword", type="str" }, + { map="tcldbid", ts="tcldbid", pretty="TargetClientDbId", type="ClientDbId" }, + { map="time", ts="time", pretty="Time", type="DurationSeconds" }, + { map="time@initivexpand2", ts="time", pretty="Time", type="DateTime" }, + { map="timestamp", ts="timestamp", pretty="Timestamp", type="DateTime" }, + { map="tname", ts="tname", pretty="TargetName", type="str" }, + { map="token", ts="token", pretty="Token", type="str" }, + { map="token_created", ts="token_created", pretty="TokenCreateTime", type="DateTime" }, + { map="token_description", ts="token_description", pretty="TokenDescription", type="str" }, + { map="tokendescription", ts="tokendescription", pretty="TokenDescription", type="str" }, + { map="token_id1", ts="token_id1", pretty="TokenId1", type="u64" }, # {ServerGroup|ChannelGroup} + { map="tokenid1", ts="tokenid1", pretty="TokenId1", type="u64" }, # {ServerGroup|ChannelGroup} + { map="token_id2", ts="token_id2", pretty="TokenId2", type="ChannelId" }, # ChannelId + { map="tokenid2", ts="tokenid2", pretty="TokenId2", type="ChannelId" }, # ChannelId + { map="token_type", ts="token_type", pretty="TokenType", type="TokenType" }, + { map="tokentype", ts="tokentype", pretty="TokenType", type="TokenType" }, + { map="token1", ts="token1", pretty="Token1", type="str" }, + { map="token2", ts="token2", pretty="Token2", type="str" }, + { map="tokencustomset", ts="tokencustomset", pretty="TokenCustomSet", type="str" }, + { map="total_clients", ts="total_clients", pretty="ClientsTotal", type="i32" }, + { map="total_clients_family", ts="total_clients_family", pretty="FamilyClientsTotal", type="i32" }, + { map="tsgid", ts="tsgid", pretty="TargetServerGroupId", type="ServerGroupId" }, + { map="type@ft", ts="type", pretty="IsFile", type="bool" }, + { map="type@group", ts="type", pretty="GroupType", type="GroupType" }, + { map="uid", ts="uid", pretty="Uid", type="Uid" }, + { map="v", ts="v", pretty="PermissionValue", type="i32" }, # integer, size guessed + { map="value", ts="value", pretty="Value", type="str" }, + { map="virtualserver_administrative_domain", ts="virtualserver_administrative_domain", pretty="AdministrativeDomain", type="str" }, + { map="virtualserver_antiflood_points_tick_reduce", ts="virtualserver_antiflood_points_tick_reduce", pretty="AntifloodPointsTickReduce", type="u32" }, + { map="virtualserver_antiflood_points_needed_command_block", ts="virtualserver_antiflood_points_needed_command_block", pretty="AntifloodPointsToCommandBlock", type="u32" }, + { map="virtualserver_antiflood_points_needed_ip_block", ts="virtualserver_antiflood_points_needed_ip_block", pretty="AntifloodPointsToIpBlock", type="u32" }, + { map="virtualserver_antiflood_points_needed_plugin_block", ts="virtualserver_antiflood_points_needed_plugin_block", pretty="AntifloodPointsToPluginBlock", type="u32" }, + { map="virtualserver_ask_for_privilegekey", ts="virtualserver_ask_for_privilegekey", pretty="AskForPrivilegekey", type="bool" }, + { map="virtualserver_autostart", ts="virtualserver_autostart", pretty="Autostart", type="bool" }, + { map="virtualserver_capability_extensions", ts="virtualserver_capability_extensions", pretty="CapabilityExtensions", type="str" }, # TODO mod="array"? + { map="virtualserver_channel_temp_delete_delay_default", ts="virtualserver_channel_temp_delete_delay_default", pretty="TempChannelDefaultDeleteDelay", type="DurationSeconds" }, + { map="virtualserver_channelsonline", ts="virtualserver_channelsonline", pretty="ChannelCount", type="u64" }, + { map="virtualserver_client_connections", ts="virtualserver_client_connections", pretty="ConnectionCountTotal", type="u64" }, + { map="virtualserver_clientsonline", ts="virtualserver_clientsonline", pretty="ClientCount", type="u16" }, + { map="virtualserver_codec_encryption_mode", ts="virtualserver_codec_encryption_mode", pretty="CodecEncryptionMode", type="CodecEncryptionMode" }, + { map="virtualserver_complain_autoban_count", ts="virtualserver_complain_autoban_count", pretty="ComplainAutobanCount", type="u32" }, + { map="virtualserver_complain_autoban_time", ts="virtualserver_complain_autoban_time", pretty="ComplainAutobanTime", type="DurationSeconds" }, + { map="virtualserver_complain_remove_time", ts="virtualserver_complain_remove_time", pretty="ComplainRemoveTime", type="DurationSeconds" }, + { map="virtualserver_created", ts="virtualserver_created", pretty="Created", type="DateTime" }, + { map="virtualserver_default_channel_group", ts="virtualserver_default_channel_group", pretty="DefaultChannelGroup", type="ChannelGroupId" }, + { map="virtualserver_default_channel_admin_group", ts="virtualserver_default_channel_admin_group", pretty="DefaultChannelAdminGroup", type="ChannelGroupId" }, + { map="virtualserver_default_server_group", ts="virtualserver_default_server_group", pretty="DefaultServerGroup", type="ServerGroupId" }, + { map="virtualserver_download_quota", ts="virtualserver_download_quota", pretty="DownloadQuota", type="u64" }, + { map="virtualserver_flag_password", ts="virtualserver_flag_password", pretty="HasPassword", type="bool" }, + { map="virtualserver_hostbanner_gfx_interval", ts="virtualserver_hostbanner_gfx_interval", pretty="HostbannerGfxInterval", type="DurationSeconds" }, + { map="virtualserver_hostbanner_gfx_url", ts="virtualserver_hostbanner_gfx_url", pretty="HostbannerGfxUrl", type="str" }, + { map="virtualserver_hostbanner_mode", ts="virtualserver_hostbanner_mode", pretty="HostbannerMode", type="HostBannerMode" }, + { map="virtualserver_hostbanner_url", ts="virtualserver_hostbanner_url", pretty="HostbannerUrl", type="str" }, + { map="virtualserver_hostbutton_gfx_url", ts="virtualserver_hostbutton_gfx_url", pretty="HostbuttonGfxUrl", type="str" }, + { map="virtualserver_hostbutton_tooltip", ts="virtualserver_hostbutton_tooltip", pretty="HostbuttonTooltip", type="str" }, + { map="virtualserver_hostbutton_url", ts="virtualserver_hostbutton_url", pretty="HostbuttonUrl", type="str" }, + { map="virtualserver_hostmessage", ts="virtualserver_hostmessage", pretty="Hostmessage", type="str" }, + { map="virtualserver_hostmessage_mode", ts="virtualserver_hostmessage_mode", pretty="HostmessageMode", type="HostMessageMode" }, + { map="virtualserver_icon_id", ts="virtualserver_icon_id", pretty="Icon", type="IconId" }, + { map="virtualserver_id", ts="virtualserver_id", pretty="VirtualServerId", type="u64" }, + { map="virtualserver_ip", ts="virtualserver_ip", pretty="Ips", type="IpAddr", mod="array" }, + { map="virtualserver_log_client", ts="virtualserver_log_client", pretty="LogClient", type="bool" }, + { map="virtualserver_log_query", ts="virtualserver_log_query", pretty="LogQuery", type="bool" }, + { map="virtualserver_log_channel", ts="virtualserver_log_channel", pretty="LogChannel", type="bool" }, + { map="virtualserver_log_permissions", ts="virtualserver_log_permissions", pretty="LogPermissions", type="bool" }, + { map="virtualserver_log_server", ts="virtualserver_log_server", pretty="LogServer", type="bool" }, + { map="virtualserver_log_filetransfer", ts="virtualserver_log_filetransfer", pretty="LogFiletransfer", type="bool" }, + { map="virtualserver_machine_id", ts="virtualserver_machine_id", pretty="MachineId", type="str" }, + { map="virtualserver_max_download_total_bandwidth", ts="virtualserver_max_download_total_bandwidth", pretty="MaxDownloadBandwidthTotal", type="u64" }, + { map="virtualserver_max_upload_total_bandwidth", ts="virtualserver_max_upload_total_bandwidth", pretty="MaxUploadBandwidthTotal", type="u64" }, + { map="virtualserver_maxclients", ts="virtualserver_maxclients", pretty="MaxClients", type="u16" }, + { map="virtualserver_min_android_version", ts="virtualserver_min_android_version", pretty="MinAndroidVersion", type="DateTime" }, + { map="virtualserver_min_client_version", ts="virtualserver_min_client_version", pretty="MinClientVersion", type="DateTime" }, + { map="virtualserver_min_clients_in_channel_before_forced_silence", ts="virtualserver_min_clients_in_channel_before_forced_silence", pretty="MinClientsInChannelBeforeForcedSilence", type="u32" }, + { map="virtualserver_min_ios_version", ts="virtualserver_min_ios_version", pretty="MinIosVersion", type="DateTime" }, + { map="virtualserver_month_bytes_downloaded", ts="virtualserver_month_bytes_downloaded", pretty="BytesDownloadedMonth", type="u64" }, + { map="virtualserver_month_bytes_uploaded", ts="virtualserver_month_bytes_uploaded", pretty="BytesUploadedMonth", type="u64" }, + { map="virtualserver_name", ts="virtualserver_name", pretty="Name", type="str" }, + { map="virtualserver_name_phonetic", ts="virtualserver_name_phonetic", pretty="PhoneticName", type="str" }, + { map="virtualserver_needed_identity_security_level", ts="virtualserver_needed_identity_security_level", pretty="NeededIdentitySecurityLevel", type="u8" }, + { map="virtualserver_nickname", ts="virtualserver_nickname", pretty="Nickname", type="str" }, # `:`-separated array + { map="virtualserver_password", ts="virtualserver_password", pretty="Password", type="str" }, + { map="virtualserver_platform", ts="virtualserver_platform", pretty="Platform", type="str" }, + { map="virtualserver_port", ts="virtualserver_port", pretty="Port", type="u16" }, + { map="virtualserver_priority_speaker_dimm_modificator", ts="virtualserver_priority_speaker_dimm_modificator", pretty="PrioritySpeakerDimmModificator", type="f32" }, + { map="virtualserver_query_client_connections", ts="virtualserver_query_client_connections", pretty="QueryCountTotal", type="u64" }, + { map="virtualserver_queryclientsonline", ts="virtualserver_queryclientsonline", pretty="QueryCount", type="u32" }, + { map="virtualserver_reserved_slots", ts="virtualserver_reserved_slots", pretty="ReservedSlots", type="u16" }, + { map="virtualserver_status", ts="virtualserver_status", pretty="VirtualServerStatus", type="str" }, + { map="virtualserver_total_bytes_downloaded", ts="virtualserver_total_bytes_downloaded", pretty="BytesDownloadedTotal", type="u64" }, + { map="virtualserver_total_bytes_uploaded", ts="virtualserver_total_bytes_uploaded", pretty="BytesUploadedTotal", type="u64" }, + { map="virtualserver_total_packetloss_speech", ts="virtualserver_total_packetloss_speech", pretty="TotalPacketlossSpeech", type="f32" }, + { map="virtualserver_total_packetloss_keepalive", ts="virtualserver_total_packetloss_keepalive", pretty="TotalPacketlossKeepalive", type="f32" }, + { map="virtualserver_total_packetloss_control", ts="virtualserver_total_packetloss_control", pretty="TotalPacketlossControl", type="f32" }, + { map="virtualserver_total_packetloss_total", ts="virtualserver_total_packetloss_total", pretty="TotalPacketloss", type="f32" }, + { map="virtualserver_total_ping", ts="virtualserver_total_ping", pretty="TotalPing", type="DurationMillisecondsFloat" }, + { map="virtualserver_unique_identifier", ts="virtualserver_unique_identifier", pretty="VirtualServerUid", type="Uid" }, + { map="virtualserver_upload_quota", ts="virtualserver_upload_quota", pretty="UploadQuota", type="u64" }, + { map="virtualserver_uptime", ts="virtualserver_uptime", pretty="Uptime", type="DurationSeconds" }, + { map="virtualserver_version", ts="virtualserver_version", pretty="Version", type="str" }, + { map="virtualserver_weblist_enabled", ts="virtualserver_weblist_enabled", pretty="WeblistEnabled", type="bool" }, + { map="virtualserver_welcomemessage", ts="virtualserver_welcomemessage", pretty="WelcomeMessage", type="str" }, + + # Error stuff + { map="error_id", ts="id", pretty="Id", type="Ts3ErrorCode" }, + { map="failed_permid", ts="failed_permid", pretty="MissingPermissionId", type="PermissionId" }, + { map="return_code", ts="return_code", pretty="ReturnCode", type="str" }, + { map="extra_msg", ts="extra_msg", pretty="ExtraMessage", type="str" }, + + # 3.1 + { map="l", ts="l", pretty="License", type="str" }, + { map="tvd", ts="tvd", pretty="Tvd", type="str" }, + { map="proof", ts="proof", pretty="Proof", type="str" }, + { map="ot", ts="ot", pretty="Ot", type="bool" }, + + # TeaSpeak + { map="virtualserver_country", ts="virtualserver_country_code", pretty="CountryCode", type="str" }, + { map="virtualserver_default_music_group", ts="virtualserver_default_music_group", pretty="DefaultMusicGroup", type="ServerGroupId" }, + { map="root", ts="root", pretty="RootKey", type="str" }, +] + +# The "msg_group: array specifies all messages which can be sent between client +# and server. +# They are categorized into message groups whereby each group has a list of +# default modifiers which are applied on each message in the group. +# [Message structure]: +# - "name": The high-level name of the message. +# - "notify": The event name as teamspeak uses it (can be omitted when +# | response=true; this means that it can't be received without request). +# - "attributes": The "map"-name from all fields which are a parameter of this +# | command. The map name can be suffixed with a '?' to make it optional. +# | All non-optional fields must be set when receiving this message, +# | otherwise the message can/should be considered as invalid. +# [Message modifiers]: +# - "s2c": This message can be received as client (read: "server to client") +# - "c2s": This message can be received as server (read: "client to server") +# - "response": +# | - true: This message can appear without the event name as an answer to +# | | a request command (see "notify" before). +# | - false: This message will always be sent with the notify event name. +# - "low": The "lowcommand" packet must be used for this command. (Ignore for +# | query). +# - "np": The "newprotocol" flag must be set for this command. (Ignore for +# | query). + +# Client: "cid", "client_idle_time", "client_unique_identifier", "client_nickname", "client_version", "client_platform", "client_input_muted", "client_output_muted", "client_outputonly_muted", "client_input_hardware", "client_output_hardware", "client_default_channel", "client_meta_data", "client_is_recording", "client_version_sign", "client_security_hash", "client_login_name", "client_database_id", "client_channel_group_id", "client_servergroups", "client_created", "client_lastconnected", "client_totalconnections", "client_away", "client_away_message", "client_type", "client_flag_avatar", "client_talk_power", "client_talk_request", "client_talk_request_msg", "client_description", "client_is_talker", "client_month_bytes_uploaded", "client_month_bytes_downloaded", "client_total_bytes_uploaded", "client_total_bytes_downloaded", "client_is_priority_speaker", "client_unread_messages", "client_nickname_phonetic", "client_needed_serverquery_view_power", "client_default_token", "client_icon_id", "client_is_channel_commander", "client_country", "client_channel_group_inherited_channel_id", "client_badges", "client_myteamspeak_id", "client_integrations", "client_base64HashClientUID", "connection_filetransfer_bandwidth_sent", "connection_filetransfer_bandwidth_received", "connection_packets_sent_total", "connection_bytes_sent_total", "connection_packets_received_total", "connection_bytes_received_total", "connection_bandwidth_sent_last_second_total", "connection_bandwidth_sent_last_minute_total", "connection_bandwidth_received_last_second_total", "connection_bandwidth_received_last_minute_total", "connection_connected_time", "connection_client_ip" +# Channel: "channel_order?", "channel_name?", "channel_topic?", "channel_flag_default?", "channel_flag_password?", "channel_flag_permanent?", "channel_flag_semi_permanent?", "channel_codec?", "channel_codec_quality?", "channel_needed_talk_power?", "channel_icon_id?", "channel_maxclients?", "channel_maxfamilyclients?", "channel_codec_latency_factor?", "channel_codec_is_unencrypted?", "channel_delete_delay?", "channel_flag_maxclients_unlimited?", "channel_flag_maxfamilyclients_unlimited?", "channel_flag_maxfamilyclients_inherited?", "channel_name_phonetic?", "cpid?" + +# Server to Client Notifications +[[msg_group]] +default = { s2c=true, c2s=false, response=false, low=false, np=false } +msg = [ + { name="ChannelChanged", notify="notifychannelchanged", attributes=["cid"] }, + { name="ChannelDescriptionChanged", notify="notifychanneldescriptionchanged", attributes=["cid"] }, + # TODO check with ChannelData + { name="ChannelList", notify="channellist", attributes=["cid", "cpid", "channel_name", "channel_topic", "channel_codec", "channel_codec_quality", "channel_maxclients", "channel_maxfamilyclients", "channel_order", "channel_flag_permanent", "channel_flag_semi_permanent", "channel_flag_default", "channel_flag_password", "channel_codec_latency_factor", "channel_codec_is_unencrypted", "channel_delete_delay", "channel_flag_maxclients_unlimited", "channel_flag_maxfamilyclients_unlimited", "channel_flag_maxfamilyclients_inherited", "channel_needed_talk_power", "channel_forced_silence", "channel_name_phonetic", "channel_icon_id", "channel_flag_private?", "channel_unique_identifier?", "channel_banner_gfx_url?", "channel_banner_mode?", "channel_storage_quota?"] }, + { name="ChannelListFinished", notify="channellistfinished", attributes=[] }, + { name="ChannelMoved", notify="notifychannelmoved", attributes=["order", "cid", "invokerid", "invokername", "invokeruid?", "reasonid", "cpid"] }, + { name="ChannelPasswordChanged", notify="notifychannelpasswordchanged", attributes=["cid"] }, + { name="ChannelPermissionHints", notify="notifychannelpermhints", attributes=["cid", "flags@channel_ph"] }, + { name="ChannelSubscribed", notify="notifychannelsubscribed", attributes=["cid", "es?"] }, + { name="ChannelUnsubscribed", notify="notifychannelunsubscribed", attributes=["cid"] }, + { name="ClientChannelGroupChanged", notify="notifyclientchannelgroupchanged", attributes=["invokerid", "invokername", "invokeruid?", "cgid", "cgi", "cid", "clid"] }, + { name="ClientChatClosed", notify="notifyclientchatclosed", attributes=["clid", "cluid"] }, + { name="ClientChatComposing", notify="notifyclientchatcomposing", attributes=["clid", "cluid"] }, + { name="ClientConnectionInfo", notify="notifyconnectioninfo", attributes=["clid", "connection_ping?", "connection_ping_deviation?", "connection_connected_time?", "connection_client_ip?", "connection_client_port?", "connection_packets_sent_speech?", "connection_packets_sent_keepalive?", "connection_packets_sent_control?", "connection_bytes_sent_speech?", "connection_bytes_sent_keepalive?", "connection_bytes_sent_control?", "connection_packets_received_speech?", "connection_packets_received_keepalive?", "connection_packets_received_control?", "connection_bytes_received_speech?", "connection_bytes_received_keepalive?", "connection_bytes_received_control?", "connection_server2client_packetloss_speech?", "connection_server2client_packetloss_keepalive?", "connection_server2client_packetloss_control?", "connection_server2client_packetloss_total?", "connection_client2server_packetloss_speech", "connection_client2server_packetloss_keepalive", "connection_client2server_packetloss_control", "connection_client2server_packetloss_total", "connection_bandwidth_sent_last_second_speech?", "connection_bandwidth_sent_last_second_keepalive?", "connection_bandwidth_sent_last_second_control?", "connection_bandwidth_sent_last_minute_speech?", "connection_bandwidth_sent_last_minute_keepalive?", "connection_bandwidth_sent_last_minute_control?", "connection_bandwidth_received_last_second_speech?", "connection_bandwidth_received_last_second_keepalive?", "connection_bandwidth_received_last_second_control?", "connection_bandwidth_received_last_minute_speech?", "connection_bandwidth_received_last_minute_keepalive?", "connection_bandwidth_received_last_minute_control?", "connection_filetransfer_bandwidth_sent?", "connection_filetransfer_bandwidth_received?", "connection_idle_time"] }, + { name="ClientConnectionInfoUpdateRequest", notify="notifyconnectioninforequest", attributes=[] }, + { name="ClientEnterView", notify="notifycliententerview", attributes=["reasonid", "ctid", "invokerid?", "invokername?", "invokeruid?", "clid", "client_database_id", "client_nickname", "client_type", "cfid", "client_unique_identifier", "client_flag_avatar", "client_description", "client_icon_id", "client_input_muted", "client_output_muted", "client_outputonly_muted", "client_input_hardware", "client_output_hardware", "client_meta_data", "client_is_recording", "client_channel_group_id", "client_channel_group_inherited_channel_id", "client_servergroups", "client_away", "client_away_message", "client_talk_power", "client_talk_request", "client_talk_request_msg", "client_is_talker", "client_is_priority_speaker", "client_unread_messages", "client_nickname_phonetic", "client_needed_serverquery_view_power", "client_is_channel_commander", "client_country", "client_badges", "client_myteamspeak_id", "client_integrations", "client_myteamspeak_avatar?", "client_signed_badges?", "client_estimated_location?", "client_totalconnections?", "client_user_tag?"] }, + { name="ClientLeftView", notify="notifyclientleftview", attributes=["reasonmsg?", "bantime?", "reasonid?", "ctid", "invokerid?", "invokername?", "invokeruid?", "clid", "cfid"] }, + { name="ClientMoved", notify="notifyclientmoved", attributes=["clid", "reasonid", "cfid?", "ctid", "invokerid?", "invokername?", "invokeruid?", "reasonmsg?"] }, + { name="ClientNeededPermissions", notify="notifyclientneededpermissions", attributes=["permid", "permvalue?"] }, + { name="ClientPermissionHints", notify="notifyclientpermhints", attributes=["clid", "flags@client_ph"] }, + { name="ClientServerGroupAdded", notify="notifyservergroupclientadded", attributes=["name", "sgid", "invokerid", "invokername", "invokeruid?", "clid", "cluid"] }, + { name="ClientServerGroupRemoved", notify="notifyservergroupclientdeleted", attributes=["name", "sgid", "invokerid", "invokername", "invokeruid?", "clid", "cluid"] }, + { name="ClientUpdated", notify="notifyclientupdated", attributes=["clid", "invokerid?", "invokername?", "invokeruid?", "client_nickname?", "client_unread_messages?", "client_version?", "client_platform?", "client_login_name?", "client_created?", "client_lastconnected?", "client_totalconnections?", "client_month_bytes_uploaded?", "client_month_bytes_downloaded?", "client_total_bytes_uploaded?", "client_total_bytes_downloaded?", "client_input_muted?", "client_input_hardware?", "client_output_muted?", "client_meta_data?", "client_output_hardware?", "client_description?", "client_is_priority_speaker?", "client_is_channel_commander?", "client_flag_avatar?", "client_signed_badges?", "client_talk_request?", "client_talk_request_msg?", "client_is_talker?", "client_nickname_phonetic?", "client_is_recording?", "client_servergroups?", "client_myteamspeak_id?", "client_badges?", "client_myteamspeak_avatar?", "client_talk_power?", "client_icon_id?", "client_away?", "client_away_message?", "client_channel_group_inherited_channel_id?", "client_channel_group_id?", "client_needed_serverquery_view_power?", "client_user_tag?"] }, + { name="CommandError", notify="error", attributes=["error_id", "msg", "failed_permid?", "return_code?", "extra_msg?"] }, + { name="FileListFinished", notify="notifyfilelistfinished", attributes=["cid", "path"] }, + { name="FiletransferStatus", notify="notifystatusfiletransfer", attributes=["clientftfid", "status@err", "msg", "size"] }, + { name="InitIvExpand", notify="initivexpand", attributes=["alpha", "beta", "omega"] }, + { name="InitIvExpand2", notify="initivexpand2", attributes=["l", "beta", "omega", "ot?", "proof", "tvd", "time@initivexpand2?", "root?"] }, + { name="InitServer", notify="initserver", attributes=["virtualserver_name", "virtualserver_welcomemessage", "virtualserver_platform", "virtualserver_version", "virtualserver_maxclients", "virtualserver_created", "virtualserver_codec_encryption_mode", "virtualserver_hostmessage", "virtualserver_hostmessage_mode", "virtualserver_default_server_group", "virtualserver_default_channel_group", "virtualserver_id", "virtualserver_ip?", "virtualserver_ask_for_privilegekey", "lt?", "virtualserver_hostbanner_url", "virtualserver_hostbanner_gfx_url", "virtualserver_hostbanner_gfx_interval", "virtualserver_priority_speaker_dimm_modificator", "virtualserver_hostbutton_tooltip", "virtualserver_hostbutton_url", "virtualserver_hostbutton_gfx_url", "virtualserver_name_phonetic", "virtualserver_icon_id", "virtualserver_hostbanner_mode", "virtualserver_channel_temp_delete_delay_default", "virtualserver_nickname?", "virtualserver_unique_identifier?", "virtualserver_default_music_group?", "virtualserver_default_channel_admin_group?", "virtualserver_weblist_enabled?", "virtualserver_country?", "virtualserver_capability_extensions?", "virtualserver_administrative_domain?", "client_nickname@initserver?", "client_version@initserver?", "client_platform@initserver?", "client_input_muted?", "client_output_muted?", "client_outputonly_muted?", "client_input_hardware?", "client_output_hardware?", "client_default_channel?", "client_default_channel_password?", "client_server_password?", "client_meta_data?", "client_version_sign@initserver?", "client_security_hash?", "client_key_offset?", "client_away?", "client_away_message?", "client_nickname_phonetic@initserver?", "client_default_token?", "client_badges?", "client_myteamspeak_id?", "client_integrations?", "client_active_integrations_info?", "client_myteamspeak_avatar?", "client_signed_badges?", "acn", "aclid", "pv", "client_talk_power", "client_needed_serverquery_view_power", "client_user_tag?"] }, + { name="PluginCommand", notify="notifyplugincmd", attributes=["name", "data", "invokerid?", "invokername?", "invokeruid?"] }, + { name="ServerEdited", notify="notifyserveredited", attributes=["invokerid", "invokername", "invokeruid?", "reasonid", "virtualserver_name?", "virtualserver_nickname?", "virtualserver_codec_encryption_mode?", "virtualserver_default_server_group?", "virtualserver_default_channel_group?", "virtualserver_hostbanner_url?", "virtualserver_hostbanner_gfx_url?", "virtualserver_hostbanner_gfx_interval?", "virtualserver_priority_speaker_dimm_modificator?", "virtualserver_hostbutton_tooltip?", "virtualserver_hostbutton_url?", "virtualserver_hostbutton_gfx_url?", "virtualserver_name_phonetic?", "virtualserver_icon_id?", "virtualserver_hostbanner_mode?", "virtualserver_channel_temp_delete_delay_default?" ] }, + { name="ServerTempPasswordList", notify="notifyservertemppasswordlist", attributes=["nickname", "uid", "desc", "pw_clear", "start@tmppw", "end", "tcid", "tcpw"] }, + { name="ServerUpdated", notify="notifyserverupdated", attributes=["virtualserver_welcomemessage", "virtualserver_maxclients", "virtualserver_clientsonline", "virtualserver_channelsonline", "virtualserver_uptime", "virtualserver_hostmessage", "virtualserver_hostmessage_mode", "virtualserver_flag_password", "virtualserver_default_channel_admin_group", "virtualserver_max_download_total_bandwidth", "virtualserver_max_upload_total_bandwidth", "virtualserver_complain_autoban_count", "virtualserver_complain_autoban_time", "virtualserver_complain_remove_time", "virtualserver_min_clients_in_channel_before_forced_silence", "virtualserver_antiflood_points_tick_reduce", "virtualserver_antiflood_points_needed_command_block", "virtualserver_antiflood_points_needed_ip_block", "virtualserver_client_connections", "virtualserver_query_client_connections", "virtualserver_queryclientsonline", "virtualserver_download_quota", "virtualserver_upload_quota", "virtualserver_month_bytes_downloaded", "virtualserver_month_bytes_uploaded", "virtualserver_total_bytes_downloaded", "virtualserver_total_bytes_uploaded", "virtualserver_port", "virtualserver_autostart", "virtualserver_machine_id", "virtualserver_needed_identity_security_level", "virtualserver_log_client", "virtualserver_log_query", "virtualserver_log_channel", "virtualserver_log_permissions", "virtualserver_log_server", "virtualserver_log_filetransfer", "virtualserver_min_client_version", "virtualserver_reserved_slots", "virtualserver_total_packetloss_speech", "virtualserver_total_packetloss_keepalive", "virtualserver_total_packetloss_control", "virtualserver_total_packetloss_total", "virtualserver_total_ping", "virtualserver_weblist_enabled", "virtualserver_min_android_version", "virtualserver_min_ios_version", "virtualserver_antiflood_points_needed_plugin_block"] }, + { name="TokenUsed", notify="notifytokenused", attributes=["token", "tokencustomset", "token1", "token2", "clid", "cldbid", "cluid"] }, +] + +# Server to Client Notifications (Low) +[[msg_group]] +default = { s2c=true, c2s=false, response=false, low=true, np=false } +msg = [ + # Response to channelgetdescription + { name="ChannelEditedLow", notify="notifychanneledited", attributes=["cid", "reasonid", "channel_description?"] }, + { name="ClientPoke", notify="notifyclientpoke", attributes=["invokerid", "invokername", "invokeruid?", "msg"] }, +] + +# Server to Client Responses +[[msg_group]] +default = { s2c=true, c2s=false, response=true, low=false, np=false } +msg = [ + # ChannelCreate + { name="ChannelCreateResponse", attributes=["cid"] }, + # channelinfo + { name="ChannelInfoResponse", attributes=["pid", "channel_name", "channel_topic", "channel_description", "channel_password?", "channel_codec", "channel_codec_quality", "channel_maxclients", "channel_maxfamilyclients", "channel_order", "channel_flag_permanent", "channel_flag_semi_permanent", "channel_flag_default", "channel_flag_password", "channel_codec_latency_factor", "channel_codec_is_unencrypted", "channel_security_salt?", "channel_delete_delay", "channel_unique_identifier?", "channel_flag_maxclients_unlimited", "channel_flag_maxfamilyclients_unlimited", "channel_flag_maxfamilyclients_inherited", "channel_filepath", "channel_needed_talk_power", "channel_forced_silence", "channel_name_phonetic?", "channel_icon_id", "channel_banner_gfx_url?", "channel_banner_mode", "seconds_empty"] }, + # channellist + { name="ChannelListResponse", attributes=["cid", "pid", "channel_order", "channel_name", "total_clients", "channel_needed_subscribe_power", + "channel_topic?", # -topic + "channel_flag_default?", # -flags + "channel_flag_password?", # -flags + "channel_flag_permanent?", # -flags + "channel_flag_semi_permanent?", # -flags + "channel_codec?", # -voice + "channel_codec_quality?", # -voice + "channel_needed_talk_power?", # -voice + "total_clients_family?", # -limits + "channel_maxclients?", # -limits + "channel_maxfamilyclients?", # -limits + "channel_icon_id?", # -icon + "seconds_empty?", # -secondsempty + ] }, + # channelfind + { name="ChannelFind", attributes=["cid", "channel_name"] }, + # clientlist + { name="ClientList", attributes=["clid", "cid", "client_database_id", "client_nickname", "client_type", + "client_unique_identifier?", # -uid + "client_away?", # -away + "client_away_message?", # -away + "client_flag_talking?", # -voice + "client_input_muted?", # -voice + "client_output_muted?", # -voice + "client_input_hardware?", # -voice + "client_output_hardware?", # -voice + "client_talk_power?", # -voice + "client_is_talker?", # -voice + "client_is_priority_speaker?", # -voice + "client_is_recording?", # -voice + "client_is_channel_commander?", # -voice + "client_idle_time?", # -times + "client_created?", # -times + "client_lastconnected?", # -times + "client_servergroups?", # -groups + "client_channel_group_id?", # -groups + "client_channel_group_inherited_channel_id?", # -groups + "client_version?", # -info + "client_platform?", # -info + "client_country?", # -country + "connection_client_ip?", # -ip + "client_badges?", # - badges + ] }, + # clientdbinfo + { name="ClientDbInfo", attributes=["client_lastip", "clid", "client_unique_identifier", "cid", "client_database_id", "client_nickname", "client_type", "client_flag_avatar", "client_description", "client_icon_id", "client_created", "client_lastconnected", "client_totalconnections", "client_month_bytes_uploaded", "client_month_bytes_downloaded", "client_total_bytes_uploaded", "client_total_bytes_downloaded", "client_base64HashClientUID"] }, + # clientinfo + { name="ClientInfo", attributes=["client_idle_time", "client_version", "client_version_sign", "client_platform", "client_default_channel", "client_security_hash", "client_login_name", "client_default_token", "connection_filetransfer_bandwidth_sent", "connection_filetransfer_bandwidth_received", "connection_packets_sent_total", "connection_packets_received_total", "connection_bytes_sent_total", "connection_bytes_received_total", "connection_bandwidth_sent_last_second_total", "connection_bandwidth_received_last_second_total", "connection_bandwidth_sent_last_minute_total", "connection_bandwidth_received_last_minute_total", "connection_connected_time", "connection_client_ip", "cid", "client_unique_identifier", "client_database_id", "client_nickname", "client_type", "client_input_muted", "client_output_muted", "client_outputonly_muted", "client_input_hardware", "client_output_hardware", "client_meta_data", "client_is_recording", "client_channel_group_id", "client_channel_group_inherited_channel_id", "client_servergroups", "client_away", "client_away_message", "client_talk_power", "client_talk_request", "client_talk_request_msg", "client_is_talker", "client_is_priority_speaker", "client_unread_messages", "client_nickname_phonetic", "client_needed_serverquery_view_power", "client_is_channel_commander", "client_country", "client_badges", "client_created", "client_lastconnected", "client_totalconnections", "client_month_bytes_uploaded", "client_month_bytes_downloaded", "client_total_bytes_uploaded", "client_total_bytes_downloaded", "client_base64HashClientUID", "client_flag_avatar", "client_description", "client_icon_id", "client_myteamspeak_id?", "client_integrations?"] }, + # serverlist + { name="ServerListResponse", attributes=["virtualserver_id", "virtualserver_port", "virtualserver_status", + "virtualserver_clientsonline?", # not -short + "virtualserver_queryclientsonline?", # not -short + "virtualserver_maxclients?", # not -short + "virtualserver_uptime?", # not -short + "virtualserver_autostart?", # not -short + "virtualserver_machine_id?", # not -short + "virtualserver_name?", # not -short + "virtualserver_unique_identifier?", # -uid + ] }, + # servergroupadd + { name="ServerGroupAddResponse", attributes=["sgid"] }, + # whoami + { name="WhoAmI", attributes=["client_id", "client_channel_id", "client_nickname", "client_database_id", "client_login_name", "client_origin_server_id", "virtualserver_id", "virtualserver_unique_identifier", "virtualserver_port", "virtualserver_status", "client_unique_identifier"] }, +] + +# Server to Client Hybrid +[[msg_group]] +default = { s2c=true, c2s=false, response=true, low=false, np=false } +msg = [ + { name="BanList", notify="notifybanlist", attributes=["banid", "ip", "name", "uid", "mytsid?", "lastnickname", "created", "duration@time", "invokercldbid", "invokername", "invokeruid?", "reason", "enforcements"] }, + { name="ChannelClientPermList", notify="notifychannelclientpermlist", attributes=["cid", "cldbid", "permid?", "permsid?", "permvalue", "permnegated", "permskip"] }, + { name="ChannelCreated", notify="notifychannelcreated", attributes=["cid", "invokerid", "invokername", "invokeruid?", "channel_order", "channel_name", "channel_topic?", "channel_flag_default?", "channel_flag_password?", "channel_flag_permanent?", "channel_flag_semi_permanent?", "channel_codec?", "channel_codec_quality?", "channel_needed_talk_power?", "channel_icon_id?", "channel_maxclients?", "channel_maxfamilyclients?", "channel_codec_latency_factor?", "channel_codec_is_unencrypted?", "channel_delete_delay?", "channel_unique_identifier?", "channel_flag_maxclients_unlimited?", "channel_flag_maxfamilyclients_unlimited?", "channel_flag_maxfamilyclients_inherited?", "channel_name_phonetic?", "channel_storage_quota?", "cpid"] }, + { name="ChannelDeleted", notify="notifychanneldeleted", attributes=["cid", "invokerid", "invokername", "invokeruid?"] }, + # Has no invoker when we requested the description with: channelgetdescription cid=1 + { name="ChannelEdited", notify="notifychanneledited", attributes=["cid", "invokerid?", "invokername?", "invokeruid?", "reasonid", "channel_order?", "channel_name?", "channel_topic?", "channel_flag_default?", "channel_flag_password?", "channel_flag_permanent?", "channel_flag_semi_permanent?", "channel_codec?", "channel_codec_quality?", "channel_needed_talk_power?", "channel_icon_id?", "channel_maxclients?", "channel_maxfamilyclients?", "channel_codec_latency_factor?", "channel_codec_is_unencrypted?", "channel_delete_delay?", "channel_flag_maxclients_unlimited?", "channel_flag_maxfamilyclients_unlimited?", "channel_flag_maxfamilyclients_inherited?", "channel_name_phonetic?", "cpid?", "channel_description?"] }, + { name="ChannelGroupClientList", notify="notifychannelgroupclientlist", attributes=["cid", "cldbid", "cgid"] }, + { name="ChannelGroupList", notify="notifychannelgrouplist", attributes=["cgid", "name", "type@group", "iconid", "savedb", "sortid", "namemode", "n_modifyp", "n_member_addp", "n_member_removep?"] }, + { name="ChannelGroupPermList", notify="notifychannelgrouppermlist", attributes=["cgid", "permid?", "permsid?", "permvalue", "permnegated", "permskip"] }, + { name="ChannelPermList", notify="notifychannelpermlist", attributes=["cid", "permid", "permvalue", "permnegated", "permskip"] }, + { name="ClientDbFind", notify="notifyclientdbfind", attributes=["cldbid", "client_unique_identifier", "client_nickname", "client_lastconnected", "client_totalconnections"] }, + { name="ClientDbIdFromUid", notify="notifyclientdbidfromuid", attributes=["cluid", "cldbid"] }, + { name="ClientDbList", notify="notifyclientdblist", attributes=["cldbid", "client_unique_identifier", "client_nickname", "client_created", "client_lastconnected", "client_totalconnections", "client_description", "client_lastip"] }, + { name="ClientIds", notify="notifyclientids", attributes=["cluid", "clid", "name"] }, + { name="ClientNameFromDbId", notify="notifyclientnamefromdbid", attributes=["cluid", "cldbid", "name"] }, + { name="ClientNameFromUid", notify="notifyclientnamefromuid", attributes=["cluid", "cldbid", "name"] }, + { name="ClientUidFromClid", notify="notifyclientuidfromclid", attributes=["cluid", "clid", "nickname"] }, + { name="ClientPermList", notify="notifyclientpermlist", attributes=["cldbid", "permid?", "permsid?", "permvalue", "permnegated", "permskip"] }, + { name="ClientSetServerQueryLogin", notify="notifyclientserverqueryloginpassword", attributes=["client_login_password"] }, + { name="ComplainList", notify="notifycomplainlist", attributes=["tcldbid", "tname", "fcldbid", "fname", "message", "timestamp"] }, + { name="FileDownload", notify="notifystartdownload", attributes=["clientftfid", "serverftfid", "ftkey", "port", "size", "proto", "ip?"] }, + { name="FileInfo", notify="notifyfileinfo", attributes=["cid", "path", "name", "size", "datetime"] }, + { name="FileList", notify="notifyfilelist", attributes=["cid", "path", "name", "size", "datetime", "type@ft"] }, + { name="Filetransfer", notify="notifyfiletransferlist", attributes=["clid", "path", "name", "size", "sizedone", "clientftfid", "serverftfid", "sender", "status@ft", "current_speed", "average_speed", "runtime"] }, + { name="FileUpload", notify="notifystartupload", attributes=["clientftfid", "serverftfid", "ftkey", "port", "seekpos", "proto", "ip?"] }, + { name="OfflineMessage", notify="notifymessage", attributes=["msgid", "cluid", "subject", "message", "timestamp"] }, + { name="OfflineMessageList", notify="notifymessagelist", attributes=["msgid", "cluid", "subject", "timestamp", "flag_read"] }, + { name="PermFind", notify="notifypermfind", attributes=["t", "id1", "id2", "p"] }, + { name="PermList", notify="notifypermissionlist", attributes=["group_id_end", "permid?", "permname?", "permdesc?"] }, # Note: very weird ordering + { name="PermOverview", notify="notifypermoverview", attributes=["cldbid", "cid", "t", "id1", "id2", "p", "v", "n", "s"] }, + { name="ServerConnectionInfo", notify="notifyserverconnectioninfo", attributes=["connection_filetransfer_bandwidth_sent", "connection_filetransfer_bandwidth_received", "connection_filetransfer_bytes_sent_total", "connection_filetransfer_bytes_received_total", "connection_packets_sent_total", "connection_bytes_sent_total", "connection_packets_received_total", "connection_bytes_received_total", "connection_bandwidth_sent_last_second_total", "connection_bandwidth_sent_last_minute_total", "connection_bandwidth_received_last_second_total", "connection_bandwidth_received_last_minute_total", "connection_connected_time@server", "connection_packetloss_total", "connection_ping"] }, + { name="ServerGroupClientList", notify="notifyservergroupclientlist", attributes=["sgid", "cldbid", "client_nickname?", "client_unique_identifier?"] }, + { name="ServerGroupList", notify="notifyservergrouplist", attributes=["sgid", "name", "type@group", "iconid", "savedb", "sortid", "namemode", "n_modifyp", "n_member_addp", "n_member_removep?"] }, + { name="ServerGroupPermList", notify="notifyservergrouppermlist", attributes=["sgid", "permid?", "permsid?", "permvalue", "permnegated", "permskip"] }, + { name="ServerGroupsByClientId", notify="notifyservergroupsbyclientid", attributes=["name", "sgid", "cldbid"] }, + { name="ServerLog", notify="notifyserverlog", attributes=["last_pos", "file_size", "log"] }, + { name="TextMessage", notify="notifytextmessage", attributes=["targetmode@msg", "msg", "target@msg?", "invokerid", "invokername", "invokeruid?", "timestamp?"] }, + { name="TokenAdd", notify="notifytokenadd", attributes=["token"] }, + { name="TokenList", notify="notifytokenlist", attributes=["token", "token_type", "token_id1", "token_id2", "token_created", "token_description"] }, +] + +# Client to Server Notifications +[[msg_group]] +default = { s2c=false, c2s=true, response=false, low=false, np=false } +msg = [ + { name="ClientInit", notify="clientinit", attributes=["client_nickname", "client_version", "client_platform", "client_input_hardware", "client_output_hardware", "client_input_muted?", "client_output_muted?", "client_away?", "client_away_message?", "client_default_channel", "client_default_channel_password", "client_server_password", "client_meta_data", "client_version_sign", "client_key_offset", "client_nickname_phonetic", "client_default_token", "hwid", "client_badges?", "client_security_hash?", "client_myteamspeak_id?", "client_integrations?", "client_active_integrations_info?", "client_myteamspeak_avatar?", "client_signed_badges?" ] }, + { name="ClientInitIv", notify="clientinitiv", attributes=["alpha", "omega", "ot?", "ip"] }, + { name="PluginCommandRequest", notify="plugincmd", attributes=["name", "data", "targetmode@plugin", "target@plugin?"] }, + # banadd ip=42\\.42\\.42\\.42 name=test uid=b+P0CqXms5I0C+A66HZ4Sbu\/PNw= time=5 banreason=test + # -> void + { name="BanAdd", notify="banadd", attributes=["ip?", "name?", "uid?", "time?", "banreason?"] }, + # banclient uid=Np\/KHoMinRjzz54VORp6Ks\/3b3c= time=1 banreason=this\sperson + # -> void + { name="BanClient", notify="banclient", attributes=["clid", "time?", "banreason?"] }, + # bandel banid=4 + # bandel banid=1 return_code=1:21 return_code=__1:21_1:21 + # error id=0 msg=ok return_code=1:21 + # -> void + { name="BanDel", notify="bandel", attributes=["banid"] }, + # bandelall + # -> void + { name="BanDelAll", notify="bandelall", attributes=[] }, + # banlist return_code=1:5 + # -> {BanList} notifybanlist banid=3 ip=42\\.42\\.42\\.42 name=test uid=b+P0CqXms5I0C+A66HZ4Sbu\/PNw= lastnickname=AudioBud created=1538835372 duration=5 invokername=Splamy invokercldbid=2 invokeruid=uA0U7t4PBxdJ5TLnarsOHQh4\/tY= reason=test enforcements=0 + { name="BanListRequest", notify="banlist", attributes=[] }, + # [NOT FULL] + { name="BindingList", notify="bindinglist", attributes=["subsystem?"] }, + # channeladdperm cid=1 permid=78 permvalue=75 + # -> void + { name="ChannelAddPerm", notify="channeladdperm", attributes=["cid", "permid?", "permsid?", "permvalue"] }, + # channelclientaddperm cid=1 cldbid=2 permid=183 permvalue=1 + # -> void + { name="ChannelClientAddPerm", notify="channelclientaddperm", attributes=["cid", "cldbid", "permid?", "permsid?", "permvalue"] }, + # channelclientdelperm cid=1 cldbid=2 permid=185 + # -> void + { name="ChannelClientDelPerm", notify="channelclientdelperm", attributes=["cid", "cldbid", "permid?", "permsid?"] }, + # channelclientpermlist cid=1 cldbid=2 + # -> {ChannelClientPermList} notifychannelclientpermlist cid=1 cldbid=2 permid=183 permvalue=1 permnegated=0 permskip=0 + { name="ChannelClientPermListRequest", notify="channelclientpermlist", attributes=["cid", "cldbid"] }, # -permsid + # channelcreate cpid=0 channel_name=testcreate channel_codec_quality=6 channel_flag_permanent=1 channel_codec_is_unencrypted=1 channel_flag_maxfamilyclients_unlimited=0 channel_flag_maxfamilyclients_inherited=1 + # -> {ChannelCreated} notifychannelcreated cid=2 cpid=0 channel_name=testcreate channel_codec_quality=6 channel_order=1 channel_flag_permanent=1 channel_codec_is_unencrypted=1 channel_flag_maxfamilyclients_unlimited=0 channel_flag_maxfamilyclients_inherited=1 invokerid=3 invokername=Splamy invokeruid=uA0U7t4PBxdJ5TLnarsOHQh4\/tY= + { name="ChannelCreate", notify="channelcreate", attributes=["cpid?", "channel_name", "channel_topic?", "channel_description?", "channel_password?", "channel_codec?", "channel_codec_quality?", "channel_maxclients?", "channel_maxfamilyclients?", "channel_order?", "channel_flag_password?", "channel_codec_is_unencrypted?", "channel_delete_delay?", "channel_flag_maxclients_unlimited?", "channel_flag_maxfamilyclients_unlimited?", "channel_flag_maxfamilyclients_inherited?", "channel_name_phonetic?", "channel_flag_permanent?", "channel_flag_semi_permanent?", "channel_flag_default?"] }, + # channeldelete cid=2 + # -> {ChannelDeleted} notifychanneldeleted invokerid=3 invokername=Splamy invokeruid=uA0U7t4PBxdJ5TLnarsOHQh4\/tY= + { name="ChannelDelete", notify="channeldelete", attributes=["cid", "force"] }, + # channeldelperm cid=1 permid=78 + # -> void + { name="ChannelDelPerm", notify="channeldelperm", attributes=["cid", "permid?", "permsid?"] }, + # channelgetdescription cid=1 + # -> {ChannelEditedLow} notifychanneledited cid=1 channel_description=blub + { name="ChannelDescriptionRequest", notify="channelgetdescription", attributes=["cid"] }, + # channeledit cid=2 channel_codec=5 + # -> void + { name="ChannelEdit", notify="channeledit", attributes=["cid", "channel_order?", "channel_name?", "channel_topic?", "channel_flag_default?", "channel_flag_password?", "channel_password?", "channel_flag_permanent?", "channel_flag_semi_permanent?", "channel_codec?", "channel_codec_quality?", "channel_needed_talk_power?", "channel_maxclients?", "channel_maxfamilyclients?", "channel_codec_latency_factor?", "channel_codec_is_unencrypted?", "channel_delete_delay?", "channel_flag_maxclients_unlimited?", "channel_flag_maxfamilyclients_unlimited?", "channel_flag_maxfamilyclients_inherited?", "channel_name_phonetic?", "channel_description?"] }, + # channelfind pattern=Def + # -> {ChannelFind} cid=1 channel_name=Default\sChannel|cid=3 channel_name=Default + { name="ChannelFindRequest", notify="channelfind", attributes=["pattern"] }, + # channelgroupadd name=TestGroup type=1 + # -> {ChannelGroupList} notifychannelgrouplist cgid=1 name=Channel\sAdmin type=0 iconid=100 savedb=1 sortid=0 namemode=0 n_modifyp=75 n_member_addp=50 n_member_removep=50|cgid=2 name=Operator type=0 iconid=200 savedb=1 sortid=0 namemode=0 n_modifyp=75 n_member_addp=30 n_member_removep=30|... + { name="ChannelGroupAdd", notify="channelgroupadd", attributes=["name", "type@group?"] }, + # channelgroupaddperm cgid=9 permid=146 permvalue=1 + # -> void + { name="ChannelGroupAddPerm", notify="channelgroupaddperm", attributes=["cgid", "permid?", "permsid?", "permvalue"] }, + # channelgroupclientlist cid=1 cgid=9 cldbid=0 + # -> {ChannelGroupClientList} notifychannelgroupclientlist cid=1 cldbid=2 cgid=9 + { name="ChannelGroupClientListRequest", notify="channelgroupclientlist", attributes=["cid?", "cldbid?", "cgid?"] }, + # channelgroupcopy name=TestGroup2\s(Copy) scgid=9 tcgid=0 + # -> {ChannelGroupList} notifychannelgrouplist ... + { name="ChannelGroupCopy", notify="channelgroupcopy", attributes=["scgid", "tcgid", "name", "type@group"] }, + # channelgroupdel cgid=10 force=0 + # -> {ChannelGroupList} notifychannelgrouplist ... + { name="ChannelGroupDel", notify="channelgroupdel", attributes=["cgid", "force"] }, + # channelgroupdelperm cgid=10 permid=146 + # -> void + { name="ChannelGroupDelPerm", notify="channelgroupdelperm", attributes=["cgid", "permid?", "permsid?"] }, + # channelgrouplist + # -> {ChannelGroupList} notifychannelgrouplist ... + { name="ChannelGroupListRequest", notify="channelgrouplist", attributes=[] }, + # channelgrouppermlist cgid=9 + # -> {ChannelGroupPermList} notifychannelgrouppermlist cgid=9 permid=164 permvalue=75 permnegated=0 permskip=0|permid=166 permvalue=75 permnegated=0 permskip=0|permid=168 permvalue=75 permnegated=0 permskip=0 + { name="ChannelGroupPermListRequest", notify="channelgrouppermlist", attributes=["cgid"] }, # -permsid + # channelgrouprename cgid=9 name=TestGroup2 + # -> {ChannelGroupList} notifychannelgrouplist ... + { name="ChannelGroupRename", notify="channelgrouprename", attributes=["cgid", "name"] }, + # channelinfo cid=3 + # -> {ChannelInfoResponse} pid=0 channel_name=Default channel_topic channel_description channel_password channel_codec=4 channel_codec_quality=6 channel_maxclients=-1 channel_maxfamilyclients=-1 channel_order=1 channel_flag_permanent=0 channel_flag_semi_permanent=0 channel_flag_default=0 channel_flag_password=0 channel_codec_latency_factor=1 channel_codec_is_unencrypted=1 channel_security_salt channel_delete_delay=0 channel_flag_maxclients_unlimited=1 channel_flag_maxfamilyclients_unlimited=0 channel_flag_maxfamilyclients_inherited=1 channel_filepath=files\\virtualserver_1\\channel_3 channel_needed_talk_power=0 channel_forced_silence=0 channel_name_phonetic channel_icon_id=0 channel_flag_private=0 seconds_empty=-1 + { name="ChannelInfoRequest", notify="channelinfo", attributes=["cid"] }, + # channellist + # -> cid=1 pid=0 channel_order=0 channel_name=Default\sChannel total_clients=0 channel_needed_subscribe_power=0|cid=3 pid=0 channel_order=1 channel_name=Default total_clients=1 channel_needed_subscribe_power=0 + { name="ChannelListRequest", notify="channellist", attributes=[] }, # [-topic] [-flags] [-voice] [-limits] [-icon] [-secondsempty] + # channelmove cid=3 cpid=1 + # -> {ChannelMoved} notifychannelmoved cid=3 cpid=1 order=0 reasonid=1 invokerid=3 invokername=Splamy invokeruid=uA0U7t4PBxdJ5TLnarsOHQh4\/tY= + { name="ChannelMove", notify="channelmove", attributes=["cid", "cpid", "order?"] }, + # channelpermlist cid=3 + # -> {ChannelPermList} notifychannelpermlist cid=3 permid=82 permvalue=75 permnegated=0 permskip=0|permid=132 permvalue=75 permnegated=0 permskip=0 + { name="ChannelPermListRequest", notify="channelpermlist", attributes=["cid"] }, # -permsid + # channelsubscribe cid=8 + # -> {ChannelSubscribed} notifychannelsubscribed cid=8 es=31020 + { name="ChannelSubscribe", notify="channelsubscribe", attributes=["cid"] }, + # channelsubscribeall + # -> {ChannelSubscribed} notifychannelsubscribed cid=5 es=30852|cid=6 es=30852|cid=8 es=30852 + { name="ChannelSubscribeAll", notify="channelsubscribeall", attributes=[] }, + # channelunsubscribe cid=8 + # -> {ChannelUnsubscribed} notifychannelunsubscribed cid=8 + { name="ChannelUnsubscribe", notify="channelunsubscribe", attributes=["cid"] }, + # channelunsubscribeall + # -> {ChannelUnsubscribed} notifychannelunsubscribed cid=5|cid=6|cid=8 + { name="ChannelUnsubscribeAll", notify="channelunsubscribeall", attributes=[] }, + # clientaddperm cldbid=2 permid=177 permvalue=75 permskip=0 + # -> {ClientNeededPermissions} notifyclientneededpermissions permid=177 permvalue=75 + { name="ClientAddPerm", notify="clientaddperm", attributes=["cldbid", "permid?", "permsid?", "permvalue", "permskip"] }, + # clientchatclosed clid=3 cluid=uA0U7t4PBxdJ5TLnarsOHQh4\/tY= + # -> void + { name="ClientChatClose", notify="clientchatclosed", attributes=["clid", "cluid"] }, + # getconnectioninfo clid=1 + # -> notifyconnectioninfo clid=1 connection_client_ip=[::1] connection_client_port=58283 connection_client2server_packetloss_speech=0.0000 connection_client2server_packetloss_keepalive=0.0000 connection_client2server_packetloss_control=0.0000 connection_client2server_packetloss_total=0.0000 connection_idle_time=195951 + { name="ClientConnectionInfoRequest", notify="getconnectioninfo", attributes=["clid"] }, + # clientdbdelete cldbid=10 + # -> void + { name="ClientDbDelete", notify="clientdbdelete", attributes=["cldbid"] }, + # TODO !!! + { name="ClientDbEdit", notify="clientdbedit", attributes=["cldbid"] }, # TODO PROPERTIES ! + # clientdbfind pattern=%spl% -details + # clientdbfind pattern=%myuid% -uid -details return_code=1:z + # -> {ClientDbFind} notifyclientdbfind cldbid=2 client_unique_identifier=uA0U7t4PBxdJ5TLnarsOHQh4\/tY= client_nickname=Splamy client_lastconnected=1539260951 client_totalconnections=20 + { name="ClientDbFindRequest", notify="clientdbfind", attributes=["pattern"] }, # -uid, -details || the -details is undocumentd but works in both query/full + # clientdbinfo cldbid=2 + # -> client_unique_identifier=uA0U7t4PBxdJ5TLnarsOHQh4\/tY= client_nickname=Splamy client_database_id=2 client_created=1537603744 client_lastconnected=1539260951 client_totalconnections=20 client_flag_avatar client_description client_month_bytes_uploaded=0 client_month_bytes_downloaded=131916 client_total_bytes_uploaded=0 client_total_bytes_downloaded=144480 client_base64HashClientUID=lianbeoonoapahbhejofdcohgkllaobnaihipong client_lastip=::1 + { name="ClientDbInfoRequest", notify="clientdbinfo", attributes=["cldbid"] }, + # clientdblist start=0 duration=10 + # -> {ClientDbList} notifyclientdblist cldbid=2 client_unique_identifier=uA0U7t4PBxdJ5TLnarsOHQh4\/tY= client_nickname=Splamy client_created=1537603744 client_lastconnected=1539260951 client_totalconnections=20 client_description client_lastip=::1 | ... + { name="ClientDbListRequest", notify="clientdblist", attributes=["start@list?", "duration@list?"] }, # -count + # clientdelperm cldbid=2 permid=177 + # -> {ClientNeededPermissions} notifyclientneededpermissions permid=177 + { name="ClientDelPerm", notify="clientdelperm", attributes=["cldbid", "permid?", "permsid?"] }, + # clientedit clid=2 client_description=desc client_is_talker=1 + { name="ClientEdit", notify="clientedit", attributes=["clid", "client_description?", "client_is_talker?"] }, + # clientfind pattern=Spla + # -> clid=1 client_nickname=Splamy + { name="ClientFindRequest", notify="clientfind", attributes=["pattern"] }, + # clientgetdbidfromuid cluid=uA0U7t4PBxdJ5TLnarsOHQh4\/tY= + # -> {ClientDbIdFromUid} notifyclientdbidfromuid cluid=uA0U7t4PBxdJ5TLnarsOHQh4\/tY= cldbid=2 + { name="ClientDbIdFromUidRequest", notify="clientgetdbidfromuid", attributes=["cluid"] }, + # clientgetids cluid=uA0U7t4PBxdJ5TLnarsOHQh4\/tY= + # -> {ClientIds} notifyclientids cluid=uA0U7t4PBxdJ5TLnarsOHQh4\/tY= clid=1 + { name="ClientIdsRequest", notify="clientgetids", attributes=["cluid"] }, + # clientgetnamefromdbid cldbid=2 + # -> {ClientNameFromDbId} notifyclientnamefromdbid cluid=uA0U7t4PBxdJ5TLnarsOHQh4\/tY= cldbid=2 name=Splamy + { name="ClientNameFromDbIdRequest", notify="clientgetnamefromdbid", attributes=["cldbid"] }, + # clientgetnamefromuid cluid=uA0U7t4PBxdJ5TLnarsOHQh4\/tY= + # -> {ClientNameFromUid} notifyclientnamefromuid cluid=uA0U7t4PBxdJ5TLnarsOHQh4\/tY= cldbid=2 name=Splamy + { name="ClientNameFromUidRequest", notify="clientgetnamefromuid", attributes=["cluid"] }, + # clientgetuidfromclid clid=1 + # -> {ClientUidFromClid} notifyclientuidfromclid clid=1 cluid=uA0U7t4PBxdJ5TLnarsOHQh4\/tY= nickname=Splamy + { name="ClientUidFromClidRequest", notify="clientgetuidfromclid", attributes=["clid"] }, + # clientgetvariables clid=2 + # -> {ClientUpdated} notifyclientupdated clid=2 client_version=3.2.3\s[Build:\s1538467030] client_platform=Windows client_login_name client_created=1538835269 client_lastconnected=1539267929 client_totalconnections=3 client_month_bytes_uploaded=0 client_month_bytes_downloaded=0 client_total_bytes_uploaded=0 client_total_bytes_downloaded=0 + { name="ClientVariablesRequest", notify="clientgetvariables", attributes=["clid"] }, + # clientinfo clid=1 + # -> {ClientInfo?} cid=4 client_idle_time=432921 client_unique_identifier=uA0U7t4PBxdJ5TLnarsOHQh4\/tY= client_nickname=Splamy client_version=3.2.3\s[Build:\s1538467030] client_platform=Windows client_input_muted=0 client_output_muted=0 client_outputonly_muted=0 client_input_hardware=0 client_output_hardware=1 client_default_channel=\/3 client_meta_data client_is_recording=0 client_version_sign=dZ1i\/CsCaAh4F7Pi2F\/FfaBpdTmUuNVsAIRnqm86FUR3HhwBRn+xlmbwRF8gObgFMuwFMCLmawncFWplSILKAQ== client_security_hash client_login_name client_database_id=2 client_channel_group_id=5 client_servergroups=6 client_created=1537603744 client_lastconnected=1539260951 client_totalconnections=20 client_away=0 client_away_message client_type=0 client_flag_avatar client_talk_power=75 client_talk_request=0 client_talk_request_msg client_description client_is_talker=0 client_month_bytes_uploaded=0 client_month_bytes_downloaded=131916 client_total_bytes_uploaded=0 client_total_bytes_downloaded=144480 client_is_priority_speaker=0 client_unread_messages=0 client_nickname_phonetic client_needed_serverquery_view_power=75 client_default_token client_icon_id=0 client_is_channel_commander=0 client_country client_channel_group_inherited_channel_id=4 client_badges=overwolf=0 client_myteamspeak_id client_integrations client_base64HashClientUID=lianbeoonoapahbhejofdcohgkllaobnaihipong connection_filetransfer_bandwidth_sent=0 connection_filetransfer_bandwidth_received=0 connection_packets_sent_total=14972 connection_bytes_sent_total=634932 connection_packets_received_total=19657 connection_bytes_received_total=1176471 connection_bandwidth_sent_last_second_total=81 connection_bandwidth_sent_last_minute_total=81 connection_bandwidth_received_last_second_total=83 connection_bandwidth_received_last_minute_total=87 connection_connected_time=7411717 connection_client_ip=[::1] + { name="ClientInfoRequest", notify="clientinfo", attributes=["clid"] }, + # clientkick reasonid=4 reasonmsg=yo clid=3 + # -> {ClientMoved} notifyclientmoved ctid=1 reasonid=4 invokerid=1 invokername=Splamy invokeruid=uA0U7t4PBxdJ5TLnarsOHQh4\/tY= reasonmsg=yo clid=3 + { name="ClientKick", notify="clientkick", attributes=["clid", "reasonid", "reasonmsg?"] }, + # clientlist + # clid=1 cid=4 client_database_id=2 client_nickname=Splamy client_type=0 | ... + { name="ClientListRequest", notify="clientlist", attributes=[] }, # [-uid] [-away] [-voice] [-times] [-groups] [-info] [-country] [-ip] [-badges] + # clientmove cid=4 cpw clid=2 + # -> {ClientMoved} notifyclientmoved ctid=4 reasonid=1 invokerid=1 invokername=Splamy invokeruid=uA0U7t4PBxdJ5TLnarsOHQh4\/tY= clid=3 + { name="ClientMove", notify="clientmove", attributes=["clid", "cid", "cpw?"] }, + # clientpermlist cldbid=2 + # -> {ClientPermList} notifyclientpermlist cldbid=2 permid=177 permvalue=75 permnegated=0 permskip=0 + { name="ClientPermListRequest", notify="clientpermlist", attributes=["cldbid"] }, # -permsid + # clientpoke clid=3 msg=hi + # -> void + { name="ClientPokeRequest", notify="clientpoke", attributes=["clid", "msg"] }, + # clientsetserverquerylogin cldbid=2 client_login_name=hax client_login_password + # -> {ClientSetServerQueryLogin} notifyclientserverqueryloginpassword client_login_password=qm2niw4m + { name="ClientSetServerQueryLoginRequest", notify="clientsetserverquerylogin", attributes=["client_login_name", "client_login_password?", "cldbid?"] }, # 'client_login_password' is always ignored, 'cldbid' only exists for full client(?) + # clientupdate client_nickname=Seebi1 client_input_muted=1 client_away=1 client_away_message=AFK return_code=__1_ + { name="ClientUpdate", notify="clientupdate", attributes=["client_nickname?", "client_input_muted?", "client_output_muted?", "client_away?", "client_away_message?", "client_input_hardware?", "client_output_hardware?", "client_is_channel_commander?", "client_flag_avatar?", "client_nickname_phonetic?", "client_talk_request@clientupdate?", "client_talk_request_msg?", "client_is_recording?", "client_badges?"] }, + # complainadd tcldbid=7 message=annoying + # -> void + { name="ComplainAdd", notify="complainadd", attributes=["tcldbid", "message"] }, + # complaindel tcldbid=7 fcldbid=2 + # -> void + { name="ComplainDel", notify="complaindel", attributes=["tcldbid", "fcldbid"] }, + # complaindelall tcldbid=7 + # -> void + { name="ComplainDelAll", notify="complaindelall", attributes=["tcldbid"] }, + # complainlist tcldbid=0 + # -> {ComplainList} notifycomplainlist tcldbid=7 tname=Test01 fcldbid=2 fname=Splamy message=annoying timestamp=1539269750 + { name="ComplainListRequest", notify="complainlist", attributes=["tcldbid?"] }, + # customdelete ident=s cldbid=2 + # -> void + { name="CustomDelete", notify="customdelete", attributes=["cldbid", "ident"] }, + # custominfo cldbid=2 + # cldbid=2 ident=s value=1234 + { name="CustomInfoRequest", notify="custominfo", attributes=["cldbid"] }, + # customsearch ident=s pattern=%1% + # -> cldbid=2 ident=s value=1234 + { name="CustomSearch", notify="customsearch", attributes=["ident", "pattern"] }, + # customset cldbid=2 ident=s value=1234 + # -> void + { name="CustomSet", notify="customset", attributes=["cldbid", "ident", "value"] }, + # ftcreatedir cid=4 cpw dirname=\/test + # -> void + { name="CreateDirectory", notify="ftcreatedir", attributes=["cid", "cpw", "dirname"] }, + # ftdeletefile cid=4 cpw name=\/Doxyfile2 + # -> void + { name="DeleteFile", notify="ftdeletefile", attributes=["cid", "cpw", "name"] }, + # ftgetfileinfo cid=7 name=\/Egg.ogg cpw + # -> {FileInfo} notifyfileinfo cid=7 name=\/Egg.ogg size=6009201 datetime=1523479202 + { name="FileInfoRequest", notify="ftgetfileinfo", attributes=["cid", "cpw", "name"] }, + # ftgetfilelist cid=4 cpw path=\/ + # -> {FileList} notifyfilelist cid=4 path=\/ return_code=1:15 name=Doxyfile size=11984 datetime=1539276009 type=1 + # -> {FileListFinished} notifyfilelistfinished cid=4 path=\/ + { name="FileListRequest", notify="ftgetfilelist", attributes=["cid", "cpw", "path"] }, + # ftinitdownload clientftfid=4096 name=\/Doxyfile2 cid=4 cpw seekpos=0 proto=1 + # -> {FileDownload} notifystartdownload clientftfid=4096 serverftfid=1 ftkey=YkmvbK7ibKPJPTRONaY68j3S\/fjx7dkO port=30033 size=11984 proto=1 + { name="InitDownload", notify="ftinitdownload", attributes=["clientftfid", "name", "cid", "cpw", "seekpos", "proto"] }, + # ftinitupload clientftfid=4096 name=\/Doxyfile size=11984 cid=4 cpw overwrite=0 resume=0 proto=1 + # -> {FileUpload} notifystartupload clientftfid=4096 serverftfid=1 ftkey=U2VNc4+cRZdCKMdR6JECqfz8Ix1L40SM port=30033 seekpos=0 proto=1 + { name="InitUpload", notify="ftinitupload", attributes=["clientftfid", "name", "cid", "cpw", "size", "overwrite", "resume", "proto"] }, + # ftlist + # -> {Filetransfer} notifyfiletransferlist clid=1 path=files\\virtualserver_1\\channel_4 name=Win10_1709_German_x64_Pro.iso size=3825467392 sizedone=1324744704 clientftfid=4096 serverftfid=1 sender=0 status=1 current_speed=101380912.0000 average_speed=98684800.0000 runtime=13 + { name="ListFiletransfers", notify="ftlist", attributes=[] }, + # ftrenamefile cid=4 cpw tcid=4 tcpw oldname=\/Doxyfile newname=\/Doxyfile2 + # -> void + { name="RenameFile", notify="ftrenamefile", attributes=["cid", "cpw", "tcid?", "tcpw?", "oldname", "newname"] }, + # ftstop serverftfid=1 clientftfid=4096 delete=1 + # -> {FiletransferStatus} notifystatusfiletransfer clientftfid=4096 status=2066 msg=file\stransfer\scanceled size=1736753152 + { name="StopFiletransfer", notify="ftstop", attributes=["serverftfid", "delete"] }, + # gm msg=test + # -> {TextMessage} notifytextmessage targetmode=3 msg=test invokerid=0 invokername=Server + { name="GlobalMessage", notify="gm", attributes=["msg"] }, + # hostinfo + # -> instance_uptime=2654 host_timestamp_utc=1539341335 virtualservers_running_total=1 virtualservers_total_maxclients=32 virtualservers_total_clients_online=1 virtualservers_total_channels_online=1 connection_filetransfer_bandwidth_sent=0 connection_filetransfer_bandwidth_received=0 connection_filetransfer_bytes_sent_total=0 connection_filetransfer_bytes_received_total=0 connection_packets_sent_total=3753 connection_bytes_sent_total=188803 connection_packets_received_total=3755 connection_bytes_received_total=167844 connection_bandwidth_sent_last_second_total=81 connection_bandwidth_sent_last_minute_total=81 connection_bandwidth_received_last_second_total=83 connection_bandwidth_received_last_minute_total=87 + { name="HostInfoRequest", notify="hostinfo", attributes=[] }, + # TODO !!! + { name="InstanceEdit", notify="instanceedit", attributes=[] }, # TODO PROPERTIES ! + # instanceinfo + # -> serverinstance_database_version=29 serverinstance_filetransfer_port=30033 serverinstance_max_download_total_bandwidth=18446744073709551615 serverinstance_max_upload_total_bandwidth=18446744073709551615 serverinstance_guest_serverquery_group=1 serverinstance_serverquery_flood_commands=10 serverinstance_serverquery_flood_time=3 serverinstance_serverquery_ban_time=600 serverinstance_template_serveradmin_group=3 serverinstance_template_serverdefault_group=5 serverinstance_template_channeladmin_group=1 serverinstance_template_channeldefault_group=4 serverinstance_permissions_version=21 serverinstance_pending_connections_per_ip=0 + { name="InstanceInfo", notify="instanceinfo", attributes=[] }, + # logadd loglevel=1 logmsg=test + # -> void + { name="LogAdd", notify="logadd", attributes=["loglevel", "logmsg"] }, + # login $ + # -> void + { name="Login", notify="login", attributes=["client_login_name", "client_login_password"] }, + # logout + # -> void + { name="Logout", notify="logout", attributes=[] }, + # logview lines=100 begin_pos=0 reverse=1 instance=0 + # -> {ServerLog} notifyserverlog last_pos=0 file_size=9148 l=2018-10-12\s10:52:30.795253\pERROR\s\s\s\pCustom\s\s\s\s\s\s\s\s\p1\s\s\ptest|l=2018-10-12\s10:48:55.130491\pINFO\s\s\s\s\pVirtualServerBase\p1\s\s\pquery\sclient\sdisconnected\s'serveradmin\sfrom\s127.0.0.1:51093'(id:1)\sreason\s'reasonmsg=connection\slost'| ... + { name="LogView", notify="logview", attributes=["lines?", "reverse?", "instance?", "begin_pos?"] }, + # messageadd cluid=uA0U7t4PBxdJ5TLnarsOHQh4\/tY= subject=hrad message=ms + # -> void + { name="OfflineMessageAdd", notify="messageadd", attributes=["cluid", "subject", "message"] }, + # messagedel msgid=1 + # -> {ClientUpdated} notifyclientupdated clid=4 client_unread_messages=0 + { name="OfflineMessageDel", notify="messagedel", attributes=["msgid"] }, + # messageget msgid=1 + # -> {OfflineMessage} notifymessage msgid=1 cluid=uA0U7t4PBxdJ5TLnarsOHQh4\/tY= subject=hrad message=ms timestamp=1539341886 + { name="OfflineMessageGet", notify="messageget", attributes=["msgid"] }, + # messagelist + # -> {OfflineMessageList} notifymessagelist msgid=1 cluid=uA0U7t4PBxdJ5TLnarsOHQh4\/tY= subject=hrad timestamp=1539341886 flag_read=0 + { name="OfflineMessageListRequest", notify="messagelist", attributes=[] }, + # messageupdateflag msgid=1 flag=1 + # -> {ClientUpdated} notifyclientupdated clid=4 client_unread_messages=0 + { name="OfflineMessageUpdateFlag", notify="messageupdateflag", attributes=["msgid", "flag"] }, + # permfind permid=1 + # -> {PermFind} notifypermfind t=0 id1=6 id2=0 p=1 + { name="PermFindRequest", notify="permfind", attributes=["permid?", "permsid?"] }, + # permget permid=1 + # -> permsid=b_serverinstance_help_view permid=1 permvalue=1 + { name="PermRequest", notify="permget", attributes=["permid"] }, + # permidgetbyname permsid=b_serverinstance_permission_list + # -> permsid=b_serverinstance_permission_list permid=6 + { name="PermIdByNameRequest", notify="permidgetbyname", attributes=["permsid"] }, + # permissionlist + # -> {PermList} notifypermissionlist group_id_end=0|group_id_end=7|group_id_end=13|group_id_end=18|group_id_end=21|group_id_end=21|group_id_end=33|group_id_end=47|group_id_end=77|group_id_end=82|group_id_end=83|group_id_end=106|group_id_end=126|group_id_end=132|group_id_end=143|group_id_end=151|group_id_end=160|group_id_end=162|group_id_end=170|group_id_end=172|group_id_end=190|group_id_end=197|group_id_end=215|group_id_end=227|group_id_end=232|group_id_end=248|permname=b_serverinstance_help_view permdesc=Retrieve\sinformation\sabout\sServerQuery\scommands|permname=b_serverinstance_version_view permdesc=Retrieve\sglobal\sserver\sversion\s(including\splatform\sand\sbuild\snumber)|permname=b_serverinstance_info_view permdesc=Retrieve\sglobal\sserver\sinformation|permname=b_serverinstance_virtualserver_list permdesc=List\svirtual\sservers\sstored\sin\sthe\sdatabase|... + { name="PermListRequest", notify="permissionlist", attributes=[] }, + # permoverview cid=1 cldbid=2 permid=1 + # -> {PermOverview} notifypermoverview cldbid=2 cid=1 t=0 id1=6 id2=0 p=1 v=1 n=0 s=0 + { name="PermOverviewRequest", notify="permoverview", attributes=["cid", "cldbid", "permid?", "permsid?"] }, + # TODO + { name="PermReset", notify="permreset", attributes=[] }, + # {TokenAddRequest} + # -> (same) + { name="PrivilegeKeyAddRequest", notify="privilegekeyadd", attributes=["tokentype", "tokenid1", "tokenid2", "tokendescription?", "tokencustomset?"] }, + # {TokenDelete} + # -> (same) + { name="PrivilegeKeyDelete", notify="privilegekeydelete", attributes=["token"] }, + # {TokenListRequest} + # -> (same) + { name="PrivilegeKeyListRequest", notify="privilegekeylist", attributes=[] }, + # {TokenUse} + # -> (same) + { name="PrivilegeKeyUse", notify="privilegekeyuse", attributes=["token"] }, + # quit $ + # -> void + { name="Quit", notify="quit", attributes=[] }, + # sendtextmessage targetmode=2 msg=hi + # -> {TextMessage} notifytextmessage targetmode=2 msg=hi invokerid=4 invokername=Splamy invokeruid=uA0U7t4PBxdJ5TLnarsOHQh4\/tY= + { name="SendTextMessage", notify="sendtextmessage", attributes=["targetmode@msg", "target@msg?", "msg"] }, + # TODO + { name="ServerCreate", notify="servercreate", attributes=["virtualserver_name"] }, # TODO PROPERTIES ! + # TODO + { name="ServerDelete", notify="serverdelete", attributes=["sid"] }, + # virtualserver_password is sent two times in this message by the official client + { name="ServerEdit", notify="serveredit", attributes=["sid?", "virtualserver_name?", "virtualserver_welcomemessage?", "virtualserver_maxclients?", "virtualserver_password?", "virtualserver_hostmessage?", "virtualserver_hostmessage_mode?", "virtualserver_hostbanner_url?", "virtualserver_hostbanner_gfx_url?", "virtualserver_hostbanner_gfx_interval?", "virtualserver_hostbutton_tooltip?", "virtualserver_hostbutton_url?", "virtualserver_hostbutton_gfx_url?", "virtualserver_icon_id?", "virtualserver_reserved_slots?", "virtualserver_hostbanner_mode?", "virtualserver_nickname?", "virtualserver_max_download_total_bandwidth?", "virtualserver_max_upload_total_bandwidth?", "virtualserver_download_quota?", "virtualserver_upload_quota?", "virtualserver_antiflood_points_tick_reduce?", "virtualserver_antiflood_points_needed_command_block?", "virtualserver_antiflood_points_needed_ip_block?", "virtualserver_codec_encryption_mode?", "virtualserver_needed_identity_security_level?", "virtualserver_default_server_group?", "virtualserver_default_channel_group?", "virtualserver_default_channel_admin_group?", "virtualserver_complain_autoban_count?", "virtualserver_complain_autoban_time?", "virtualserver_complain_remove_time?", "virtualserver_min_clients_in_channel_before_forced_silence?", "virtualserver_priority_speaker_dimm_modificator?", "virtualserver_name_phonetic?", "virtualserver_channel_temp_delete_delay_default?", "virtualserver_weblist_enabled?", "virtualserver_log_client?", "virtualserver_log_query?", "virtualserver_log_channel?", "virtualserver_log_permissions?", "virtualserver_log_server?", "virtualserver_log_filetransfer?"] }, + # servergetvariables + # -> {ServerUpdated} notifyserverupdated virtualserver_welcomemessage=Welcome\sto\sTeamSpeak,\scheck\s[URL]www.teamspeak.com[\/URL]\sfor\slatest\sinformation virtualserver_maxclients=32 virtualserver_clientsonline=2 virtualserver_channelsonline=1 virtualserver_uptime=1523 virtualserver_hostmessage virtualserver_hostmessage_mode=0 virtualserver_flag_password=0 virtualserver_default_channel_admin_group=5 virtualserver_max_download_total_bandwidth=18446744073709551615 virtualserver_max_upload_total_bandwidth=18446744073709551615 virtualserver_complain_autoban_count=5 virtualserver_complain_autoban_time=1200 virtualserver_complain_remove_time=3600 virtualserver_min_clients_in_channel_before_forced_silence=100 virtualserver_antiflood_points_tick_reduce=5 virtualserver_antiflood_points_needed_command_block=150 virtualserver_antiflood_points_needed_ip_block=250 virtualserver_client_connections=1 virtualserver_query_client_connections=1 virtualserver_queryclientsonline=1 virtualserver_download_quota=18446744073709551615 virtualserver_upload_quota=18446744073709551615 virtualserver_month_bytes_downloaded=143900 virtualserver_month_bytes_uploaded=1737584828 virtualserver_total_bytes_downloaded=156464 virtualserver_total_bytes_uploaded=1737647648 virtualserver_port=9987 virtualserver_autostart=1 virtualserver_machine_id virtualserver_needed_identity_security_level=8 virtualserver_log_client=1 virtualserver_log_query=1 virtualserver_log_channel=1 virtualserver_log_permissions=1 virtualserver_log_server=1 virtualserver_log_filetransfer=1 virtualserver_min_client_version=1513163251 virtualserver_reserved_slots=0 virtualserver_total_packetloss_speech=0.0000 virtualserver_total_packetloss_keepalive=0.0000 virtualserver_total_packetloss_control=0.0000 virtualserver_total_packetloss_total=0.0000 virtualserver_total_ping=0.0000 virtualserver_weblist_enabled=1 virtualserver_min_android_version=1502275280 virtualserver_min_ios_version=1502275280 virtualserver_antiflood_points_needed_plugin_block=0 + { name="ServerVariablesRequest", notify="servergetvariables", attributes=[] }, + # servergroupadd name=test type=1 + # -> {ServerGroupList} notifyservergrouplist sgid=1 name=Guest\sServer\sQuery type=2 iconid=0 savedb=0 sortid=0 namemode=0 n_modifyp=100 n_member_addp=0 n_member_removep=0|... + { name="ServerGroupAdd", notify="servergroupadd", attributes=["name", "type@group?"] }, + # servergroupaddclient sgid=9 cldbid=2 + # -> void + { name="ServerGroupAddClient", notify="servergroupaddclient", attributes=["sgid", "cldbid"] }, + # servergroupaddperm sgid=9 permid=179 permvalue=1 permnegated=0 permskip=0 + # -> void + { name="ServerGroupAddPerm", notify="servergroupaddperm", attributes=["sgid", "permid?", "permsid?", "permvalue", "permnegated", "permskip"] }, + # TODO + { name="ServerGroupAutoAddPerm", notify="servergroupautoaddperm", attributes=["sgtype", "permid?", "permsid?", "permvalue", "permnegated", "permskip"] }, + # TODO + { name="ServerGroupAutoDelPerm", notify="servergroupautodelperm", attributes=["sgtype", "permid?", "permsid?"] }, + # servergroupclientlist sgid=6 -names + # -> {ServerGroupClientList} notifyservergroupclientlist sgid=6 cldbid=2 client_nickname=Splamy client_unique_identifier=uA0U7t4PBxdJ5TLnarsOHQh4\/tY=|cldbid=4 client_nickname=AudioBud client_unique_identifier=b+P0CqXms5I0C+A66HZ4Sbu\/PNw=|cldbid=8 client_nickname=Bot client_unique_identifier=lks7QL5OVMKo4pZ79cEOI5r5oEA=|cldbid=48 client_nickname=TestClient1 client_unique_identifier=r6YwpyjxGM7nJp21NlgCoaLRg9I= + { name="ServerGroupClientListRequest", notify="servergroupclientlist", attributes=["sgid"] }, # -names + # servergroupcopy name=test\s(Copy) ssgid=9 tsgid=0 type=1 + # -> {ServerGroupList} notifyservergrouplist ... + { name="ServerGroupCopy", notify="servergroupcopy", attributes=["ssgid", "tsgid", "name", "type@group"] }, + # servergroupdel sgid=10 force=0 + # -> void + { name="ServerGroupDel", notify="servergroupdel", attributes=["sgid", "force"] }, + # servergroupdelclient sgid=9 cldbid=2 + # -> void + { name="ServerGroupDelClient", notify="servergroupdelclient", attributes=["sgid", "cldbid"] }, + # servergroupdelperm sgid=9 permid=179 + # -> void + { name="ServerGroupDelPerm", notify="servergroupdelperm", attributes=["sgid", "permid?", "permsid?"] }, + # servergrouplist + # -> {ServerGroupList} notifyservergrouplist ... + { name="ServerGroupListRequest", notify="servergrouplist", attributes=[] }, + # servergrouppermlist sgid=7 + # -> {ServerGroupPermList} notifyservergrouppermlist sgid=7 permid=23 permvalue=1 permnegated=0 permskip=0|permid=24 permvalue=1 permnegated=0 permskip=0|... + { name="ServerGroupPermListRequest", notify="servergrouppermlist", attributes=["sgid"] }, # -permsid + # servergrouprename sgid=9 name=testYY + # -> {ServerGroupList} notifyservergrouplist ... + { name="ServerGroupRename", notify="servergrouprename", attributes=["sgid", "name"] }, + # servergroupsbyclientid cldbid=2 + # -> {ServerGroupsByClientId} notifyservergroupsbyclientid name=Server\sAdmin sgid=6 cldbid=2|name=Normal sgid=7 cldbid=2|name=testYY sgid=9 cldbid=2 + { name="ServerGroupsByClientIdRequest", notify="servergroupsbyclientid", attributes=["cldbid"] }, + # serveridgetbyport virtualserver_port=9987 + # -> server_id=1 + { name="ServerIdGetByPort", notify="serveridgetbyport", attributes=["virtualserver_port"] }, + # serverinfo + # -> virtualserver_unique_identifier=SwHpaSmzsKpQ4ksmdkMFOMpBhqA= virtualserver_name=TeamSpeak\s]I[\sServer virtualserver_welcomemessage=Welcome\sto\sTeamSpeak,\scheck\s[URL]www.teamspeak.com[\/URL]\sfor\slatest\sinformation virtualserver_platform=Windows virtualserver_version=3.4.0\s[Build:\s1536564584] virtualserver_maxclients=32 virtualserver_password virtualserver_clientsonline=1 virtualserver_channelsonline=1 virtualserver_created=1537603734 virtualserver_uptime=7590 virtualserver_codec_encryption_mode=0 virtualserver_hostmessage virtualserver_hostmessage_mode=0 virtualserver_filebase=files\\virtualserver_1 virtualserver_default_server_group=8 virtualserver_default_channel_group=8 virtualserver_flag_password=0 virtualserver_default_channel_admin_group=5 virtualserver_max_download_total_bandwidth=18446744073709551615 virtualserver_max_upload_total_bandwidth=18446744073709551615 virtualserver_hostbanner_url virtualserver_hostbanner_gfx_url virtualserver_hostbanner_gfx_interval=0 virtualserver_complain_autoban_count=5 virtualserver_complain_autoban_time=1200 virtualserver_complain_remove_time=3600 virtualserver_min_clients_in_channel_before_forced_silence=100 virtualserver_priority_speaker_dimm_modificator=-18.0000 virtualserver_id=1 virtualserver_antiflood_points_tick_reduce=5 virtualserver_antiflood_points_needed_command_block=150 virtualserver_antiflood_points_needed_ip_block=250 virtualserver_client_connections=5 virtualserver_query_client_connections=4 virtualserver_hostbutton_tooltip virtualserver_hostbutton_url virtualserver_hostbutton_gfx_url virtualserver_queryclientsonline=0 virtualserver_download_quota=18446744073709551615 virtualserver_upload_quota=18446744073709551615 virtualserver_month_bytes_downloaded=143900 virtualserver_month_bytes_uploaded=1737584828 virtualserver_total_bytes_downloaded=156464 virtualserver_total_bytes_uploaded=1737647648 virtualserver_port=9987 virtualserver_autostart=1 virtualserver_machine_id virtualserver_needed_identity_security_level=8 virtualserver_log_client=1 virtualserver_log_query=1 virtualserver_log_channel=1 virtualserver_log_permissions=1 virtualserver_log_server=1 virtualserver_log_filetransfer=1 virtualserver_min_client_version=1513163251 virtualserver_name_phonetic virtualserver_icon_id=0 virtualserver_reserved_slots=0 virtualserver_total_packetloss_speech=0.0000 virtualserver_total_packetloss_keepalive=0.0000 virtualserver_total_packetloss_control=0.0000 virtualserver_total_packetloss_total=0.0000 virtualserver_total_ping=0.0000 virtualserver_ip=0.0.0.0,\s:: virtualserver_weblist_enabled=1 virtualserver_ask_for_privilegekey=0 virtualserver_hostbanner_mode=0 virtualserver_channel_temp_delete_delay_default=0 virtualserver_min_android_version=1502275280 virtualserver_min_ios_version=1502275280 virtualserver_nickname virtualserver_antiflood_points_needed_plugin_block=0 virtualserver_status=online connection_filetransfer_bandwidth_sent=0 connection_filetransfer_bandwidth_received=0 connection_filetransfer_bytes_sent_total=0 connection_filetransfer_bytes_received_total=0 connection_packets_sent_speech=0 connection_bytes_sent_speech=0 connection_packets_received_speech=0 connection_bytes_received_speech=0 connection_packets_sent_keepalive=17990 connection_bytes_sent_keepalive=737590 connection_packets_received_keepalive=17990 connection_bytes_received_keepalive=755578 connection_packets_sent_control=620 connection_bytes_sent_control=121323 connection_packets_received_control=636 connection_bytes_received_control=78134 connection_packets_sent_total=18610 connection_bytes_sent_total=858913 connection_packets_received_total=18626 connection_bytes_received_total=833712 connection_bandwidth_sent_last_second_total=81 connection_bandwidth_sent_last_minute_total=83 connection_bandwidth_received_last_second_total=83 connection_bandwidth_received_last_minute_total=90 + { name="ServerInfo", notify="serverinfo", attributes=[] }, + # serverlist + # -> {ServerListResponse} virtualserver_id=1 virtualserver_port=9987 virtualserver_status=online virtualserver_clientsonline=1 virtualserver_queryclientsonline=0 virtualserver_maxclients=32 virtualserver_uptime=7629 virtualserver_name=TeamSpeak\s]I[\sServer virtualserver_autostart=1 virtualserver_machine_id + { name="ServerListRequest", notify="serverlist", attributes=[] }, # -uid -short -all -onlyoffline + # [NOT FULL] + { name="ServerNotifyRegister", notify="servernotifyregister", attributes=["event", "id?"] }, + # [NOT FULL] + { name="ServerNotifyUnregister", notify="servernotifyunregister", attributes=[] }, + # TODO + { name="ServerProcessStop", notify="serverprocessstop", attributes=["reasonmsg?"] }, + # serverrequestconnectioninfo + # -> {ServerConnectionInfo} notifyserverconnectioninfo connection_filetransfer_bandwidth_sent=0 connection_filetransfer_bandwidth_received=0 connection_filetransfer_bytes_sent_total=0 connection_filetransfer_bytes_received_total=0 connection_packets_sent_total=1789 connection_bytes_sent_total=94989 connection_packets_received_total=1791 connection_bytes_received_total=81239 connection_bandwidth_sent_last_second_total=863 connection_bandwidth_sent_last_minute_total=107 connection_bandwidth_received_last_second_total=251 connection_bandwidth_received_last_minute_total=93 connection_connected_time=1703 connection_packetloss_total=0.0000 connection_ping=0.0000 + { name="ServerConnectionInfoRequest", notify="serverrequestconnectioninfo", attributes=[] }, + # TODO + { name="ServerSnapshotCreate", notify="serversnapshotcreate", attributes=[] }, + # TODO + { name="ServerSnapshotDeploy", notify="serversnapshotdeploy", attributes=[] }, # -mapping + # TODO + { name="ServerStart", notify="serverstart", attributes=["sid"] }, + # TODO + { name="ServerStop", notify="serverstop", attributes=["sid", "reasonmsg?"] }, + # servertemppasswordadd pw=1234 desc=asdf duration=42 tcid=1 tcpw=4321 + # -> void + { name="ServerTempPasswordAdd", notify="servertemppasswordadd", attributes=["pw", "desc", "duration@time", "tcid", "tcpw"] }, + # servertemppassworddel pw=1234 + # -> void + { name="ServerTempPasswordDel", notify="servertemppassworddel", attributes=["pw"] }, + # servertemppasswordlist + # -> {ServerTempPasswordList} notifyservertemppasswordlist nickname=Splamy uid=uA0U7t4PBxdJ5TLnarsOHQh4\/tY= desc=asdf pw_clear=1234 start=1539346669 end=1539346711 tcid=1 tcpw=4321 + { name="ServerTempPasswordListRequest", notify="servertemppasswordlist", attributes=[] }, + # setclientchannelgroup cgid=9 cid=1 cldbid=2 + # -> {ClientChannelGroupChanged} notifyclientchannelgroupchanged invokerid=3 invokername=Splamy invokeruid=uA0U7t4PBxdJ5TLnarsOHQh4\/tY= cgid=9 cid=3 clid=3 cgi=3 + { name="SetClientChannelGroup", notify="setclientchannelgroup", attributes=["cgid", "cid", "cldbid"] }, + # setconnectioninfo connection_ping=0.0000 connection_ping_deviation=0.3143 connection_packets_sent_speech=1 connection_packets_sent_keepalive=10 connection_packets_sent_control=44 connection_bytes_sent_speech=44 connection_bytes_sent_keepalive=412 connection_bytes_sent_control=5830 connection_packets_received_speech=0 connection_packets_received_keepalive=10 connection_packets_received_control=40 connection_bytes_received_speech=0 connection_bytes_received_keepalive=408 connection_bytes_received_control=5421 connection_server2client_packetloss_speech=0.0000 connection_server2client_packetloss_keepalive=0.0000 connection_server2client_packetloss_control=0.0000 connection_server2client_packetloss_total=0.0000 connection_bandwidth_sent_last_second_speech=0 connection_bandwidth_sent_last_second_keepalive=40 connection_bandwidth_sent_last_second_control=552 connection_bandwidth_sent_last_minute_speech=4 connection_bandwidth_sent_last_minute_keepalive=41 connection_bandwidth_sent_last_minute_control=639 connection_bandwidth_received_last_second_speech=0 connection_bandwidth_received_last_second_keepalive=40 connection_bandwidth_received_last_second_control=147 connection_bandwidth_received_last_minute_speech=0 connection_bandwidth_received_last_minute_keepalive=41 connection_bandwidth_received_last_minute_control=595 + { name="SetConnectionInfo", notify="setconnectioninfo", attributes=["connection_ping", "connection_ping_deviation", "connection_packets_sent_speech", "connection_packets_sent_keepalive", "connection_packets_sent_control", "connection_bytes_sent_speech", "connection_bytes_sent_keepalive", "connection_bytes_sent_control", "connection_packets_received_speech", "connection_packets_received_keepalive", "connection_packets_received_control", "connection_bytes_received_speech", "connection_bytes_received_keepalive", "connection_bytes_received_control", "connection_server2client_packetloss_speech", "connection_server2client_packetloss_keepalive", "connection_server2client_packetloss_control", "connection_server2client_packetloss_total", "connection_bandwidth_sent_last_second_speech", "connection_bandwidth_sent_last_second_keepalive", "connection_bandwidth_sent_last_second_control", "connection_bandwidth_sent_last_minute_speech", "connection_bandwidth_sent_last_minute_keepalive", "connection_bandwidth_sent_last_minute_control", "connection_bandwidth_received_last_second_speech", "connection_bandwidth_received_last_second_keepalive", "connection_bandwidth_received_last_second_control", "connection_bandwidth_received_last_minute_speech", "connection_bandwidth_received_last_minute_keepalive", "connection_bandwidth_received_last_minute_control"] }, + # tokenadd tokentype=0 tokenid1=7 tokenid2=0 tokendescription=test + # -> {TokenAdd} notifytokenadd token=jnKIAfA2aiDW9ZMPj5CPmuXLIOR3tdYwDn70B9Hw + { name="TokenAddRequest", notify="tokenadd", attributes=["tokentype", "tokenid1", "tokenid2", "tokendescription?", "tokencustomset?"] }, + # tokendelete token=ECsX5mdv9YlHRMB90mkfd4SIIJh2W62TRqn8p+RS + # -> void + { name="TokenDelete", notify="tokendelete", attributes=["token"] }, + # tokenlist + # -> {TokenList} notifytokenlist token=jnKIAfA2aiDW9ZMPj5CPmuXLIOR3tdYwDn70B9Hw token_type=0 token_id1=7 token_id2=0 token_created=1539343950 token_description=test|... + { name="TokenListRequest", notify="tokenlist", attributes=[] }, + # tokenuse token=CHu62WH7P5vVhNP3NnLS4hxoVgWdKeAwdU8q7Iaf + # -> (vary) + { name="TokenUse", notify="tokenuse", attributes=["token"] }, + # use $ + # -> void + { name="Use", notify="use", attributes=["sid?", "port?"] }, # -virtual + # version + # -> version=3.4.0 build=1536564584 platform=Windows + { name="VersionRequest", notify="version", attributes=[] }, + # whoami + # -> {WhoAmI} virtualserver_status=online virtualserver_id=1 virtualserver_unique_identifier=SwHpaSmzsKpQ4ksmdkMFOMpBhqA= virtualserver_port=9987 client_id=4 client_channel_id=1 client_nickname=Splamy client_database_id=0 client_login_name client_unique_identifier client_origin_server_id=0 + { name="WhoAmIRequest", notify="whoami", attributes=[] }, + # clientdisconnect reasonid=7 reasonmsg=Client\sdisconnected + { name="Disconnect", notify="clientdisconnect", attributes=["reasonid?", "reasonmsg?"] }, +] diff --git a/crates/proto/tsproto-structs/declarations/MessagesToBook.toml b/crates/proto/tsproto-structs/declarations/MessagesToBook.toml new file mode 100644 index 0000000..c3e61e2 --- /dev/null +++ b/crates/proto/tsproto-structs/declarations/MessagesToBook.toml @@ -0,0 +1,268 @@ +# All properties which have an identical 'High-Level' name are copied implicitly + +[[rule]] +from = "ChannelCreated" +id = ["ChannelId"] +to = "Channel" +# add/update/remove +operation = "add" +properties = [ + { from="ParentId", to="Parent" }, + { function="ChannelTypeCcFun", tolist=["ChannelType"] }, + { function="ChannelOrderCcFun", tolist=["Order"] }, + { function="MaxClientsCcFun", tolist=["MaxClients", "MaxFamilyClients"] }, + # Default codec is opus voice + { function="ChannelCodecCcFun", tolist=["Codec"] }, + { function="ReturnFalse", tolist=["ForcedSilence"] }, + { function="ReturnFalse", tolist=["Subscribed"] }, + { function="ReturnNone", tolist=["IsPrivate"] }, + { function="ReturnNone", tolist=["Guid"] }, + { function="ReturnNone", tolist=["OptionalData"] }, + { function="ReturnNone", tolist=["PermissionHints"] }, +] + +[[rule]] +from = "ChannelDeleted" +id = ["ChannelId"] +to = "Channel" +operation = "remove" + +[[rule]] +from = "ChannelEdited" +id = ["ChannelId"] +to = "Channel" +operation = "update" +properties = [ + { function="MaxClientsCeFun", tolist=["MaxClients", "MaxFamilyClients"] }, + { function="ChannelTypeCeFun", tolist=["ChannelType"] }, + { function="ChannelOrderCeFun", tolist=["Order"] }, +] + +[[rule]] +from = "ChannelEdited" +id = ["ChannelId"] +to = "OptionalChannelData" +operation = "update" +properties = [ +] + +[[rule]] +from = "ChannelEditedLow" +id = ["ChannelId"] +to = "OptionalChannelData" +operation = "update" +properties = [ +] + +[[rule]] +from = "ChannelDescriptionChanged" +id = ["ChannelId"] +to = "OptionalChannelData" +operation = "remove" + +[[rule]] +from = "ChannelGroupList" +id = ["ChannelGroup"] +to = "ChannelGroup" +operation = "add" + +[[rule]] +from = "ChannelList" +id = ["ChannelId"] +to = "Channel" +operation = "add" +properties = [ + { from="ParentId", to="Parent" }, + { function="MaxClientsClFun", tolist=["MaxClients", "MaxFamilyClients"] }, + { function="ChannelTypeClFun", tolist=["ChannelType"] }, + { function="ReturnFalse", tolist=["Subscribed"] }, + { function="ReturnNone", tolist=["PermissionHints"] }, + { function="ReturnNone", tolist=["OptionalData"] }, +] + +[[rule]] +from = "ChannelMoved" +id = ["ChannelId"] +to = "Channel" +operation = "update" +properties = [ + { from="ParentId", to="Parent" }, + { function="ChannelOrderCmFun", tolist=["Order"] }, +] + +[[rule]] +from = "ChannelPermissionHints" +id = ["ChannelId"] +to = "Channel" +operation = "update" +properties = [ + { from="Flags", to="PermissionHints" }, +] + +[[rule]] +from = "ChannelSubscribed" +id = ["ChannelId"] +to = "Channel" +operation = "update" +properties = [ + { function="ChannelSubscribeFun", tolist=["Subscribed"] }, +] + +[[rule]] +from = "ChannelUnsubscribed" +id = ["ChannelId"] +to = "Channel" +operation = "update" +properties = [ + { function="ChannelUnsubscribeFun", tolist=["Subscribed"] }, +] + +[[rule]] +from = "ClientChannelGroupChanged" +id = ["ClientId"] +to = "Client" +operation = "update" + +[[rule]] +from = "ClientEnterView" +id = ["ClientId"] +to = "Client" +operation = "add" +properties = [ + { from="TargetChannelId", to="Channel" }, + { function="AwayCevFun", tolist=["AwayMessage"] }, + { function="ClientTypeCevFun", tolist=["ClientType"] }, + { function="TalkPowerCevFun", tolist=["TalkPowerRequest"] }, + { function="ReturnNone", tolist=["PermissionHints"] }, + { function="ReturnNone", tolist=["OptionalData"] }, + { function="ReturnNone", tolist=["ConnectionData"] }, +] + +[[rule]] +from = "ClientLeftView" +id = ["ClientId"] +to = "Client" +operation = "remove" + +[[rule]] +from = "ClientMoved" +id = ["ClientId"] +to = "Client" +operation = "update" +properties = [ + { from="TargetChannelId", to="Channel" }, + # Set channel subscribed when the current client is moved + { function="SubscribeChannelFun", tolist=[] }, +] + +[[rule]] +from = "ClientConnectionInfo" +id = ["ClientId"] +to = "ConnectionClientData" +operation = "update" +properties = [ + { function="AddressFun", tolist=["ClientAddress"] }, +] + +[[rule]] +from = "ClientServerGroupAdded" +id = ["ClientId"] +to = "Client" +operation = "update" +properties = [ + { from="ServerGroupId", to="ServerGroups", operation="add" }, + # We explicitly throw away the server group name. + # Otherwise it would overwrite our client name because of automated + # matching. + { function="VoidFun", tolist=["Name"] }, +] + +[[rule]] +from = "ClientServerGroupRemoved" +id = ["ClientId"] +to = "Client" +operation = "update" +properties = [ + { from="ServerGroupId", to="ServerGroups", operation="remove" }, + { function="VoidFun", tolist=["Name"] }, +] + +[[rule]] +from = "ClientUpdated" +id = ["ClientId"] +to = "Client" +operation = "update" +properties = [ + { function="AwayCuFun", tolist=["AwayMessage"] }, + { function="TalkPowerCuFun", tolist=["TalkPowerRequest"] }, +] + +[[rule]] +from = "ClientUpdated" +id = ["ClientId"] +to = "OptionalClientData" +operation = "update" +properties = [ + { function="ReturnSomeNone", tolist=["VersionSign"] }, +] + +[[rule]] +from = "ClientPermissionHints" +id = ["ClientId"] +to = "Client" +operation = "update" +properties = [ + { from="Flags", to="PermissionHints" }, +] + +[[rule]] +from = "InitServer" +id = [] +to = "Server" +operation = "add" +properties = [ + { from="VirtualServerId", to="Id" }, + # `Uid` is generated from public key + # ClientName, ClientId, TalkPower, NeededServerqueryViewPower + { function="SetClientDataFun", tolist=[] }, +] + +[[rule]] +from = "ServerEdited" +id = [] +to = "Server" +operation = "update" + +[[rule]] +from = "ServerEdited" +id = [] +to = "OptionalServerData" +operation = "remove" + +[[rule]] +from = "ServerUpdated" +id = [] +to = "Server" +operation = "update" + +[[rule]] +from = "ServerGroupList" +id = ["ServerGroupId"] +to = "ServerGroup" +operation = "add" + +[[rule]] +from = "ServerConnectionInfo" +id = [] +to = "ConnectionServerData" +operation = "update" +properties = [ +] + +[[rule]] +from = "ServerUpdated" +id = [] +to = "OptionalServerData" +operation = "update" +properties = [ +] diff --git a/crates/proto/tsproto-structs/declarations/Packets.txt b/crates/proto/tsproto-structs/declarations/Packets.txt new file mode 100644 index 0000000..63bd490 --- /dev/null +++ b/crates/proto/tsproto-structs/declarations/Packets.txt @@ -0,0 +1,151 @@ +Packet + // Content + Header + // name type ?value + /// EAX Message Authentication Code + mac [u8; 8] + /// Packet id + p_id u16 + /// Client id + ?c_id u16 + // Pre condition + ++ *from_client + /// Flags: + /// + /// - 0x80 Unencrypted + /// - 0x40 Compressed + /// - 0x20 Newprotocol + /// - 0x10 Fragmented + flags - + /// Packet type: Higher nibble: Flags; Lower nibble: Packet type + /// + /// Packet types: + /// + /// - 0x0 Voice + /// - 0x1 Voice whisper + /// - 0x2 Command + /// - 0x3 Command low + /// - 0x4 Ping + /// - 0x5 Pong + /// - 0x6 Ack + /// - 0x7 Ack low + /// - 0x8 Init + p_type u8 + // Post conditions + ++ (res.p_type & 0xf) <= 8 + // Enum + #Data + #C2SInit + ++ header.mac.iter().eq(b"TS3INIT1") + ++ header.c_id.is_some() + ++ header.get_type() == PacketType::Init + Init0 + /// Teamspeak version as timestamp + version u32 + /// Init packet step number + - u8 0 + /// Current timestamp + timestamp u32 + random0 [u8; 4] + /// Reserved + - [u8; 8] [0; 8] + Init2 + /// Teamspeak version as timestamp + version u32 + /// Init packet step number + - u8 2 + random1 [u8; 16] + random0_r [u8; 4] + Init4 + /// Teamspeak version as timestamp + version u32 + /// Init packet step number + - u8 4 + x [u8; 64] + n [u8; 64] + level u32 + random2 [u8; 100] + /// y = x ^ (2 ^ level) % n + y [u8; 64] + command Command + ++ if let C2SInit::Init4 { ref command, .. } = res { command.command == "clientinitiv" && command.has_arg("alpha") && command.has_arg("omega") } else { true } + #S2CInit + ++ header.mac.iter().eq(b"TS3INIT1") + ++ header.c_id.is_none() + ++ header.get_type() == PacketType::Init + Init1 + /// Init packet step number + - u8 1 + random1 [u8; 16] + /// Reversed `random0` + random0_r [u8; 4] + Init3 + /// Init packet step number + - u8 3 + x [u8; 64] + n [u8; 64] + level u32 + random2 [u8; 100] + Init127 + /// Init packet step number + - u8 127 + - u8 0 + VoiceC2S + ++ header.get_type() == PacketType::Voice + ++ header.c_id.is_some() + id u16 + codec_type u8 + voice_data Vec + VoiceS2C + ++ header.get_type() == PacketType::Voice + ++ header.c_id.is_none() + id u16 + /// The id of the talking client + from_id u16 + codec_type u8 + voice_data Vec + VoiceWhisperC2S + ++ header.get_type() == PacketType::VoiceWhisper + ++ header.c_id.is_some() + ++ !header.get_newprotocol() + id u16 + codec_type u8 + channel_count u8 + client_count u8 + /// [u64; channel_count], [u16; client_count], voice_data + data Vec + VoiceWhisperNewC2S + ++ header.get_type() == PacketType::VoiceWhisper + ++ header.c_id.is_some() + ++ header.get_newprotocol() + id u16 + codec_type u8 + whisper_type u8 + whisper_target u8 + /// The targeted channel or group id (or 0 if not applicable) + target_id u64 + voice_data Vec + VoiceWhisperS2C + ++ header.get_type() == PacketType::VoiceWhisper + ++ header.c_id.is_none() + id u16 + /// The id of the talking client + from_id u16 + codec_type u8 + voice_data Vec + Command Command + ++ header.get_type() == PacketType::Command + CommandLow Command + ++ header.get_type() == PacketType::CommandLow + Ping + ++ header.get_type() == PacketType::Ping + //- u16 0xeee9 + /// Pong with packet id + Pong u16 + ++ header.get_type() == PacketType::Pong + /// Pong with packet id + Ack u16 + ++ header.get_type() == PacketType::Ack + /// Pong with packet id + AckLow u16 + ++ header.get_type() == PacketType::AckLow diff --git a/crates/proto/tsproto-structs/declarations/Permissions.csv b/crates/proto/tsproto-structs/declarations/Permissions.csv new file mode 100644 index 0000000..7832387 --- /dev/null +++ b/crates/proto/tsproto-structs/declarations/Permissions.csv @@ -0,0 +1,250 @@ +name,doc +unknown,May occur on error returns with no associated permission +b_serverinstance_help_view,Retrieve information about ServerQuery commands +b_serverinstance_version_view,Retrieve global server version (including platform and build number) +b_serverinstance_info_view,Retrieve global server information +b_serverinstance_virtualserver_list,List virtual servers stored in the database +b_serverinstance_binding_list,List active IP bindings on multi-homed machines +b_serverinstance_permission_list,List permissions available available on the server instance +b_serverinstance_permission_find,Search permission assignments by name or ID +b_virtualserver_create,Create virtual servers +b_virtualserver_delete,Delete virtual servers +b_virtualserver_start_any,Start any virtual server in the server instance +b_virtualserver_stop_any,Stop any virtual server in the server instance +b_virtualserver_change_machine_id,Change a virtual servers machine ID +b_virtualserver_change_template,Edit virtual server default template values +b_serverquery_login,Login to ServerQuery +b_serverinstance_textmessage_send,Send text messages to all virtual servers at once +b_serverinstance_log_view,Retrieve global server log +b_serverinstance_log_add,Write to global server log +b_serverinstance_stop,Shutdown the server process +b_serverinstance_modify_settings,Edit global settings +b_serverinstance_modify_querygroup,Edit global ServerQuery groups +b_serverinstance_modify_templates,Edit global template groups +b_virtualserver_select,Select a virtual server +b_virtualserver_info_view,Retrieve virtual server information +b_virtualserver_connectioninfo_view,Retrieve virtual server connection information +b_virtualserver_channel_list,List channels on a virtual server +b_virtualserver_channel_search,Search for channels on a virtual server +b_virtualserver_client_list,List clients online on a virtual server +b_virtualserver_client_search,Search for clients online on a virtual server +b_virtualserver_client_dblist,List client identities known by the virtual server +b_virtualserver_client_dbsearch,Search for client identities known by the virtual server +b_virtualserver_client_dbinfo,Retrieve client information +b_virtualserver_permission_find,Find permissions +b_virtualserver_custom_search,Find custom fields +b_virtualserver_start,Start own virtual server +b_virtualserver_stop,Stop own virtual server +b_virtualserver_token_list,List privilege keys available +b_virtualserver_token_add,Create new privilege keys +b_virtualserver_token_use,Use a privilege keys to gain access to groups +b_virtualserver_token_delete,Delete a privilege key +b_virtualserver_log_view,Retrieve virtual server log +b_virtualserver_log_add,Write to virtual server log +b_virtualserver_join_ignore_password,Join virtual server ignoring its password +b_virtualserver_notify_register,Register for server notifications +b_virtualserver_notify_unregister,Unregister from server notifications +b_virtualserver_snapshot_create,Create server snapshots +b_virtualserver_snapshot_deploy,Deploy server snapshots +b_virtualserver_permission_reset,Reset the server permission settings to default values +b_virtualserver_modify_name,Modify server name +b_virtualserver_modify_welcomemessage,Modify welcome message +b_virtualserver_modify_maxclients,Modify servers max clients +b_virtualserver_modify_reserved_slots,Modify reserved slots +b_virtualserver_modify_password,Modify server password +b_virtualserver_modify_default_servergroup,Modify default Server Group +b_virtualserver_modify_default_channelgroup,Modify default Channel Group +b_virtualserver_modify_default_channeladmingroup,Modify default Channel Admin Group +b_virtualserver_modify_channel_forced_silence,Modify channel force silence value +b_virtualserver_modify_complain,Modify individual complain settings +b_virtualserver_modify_antiflood,Modify individual antiflood settings +b_virtualserver_modify_ft_settings,Modify file transfer settings +b_virtualserver_modify_ft_quotas,Modify file transfer quotas +b_virtualserver_modify_hostmessage,Modify individual hostmessage settings +b_virtualserver_modify_hostbanner,Modify individual hostbanner settings +b_virtualserver_modify_hostbutton,Modify individual hostbutton settings +b_virtualserver_modify_port,Modify server port +b_virtualserver_modify_autostart,Modify server autostart +b_virtualserver_modify_needed_identity_security_level,Modify required identity security level +b_virtualserver_modify_priority_speaker_dimm_modificator,Modify priority speaker dimm modificator +b_virtualserver_modify_log_settings,Modify log settings +b_virtualserver_modify_min_client_version,Modify min client version +b_virtualserver_modify_icon_id,Modify server icon +b_virtualserver_modify_weblist,Modify web server list reporting settings +b_virtualserver_modify_codec_encryption_mode,Modify codec encryption mode +b_virtualserver_modify_temporary_passwords,Modify temporary serverpasswords +b_virtualserver_modify_temporary_passwords_own,Modify own temporary serverpasswords +b_virtualserver_modify_channel_temp_delete_delay_default,Modify default temporary channel delete delay +b_virtualserver_modify_nickname,Modify server nicknames +b_virtualserver_modify_integrations,Modify integrations +i_channel_min_depth,Min channel creation depth in hierarchy +i_channel_max_depth,Max channel creation depth in hierarchy +b_channel_group_inheritance_end,Stop inheritance of channel group permissions +i_channel_permission_modify_power,Modify channel permission power +i_channel_needed_permission_modify_power,Needed modify channel permission power +b_channel_info_view,Retrieve channel information +b_channel_create_child,Create sub-channels +b_channel_create_permanent,Create permanent channels +b_channel_create_semi_permanent,Create semi-permanent channels +b_channel_create_temporary,Create temporary channels +b_channel_create_private,Create private channel +b_channel_create_with_topic,Create channels with a topic +b_channel_create_with_description,Create channels with a description +b_channel_create_with_password,Create password protected channels +b_channel_create_modify_with_codec_speex8,Create channels using Speex Narrowband (8 kHz) codecs +b_channel_create_modify_with_codec_speex16,Create channels using Speex Wideband (16 kHz) codecs +b_channel_create_modify_with_codec_speex32,Create channels using Speex Ultra-Wideband (32 kHz) codecs +b_channel_create_modify_with_codec_celtmono48,Create channels using the CELT Mono (48 kHz) codec +b_channel_create_modify_with_codec_opusvoice,Create channels using OPUS (voice) codec +b_channel_create_modify_with_codec_opusmusic,Create channels using OPUS (music) codec +i_channel_create_modify_with_codec_maxquality,Create channels with custom codec quality +i_channel_create_modify_with_codec_latency_factor_min,Create channels with minimal custom codec latency factor +b_channel_create_with_maxclients,Create channels with custom max clients +b_channel_create_with_maxfamilyclients,Create channels with custom max family clients +b_channel_create_with_sortorder,Create channels with custom sort order +b_channel_create_with_default,Create default channels +b_channel_create_with_needed_talk_power,Create channels with needed talk power +b_channel_create_modify_with_force_password,Create new channels only with password +i_channel_create_modify_with_temp_delete_delay,Max delete delay for temporary channels +b_channel_modify_parent,Move channels +b_channel_modify_make_default,Make channel default +b_channel_modify_make_permanent,Make channel permanent +b_channel_modify_make_semi_permanent,Make channel semi-permanent +b_channel_modify_make_temporary,Make channel temporary +b_channel_modify_name,Modify channel name +b_channel_modify_topic,Modify channel topic +b_channel_modify_description,Modify channel description +b_channel_modify_password,Modify channel password +b_channel_modify_codec,Modify channel codec +b_channel_modify_codec_quality,Modify channel codec quality +b_channel_modify_codec_latency_factor,Modify channel codec latency factor +b_channel_modify_maxclients,Modify channels max clients +b_channel_modify_maxfamilyclients,Modify channels max family clients +b_channel_modify_sortorder,Modify channel sort order +b_channel_modify_needed_talk_power,Change needed channel talk power +i_channel_modify_power,Channel modify power +i_channel_needed_modify_power,Needed channel modify power +b_channel_modify_make_codec_encrypted,Make channel codec encrypted +b_channel_modify_temp_delete_delay,Modify temporary channel delete delay +b_channel_delete_permanent,Delete permanent channels +b_channel_delete_semi_permanent,Delete semi-permanent channels +b_channel_delete_temporary,Delete temporary channels +b_channel_delete_flag_force,Force channel delete +i_channel_delete_power,Delete channel power +i_channel_needed_delete_power,Needed delete channel power +b_channel_join_permanent,Join permanent channels +b_channel_join_semi_permanent,Join semi-permanent channels +b_channel_join_temporary,Join temporary channels +b_channel_join_ignore_password,Join channel ignoring its password +b_channel_join_ignore_maxclients,Ignore channels max clients limit +i_channel_join_power,Channel join power +i_channel_needed_join_power,Needed channel join power +i_channel_subscribe_power,Channel subscribe power +i_channel_needed_subscribe_power,Needed channel subscribe power +i_channel_description_view_power,Channel description view power +i_channel_needed_description_view_power,Needed channel needed description view power +i_icon_id,Group icon identifier +i_max_icon_filesize,Max icon filesize in bytes +b_icon_manage,Enables icon management +b_group_is_permanent,Group is permanent +i_group_auto_update_type,Group auto-update type +i_group_auto_update_max_value,Group auto-update max value +i_group_sort_id,Group sort id +i_group_show_name_in_tree,Show group name in tree depending on selected mode +b_virtualserver_servergroup_list,List server groups +b_virtualserver_servergroup_permission_list,List server group permissions +b_virtualserver_servergroup_client_list,List clients from a server group +b_virtualserver_channelgroup_list,List channel groups +b_virtualserver_channelgroup_permission_list,List channel group permissions +b_virtualserver_channelgroup_client_list,List clients from a channel group +b_virtualserver_client_permission_list,List client permissions +b_virtualserver_channel_permission_list,List channel permissions +b_virtualserver_channelclient_permission_list,List channel client permissions +b_virtualserver_servergroup_create,Create server groups +b_virtualserver_channelgroup_create,Create channel groups +i_group_modify_power,Group modify power +i_group_needed_modify_power,Needed group modify power +i_group_member_add_power,Group member add power +i_group_needed_member_add_power,Needed group member add power +i_group_member_remove_power,Group member delete power +i_group_needed_member_remove_power,Needed group member delete power +i_permission_modify_power,Permission modify power +b_permission_modify_power_ignore,Ignore needed permission modify power +b_virtualserver_servergroup_delete,Delete server groups +b_virtualserver_channelgroup_delete,Delete channel groups +i_client_permission_modify_power,Client permission modify power +i_client_needed_permission_modify_power,Needed client permission modify power +i_client_max_clones_uid,Max additional connections per client identity +i_client_max_idletime,Max idle time in seconds +i_client_max_avatar_filesize,Max avatar filesize in bytes +i_client_max_channel_subscriptions,Max channel subscriptions +b_client_is_priority_speaker,Client is priority speaker +b_client_skip_channelgroup_permissions,Ignore channel group permissions +b_client_force_push_to_talk,Force Push-To-Talk capture mode +b_client_ignore_bans,Ignore bans +b_client_ignore_antiflood,Ignore antiflood measurements +b_client_issue_client_query_command,Issue query commands from client +b_client_use_reserved_slot,Use an reserved slot +b_client_use_channel_commander,Use channel commander +b_client_request_talker,Allow to request talk power +b_client_avatar_delete_other,Allow deletion of avatars from other clients +b_client_is_sticky,Client will be sticked to current channel +b_client_ignore_sticky,Client ignores sticky flag +b_client_info_view,Retrieve client information +b_client_permissionoverview_view,Retrieve client permissions overview +b_client_permissionoverview_own,Retrieve clients own permissions overview +b_client_remoteaddress_view,View client IP address and port +i_client_serverquery_view_power,ServerQuery view power +i_client_needed_serverquery_view_power,Needed ServerQuery view power +b_client_custom_info_view,View custom fields +i_client_kick_from_server_power,Client kick power from server +i_client_needed_kick_from_server_power,Needed client kick power from server +i_client_kick_from_channel_power,Client kick power from channel +i_client_needed_kick_from_channel_power,Needed client kick power from channel +i_client_ban_power,Client ban power +i_client_needed_ban_power,Needed client ban power +i_client_move_power,Client move power +i_client_needed_move_power,Needed client move power +i_client_complain_power,Complain power +i_client_needed_complain_power,Needed complain power +b_client_complain_list,Show complain list +b_client_complain_delete_own,Delete own complains +b_client_complain_delete,Delete complains +b_client_ban_list,Show banlist +b_client_ban_create,Add a ban +b_client_ban_delete_own,Delete own bans +b_client_ban_delete,Delete bans +i_client_ban_max_bantime,Max bantime +i_client_private_textmessage_power,Client private message power +i_client_needed_private_textmessage_power,Needed client private message power +b_client_server_textmessage_send,Send text messages to virtual server +b_client_channel_textmessage_send,Send text messages to channel +b_client_offline_textmessage_send,Send offline messages to clients +i_client_talk_power,Client talk power +i_client_needed_talk_power,Needed client talk power +i_client_poke_power,Client poke power +i_client_needed_poke_power,Needed client poke power +b_client_set_flag_talker,Set the talker flag for clients and allow them to speak +i_client_whisper_power,Client whisper power +i_client_needed_whisper_power,Client needed whisper power +b_client_modify_description,Edit a clients description +b_client_modify_own_description,Allow client to edit own description +b_client_modify_dbproperties,Edit a clients properties in the database +b_client_delete_dbproperties,Delete a clients properties in the database +b_client_create_modify_serverquery_login,Create or modify own ServerQuery account +b_ft_ignore_password,Browse files without channel password +b_ft_transfer_list,Retrieve list of running filetransfers +i_ft_file_upload_power,File upload power +i_ft_needed_file_upload_power,Needed file upload power +i_ft_file_download_power,File download power +i_ft_needed_file_download_power,Needed file download power +i_ft_file_delete_power,File delete power +i_ft_needed_file_delete_power,Needed file delete power +i_ft_file_rename_power,File rename power +i_ft_needed_file_rename_power,Needed file rename power +i_ft_file_browse_power,File browse power +i_ft_needed_file_browse_power,Needed file browse power +i_ft_directory_create_power,Create directory power +i_ft_needed_directory_create_power,Needed create directory power +i_ft_quota_mb_download_per_client,Download quota per client in MByte +i_ft_quota_mb_upload_per_client,Upload quota per client in MByte diff --git a/crates/proto/tsproto-structs/declarations/README.md b/crates/proto/tsproto-structs/declarations/README.md new file mode 100644 index 0000000..91b39b5 --- /dev/null +++ b/crates/proto/tsproto-structs/declarations/README.md @@ -0,0 +1,26 @@ +# TeamSpeak Declarations + +This repository contains all kind of data which is related to TeamSpeak. + +This data is used for code generation in various projects, therefore all the data is machine readable. + +- [Errors.csv](Errors.csv): The error codes of TeamSpeak +- [Permissions.csv](Permissions.csv): The permissions in TeamSpeak +- [Messages.toml](Messages.toml): Commands, sent over TeamSpeak connections +- [Book.toml](Book.toml): Declarations for keeping track of all things which happen on a server +- [Enums.toml](Enums.toml): Various enums used in commands +- [MessagesToBook.toml](MessagesToBook.toml): Mappings from commands to book structs that allow to automatically update the tracked state +- [BookToMessages.toml](BookToMessages.toml): Functions that can be called on book structs and generate commands +- [Versions.csv](Versions.csv): A bunch of client versions where the versionHash is known +- [Badges.csv](Badges.csv): List of known badges + +The low level TeamSpeak protocol is described in [ts3protocol.md](ts3protocol.md). + +## License + +Licensed under either of + + * [Apache License, Version 2.0](LICENSE-APACHE) + * [MIT license](LICENSE-MIT) + +at your option. diff --git a/crates/proto/tsproto-structs/declarations/Versions.csv b/crates/proto/tsproto-structs/declarations/Versions.csv new file mode 100644 index 0000000..224e056 --- /dev/null +++ b/crates/proto/tsproto-structs/declarations/Versions.csv @@ -0,0 +1,1417 @@ +version,platform,hash +3.0.11 [Build: 1374563791],Windows,hQCwiLP5f4GIcDG5KQ1T+CNFGqRxyw5MXCHE8KjWRIgkjCuGSryK4vpPy70EURH3blQ8TKrax8BEorHlpnpdAQ== +3.0.11 [Build: 1374830986],Windows,PJvjEuApy2McckLGGnAgw8kB2FE+yb4J/TuUdaLj+x5JVghSBR5tKJDQklLurJrshKynWzYYtokrtgBxTAz5CA== +3.0.11 [Build: 1375083581],Windows,54wPDkfv0kT56UE0lv/LFkFJObH+Q4Irmo4Brfz1EcvjVhj8hJ+RCHcVTZsdKU2XvVvh+VLJpURulEHsAOsyBw== +3.0.11.1 [Build: 1375367141],Windows,2xNEoMd2TBeOj6PRSEftjE0fTSjq9dnqt8ttFVYdS3Kp9NHX/jBNycD3XCnNtsmHtHgQkczq1x2qQb1KFfg5Cw== +3.0.11.1 [Build: 1375773286],Linux,JMTTCSHw+ibyhqCDCWRgby/oJ5uAYHk0/QOwqqI5rNHCKTkb+ce6N+4J38WXAnRmtcEaMb0s30s3ipQBokrqDw== +3.0.11.1 [Build: 1375773286],OS X,BngQ1112epNzhND5v7uDdbClbP9dSWczXKxvi1iRQo+xWt7WLYKJu/05MrW/CtPVtKwlT4PnbfI0Trvw+HvUCA== +3.0.11.1 [Build: 1375773286],Windows,Qfvcn4uQmKETDsD4LbtdbZR8rDetJ26Z/bVbu5SZJjMjGlYEMSbJnR4PtOBshdMSEwEsAJf1G+5tjx+onm2fDA== +3.0.12 [Build: 1378199876],Windows,1uVn+Px0c733pYcYmid+3MwrJaq2KMIzvqIktMkICNhOYPViYfwUqTbFHMMx/CzLNKEevP57HyQ1TFdGdPU7BQ== +3.0.12 [Build: 1378301061],Windows,bbShDADD1HUCnPI7F4EG92k0L5qU3M+vsMOZu94xdMfw6Ru1mo6UZ/ctNnrDPHsFZjcSUPOV2myjurknhaUUCg== +3.0.12 [Build: 1378461722],Windows,3z7xnPRdMYJ3S+w6Jx7XyzpiXI2Cu+zSMG4Gr+F9cgKAWvdFp6dPvysT9bBtrkDWWL+hnZluCx/+1fmEcjXrAg== +3.0.12 [Build: 1378715177],Windows,x6wFA5xqjenf6kbAh36IC4CkrbT8/uSBpgjM9juSt9oxGCXLqHOC2oaYlB1zZSJZjT4sOrnp0M+uOdVjYCzLCg== +3.0.13 [Build: 1380008864],Windows,E/MlNft7LXOD5AdgVE8ekxWyrBXDXmfM+I2GDhUiOxlyIzXf0LLq7xtiq79yNqp1CLT3SYKFtIZhaT+YWUqKCw== +3.0.13 [Build: 1380283653],Windows,7dA+6EbVyMevol4gE3/Cu1WonRjqu1C6pTWF+txApbaiTgKtZ/ky+NVxluPkSDnCxXN1pOR4uGdF6B7LUqQgDQ== +3.0.13 [Build: 1380616389],Android,04JRo/B0zh54n18a61qWr3qFUrEVQeEiy7dyIEVhCLMwY8QJwk7kwG7GQKSxnr0rmRfTzD7iDXMUWlcwgkc/Cg== +3.0.13.1 [Build: 1382530211],OS X,0KNdNcf2zmYUV7JzfKlXdM0Y6/dv9LOlETE8h2mTxq0YitdbZSObUdAJvrdiKX0LH2QP4h3QF2JeXyzjRSQTCw== +3.0.13.1 [Build: 1382530211],Windows,bCIfLPUgTM6C0kNkesvhcxaDPvV9h6qLbYVy9cQVSP5lzaYebZaeDzAOOHsdjKcRTa6LU1oHEdz9D/d+2gxJCw== +3.0.14 [Build: 1387444094],Windows,3BFPkbf8KQ3udBXLoMpm41txWJ2M+vsKzXYVaBMCr4xSiPBcdnol8lUgrBLV3dNIHjGZlZXqmqtz+/qmsnu0Bw== +3.0.14 [Build: 1392643117],Windows,/k5bfFDSb0KBHNO5BBloS2vvVXu2S9iuxRa8L9prP+zbfR/EoGuzz1Vlpm/pxxeDQpcJ7oLog9wsdgBAF0nVAg== +3.0.14 [Build: 1393597517],Windows,vKRbu9Nf8d54bAEJAywHU9qIhpR89dvcmq0ff+Ak+umKqLKzMl02YwP9qx+oSgj5UQOpt9nMST/8puhHmD9QBQ== +3.0.14 [Build: 1394114560],Windows,mxBQYmj5bfirNWiVvbsFT8ybN2oov3CQ0fQmBpHWgBBJk9EM8NKmqMCpfpqVLFcubkCK7gs1hbYRXQ5DhuixBQ== +3.0.14 [Build: 1394624943],Windows,F0WIO9sBVzG893AtX2Jfd98cH6yZPAnfMBNvBlQbAIfvfyiq+cbjZ31AUngEjq7UPIYdnYSsdRX9hczwdBrKAQ== +3.0.15 [Build: 1401808190],Windows,Bo28W8+xHTRqVAiayKwRSmp1iojqY8NhhuhjSbvbovx9Mby8YNTWdY7/HHCfOt+nEYLhcGnxcssR0aJhShItAw== +3.0.15 [Build: 1402646489],Windows,Jv5wg8X7HZv2NwbAX8b9L5gyDFN3mPI1veCRV/IbxwvRVzS0PL1vvHqDJYfyjIsrtM0VPLBhnuF4PswmEdueBA== +3.0.15 [Build: 1403250090],Windows,FKKAHPwV1swKwH6mqHqdcGuYm8o5mZw4WreBxJrQjOprC3NXXcJviPe0p7EZPI810HOWMfmQRUgFpggoRL8kAQ== +3.0.15.1 [Build: 1405341092],Windows,b+hr0KQWOVW2WEn49BmNb08R9zimsJcThm2gEeF7EAgRUeUDYzeplh5HrHmda0ftbbnrzWV33U/GOo2LAs/rAg== +3.0.16 [Build: 1406898538],Windows,UoK5KLpRJfF9KnF9EURK8CbdI4WgjigfvVVgSUc9lokIvCpFTYwGuKfgL4oW8I1ldnzHTbs1Q0gtGcrzI0KwBQ== +3.0.16 [Build: 1407159763],Linux,8776GitHAgkFPfOLxEh5x+Luuh4NrYPEJUdsUzNKndcAuWMYjwQTZkmeZOeG/swdn/p2Cg2pRfZfsIFSOAUWCQ== +3.0.16 [Build: 1407159763],OS X,vLAH2cYjkF/3sQCgr/zSmtffXcH2flI2vOnUP3uNIDSm8gKO61Q2hOdQaUzXE1yekLSMx2E9RYz+OQjQ868KAw== +3.0.16 [Build: 1407159763],Windows,Y1DuQGXo/8/rYznEGyeQHgpvZMuiCH4FYm4QVyAgLYyMpNpc/LM7XetVWhDQxGsNejkN/2olI7GVJkt4X+ooDg== +3.0.19 [Build: 1435141265],Android,9lfj+Rx9nTpxIkhnLLubSMZQA7NcTGVxrOtz+ID4frN+1u2NVTChx9lht4RDSg58b8N6+LKIZIl8b8mIcNP6Dg== +3.0.17 [Build: 1437491062],Windows,zlKTIfyJfjeXw9tL9MJsu5RLqKf1RrcNC+c2MQyoVwYBiSMpGJJ8KAyKtyDdK6WiKM0iIF5vjCnYBXAun9dqCw== +3.0.17 [Build: 1437730067],Windows,JDOrqErAA93ukBMRfhI3pDqHbvIQcF9uHAJjZAlR9X1/1aESp9TDwatFAXqXF78OJA9EI+E5XTheL+BjXTwHCA== +3.0.17 [Build: 1438160323],Windows,TtQjq217fCW3emP2G6VECMsXRWsMyt8RDs1u7iPUlRUJvGN86REPvCRBnnF3T0nwfVsqqct40qxtLzhkkYwLCg== +3.0.17 [Build: 1438246387],Windows,K+aWgISXjmTdJYXD/lW9du+RAz3ss/3nMQeUhHK1mHEKKiPe9pI+uizi+yXSj3B4bKFOzTpmrUayHVO3aSL9Dg== +3.0.17 [Build: 1438673913],Windows,znDjHvCgmQF/jQKTK49X8tnXqF7AGXfS2XYcogww4XxNTBxp2tf1aFc/jgboKco9EuVa0ku2cf/xg9wW3Cm7AQ== +3.0.18 [Build: 1441371697],Windows,7uMCLHsNLl9pqL8m7foMBh4qsQZQ84eumhqWW7+A75WbQWFfN9XQ0f2UUEMzDQxbbLwWFuIO8XkzI90LbLG+Aw== +3.0.18 [Build: 1442498553],Windows,NTcB2oaqPYbZRFSIccNpPHr39SysqffsBRS+AmYicYxUhSj9lO1NWsRTLF9fQOyaCP3m+DAfUZfRgSG3Atv/Dw== +3.0.18 [Build: 1442913547],Windows,qBdVDaq6KdRBago4oxqd2E2vnepEu+/i1s6nSPfQm+3Wyd6gwmOomFrU7vNR0cmqu4fPvyWb9CnfYJmqPheHAQ== +3.0.18 [Build: 1442998335],Windows,vUgm8mJoeVLBG6qB2HcYF7YNG4D+H/4edILaZbHze2Unua6mrBvNmbtRkRtmRyDZSd7sVQHMApinRDgGT1mUBw== +3.0.18.1 [Build: 1444491275],Windows,xqfa3CUd2GFiTqjJWYzcu9ZbxVVLng8qIMKlVxMqWdiM8JrTRiXBAaTBDd8Xc+flVe+rGSIOZTkXRsz1rqjiAA== +3.0.19 [Build: 1445263695],Windows,z2CS87ly6Z6AHMVfs4UjhL+xobHbr/QcjjvudTL7mfrfSwe4Bm0pBaoWw+xlo8Qvtkk1OQeYjZxwUXJOJJ1wDQ== +3.0.18.2 [Build: 1445512488],Linux,W9sU8xDfWZ+eQryTdNxXVXM5Ak81wJpYKDLOiJoJUuEXoxcPnKBWpTr5JPrUzheQvkUYUIJf6WzgGAG2B7GYCg== +3.0.18.2 [Build: 1445512488],OS X,hRZrg1T+25VXJffJoM9hV1qPe90HHrjbuHJM4SOj2QIasS+5bFSgzZ50/zus7Yzj8ZUovPWwn7B7WwdyiU29BQ== +3.0.18.2 [Build: 1445512488],Windows,F0hY25Dtja0wcU6dzC39rNuYbhnDAbIwPHC3VO9Oicf13kUY2I2g6scPZ3p195Cw9gUYdBIRYm8ucHEhtSeWCw== +3.0.18.2 [Build: 1445516611],iOS,TEC965pHLJhoiNA2N95xBjQfh2n6uasS3BRFraucFv/+WgAKCKeoUYb3tu6feO5zvTEEiH6YCsedQdhbU1FFCw== +3.0.20.2 [Build: 1445517273],Android,fp6DjpIL/GlTmI3o2QEhwnXUj/pY7OFvZVPbtFBizI2Rloqm+8i0jG8Iwk05ZBn1bDOF6acPzHjBwZgl8CeWAg== +3.0.21 [Build: 1449476724],Android,X/xPOfXLC8ycGeWMlBc5zbyjQdBj7gYFVaSfG95gcZLoNijUaWDkB8DiqBfDvmef2JgmF8YdKTdmwjUm2n5MCw== +3.0.19 [Build: 1455611032],Windows,oFIR1O/nAb4DYuJFlHQ+KgpljBKdle59E4+iNSneNp6RmhGc/I2W/sUIkkjPOlnWO/7SVCGG+KRzmQPrlvggCA== +3.0.19 [Build: 1457598290],Windows,FNmch2Flbwd+UFBd5i8obSRyV4MZlAjYsljWzklqWFOE+exiYYJqYGH2mT7+CmaxwJkzVHlggykRMIuwj9wTAA== +3.0.19 [Build: 1459504131],Linux,48s6oiT+4yKVJPsEzbPUZ2L2LqrKJ0bixxVmTFjS5f5EsfDFbD8bl7t3V+OQd84bgN7t8W80B/fjEW45IszpAg== +3.0.19 [Build: 1459504131],Windows,JoHyZHF4k/a3+QH1zPNSEzc40487fzbpssyRZtoWB5kbQorAJgwlpcScA08J4vjGoUbdaTZsT0vCw56wo/Q9Ag== +3.0.19.1 [Build: 1461588969],OS X,J4cWj2v28tC/8uRqXB1nnAQPfFngOFE/E4Yx7uKMY+Cb8csFrhsJW4J8i+t3dpvZeMJ0BJnB0a/dZ1iL4zh1Dw== +3.0.19.1 [Build: 1461588969],Windows,KYo52MA89dowkYpFU1KixgHngjbJ6F2Yi++5tbaqBlBpz9YikX2gI3sqmU1kP1ghsKCLKM7o0patDH1hv9bmAg== +3.0.23 [Build: 1463662487],Android,RN+cwFI+jSHJEhggucIuUyEteWNVFy4iw0QDp3qn2UzfopypFVE9BPZqJjBUGeoCN7Q/SfYL4RNIRzJEQaZUCA== +3.0.20 [Build: 1465542546],Windows,vDK31sOwOvDpTXgqAJzmR1NzeUeSDG9dLMgIz5LCX+KpDSVD/qU60mzScz9tuc9AsLyrL8DxHpDDO3eQD+hYCA== +3.0.19.2 [Build: 1466597785],Windows,sDOzu7rCGb7kBID2WbBk35DjPijKkXzujnsAtLhXxhkQ+am0JlDOpuU1ISHhq9gCl/Qo0dzc723o0AIPI+yoCQ== +3.0.19.3 [Build: 1466672534],Windows,a1OYzvM18mrmfUQBUgxYBxYz2DUU6y5k3/mEL6FurzU0y97Bd1FL7+PRpcHyPkg4R+kKAFZ1nhyzbgkGphDWDg== +3.0.19.4 [Build: 1468491418],Linux,jvhhk75EV3nCGeewx4Y5zZmiZSN07q5ByKZ9Wlmg85aAbnw7c1jKq5/Iq0zY6dfGwCEwuKod0I5lQcVLf2NTCg== +3.0.19.4 [Build: 1468491418],OS X,Pvcizdk3HRQMzTLt7goUYBmmS5nbAS1g2E6HIypLU+9eXTqGTBLim0UUtKc0s867TFHbK91GroDrTtv0aMUGAw== +3.0.19.4 [Build: 1468491418],Windows,ldWL49uDKC3N9uxdgWRMTOzUuiG1nBqUiOa+Nal5HvdxJiN4fsTnmmPo5tvglN7WqoVoFfuuKuYq1LzodtEtCg== +3.1 [Build: 1471417187],Windows,Vr9F7kbVorcrkV5b/Iw+feH9qmDGvfsW8tpa737zhc1fDpK5uaEo6M5l2DzgaGqqOr3GKl5A7PF9Sj6eTM26Aw== +3.1 [Build: 1472203002],Windows,0HO60MuQm1Emn+G+ai8aJWFwcFF/y032y8pnoFGSgtMZE8RfuEmb+epDHoXlSHVwHaWy6pAafU5GvzAtKmFTDQ== +3.1 [Build: 1475158080],Linux,G0j7r7DswTMF+Fuqroy6/BR+tn02AOy0IZPlg9ZIW6r2m79yudZgrbm1TB4XoUpiFfex3ImdjOQnaFRQPONpBg== +3.1 [Build: 1475158080],Windows,jVCy5/F04fJ1aFFiHPXClAwNNHy9V9VcQP/b4kwPBTs242hqt4hyeK8kw/iFnTBtvdE44lv7ug4exrrXAh6jDQ== +3.1 [Build: 1476372595],Linux,rJDhRKN4NZhUZDVVK33cIvBrxCyc/UT4casQfBAkD8c6ZgL0J48BYIRPnGGAauwZyJtEyJieuZUiMRrZ1t6WCw== +3.1 [Build: 1476372595],Windows,RFV+pRwf2vMW/uflREuz0PE1K4J/EnuGq36DSggBF6wCjNmLv4IHokyb4rN16LW/EWZ8ny1zZrfdp9oRtb99Cg== +3.1 [Build: 1476720122],Linux,q5nPwQYNVpRIHr3kIjDECqgI55XRRjJnwuSQF7oNDO19KObGUtLiOpvnH70/5lQV/LnTW+Y8MOAep3UF4gRuBA== +3.1 [Build: 1476720122],Windows,Vvypi6dNQifos6pVSYKx5tQJSS/fyx4/3N8RWLnoLqSqrOiwepc4pLd3F+mafm+dSC996FQNNATGDPGPxsB/Bg== +3.1 [Build: 1478701553],Linux,BDP8PGSwrXJjyZAX2FUPnII72ovKOO12cr0B17cUS7Kvueuk5xRi6cC7q+sz8yOOV/+JIDB/RZix3mkSeAVdBw== +3.1 [Build: 1478701553],Windows,6M7zXboPykVY5FP1LFeDho+BtAoWXKiT5gyIzRxm/Ht8BY+dVFTLEnGrzEFwHEjo8ux0ZVAE9uEwqVCEcvYMCQ== +3.1 [Build: 1480583762],Linux,4TE9KGToLdye1zZzEz1OSjF2lsSRJUtcRB00nNvdSrhNCJmpyuSyTu1NSJxLnOud56B9MF2z2EQo4E99rRqBDQ== +3.1 [Build: 1480583762],Windows,IGq93SEt29FgghlMGD290LEsWBxQ7gW+qZy9Qok1xUiWGsxVSivYrtJ37V9jCA5pSAD3XOXui64+6cLiUN5LAA== +3.1 [Build: 1481641346],iOS,SDH0QNTA1wDQdfIU0HbcRugD3qkkPHnvlSq/IeW/I4A2myFQnDbzm8ilEGR0vOU4NoTae8CH5XsBmRqwyPIeBA== +3.1 [Build: 1481795005],Linux,xpJQcdaIImbctnJw0PnLQOIZBcmN+HDGcjxoIW8So7SSdSYLyUI5lAECWaCewbYmNKqaO85YqXPiNXfOBM5fBA== +3.1 [Build: 1481795005],Windows,3TpZZM0V+PKHELFnsfRPoKjEFfvfHUL/6mUP5LHbI3nvmdOjRqEEKi4ndXZG6OpWOKQ3VeadHDH0KBfD8EI2Cg== +3.1.0 [Build: 1481889010],Android,eH8svg9XpltTbw+UYkQ4ixfqpbEAhwO9nmDDUWuI11swEU3Ye5HKGlFv70LxHZSgYlEqEH/N1J9U4ygptbPIDg== +3.1.0.1 [Build: 1484223040],Linux,xWfxm14Vw53mTMHuzeaIM428KkoI/2wuoR4O2TIuy2Q7ZpwaN48vG0rMJbUQNVycP8rRHg+bIGuFiJai8f5dDg== +3.1.0.1 [Build: 1484223040],Windows,oaaorJ4co/sS2m5JT5oRiu9AieW6kfFY+RENqPfp26iP4pbWbf9GcZj+JhDA+/JyLpfueCcSulZSRRbash2JCw== +3.1.1 [Build: 1486051051],Linux,UvsdbWQht3KHW2bdgfSYsh25G2091NE5MK4qbhmajLt2+v8ikreJGfnEsVACn54htHKhp59SnJTWly9m3c1yCg== +3.1.1 [Build: 1486051051],Windows,41Ed+R6kN3IRMzxd55wiGjKlz0Kj5txi2j/K/fO86dbE16sTTWU60/5Qom61p0OzjKXn8rSptl+2q+838lKVCg== +3.1.1 [Build: 1486485240],Linux,NAyvIAYKfS8I/e8zug/XXg8XEbjjFJQ7CjRFaBQKLoPF7W8GfTXqGzFdIRmllg9GLYKm93kEf+dCFNzkLIagAQ== +3.1.1 [Build: 1486485240],Windows,CZIC/dYL5ntRZZKoa5OFf6sJUU+Fh7nyI2dSegOxoLO0kJTkVVp8FZ23j/gOKvFZZyToQRkmNvHnBAYbp9XsCA== +3.1.1 [Build: 1486712038],Linux,umeERdZkG9pS3oeJTirnYK9Q947j8lVlszz2VXBPcjhQrsiKFM6lIkbj3K2HSqA/hJ+sUOcuZgo880PmU6ZdCw== +3.1.1 [Build: 1486712038],Windows,sryyx++NhRWKDAo+Tnwv9N+IrOaQBP0XjjDszY0BBv0YIMr4jmdHtgrwzWkUqhU7kfql7qBWIhlb/r0l1ZHeBw== +3.1.1.1 [Build: 1487668590],Linux,0B4RK2WOu5w39+CLznQtaexYeNqqBwU9YHBvSLw3bu+OAne8XtFc2NJzepjynrxwc1/xsmrm8uEZJzqzF+TcAg== +3.1.1.1 [Build: 1487668590],OS X,WrETtyinA18FGhiDC458SwfGDozCnM+euEDmCeyC1YgQnfaEC49FtoVAbw2fry/daonzgxmyNBymVHhoUX5iDA== +3.1.1.1 [Build: 1487668590],Windows,CchjMitGiVGfRlGph0D1mDjOCJCnkVxR/WuYvNHdPyeQUCncRWML8jYxYfnhRF6CzViwYRnsmZkN+W5oenB2CQ== +3.1.0.2 [Build: 1487778817],Android,vX2nNdYEMnwAZ2wAOAp0hsDhg099qaLv5r/rzNrfAMpXfI3JnTU7bhPxAZIh7qGk3+Geh7ffuefwoHBQRoThAQ== +3.1.2 [Build: 1489662774],Linux,W9TgKEviDgWvrQErw8vaoQcPboaUx8xRL5MPoQzlur9eO2yseHgvzkpWGYqSQyCI+ptcCpTHaXRFym0imKnfBA== +3.1.2 [Build: 1489662774],OS X,571chpoaq6bxLisThXfiU3zB7pU0NOmH/Qso8ABTR0TXmcK9Y16pYwmPFs/d7fmcHVeI3xSM4dbgzKjRSB61Dg== +3.1.2 [Build: 1489662774],Windows,5Aaj21gGFtrjW9424ezfLa1SMQBpZvgQgcJLZmrLoNMe4XebBPV2s8rxEDAIodfFpruLxLFbFpH63A/BGnJyDw== +3.1.3 [Build: 1490279472],Linux,Y1M2TQvKLGmUSP4YPuTBQOeUxmF+jaqazFXuN4v2gOKP8QmxyYOsg9PsG9z7SFYQkgneQxs8QdzC+IGo0bOWBQ== +3.1.3 [Build: 1490279472],Windows,7RPY2bzJmMdgVX24VuKD3lTnYYb6yHWqfn2x21tFOjXL9q+2t7tU9Vy8Bh5/IpeiqklUHTWc23mWpYOCoW9eCA== +3.1.2 [Build: 1490288199],Android,ODB8HVKiqknnIIhKVxhz/YoO6cbm08FFSohoDyTSR8/PQBAkSccjKWCXHgBIlml+nxJ4dOBs94+HBXfDHUQFDA== +3.1.2 [Build: 1490291439],iOS,mTC8yRgh04oHF3jKleXVy5324ysJKp2LQIUhWh85MXqPTjh9CD0pgiUIoTuCzDQTNutAzRefcLVwniaIhNCnAw== +3.1.4 [Build: 1491993378],Linux,wJPx0S2Q2S8EgSEpZhu+Yp80d6xVQDX5u9DYgm7XxI7sh7gJIoBbdaE5cfjwR2UN6XFyV+V/2AV4stB3CxtgCQ== +3.1.4 [Build: 1491993378],OS X,JSg4RcthTCvJUSXTLhrmdPt1592Nk1lG9AuXg+yIyOBL6tlb030+hXniu/QrI2NeNHAMYxTJgZyi+rTnu6sFCQ== +3.1.4 [Build: 1491993378],Windows,rwdyEwnJCzbVfNCqbxMrRyhL5BSYqYSzKQkeZ6m5KImc1F8VB8wEkwwwyxoG7SimC/sxIyy4h27CjBFP6rcgBQ== +3.1.3.1 [Build: 1493128735],Android,Me2oMSfwCsCCGsBtgDTy+TCidslmK66JxQVR2qFsKv0v6izk6o7jzuPIFdL8Fo4rVegdCyuXPbzmOPe9j71YCQ== +3.1.5 [Build: 1496989945],Linux,874htNIqcKQfggAbYrkm3OaJAaqIgWmdqKxQUpi+g1+2+aFf9Uxb407ikxG6p2Pgnk8v9Oo/chpX7E7ZCUvfBw== +3.1.5 [Build: 1496989945],Windows,vCK7AxxVis7dQyEy5dwV3+ctSX3RUudj6OoQLW0AUDkYzkr1zp17srD6BQNZUBpaQRCQJqqDsCT4dYIpxt1vDQ== +3.1.5 [Build: 1497432760],Linux,xbASm01EnV14LfoXSPARGULDZRzsn8aqQkkGuHv3efXKc4hDCVOcFglYFi/aDbLc/KkAJlHo0WEvXZHNOXlcCg== +3.1.5 [Build: 1497432760],Windows,9yBvw4TOcihVsVlN37Gf3bV4EF1nyLMbcq5E+7WbootiDC+GNEA8oDRSeGadHhquf/B4G2CIDhhvjYW/X6+rAg== +3.1.4.2 [Build: 1498644101],Linux,Rv3SzHDwLIkuUqySQhn279jf2b7PPzCQH2q53zHWH5qyFL/Qw4m/n7ZrXEF46/sUSpOPFPYjfKMKcN/9IRCoCQ== +3.1.4.2 [Build: 1498644101],OS X,MMVozpqhiRqPHFu+skm8ftODA2waeWJx2trAx205schgiJMz+H4KOLfoa92Fjrn8kAQZxpA3krUro/iBpJYkBw== +3.1.4.2 [Build: 1498644101],Windows,WtscrpvJG13kbF6aoVzsGwQuE/WwR1b8++ydDc8IpmiXLw+zFC6zFUvLinOeE0zZgh2Hs5Amp3DZoPJSynOWBg== +3.1.5 [Build: 1498740787],Linux,pMgKa82Qhu+5V/S7EWv0+sChqG3Hcy8k5cp1EN6TG2wiZWZAoWR2GLC5CW4+SS4fRUrLADnR+PaEjB46N3T0Dw== +3.1.5 [Build: 1498740787],Windows,iL8prlQuMXIMBJrszzjyPa7k36GA9DsyVEOg5L9uoK/EFc5lXH4Pv6TYj4yPZt3p6cd8OMkPfuHfXj5bn8fpDg== +3.1.5 [Build: 1499699899],Linux,cdnb57y0GEtvwgHoubRU9f27CEeoA4iho0JuAzmdFrTArFrFSlI9kGKuypVgjKGhv/+HcVzDCj/ncM8X567xDQ== +3.1.5 [Build: 1499699899],Windows,muYzth+vZLUobeluM0GMW/U59T34gn70zVpvnIyT5ADWlcsRQ3Ex0t2iqz0yTqcgn7/e0wAmqS3OLL2ctFT3DQ== +3.1.5 [Build: 1500360741],Linux,lCOva9P9UYmAUw1s6je2f8/44GQjj1ijeK7PadhYCY+oJp9nu1gy/MVD5xAkIuYwuJlOhac3JeBg8XdEOUAMDQ== +3.1.5 [Build: 1500360741],Windows,0mCCWSFXyuWqKLM95/b/8seOCljvFCuupu5tst6G7hzTWQlPIdlsypdnEW+uN7XJwKacdQ3axHEmiTo6GpcXAQ== +3.1.5 [Build: 1500537355],Linux,Ea/9gUeh5HuXyiOZ+gRDPOn0rDHzXDVSYB70qy/BtczJPZn/0dDwQgRAF7/W6vHcaH67j+IF9AtUpuDCA6yzBw== +3.1.5 [Build: 1500537355],OS X,oiS3ROFEy4r7zhkmCuj4cro2kIwntHNpuTFpFB+zV+AkfwX3Y2F51/JJPWG0J63tPR82n3ot/JiDkJqPKBJpDg== +3.1.5 [Build: 1500537355],Windows,O9WqHB9oX0qe9AXIYmJm0+mzl6VLxNvrGF0lGlovLaig5MXUIwd6T00NkCj62OkBbzM3eECs9FUuJk7N8V0dCg== +3.1.6 [Build: 1502264952],Linux,P5cZgEH0ZHNdWRHLnXVwIe3xUB1jTqP3ptwqLkTqdA1d8maBliXF4uWVXYvcWF8vG10zhksMiHuhsf/v62L7Cg== +3.1.6 [Build: 1502264952],Windows,3l3IQ5y4PHAMro9/i2UqBT7xGZUE7sUcyjqWdhG+5AYhnVC5GuHnv4l44TtPneEcxWIYXFtoFlr2rlPhFwrkCw== +3.1.6 [Build: 1502275280],Android,sEg1lt9N9lck/Kub6/N6kffI28dEsTrybGLsLc/MeWWfZ/t3EoVwwqCcBxEbUZyszx1htnbnWbd/dYBcrjSCCw== +3.1.6 [Build: 1502873983],Linux,o+l92HKfiUF+THx2rBsuNjj/S1QpxG1fd5o3Q7qtWxkviR3LI3JeWyc26eTmoQoMTgI3jjHV7dCwHsK1BVu6Aw== +3.1.6 [Build: 1502873983],OS X,ELteM70OI6OkQ6hjOr1m1ZXxDtOeCI7pqO2ce7+Sw7CoUgKlqxreTKVSlHpD7XfCEuqo3AdNfxWUNAaBci3DDA== +3.1.6 [Build: 1502873983],Windows,73fB82Jt1lmIRHKBFaE8h1JKPGFbnt6/yrXOHwTS93Oo7Adx1usY5TzNg+8BKy9nmmA2FEBnRmz5cRfXDghnBA== +3.1.6 [Build: 1502881949],iOS,DXVaZKOza0ivNdKG66VPD/g+TYwio6XmJlCfralcUIpJuh3PI4ZgAnjxzXONzTmgFm0O/rb2iN/vvxIYwhcqAQ== +3.1.7 [Build: 1507896705],OS X,iM0IyUpaH9ak0gTtrHlRT0VGZa4rC51iZwSFwifK6iFqciSba/WkIQDWk9GUJN0OCCfatoc/fmlq8TPBnE5XCA== +3.1.7 [Build: 1507896705],Windows,Iks42KIMcmFv5vzPLhziqahcPD2AHygkepr8xHNCbqx+li5n7Htbq5LE9e1YYhRhLoS4e2HqOpKkt+/+LC8EDA== +3.1.7 [Build: 1510583507],OS X,OmMyxPhOHzkVKzOmy8U8CivSF/c3f8bYMhdAPLHVM6k2Ws69IzMUntr/yilFw4w6hni6Bz/Gd8Swe1L2YqCtCg== +3.1.7 [Build: 1512049856],OS X,CRpQYBwQr5L0vU9os6s/U8e1X7kvGAnc8iUQ67TKxywSwH7cfPRooLCTOVtevt6g0Xs2O+C1t/DS7wzyOHmHDw== +3.1.7 [Build: 1512141423],OS X,PP+/cBUDtSyV0k7lm8aYvYWAs28KL+KmXa+f0pUpDqjQDKy8dnDzJp16F4YGJxJ+2ODGPkp5YQYwts3m8T7+CA== +3.1.7 [Build: 1512391926],Windows,n2Ntx8GVlLGTmMCILg4QbXkMA9CI5FTSfa3LcrOsz07pK4FEPHa3u8eOD0g9rFMdmQSia4jYyMDWR1KomIkRAg== +3.1.7 [Build: 1512665843],Android,J04O7RCgM3ZlecpZz5H8IgWggyCJQB5KG4/MEEB5/mrW6XJEK4J5IpU3jKztkvy54B8Nrj9tbwMaRujZfILSAg== +3.1.7 [Build: 1513163251],Linux,/j5TZqPuOU8yMYPdGehvijYvU74KefRrKO5sgTUrkpeslNFiy4XfU7quKW0diLHQoPQn1t3KArdfzOAMk8dlAg== +3.1.7 [Build: 1513163251],OS X,41eIdGPhullYi9ofXewHPXf232ZbepovkYsmR3Kc4CPlA5d/K599m5BZYBYwSz1/YfKvbTzzg0VE0FRbhcZmBQ== +3.1.7 [Build: 1513163251],Windows,tdNngCAZ1ImAf7BxJzO4RXv5nBRsUERsrSOnMKVUFNQg6BS4Bzag0RFgLVzs2DRj19AC8+q5cXgH+5Ms50mTCA== +3.1.8 [Build: 1516099541],Windows,nwdwhrNjGH5IhaNoYGpJOKl0jsSYmq5f6jb0Y7ETfNNf+NqF6djEd6grCUlR7moKnkFdpRFazFsZD3E+dze9Bg== +3.1.8 [Build: 1516349129],Linux,d7zSAZK8UBKLhZBl/QBSXpSOnKuSDOIG5dybmJumkO8gnH0jHvpdSblyVoj4r5J6A8V00ocp26Y9U7mo16qQCA== +3.1.8 [Build: 1516349129],OS X,T4Ml4baqYyBOZYpt1XjxNDfkqe1iSZQoeCsMQqxVvvv45yifliizwe+5hkddsctxwY3Q1P1+/iTiW+Log5DvBg== +3.1.8 [Build: 1516349129],Windows,scnT3q9ViDVUSKceKSPQ4p50He1m0tlT9FsxSj8YMLfOoh50SKbqZEzrRTJ1aGwsGYb8x88JhjdlhDBRPhwhCQ== +3.1.8 [Build: 1516614607],Linux,LJ5q+KWT4KwBX7oR/9j9A12hBrq5ds5ony99f9kepNmqFskhT7gfB51bAJNgAMOzXVCeaItNmc10F2wUNktqCw== +3.1.8 [Build: 1516614607],OS X,93J+FDUbtRjonzFnQpGdgN6+o4jwI2M65zEKftQILCdZlGHGfc7z5Z9+TM6nU0/pnPgTqvKmaw9WYPsh88iCCA== +3.1.8 [Build: 1516614607],Windows,gDEgQf/BiOQZdAheKccM1XWcMUj2OUQqt75oFuvF2c0MQMXyv88cZQdUuckKbcBRp7RpmLInto4PIgd7mPO7BQ== +3.1.8 [Build: 1516718352],Android,XUoyBlHsOy13YVXlfDIAGsVEiBvxpAtnK8tU+jljrSoCQMCk7GqkYmwse/t9FG8tWVP+EkO5MUNunp6NXYjOBg== +3.1.8 [Build: 1516865456],Android,sG/qsKb9iZpBRXFSYY2Tuq7ZLUKHcmgA/6Qe/cx35L3risqoH4aGkPkDicuKtaQi8Ikh4IrQz6xe7V49M+8VBg== +3.1.8 [Build: 1516887927],iOS,pdWyIOpTWECIdA2NExrjqY1a7Q0alFyU7MgiDJYdiUXAspusOHwMIcfKm7oAh+Ty2gcgVgOh8wAPyZcKFKYXBA== +3.1.9 [Build: 1520246719],OS X,gTeib0sqVKETwmYTAD6rrzgmqDHE/smMgOPTiuHPj6218mgPkhWuRWAE8pD+gm3cLMBfRl/2XlllMViYbok0DQ== +3.1.9 [Build: 1520591856],OS X,3Kf8a0ShGCPKCnSREnJe40BxQ/jBPoBx2qFM5JDYHsQPPsL1sg5seapmMBdYoqMnkYYK5IHN0eSkrnwzXTPpAg== +3.1.9 [Build: 1521637641],OS X,XljC4PFgstQBBbk1dPwGWSVK4eGIJCURlbONVTkGsatSXhDqfNdpLabDbEkxc1FTjcnNUAzNwDG3rn7uiFZ1AQ== +3.1.9 [Build: 1523609596],OS X,ZtO4KjCcr1J/+ENQdwao8kheUQkcIhOahr0MmnToGRoUtVpVdXVLYn3esU2i3rG6XLLpfTU7lWUAhlWw6G3kDg== +3.1.9 [Build: 1525442084],Linux,wBcnfNU7FA0CvFeisKhywZWzmUqD6IBFbYQTveMvxWowXUjWwNHTg9tbRLQ1YgBFDdlOwV36VMX7aAMXMX2rAA== +3.1.9 [Build: 1525442084],OS X,WVaMmYPig4eG2JUM8cMMW2MA7+IoRoPUSr74CPe7oS8TLHGjYxPr1FP88op6YsFFQrPJysWmIsnGR7BiFXjHCQ== +3.1.9 [Build: 1525442084],Windows,2SLjPTFXM9hQyNkeEGYIzs0fkBffyhsh5z+ZuaCcZdDfM8vgRM5lrAU6KNspFjLddcvw8cXw6gxRY73ZHsRVBg== +3.1.10 [Build: 1528537615],Linux,jEfjYy09JfbJPZ+W3fwqygOu8uuc5raYTGpbJ5F8dHLHpqUfvmCyJVKoXRieMNkmPzeiylsUc9/HiV+8bt8tDw== +3.1.10 [Build: 1528537615],OS X,AJMF6gyw5DBtzAuW7aA7YcZaLIgOHFappwzWtE+0UUMYgMjMkSZ1LewDaW3YyRDHuLG5Nb7X26VNhFNZu+ohBw== +3.1.10 [Build: 1528537615],Windows,+/BWvueikGg4YkO1v2uuZB5vtJJgUZ5bL8cRfxAstfnCVdro2ja+4a+8rGUzDx8/vvTZOUVD6U95hnWb638MCQ== +3.2.0 [Build: 1530183207],Windows,6LYlvxFIPCVnYmmFd64H8SRmxsX+y3IZOe9ju8PbZLI5j2K7ni6Z0BfEyhVprYP9VA5o4bXVrV+uNbdGSKnjCQ== +3.2.0 [Build: 1530280071],Windows,c2M9CuucssLhQVIoye9KapFVYK7CGs1xAb6ugYivrYYs6AqkxTPP006macLaQjCrVeKTJoJN0xS+swGQMfj5BA== +3.2.0 [Build: 1530790120],Windows,hs7X6QfM1zdlKKCY2GwMpAEe3/joZqWT8hPdNj2cBRNM4zEP/V4A6nNRtQNwNbaRpWhbqdNK5Zk3c2DkKy10DA== +3.2.0 [Build: 1530859847],Android,pjvK4iy+bB5X90mQI/Rzbkes27EokJjSOoGSXCqpjuPFj8Pe6BXt3M2E9VH/1Ec2hf8h51mr3D+cycGQpHq+DA== +3.2.0 [Build: 1531390529],Windows,OLjamtIbU0PxYhLtSQrYbi1yhZZrJbGAGQJFNtZ4DZ2Ae2eeudQWY2Y8r0T27rLNckdyFqPydX0PrxKHxnZ6CQ== +3.2.0 [Build: 1531481279],OS X,VlxQyIng/96p9Kvag2U0epcVFQUubJ+cVMUUxut+rHh6znj3k0NPL/c9/vwxqOXwsCueebiOIEjieOzaPv2tAg== +3.2.0 [Build: 1531481279],Windows,Y74ib4ayZCVp7el+ou1X1k5qCjRf8Vg9zX3ACqbH7jtIricC4Mhds11uvhE7MNa5ZWPOU6OPrHmLlMW8+tgvCw== +3.2.0 [Build: 1532529142],Windows,GtYKBlk8a+tse8WnBVE9XPxg4fHVnscQ6GEQGMyG8MQbZYLHw7dwEAEmtQ6ygWerwETUVKxG+qNfGWZAF5/IAA== +3.2.0 [Build: 1533289185],Windows,757W7J3m6dYThNzDTLZzHfbU1bxqcKyTqjZT8OOZj+GQsyvrUhZhBe961sTqH1zZaNYuzNKyzeIXL+pAS9iGCw== +3.2.0 [Build: 1533739581],Linux,Vt+iPp952TU4uKwGXY0L61mXgBNfXg+1+16fnS0snPU9fhkfOKzdPN4rBELOwJ5XzZc33KdVC8rzZGYzlQceBg== +3.2.0 [Build: 1533739581],OS X,WkySbYMiHN22ra3Y1cktHyeNikQ4fZ0K++8brc+8ImYhuzrmuzeGwL+QNaPJNty7stTNCfRUSpDzVAWz5TYQCA== +3.2.0 [Build: 1533739581],Windows,TJ1XoCjQz+VxW15qiGInWf5llTBtVu+2m2ShbY0/HWTM7adLyfThq7wzSgr09Fvowibvu91nOFxTlIpPXCAVAQ== +3.2.1 [Build: 1534255236],Linux,betw82OYRNjyhXDHmmUKwR6xfvyPHBMdkn+jukQKNG8PPLKOfLFb0OAMXPZxp9n8gio840gFowwA/jnbg/OMBw== +3.2.1 [Build: 1534255236],OS X,AWbZhd8XH+s7uu5Qkb2QkdDcc9/WXfNu2iKWD+e6m2oTrOmI1Jt55SsyDTvkpBpumnWsrtR/GI2nK9HbmFhGAw== +3.2.1 [Build: 1534255236],Windows,RtNOb2UrlXwwy3lplxRilvknygxamwb3eKlRRAsG5YjrMEikStl/Sf+oJgFUFBBMSJ+q+xPx3+xfOmMxAkB8Bg== +3.2.0 [Build: 1534407950],Android,rY2Hhki/5tJZW5YyJI6S9o9zuU4IGFpONwR6JBJ3Q7Pukfj08z2brFwCmGR61RzH8IaoPxoAWXIHQoHp6fUABQ== +3.2.0 [Build: 1534410132],iOS,BIWgZdgGSu6yPwCiEDQuORaLRqV1Z17ZLcxYdLqM2hfWXiKwBOO/j5eH4IH7LGubFfDwdGcVW2RUYKATpaJAAA== +3.2.1 [Build: 1535010120],Android,HHlJgd/XKWFdPOR5N4n2hpsjZ3y5b+4f4x1tLk397GI+gcALWlehtQDSaxe2R975/dFcEWmHiFd9zSC3tsecDA== +3.2.2 [Build: 1535010838],Linux,7uY1DWoJD2x80002ha6jSkNRXGcfHAqS9hdJz80JjafvhmxlhQKSwfsofFjEq10TI8LFbhLdv7TQxd+gPyNEAg== +3.2.2 [Build: 1535010838],OS X,qvbU2yq0wzSxPLPClraVmriM1Z+yB9qq5UzQ+gxuwE6dG8k/eosJH9xBhL7bhgcJKRgY2vsL00vbiLk19c+rBA== +3.2.2 [Build: 1535010838],Windows,ZUdctNEUa/SrRrXbqFCESmKIVDJj0nJrO0vwvxDNJGB/p65vf5GqvX9p625FOXO50dxxHPIIAvJDEjM/TxeuBg== +3.2.2 [Build: 1535459906],OS X,+aKFdPYAhzafs+eBAfjYn0v4lVlIEK0Eq/KLT8qwI04/bZ/OYw7eQyioABDQXMpE/7PVt/jt7/AzlYWJikZeBQ== +3.2.2 [Build: 1535459906],Windows,ErpAeuVpXF2IMeqeCTdoaKLEKSbQkquGlr/QsohLnxwcqdW3ltuPXofu+nJRK8IgRRyDfockqDOHSSud8hRYCg== +3.2.2 [Build: 1536327256],Android,dwHJuheBuCMZlUGz2N+DeyoWokK9/ui0CCV6HE4yJ6fqjoyFIyuX9TqXho63tNKXDa0XscL1U4TOaJlgU6pWDQ== +3.2.2 [Build: 1536584091],Windows,z63aqvx/q/R/SAsO/OcYl3duuj/RuDswghIxI7MlttMqvEuYIQQrHU92kn7TkrnbOlaVCe0F+RFrilckcPlUBQ== +3.2.2 [Build: 1536587534],iOS,4rsRo3H9Uw0kui/cQkaBiqYy8ox6/gC6jDUVktcB6I71m1TeqUYy/IYMYbNSBtv0bmKntvcA0ZU79+zoXUkSAg== +3.2.2 [Build: 1536915823],Windows,aBGFNFtVk/dmfk8cEecxKYreB4ht0LmpFBr86R90kj+1MFjSTevzaJTNywm+oS1hru5VM09Mzlk+k/8JFtWGDQ== +3.2.2 [Build: 1537178465],Linux,P2NaVyWrk5AkG1KE8hTPCT6J0ql0NzLeeII4BF3WarfVjDbekqKu2sQfO7W3OSJKN3cH8w5470csP4LZ+hrkAA== +3.2.2 [Build: 1537178465],OS X,QbSOeAPhPHgZKykNbEAlzGLZe8w+ulxcZXbk07wOBGLK/vWCfQlyIDPUK5DipGBUfRY9yJvxfUx7g9b5dU8aBw== +3.2.2 [Build: 1537178465],Windows,LHJV3O+hoZZlKWDPKH4ZMCoPUarYWwnaUgfMP+Xdm/4sY5NYUYjkVQaU4FS4pqxii5jx6O4cFToG7ekFB53NBA== +3.2.3 [Build: 1537790492],Android,qLdDfrZyNIdl1pDYtyrGbOLZK/Yi/i8PE/a7QOInsEa5/RBz+HW8EBGPvazz+lLZbHrBXyp875NyrKtLnc4dDg== +3.2.4 [Build: 1537790492],Android,cJVVnQRoUWsYSaYKWZ/sIGAAMTpnBDFu8T6shyH5o9AXWLVyu2qRmVVuyvKmMSlEVlYNtVrHIlC2AHtq3l2nDg== +3.2.3 [Build: 1538467030],Linux,pEBdtUvRUmczMmHZM5xmeZuiRP/Kb/H2YShNKGpaat8aPTmG5EF+zsbjUFNWW4tnt43Yard0bWDUsrJ9/mmjBQ== +3.2.3 [Build: 1538467030],OS X,yr8F54NuExnwarhvcJ27f3LvDop1wqwrhyqEVvpliRKi0hLD3e+cW2mJWRkq0eDjPRQ2kzPvBst9yNH1MsuYAQ== +3.2.3 [Build: 1538467030],Windows,dZ1i/CsCaAh4F7Pi2F/FfaBpdTmUuNVsAIRnqm86FUR3HhwBRn+xlmbwRF8gObgFMuwFMCLmawncFWplSILKAQ== +3.2.3 [Build: 1538494750],iOS,YgRxbZGpaxVAPuC3bln8HiCdgyx8EgM37H+VCSjZnn+05+lo1w74P9LFHSVqr1NBuB5YtKNWp0xjHRbBZVJtDQ== +0.0.1 [Build: 1543011433],Windows,0yUT1LLSAOTAMPiBGOAq6lUPnXv2N49clNjQ8MSmhNQmI2lFP1LT4Vo3XTuZ0QX5IBQBxnB9nJooV2Te11HhAA== +0.0.1 [Build: 1543414034],Windows,MoJT06d4BNOJrTlC9EnTi74rpu2rv8TKvXck1FlpNfB1IQO2DgZpHPjQbcpMnkstYFd6WBWVJvM2GAr71K+VAw== +0.0.1 [Build: 1549019113],Windows,N/GCBSNBRQUruUvJ+YM8IxeH+W+OkafgefmerruLOqrD9PRtFQ6WLvQA8rY/egFZPJ0Lu4dfaTDJ8UPLtS4xDQ== +0.0.1 [Build: 1549639384],Linux,iyFuMGDAoSE8LnZuV+ezxQ0iP1dgY/4FB9yZIe2emUnS/go5HA9zx945Clwi7zO/U5xgTLGxBQvDD/IONLS+BQ== +0.0.1 [Build: 1549657968],OS X,8usYZFvBvzaRRLu7EWPT4k3/7Ikhhla/Q53Q/qzxBPH4E3LoJFg1OH+IirFlTNze518j/Qx2ZyJ2RS1oHrAWCA== +0.0.1 [Build: 1549713549],Linux,7XvKmrk7uid2ixHFeERGqcC8vupeQqDypLtw2lY9slDNPojEv//F47UaDLG+TmVk4r6S0TseIKefzBpiRtLDAQ== +0.0.1 [Build: 1549713549],OS X,xNaB5RLET+B+Y02CirR0S+qEKUqwhgQqOAbg3QHDeekc1bl+bJ68FDJUW0LZ5ewY23Vrm5LtXpRCloKIoDUrBA== +0.0.1 [Build: 1549713549],Windows,OgAHgZJmuhL/SMIbmWzGNqvJ47cOAWHSVAcYDxTJswU/B6zzEDD+kB711uqlyFH9JDZb1tbzbi45+NlcMwlJCA== +0.0.1 [Build: 1549829683],OS X,MzkDQHfzv1nZhM3y99c4neMywQvRho2sQ7Pv+SCh0V8H1LaMB/0Ui9VkafIYhaf/gVi+I9wCvM8jDvMgVaCdDA== +0.0.1 [Build: 1549829683],Windows,Tx/cUfXAdy+xB+X9e3o/OgwIoJf7EKWb9mxXc+a39+vNJzganUFUEoHnuRDyUJqZY4URM15/vhbyqQiDnRYHAg== +0.0.1 [Build: 1549895652],OS X,v/sgnywcuwFMKhOlpoKLLuT+6shYyY5eHVSOo9pm8EUzcpHFe5sh8Aa6EIi/Zisnkf3Nt6JrlGS5++bLV6h8Aw== +0.0.1 [Build: 1549957568],Windows,F7f5rksW2FaFQsjRi+6Hs5fUQVqBLk+9TcKSyAxqUcwsG8pTpeb1ImfVHPLdmq0Ua5tofVeSoeGlfj2jiwVrDA== +0.0.1 [Build: 1550066976],OS X,Rau3KBAqvD8p/lm5M26r58zk0KQJjGqqKO+E7bcOLOtikJCbCrceTRATlqoxZKRjE6Ngf3LdsUtsDYab7TO0CQ== +0.0.1 [Build: 1550084944],OS X,xdv6EalStVMxsGrjJHtcaCqHlhr2OzWRiTZrDMYMmgTiorbRbzMYdrQsNw2a6E1efbuBuHs8mLIkAT4y0KJNDQ== +0.0.1 [Build: 1550143598],OS X,sQtvL4f6Z/gBf89kgv02UFHJVufDqKWcS6bPqvNMQHlSJrU/BN3HksOq1Bt4Z1fh/0NJ9la0PuUlMmKg8FAhAg== +0.0.1 [Build: 1550226976],Linux,22vWrtMv2ObaBwrQGw2CLs2LzUQJ94KoXiVuMObXf5pfoIw2MY4ZqMt8oL9CCyQBtKl6vV3CZntLrAR25ljeDw== +0.0.1 [Build: 1550226976],OS X,kXlZanPcXrP022c7tsTaMUVCljTN4dTDHiXlGXDbtwlpqfBZvuw5k6Qm0nsUsX/lK707+2Z9xpU+WLOh3NxkDw== +0.0.1 [Build: 1550226976],Windows,4jX+WqL9KZilTrNvb8Gh6sKjVYSvgAhm+HGDgioifYpszS7nPK2UJmNxKE2wAztufWGueJsD9oEvdQvG4SjIDQ== +0.0.1 [Build: 1550255704],OS X,SfFM7wo/5BA0HxKLHOqgh35LiB5HlqtmHSnCvAiUECBDlXxL8bRmTrrXvRHLUGP+4IvM9RzMbnj9/q1vcftWDg== +0.0.1 [Build: 1550255704],Windows,D8Ci2ZJERAKMKsIBRCPxCsHPaCFajgR30yuRlNdr+QVAHmhsKODF8Mpa/YFkYpdxwGY26UR4iUDQgiBOu09aDw== +0.0.1 [Build: 1550502842],OS X,VfMBVc8YKYh9KpyihQz3c983AAOV83Gss+t1M4jeQ5AFl/+Kn3ZcVZQhjVFQnfWQ8RuVtagJUTTKlDs5XeJdCg== +0.0.1 [Build: 1550679784],OS X,nx9CIytTawoAJdYJo3wT+zTKD31lylYhjUpK8AN6ZpvlIQE95Fm7lkzN8qfEK9NRdG4p3rX/6oVXT+Iv53MvCg== +0.0.1 [Build: 1550876871],OS X,hb10qtSWPUw8gSbdQDILIRgT9RRaCM0mzj4m9MQo2xLv1EYNZZD8svVsV/qrj6uTxtJ8WLS4RrOtkgm9qPC0CQ== +0.0.1 [Build: 1551044658],OS X,b4OpbCAVsZLtkUJ5DWzH/L29v8FZN1+3Dhdi3jmrivZE1TPTdII8OoYuY5spNKJtQma8BSJHjW0XyG9YT+NqDw== +0.0.1 [Build: 1551204931],Windows,uT/wwWZnLwO4dMIlLFYiOq1ot3p2761RNGno3KaGOKRCR7km680zdws2hmgU1lVGXTmmYdSDiKwcDQPckk+lAA== +0.0.1 [Build: 1551459948],OS X,iz304gq0xhX0oYrgn9ehoY8Q5S7xeeMX8gBgQ7CYfrdQnWMVusl8NY7qJ0SJJRQhFo+l/FZBmGGozscluPMgAA== +0.0.1 [Build: 1551711227],Windows,5Js/GD8nfYOfvR5Aa4ef3B3EgItH+bcQC6woFuR94yBDgQ0W8TUQ59u4GGufbjo6s4/16otHLJ48q0+Q4HptCA== +0.0.1 [Build: 1551713318],OS X,l4lTnkGORNFQh6N3Rrm962oaeQVhKnliOYv0aLJPNCw/N2EKLMDQ2HBGdNWQSr/iWevkJUcXFQAAXy1Ql7ydAA== +0.0.1 [Build: 1551783896],Windows,KT+SQaENLWvvIpuGY55oTqOJjhamigNWl48uutyPPJDPZEcqRAkU/lh/+wrKgOl65jsNDuJOHVOlEda8VRMzDw== +0.0.1 [Build: 1552322960],OS X,rCRrdfzjZqAN8MfEm5dM0dvH5DIsTxntEEhlCI+AxNJjCgZKGnygGwXPT4unubpF0AuljnTP/as7QVbDRqf0AQ== +0.0.1 [Build: 1552322960],Windows,9EU17JQJagk/elGn4Tpewc52XsL6nkeyEDgiXBgKD3hPEi+0Froo2urFyosoFaOap5x1L6lg5lf+yyBDNIX+Bw== +0.0.1 [Build: 1552499895],OS X,OiIxmD9ntH/NHcgAImw3bR/VEDQYQR8oQMagFjjbcyQP14nDhcCGoG1Quq8Y+2q58UerHoLYV83z1Pok3zkMBQ== +0.0.1 [Build: 1552572862],OS X,AZ/MCSPFSY4JnB+YhexNtnp1IN71whrShaY+3q5FIBp0/CpNlsqeqZEf80Al1kK4KGdelUIQFwEKrBZDoAtHBw== +0.0.1 [Build: 1552572862],Windows,my05e2+UaIDGYec2KG72JGRRAOEqosp1kA1vaIFHuf7s2KNNNZPqh4bsnmJ2LWARQVJWFvrnnjsEwjsC7GdcBQ== +0.0.1 [Build: 1552575092],OS X,RerNRKL0lwhRYOYBUfIcDNB95dTIQUc4OJOsXtUTZnV5b3M4WHMb8uugT6qWZhrOObzEQ9/Wk4MazMejIyk6Dw== +0.0.1 [Build: 1552639727],OS X,dZI4OOZ920/Jz6uN3wdSY/cJBKIwYi/2Vabb/DKRI/7ne+TbMF52jHDtKR8farlOR6LKV2kgDEFfZTzPWdBIAg== +0.0.1 [Build: 1552639727],Windows,kQ+MQqHTHNXXdDr7uxwU/ioX7z3mwifmG+y3iQgFO8+t6khxdG+r681nVVJbH5DWPWkp9EybR7O+tkj8VepqBA== +0.0.1 [Build: 1552661204],OS X,/rsQcIITEztmEqkR529p5QZql3wX8PUHiRdD3Xj5J7qXfmIIdHqf5IplMc+zC4Kcst6mc+RSYjzA8hqq55FfAQ== +0.0.1 [Build: 1552982242],Windows,lTI32KaoJMMowYoN4YWvzYM5A9sU9qmy2ZFQHnRxXQejwLWv96XDeYZFBBB+BbsYlD0wbWZtvSz6diJhEnAKCg== +0.0.1 [Build: 1553161313],OS X,xiE4CVM01BoGLWxPlCBVWKzSzVFOIu4uu+1Zq1PXKzS+UIdZk+bqhqye0cHtVDwSaz6z40/4f0409K9ZcoIjCA== +0.0.1 [Build: 1553512400],OS X,1cP6H/YKjgFj0dTlSXHOZUJQ64t7hkY23vDMEJz2A1J47KmZXGwXphNHdD3GN5Pn4IfExzA0w3X01hrBb0InDg== +0.0.1 [Build: 1553512400],Windows,3vv71iNuOytrgxh6AN0W0fcxhe3LO+0L9CSKd+I95RzDeoFOLpb3L3v7mtY8RycWxvb9L9afpuKFn9EbXMTeBA== +0.0.1 [Build: 1553695906],OS X,mmpn3i5p8NlBRZK84pRrVjLouHBHMNG8ajL2RSXGcK0O4Oe+fQWW10uMF+RcfEAI7JMpfCX9hI6/CFr5zRkxAg== +0.0.1 [Build: 1554384958],OS X,KiRmVipTS+ZOMv/smwfFw7gNDoKrLMyHO5HLXT6boyo3NwpQDoOyc2UpMOmMNKZTEx9dA9uCb2q3x1SjovLjCg== +0.0.1 [Build: 1554399512],OS X,WWVBed7WmK6eLaScLDvU/AOzi3tHaaX15VciJfSZa+maEyk9mEnGpfYSccb/25q5gKv1xjHrssoy3LDLOG20Ag== +0.0.1 [Build: 1554736383],Windows,Wf73FFZU9xp0RgCeZUSBgR/4OTlvcdUBbSXjTxMaNMEeHH2G3vfOyb2HDoN4WgE9UDkDYeK8Lef68S2hru+zBw== +0.0.1 [Build: 1554822978],OS X,GJJS+cDKE7eCzEMb8FORdSWP3iVkZ13irxGmEU/UicafIjgFIpNbcFTPCzJVCJ8TbJ+uXz5Jt2LK0wu7eGkmAQ== +0.0.1 [Build: 1554822978],Windows,t/BvQLC7xOtcPZ6A1StLsc9DtOw9TEii++82zrwOkEXpQk/ts2UVcYNeonNq+tSnxuPeRM7AVQQSc5KNz5I4BQ== +0.0.1 [Build: 1554918032],Windows,swQxkzltj92y6u94gjl8i+rUdGYtGB6eWgdbmtPRzoQ6D6Ju1SRQ0J35jxk8lpL4WRp+OkBFmeVKTsJ2n0ZnAA== +3.2.5 [Build: 1554991343],Android,HkOn2tmPaY8qTNhnpZl34QkmhHJzOBVuUdeANQQoCMqDyDovii5zFJnGALyuab5/bHPl9rqy1jllmhWlm34JCA== +0.0.1 [Build: 1555000573],Windows,ss6fgeQA8LSSJpjEia5Jfh3G63JigMqCdkyqlhH7NgMzacBV/Phbcl12GcDXYlzCt/QY2xhi/ku1U+1KVD0/Ag== +0.0.1 [Build: 1555015683],Windows,AMnbAjVfFPOWlwcEFQjz0pokTLpjGEN7TdH6HliidbMBQXLlj9T/LmwRr+IT/ZjpY9+znSXLbVmF2+d0jLRLAA== +0.0.1 [Build: 1555082010],OS X,o/GYOMVcxtE+JWFjozRjS9FJ/h35gGcPfvZkc23AlglNXI5aj6oGg3Gin3M1fLOnSOxn3TSU5WhaQtvCYZgZDg== +5.0.0-355a06f9 [Build: 1555407897],macOS,1NtwyJX2p7rkrN/hWD49iu0p43r0gnaiDY+2W2aUVyGhh5cYjPz84IxzNaR4UPs4dgFpJPJM4pdf9KivwJmGDA== +5.0.0-test-192 [Build: 1555445179],macOS,e3HFhHXYOgw0BsMgkhax9sQ54BA722ZEb7W0j21k9huKC7yISTkDcrAWGCXe+pjR0mucjazMYHMzue6kJk6NDA== +5.0.0-test-192 [Build: 1555445179],Windows,2qdOjcl4ZcqYyLvp6u5oHTH9LPbergYHKASwWc+Sj6iBO3Y/jSzCawuDW9/3nKzlG0lbi/JcFtyku4DN08mCDg== +5.0.0-bf7671e7 [Build: 1555448654],macOS,ayQ8KcWuXKoPtmjRfH7WuY3ECyPWKL4JqEals0SkgB1CNqDR/PBgryvOUxN+W8N2d38BMH7g8VkdA2XeTrzZBg== +5.0.0-test-197 [Build: 1555495120],Windows,MOS8hPR38S/LAoMn+R9JXVsV+cDJVAyI/Dfpvt3NYKwiis1LqdWZymu4osfcrfJGdpSg5q6YZa1CeJSETaizCQ== +5.0.0-718a441b [Build: 1555496184],macOS,y8el2L26T6NR19KOphUYNtQ0NTe39z9PGoyYGEuQUPTBk4vG/x09RmSppdIKrj9ZV4sl+hQ8y11rCi3rRQ3bAA== +3.2.5 [Build: 1555517253],Linux,+nqAMBv2NxHYfPwHyRmleALMU/2gpiv1LAV6dmrLjNXaTS3BwLBVuysSuqHsuiK3/Xff0IRRFANz8qT1ztJqDQ== +3.2.5 [Build: 1555517253],OS X,xrP7+C0BjffIZf7FD21P/xYoCSTmq8nCa3w2q3McX2DlUIEjfMLAX7uepdeiNYZfspAWJmi9QIkpQCltNBwqAg== +3.2.5 [Build: 1555517253],Windows,iyy+8G7ksPHvXb45ijQ9Kfr8TMsCc3sGRKJLiPArx7YMPu8YV4GgYzM4+MpuMQUTlNkU7w5B0od9IJ/7E4nDDQ== +5.0.0-59fc92f9 [Build: 1555588817],macOS,p289ARagvIGDg1lknPUB07x1NUqXEN9kuMwSMKZDrO1gC0wrwAqeaMLt91uNy3VINCOjoDhBdnxMiBed4xCuDg== +3.3.0 [Build: 1555590310],OS X,4K5QbIPYfu42+ytMNgJOvYHB0kY/S+su1vsJ7zuLVlMs+XHbNhJEtjMANjDJAxfJ+fJ77VLBHf1Jo6Q5pSJFBA== +3.3.0 [Build: 1555590310],Windows,eKXdV7wEuwhoN+nk97ety2gAiNM3afKEejHNyc2slGASWXRgrorsEb8c2hcfy9D1iM/OGmsj54inilYZQz76Bw== +5.0.0-ffa1a6e8 [Build: 1555609180],macOS,DPJYkUdJdZVIP+92KuGAJ2ytN6Q723moxG+nFGD50s+I/0kPPEw6pz3B8vCD41mG7pp0aPCQoMBFqYgz7IfEAA== +5.0.0-01c1042e [Build: 1555956706],macOS,D9odXVufvwsTsmzrCZ3iOG+zCGagT3gmori1+EWm/Q3A9jUvNiTpOxUoGNdVJ72pADeVczQldGbG44RIX8zYCg== +3.3.0 [Build: 1556009531],Windows,dhfCi8/4JnkIh3iNPr/7HwzAlVfMgk2IXDdHpyduLZ4BiIOwILZuHVU6u8b/j46yYUklMulweujLaI3IRn7MCg== +3.3.0 [Build: 1556116957],Windows,fOs05Nq80Wvcu8wx7MtITPrCLuKZ6kWY7rwWGYWByri4NbVpmY9mFpfzqBcB3MgnMkp/kTU2jteCjtKjI3EEBg== +5.0.0-20262827 [Build: 1556210877],macOS,0Z+ODov6Dcu0oUuVQV8h059RbFN9+Dj+0KTRWId1GK9d2pq7IrEMzWJHI+R92KnRyaKQnOmH1RdnVzEZjeLXBw== +5.0.0-test-202 [Build: 1556234251],Windows,G5U66Tyy6vajlxvHMhboeLzd91lS1/o15sK1FyCBvbaETjRy78R33FvSLak2bOKwFlXecMlNf8HlhrsulJh7CQ== +3.3.0 [Build: 1556290731],OS X,TmPMXMIBrqHO4CWg9fcPxSKG0DxxJGb6D0pLkqJUZDHJ+tOcM2e9s5ZAmTzeDPCDnq89f5pOooPa8iPEyo4yDQ== +5.0.0-alpha203 [Build: 1556295552],macOS,DaV6Rvgau7bZng3HQr2Tt8nDffi/bNWwaBhL+OkqiUShZE2X5CPaCYix1ahZRID+XF3jANSHu7anQNgaNQ2rAQ== +5.0.0-alpha204 [Build: 1556312473],macOS,R0GsDv1WkAMMACsoigLj8zXtIDieUIfVQ7Js3kNMtV2IY3EHAr/rEvG/R8OQYJjtxDQYHu09D31BxXOLabc7AQ== +5.0.0-alpha204 [Build: 1556312473],Windows,liv9ymEJFPqK0x/duZzn9uJqfkL5tTq2WOn1omAMkomTef7k5wd0FQ71ioJhBAr5UU4rKceahVMVhwFrYwcQBQ== +5.0.0-alpha206 [Build: 1556530824],Linux,jIng2diWQpiV/D0tMDJSoA24IB2kB1weMJi16NdXRVKaULISROJHhbZKVZwOvl7Dm2yQFneUXguxzUE5bHWXAA== +5.0.0-alpha206 [Build: 1556530824],macOS,AaYqqXfOM9YSHTCNw/dVBrLUx8e/Kb+m7WmcRfEOrI+gqxS+EyqINxPQxpohpf7SW3OU2p2ic3BqaR89AFCqDQ== +5.0.0-alpha206 [Build: 1556530824],Windows,Zi50u4yizVqLgbK9Zi1jM0M4AOojMXvzSk2WhOFGdtNEaz/F4KvitnDVjtu5hzYIyrHFEY472lCCjL5o/qcbCA== +3.3.0 [Build: 1556542489],OS X,5yXva471HNY14SB2bwv8wc204PIxZu7FRaNMFPHRbruAP5hVvuCFI15SBIas+OSOwxJKqnzYkKfxAbRci2sRCA== +3.3.0 [Build: 1556542489],Windows,VRm2iUqx3CYHIXog65jCFBZDNr4/fa6RIaItQgcfCtncrK7h/c4onUaPPH0pJZ3juwLML7xktRX4re3MoHE5Dw== +5.0.0-alpha207 [Build: 1556616734],macOS,LIv/VLt/oKLDhOejNGJPQ36/7smVaUn1ChGj2FbqLSc1FJBczX/kKuGtdYAq0Qlfh3tD38NzKT9585FnFrwLBg== +5.0.0-alpha207 [Build: 1556616734],Windows,qKNjBD/w6eywswACwGTRB2Y3x+je1htUDrsEhm9+G67wysTZeM8LMgcCz0V8+zTo9b5YNNC9N8aFxl8NZeQ0AA== +3.3.0 [Build: 1556630414],OS X,LCnJGOq+P+cY30Pn2oOOK488op2EXEun1MgeMiTXlmzj/tjuvpdrxoiXC9Vu8C97eoOBVRD4hj6fN7FODaklDA== +3.3.0 [Build: 1556630414],Windows,kKY5l53E4SLiSWqc00CiuCcfeNziXPLwcXDCVcACIV45tupxzCo+w+g58qP+Z5A83NoExD+50EIuOEPzK+8AAg== +5.0.0-alpha208 [Build: 1556660248],Windows,UTdgQaFrU15818vsU2raGj6Uy8A3jbzVY2RighZqrxC/HLlA/h4IWIbiAPE3Evxv95Cgb7Vg93ufYhpSNY8EBQ== +5.0.0-alpha209 [Build: 1556801404],Windows,FhUBPJ4W9+B3Yb42X+Rw9/+hEjwZeYTnTL39h7J8WEeYBrj7ocDSsnQosz55VNleHUgLCABSn0BqG5yEJf09Dg== +5.0.0-alpha212 [Build: 1556813029],macOS,7M9RrXON8iXKOTe1N/lVC0ZuL1HIWuFyI4kWKpnTe3EUPf9LZf/tXGzRPHD2C1ih3JXxEuVuDSd46a9rwVWcAg== +5.0.0-alpha212 [Build: 1556813029],Windows,hpXm9n1GJOr5eSoMKH4U6qUPHbcoGaCjCV9heCmQa8PeunGa+ka1sgAf9H8njXUxCoQQYQDKazrTnb7DnGFIBw== +5.0.0-alpha214 [Build: 1556897845],macOS,37CHmojr18Zo1y0Lu1g/HjPAUvEePh5T/Iui+zcOobPJFwGgCNs4X+cVBGf9vzBOyd3qSi/CxbB1KL/VM9XNBQ== +5.0.0-alpha214 [Build: 1556897845],Windows,iFV4wtdkvLQPQPKtpoB4eiBNy+r0lU6hVw/C3t8ir/zgoWmuh7DaQbKu6+0Sx2zNeyg8d7AspN3ApYUWLk+5Ag== +5.0.0-alpha216 [Build: 1556918526],macOS,UoCCR0jcJHW0z3NuQsIG1XBipDMgPiHbD7zFZVnB97Q1RgsKwRyvOBumXrAeCL/SEAprkAmrU0ofYQBuR1NjAQ== +5.0.0-alpha216 [Build: 1556918526],Windows,sWDezOByhJ2GNjO5+w3oGWpI9jXXZy72iBSdSryHBMVCW3c7khfLzmpipqC/3yUACQU07yEwThcYLsK4+UYrAw== +5.0.0-alpha217 [Build: 1557239244],Windows,r/rlz7JCCAVmV1FT5mhvu6plHA6Hnq50vkSd0nlgWuvZ42OtGtpklLkk+Toc3BW6f7roO8pgqbr5rKlry+KmDQ== +5.0.0-alpha218 [Build: 1557333442],Windows,Smg0cmM4kCTX6Pby2dFZmqbVm/60S92m4RVUjLf2tXZ1lynNmJTKS/M0cFFRpYQhw9RHmKK6oAEz5rtKv/8bAQ== +5.0.0-alpha219 [Build: 1557415390],macOS,WgNuMCz2tpWDCGABKIBCT7VopmskmlVcbFM2z6ZDqPTFtmebu2iKsJ1VofMiWPknHWnllduKNW8ocvTQiJywBw== +5.0.0-alpha219 [Build: 1557415390],Windows,sXLcoviMWxxPVR0+BD9Kpv0pKDBCyk3DSKZwW2AOa0YZhrfSgTXciDXbMmOgOk362OHLxcKAw1cjGgNTrh3KBw== +5.0.0-alpha220 [Build: 1557519031],macOS,tDngpCe+wRn+fGIxTdCg9cFBIyoSF3XYSaw7ZDmumjPDRwaNqZ7U0g1DVe6xRtoOhZczhIUM2ANAaVfhhOvGBQ== +5.0.0-alpha220 [Build: 1557519031],Windows,J2z/+8j1Ls3n/f63eIhKB3IlK8vOVlw62Y9fUqUDlYNDUDWdOg4PakhvMgw26UiL419/rx0Qm6CfdjDgbU3hBQ== +5.0.0-alpha222 [Build: 1557769659],macOS,EVTuQ2+e/AXohPHoYo+VYByUjeYvP2JBy/aeYuKI912zVbrITSwG9b7JpRgAJyPUyvsLnAWKlwYA9RPtXCNIBA== +5.0.0-alpha222 [Build: 1557769659],Windows,wwbvrQ42kySxiyVqGGRajKho1yLFKfmoDiVjg5NQGUpag3lTCVn66ZS1O56nI+sfY1Yj3IwFiZbgcxbXPjBkDQ== +5.0.0-alpha223 [Build: 1557842114],macOS,oAgBumoab/97kQZaJTE/Nc/NrMVbM7B/G1Ob4mUMIWF8Orw9KBtDNJ8e3Hq1TQzNUBDiQ6Q4vub0OEUGld3pCA== +5.0.0-alpha223 [Build: 1557842114],Windows,pYAtduIWDXlkr4FuGXUhNkk5lJLropb7aoY/qKABaf4GdvWpbN9KmdgbCMvSwhXWPi0+YZoVgHS81CYWkHGGDg== +3.3.0 [Build: 1557914437],OS X,+kZH9b/Ka86RnioFhD+RS8oYQHu8Ijb9vqLdySKgRY05LVU5CJtWOCQ+IrNUOYDVqMEuHzkPGDFQFO85tHhUBw== +3.3.0 [Build: 1557914437],Windows,Cc5W6QpqeEhSa1sODAy/pmLRZ1nA1ZsUbDhwg7H0KjWoxy6l8JWMmviXLWuA8RuDzJJVJV6bQU3Hf6QcMNlRBQ== +5.0.0-alpha224 [Build: 1558094517],macOS,g0J4+3KSC1LPYXqgzO2cwb97hCgijJnOcgvuSElBLPrnhPSyC92XQZUIkBF6AqkOtIoK1TfbpvCZOpy61d5cAA== +5.0.0-alpha225 [Build: 1558176095],Windows,B37WMPFIacoScNJ4yiL/bngwZ9StFNACAJ65LezIlL1OIq+nTexacjc/qLr4oncCDzhoLCUxumsCR/bzkxESDg== +5.0.0-alpha226 [Build: 1558186695],macOS,DTRDsFrz1JRxAoqbsIiJwL5O+dn3+RDcHaQO5KS8auxPcZPa1NFC6A7cbUlDiez1zTjWf2uuGf5ZhMcv+JZIDw== +5.0.0-alpha228 [Build: 1558453482],macOS,CS8WBiOC67A/vs3iHbrG7PCF1Nv5Zcde+fiqbXha1KxJKjYJKJ2BiyfuePUtpO7YL5+G1DuDZrzIg0pFYcseDA== +5.0.0-alpha228 [Build: 1558453482],Windows,+yW0rVsjHZNWYWZLPOrhWcdGUn8xumz2dpUS+gaJyR3hR1paxzicQq58jBmZv92MmsT2Wj3Zs+UzQf5NzHLlCw== +5.0.0-alpha229 [Build: 1558545291],macOS,QHxI/Co5ZTPCPlvr0YBuXzoaTbJdl1XxGtJt6TjKBjE2VLjQwRm5Bx++jYY7Ff55IwUUhTZ98j0UTMwVsxVcBQ== +5.0.0-alpha229 [Build: 1558545291],Windows,MS7HlWUlkp3IZDBalR9xEcGPotoXh+23QecliSQ4B+01dpz7EA4e/VqknjzZrn4ns72qauMbXT/zqUqR6zAcBA== +5.0.0-alpha230 [Build: 1558630781],macOS,dCxOoelZNVXI377eBmeplmiXI8PgQUYRSk7WVnJ1cZvFQeMIEbzKHgvA5PVD1Dyj0i4FpZpucmnACglNBxY5Bg== +5.0.0-alpha230 [Build: 1558630781],Windows,llzRK5eSY3jWVuHvCwoeb5Nl10YKw6Lk5F+tAt7DkUMIwEoM7U3sxFHeMf3J/yYrenAKb6FgqB6WHqXYINPoBA== +5.0.0-07b4003d [Build: 1558632796],macOS,Bq4/nAP0mR6SYuXx3J+Qk4+UAcnqraWchH+x5GMlZ3d7qnYkysNn4WlQCEjLuO2Idayx+xdLQmq+jASWTYzPBw== +5.0.0-alpha231 [Build: 1558722704],Linux,3fMgWCWzh/v8A+EM45vXindYtEMS/Ofpt11eUyHntfr4algP622X9iyPfdOFJnnFH4ISAd7Qh56T2BvVlFPyBw== +5.0.0-alpha231 [Build: 1558722704],macOS,Dndjvq5Y3GPe6IB+9BgX+RfNqzh6CmLLBxHMdXwUvbB4CE8TPqBP7gZwnYeUjf4Ij0yOSitmeJMLseHU5UcyCQ== +5.0.0-alpha232 [Build: 1558967089],Linux,3T7hpgk1meh3GGXvZW72K/3uQolAUHFLKVM8RP90psN5oIwYmxFDgnAsoOIyktHUYyCdF6JqpUN6hl/yOYY7Dg== +5.0.0-alpha232 [Build: 1558967089],macOS,PypsLXiPjW2EQkHbaUveezItfhMQQ5aonMWlpqWezfP/zoxtvUET5yf9lFY/PqO/bFtShhmPL/tXKBI3ht4qDg== +5.0.0-alpha232 [Build: 1558967089],Windows,gzCs9to1JZ7EnKIAQ46LzsSu9VgL4fOijAvgu6dG1itUVI9ilE8WSWk6azeJQoSXXUqUhVlJEdRsjMAsSMvIBg== +3.3.0 [Build: 1558980407],OS X,Vmf0Mq8hgly/4ChaLz3m0/RM7IwJdEXyIOljGu74lv4ZKOLHE9o2K42sCdbrtG4IPXTaBlEiItNDeFmAD4FhDw== +3.3.0 [Build: 1558980407],Windows,QVrvVgvXctohZ6wGzvJFB3SnHH5TTqYHLJ0A+j4KZrpn3EKNuXpmieIjJ4NiMx+Kce2hO02FXSY/KVT4doTmCg== +3.3.0 [Build: 1559042453],Linux,U+WzCGMDh5JYkFfA7ZPDt43sZhVFW/8tHNXPeHAP+ZOK+3W0/c8TvkFiW9NR8j190KswFVYb7NOhigzXsn3jAw== +3.3.0 [Build: 1559042453],OS X,MsN0f5qqK36AtXMMP7i2yE7bXFHRST/cbB6PaD9HMDomK4q8cG5qBVIGXa7KG0PAAZUtJAXwr1c+6fCIzBJRAA== +3.3.0 [Build: 1559061820],OS X,uG9rtcA593JtA4RuwRYuSD29I1cNWa9rYub8xndRbvZ1z/qhqUk2oGwnQzeQOyzZRDzExfYiFwLLi4LGTNXADw== +3.3.0 [Build: 1559143149],OS X,JTB+B3tPBtR81UKWwPwELq7WX5SnJ8oY5yT6MyCqUAxoC82XEp7ZUYvgyuLdQ01eHNpmQNF25nyH+4+vBdeGBQ== +3.3.0 [Build: 1559144369],iOS,xXYmjT4t0D0Oll99yVPTsRXxJuqFr4ShKEtetow7ii6Qwkm3mkMIrg67NR8foo24bBQgcY+s1CQC88CD8WT6Bg== +3.3.0 [Build: 1559151651],OS X,d+imICJxJ0pW1jeHdu1+zi8P0RfgViiYRhVwSBaG39O9oWHVIriaRJKJDuqrdnjGCehX174Zyg243Ul+02AQBw== +3.3.0 [Build: 1559151651],Windows,R8rfsRoxzUGuHQIwPiMPeAC687o8NW3fzjA4f6Ivgn6b1JTSjAO2qguKhJfNjGl7EVFTagNManW9bSib6bkkBg== +3.3.0 [Build: 1559172971],OS X,ycEAOKlOA1FT53mQt3WHCbTOikB0KTgbtsJM2ZPnA7pV4cBbG7xJ3FS5WZd46lDDcl4RQuhwIIGNXf1JJs+VCA== +3.3.0 [Build: 1559207969],Linux,rF/2IHXSOMtJrVigZ8nz1gj7AO6OUmCMkPUCvtmiPXHzopjETT+juLcclvX7jUo3nElMMxPdm1ZmQcTM2HXqAw== +3.3.0 [Build: 1559207969],OS X,ZhFL5PsGfyPzPdnSEO3u+r0v1/3yrLBtQMErAd0IwJz9vY4+rTZfNhzfbxLhbg3l7NRRd9EMHtxsy0quXJNPBw== +3.3.0 [Build: 1559207969],Windows,YR+Frh2ZvoqZABO/hk0fLM5urA970HHgkNuiFCowTQkAd4n5Qv+Z9bPsjrlZF8UkIJUacX2f6yXrbEdk6fSFBw== +5.0.0-alpha234 [Build: 1559301070],macOS,gMbSOGIYOP1PpHz0Aqt+xefZSytby56+8Z/IE4yg7Fo73b9LMb/qfQRO7VvlzwSB8c72/Sw4OyzPgB56+pmdDg== +5.0.0-alpha234 [Build: 1559301070],Windows,X5SKQ8c8YGQvu4FC3E9pDzTBQAiz2SBwj7Z/woedk7feGBrj7hx3woASaEtQ33pVO0KseWVWbt8plUDFT2TuAg== +3.3.0 [Build: 1559307127],Linux,u9pIc5sk0+s1KqVj1Jrwl1eEu+1QUXOPTtPA9Q1Smt9Ym5N9mi6BOrV6Ke3DE6uu/7H0hBSYh2aeZLThX+LPDg== +3.3.0 [Build: 1559307127],OS X,uGMlFevcA6rER2uq1xdapqzmLreisA98yi/6LWK6GR2TyVWjXwMQ05DXAjflz/N4JUbuIal16BsEF/ByZ35LBw== +3.3.0 [Build: 1559307127],Windows,His8U9cnGKfL1f93iCm/9H5TSmtRFBBkcPW2czbcY7bA71IvQrXB+nxx7dNqilVxPZxqfB7yuKieGdA6kO+FBA== +3.3.0 [Build: 1559395482],OS X,RC8j63bAAQydHNNlBBJWhUS0NgMvMFhjgn6MNlzC4zQaoD61OuYrrrMyx6ks4gLwZ/+RWLBkXMZK4p+cZT6LBw== +3.3.0 [Build: 1559395482],Windows,npVq0Vd6BWXh3bhUNDAzAFU2iuQ/KIClddTjTk9QnBnF5l0uW9g1VkyjqBcDyLYpZEsa1ZFWVKOKlgnEjJJqCw== +3.3.0 [Build: 1559423503],Linux,NZ173oDGAENOy9GIYGpnWPg4Em69GM8UX5C1jzxglbECIWzIcH5r4fVnuDbTZJiOgmBacgsg1y2RbYk5r3LrCA== +3.3.0 [Build: 1559423503],OS X,O/Q031RHvRZiYRwor/T6Wru50I9bX+pcFEpiYN6WF+jh8vti2IVkkTqoKHzYu/W6K7QN0JKcmOahoL2xARdUDw== +3.3.0 [Build: 1559423503],Windows,ULqbAwG4lV8TBYWv/W8hRfkwlXFURxuhlnM8AQYWJsPEIoJyeSQjMxqAU1rHySTqYPMRM+Q/dHHY5uD2nFJwCw== +5.0.0-alpha235 [Build: 1559482103],macOS,eYJ/ihasd7Szx2o6ECEY2m0e6GYfGIDDRVDzaIFqq5TJvqQuBFtuFx5eaEfddBRfBAmPhC+14DTYvW21IKvvAg== +5.0.0-alpha236 [Build: 1559578284],Windows,QBAaSF/mQotdakJI/1KemvF2juB96IpvEqCe5fVlnSM3Jx0UV9jLnTkdYlBUYyLpRkB+DWO6GN48FnB27zNqAQ== +5.0.0-alpha238 [Build: 1559732615],macOS,0lQWZ052Se6L/o2FZk0+kLzbDS6o3acKPSCMhISh/0CZZ7ETcF/6xjVVBGZuWPNPIL+/00ncu/AwibfSUM+HDg== +5.0.0-alpha238 [Build: 1559732615],Windows,EusUrcu92SYBZj+5MjjuduCIyKYhFgEaKc70EQokZAxeeMsqATBYIzkggF1ji8DEUCbfohSiO+KMbLXUdtTtCg== +3.3.0 [Build: 1559767425],OS X,a8BpIJkdXEgxUOrFZ7Uk/fxLxOTGNdcyf4mPDC6BmXpdxjcLM5ps6U45o2tnfrd5xSONtPhaMLLLD1MhiZ2bDA== +5.0.0-alpha239 [Build: 1559815502],Windows,91txA9V5csVkRKKs4+pDDhQO5Yh4Ca0Eh/EcNAbk9yJSUVF35XfXZFTH6SNr9xE3QpfHYgHG67YPM0TsuA6WBw== +3.3.0 [Build: 1559832098],OS X,H3LyDEcQz3Rcz2CGd1Y1PqhgdUzAcO/5uoKZaeJ3qAuAc4DrChbsduBqHCb70cygPDcHT7iqM0zAeZAt9RFwAQ== +3.3.0 [Build: 1559832098],Windows,/klG/RS8bvimBdtvjJySVY7J6W810VoT/naLsi8t1aLTxA1UA9Q8n8Ze4rbMYXWKUqTpgP2dRlqnlPnV6uYDAw== +3.3.0 [Build: 1559834030],Android,Ux59iejFFnEANHPjL4dmwUgXKhvnV7dPqjzAIqYMNs0RoF9RyhsgxEaJO72IgNt7D3yaD+4lGtYfcEFG8WDKCg== +5.0.0-alpha241 [Build: 1559838513],macOS,DJytwJVmYEhdcEJHPOo7sg+oTVUFK5zRk3wRJn++OBNenKCoU7uSp1+GZbjU3nIDqrdBj9CL72dnjbCJDeVsBQ== +5.0.0-alpha241 [Build: 1559838513],Windows,AouFlEmYwG+IhVSQN1IAN5mOLQnEos3XnTkCyBoPfyvxn0EQ8kCg9L6aHj6x4kd+KMGe1h/94oYk4vS3M1gjDQ== +3.3.0 [Build: 1559847347],Linux,eu5V4pF+XgYBg4ig2/C8NEpAjBncsoeHJXDyHAXziZktezDNYTsJIIW6BkFLg4N/TiIdIJif54pCEM4L7oeODA== +3.3.0 [Build: 1559847347],OS X,Aft/7c6PYAmhwJctkpgPWbDgV4fkeN3vt0MHNEligntg7xQBSyNECO38ghO0dl25Su6A/vHBXxxobn6YAr5wBw== +3.3.0 [Build: 1559847347],Windows,gffOfzgmsY79PAQ4Hk2zHU7fpYgOsQU42Li7GnuGzORdmxmw5EpS1+sA/RYe7RsMdzkNxhvPQ3QhM2jDxJjQDw== +3.3.0 [Build: 1560032346],Linux,X8sXjPPNm42tCNhFrfNhWb4OiZMlkx2HXaLOAOJilEiG+Vs77BR//AxUuB+iZa8crBOWLgrE66oh2u4q2QcuBQ== +3.3.0 [Build: 1560032346],OS X,2iOqRuzxYSJeB+7MB20alBy61Nm9E/UlqgvbRxtN7MYTLhy0kuaAXjQYpI6HImWM/X6UJjckZvAUBg0aK7zbBQ== +3.3.0 [Build: 1560032346],Windows,9IPmbngc2CpvGe9inLOFpoJCxoU86yObNUJ1fLTzuPJCh54j4zFidNnv3Xe59gKgMzDHZ5/7H65Hubsi8j9+Cg== +5.0.0-alpha242 [Build: 1560169692],macOS,9AbGQKw34QuJg2gRcfzp0JkIdmyVWrRAUn0BOKVscQGo98CoiAEKJixVhQxsoDBb4YpgPhdTeBkGMuJy9BRVCQ== +5.0.0-alpha242 [Build: 1560169692],Windows,Q42kSe5LxJ1/sNqojdxgBwTsXMXvTmz9Ipk8eQptq6AiwOj0qS2UqapIU8Wlir0zvWYN4675mT/e/ce6yn8pAA== +3.3.0 [Build: 1560189475],OS X,WhDvkhicz+E4w/g8NRfDIRWOb8vEJkHIJjW8IiGLzx7R0o51mN7AJ9GaSVfH4za4+TGdKGFrs8Sl2VUlreqFDQ== +3.3.0 [Build: 1560189475],Windows,glcuW51nfgvusH5yBKRGvSfRRGD7I+5hWEXmK1spfOQoPVLMe46u/oxKJeIKMietJ7bLAG1t18dCI3CysuBFBQ== +3.3.0 [Build: 1560265364],OS X,Qscrve6CfWXAshiOjvUSmshhHV8QKx1FsrUmkzaOmRAFrg+SZYvjLBQsdV+xSb4UyI0v77iyXQDv82Q4/l6eAg== +3.3.0 [Build: 1560265364],Windows,3dnvBngFvSg1elIctIK8j/TWfdaxaoaf+4W3dc2v1QBW8AhTx+2zlxOaGBDFXYfL6asP82krFgoPXeEtVFVkDw== +5.0.0-alpha243 [Build: 1560345924],macOS,L8dmXQrk3+gxHpIHr6sTxr3ujyGI68oCtuOLYLDSfv/6YkEzxGJPp6pcO774ptrllOj7Td8RzTsNSaEQZo7PDw== +5.0.0-alpha243 [Build: 1560345924],Windows,ijnSy4j+gfMrSheNHP1NLhGr9J+k/jvpIaxnkmI7iwDMNg1Gqn/SIjpDqWvcdztETrDlwJ4doYYwjteGubnxAQ== +3.3.0 [Build: 1560464251],Windows,bkUu9ipgPnyMDOCbJG9rPTB87JWx4ZpCk3tKGut6dXnXgenYROA+BvPzN1k147kJ4Jdyh504E+2E7laxb8eFAQ== +3.3.0 [Build: 1560504952],OS X,5lk5x+337M2JI/TRCD9/zZoUBBqLiKjf3KdLvqyt2dTk0VCA+aG0LWgZszJR0D7lbhtA4ez4OY3GjyoOa1+uAA== +3.3.0 [Build: 1560546557],OS X,FY4pOaQF7XKxVIgIIuMJOhka9b7Fb/VLtSiHRkOstOItA8alGsR8BAD6rKVAJnBuGFv5uG3RcxHF3yydBriECA== +3.3.0 [Build: 1560850141],Linux,8giDUlJFDtdmzpfyngDzL3UP47C1+U1iwrzROU70MoiSeswf1oJujYeQ1bx4dD2OPxF4Avi/XgbZUQ/Y4NcDAA== +3.3.0 [Build: 1560850141],OS X,Z/UJgrYae1BsdKJfvMorW4/zIQ8E0sKBMTBI5Cm58oYE3TtCE9+1FpUE9VkqWSm3J8SMmu2+J/FpaK6pa8KaBQ== +3.3.0 [Build: 1560850141],Windows,v9gCHwBYJKBxLWwptMvqhj+tvWuSAz/AjcThvv/J3ZNsPeivRk4P9Y9YtalQbIRkrALQSC+qNc5wIAw4HG2cCA== +5.0.0-alpha247 [Build: 1561047486],macOS,9i+SzqDeOjSdwfQEhD/hC6arCpCaorBbELfKSVqx4CifMIv+xOtBkWPhOqg5ISTKkqUPeMBvgberODEgilMbDQ== +5.0.0-alpha247 [Build: 1561047486],Windows,7RDCJ1DN4Q+bh9FQlDdkYK5OURj/H8kwrPcxKCUXB67Al0ouj41vNzOCYul+c2hNNrv4wdmxjHjYN74T6dDVDA== +5.0.0-alpha248 [Build: 1561153809],macOS,YNHobK/oj9XzKKo2A/qcckWvHfhu0X+WeOu1rvfHHAS6S2ri8839R7GiVvN3+w01ZfxBWI5z3590Cqb3cC2qCA== +3.3.1 [Build: 1561236585],Linux,2WaGpMt2Ky110SIh+byPcwkS+Dn9U2l7VffcJsoq2PNy0ZQ+o+N2i9wR4/7kEgtgB4SHIdoA7W8rQW2LLqUaAA== +3.3.1 [Build: 1561236585],OS X,sSQDnOTwkEeo1shjPUwbs5w/xU9+5641b4695H5uGjL956turKroMABAyco7Xu4FEO6NWV0MWQDmzN5CUNEYAQ== +3.3.1 [Build: 1561236585],Windows,IV1j5Xoh3qck4Vlr3KqNuo9FYxKJ1BhVTNJ1vf2AvCQPEnQP6cYb9L4bBE4fsCw/+OiyQXt6IWm7G2cuVeC0Dg== +5.0.0-alpha249 [Build: 1561367386],macOS,MKOmBOjtv+ikyJ8NuYfr82CJCPcr1f5vBa55XTMzsV7YsN75hiLxTIHY0VOeAlI0MPnW8Mrdf5tDZHqCayiYAA== +5.0.0-alpha249 [Build: 1561367386],Windows,jgzbESSPVFNW6ZS5SG8XhSLqN6uJb5ZHFM7Hvt0JeqLSBusvLap8VEyEO0BPAFeEQV+yCs0VB8U8ny8LzSnKAw== +3.3.1 [Build: 1561495949],OS X,zCiWyOrsK8oVYT9iiLacxAB6x51Cf9jVIivvbh3gcagSudLFB/U+ZxqFZHCYxDklqTS6dBvjHaTc1OrFQxFBCg== +5.0.0-alpha252 [Build: 1561656532],macOS,1bujQHTuZ1AdYDamCS5VkEnjSEeAztO2Y8UeP4ZlN1MFrBh7dTkIN2DoGTI1/Lk+oXYua0NHgnik06UtkgICCg== +5.0.0-alpha253 [Build: 1561732636],macOS,sTvuj4X+PHD38NdHVkvLprzM/fcU4J12A0AMlYRxSXuPzDjVfLTThQoSwK8Ih3AZL6xIoegehhHolaZXawlbCg== +3.3.1 [Build: 1561761890],OS X,whf5UirES/hy/MeQmtraD7++MwLemejC79wXb2D3hwMQQH7kS6ieUOpkVnt/9PJxn6wVg2HeONo2uT1Kt9MaBw== +3.3.1 [Build: 1561761890],Windows,oGoGqFyELQKn/ZWpZl0r+oFJVpByp8d7C5ZPiaf6QjvG73uUrNvZUCUTaqTGf0QkLdktXD0HNULPqlxCfrf1Dw== +5.0.0-alpha254 [Build: 1561967684],Windows,jT69rm0NjtyA6BuZ83zcm6AD64qCgU+ipF5qI8g1XAGyejLIBS/WLCOmqCUFZTPJgBXXxpzWyBmC3kHOxJVCAw== +3.3.1 [Build: 1562186016],Linux,EyCld6pZjXiiDEXmA8iJmq0BHyiXknORkKJ+9ySuhbtQGUf0VOsfYYJ+dNjhNNwlmYmsd2ZD6rJ2oeaG7Mi5Aw== +3.3.1 [Build: 1562186016],OS X,l+cJl+SdNwU8e2B3lKL6s8NCsBDhgQ0sXOM0qq6AnsCFkERxznGaLY51vgg2NQBINtqAOueA5LNec+bZXyFMCw== +3.3.1 [Build: 1562186016],Windows,3U+9nlyiUqF4rcAOhKoJgaSaRW8TQzwiSfkEXq3MH/Gr/f9ur/khYN8P4+kPHPopA5l5IYU21G95Ift1hCrnBg== +5.0.0-alpha257 [Build: 1562592572],Windows,zmnSfIV0k+PRN8Qhd+2DMZQo9PuZraAx6ERAyMVyqu7UnXiIKrlMDUNSr1Ul3EPz4BzX82QSwB3tyeZYHZ1nBg== +5.0.0-alpha258 [Build: 1562611926],Windows,ae4LAzyzPBlPcWFQEoiYsuheWOCvW1HnqXMEM+Y6Aed9tsCewzYglA5YkBlbXe9HM1kf3c/huGy63qJrrJrcAg== +5.0.0-alpha259 [Build: 1562680101],Windows,rJJ6ECPqdvCw/4pFYAlKoHJ1yzmz0CskKfP/E9dG936W9efpnIt6ZHB5EywlDTksA8gTHanxl6zqNgQ4bnbuCg== +5.0.0-alpha260 [Build: 1562686022],Windows,Cq3SKxNkD3w7TbTCp/4dN2Pm7POHie5wTugASXsqhQBImLwvH5PpxxpuBGAHCYCP5tYswKHL/9grzeZFK/Q/BQ== +5.0.0-alpha261 [Build: 1562743548],Windows,xGhA35RYhl7Dnb/ruDpLSD3hQHEcD5f6sZOdGgHMQ8w1/DqBHDg+JPFc2pPapN8mS3sk6R1j+YXLCMFNpM22Bw== +5.0.0-alpha262 [Build: 1562749547],Windows,4qye7Z9lHZFEEdn9kGRhthAPbekPZ/kiwlZ0n8HR/Qojz28dkk9jtJGBXi6SoeSMisGa1eRe+K1f5plpdNqxCQ== +5.0.0-alpha263 [Build: 1562771414],Windows,owzBAJ05B/Zj4aLNC34famFSFtrg2oA2NROFfJkstXWKA6c8tCuWxa2e8lUqO+5FluF8SrCG09k7hjOwWQcSBg== +5.0.0-alpha264 [Build: 1562775539],Windows,Ta3PfkIvQHU+zyx18Yk2y0e5pSfUZ/7sERryRyJTgwQIs/FbmTxwqX9RVzIlnPtkWevF+A1U0kv/FzHIZvX6AA== +5.0.0-alpha265 [Build: 1562849836],Linux,t+XvNBHJr2bfK88LTXeixtr/dClF3vGFwLSiCdARkcWABykx09uzczpFRtCJWR8eYQ3ov5KXQFxce8/oeI9TDQ== +5.0.0-alpha265 [Build: 1562849836],Windows,RIDPBmjBeYRpq6ZUhKG8FdEjIw2ikTMmvr0jFTMXpth34KXOAdX+iBRCH4arRDUmwCRmjqx0eprrgt7LYFihDg== +5.0.0-alpha266 [Build: 1562943568],Windows,cOTquwaHmv9Gcv+ubFzSMS3xFR9UN7r9YXJWmdoIv3QfIetEDlpntTbklLxpRPLIUSmEkdCBQ0iDhpLB9ql3AA== +3.3.1 [Build: 1563026407],OS X,jmdDSzzwrzb/qtgd+AAqnCzZSpVng/lfmVYXEt9avpbNE0w5+MNgvkAqBGmtD9PNHfiGFC6tfmIaVTElW402DQ== +3.3.1 [Build: 1563049771],OS X,jUO4qwNRZBeBm+UV7+ft0hvxDHyvS4jRpB6Tk75UNJbHz9DYOTfix0kbPB/c35IV3yJpbKnYoyQaaRQxKD7SAA== +5.0.0-alpha-267 [Build: 1563202431],Windows,W26q3qQ7Ntn+1cqXQGR3J1j8u46qMj+ADEwuTfT1F80DENcCYe9VmbODAGd8wPDkY1it7B24VYMMSUWJzy5yBQ== +5.0.0-alpha268 [Build: 1563300665],macOS,D1DlyZVevsgVnp0lVoc3LjLsWTjo3g7AJJV3J0bCl+yW5rvKfLsz/JIdrak2MtuSbQdJ/1yXLKONbcBABfz7AA== +5.0.0-alpha268 [Build: 1563300665],Windows,FJN1araOIDI8eFoiY502BwABOv/Me8VF9khBb3tFaBH/L34c2fzTspIKVwZFs88AlXjGuZNHaatEhJN/LG5kDQ== +5.0.0-alpha269 [Build: 1563374719],Windows,LWPHabA4y5rnzvl54YmRS9d4reoQVV6m2xraGfGnhdDAeKwdlwRfAPBoypSM1GUQf0170CYNW+U8ylrhtZoODA== +5.0.0-alpha275 [Build: 1563647591],Windows,DR2+Qid9DhlZViTHp6aEbc9yHmqUK4Dj+ktgZW1O9zBaSozIx1+n4InG+41GlQ5bAU/W1+bLhhw+Jfm8YTL5BA== +5.0.0-max-updater-test-3 [Build: 1563793735],Windows,7BgxUIi/tZgE/rfJSkrn7LDoFxDAS1x1gJ+LT53/dzO6olR5njakmCLORQthMv/GOdFhoSl5rl5mfajzAmtdCQ== +5.0.0-alpha279 [Build: 1563868868],Windows,KinjpNU0pUxwJc9qoaksQgXQBhaT57NsL8ofj+/qN7GRTxuRP6gyCWUf9vw7XU/dzouyDFC16NZ+Mj6jKF5zAg== +5.0.0-alpha282 [Build: 1563983977],macOS,UdsQQGhtR5gFl12iQg+nLQyoBgyCPIIezEk54x0zWxfYA4B0hvEFyn4N+7oVKBXa56Rl/71zQsvdgyPnrPV/DQ== +5.0.0-alpha283 [Build: 1563988444],macOS,4UcLBuEHOsP7KPXrH5PoJWJwkd59XBcBvicsIKyqVdO1TJ1BOBgDkGD+/Qy0WM8UXx7Bjn19WRk9/0EHGxK9Dw== +5.0.0-alpha283 [Build: 1563988444],Windows,i+rGXZwXJBEm8SrP9BlU1udbNbZrST3ZliJSwZ+rf+GpQN8kU2Tpmr2vw6IqpYmwidi/lIyn17LHaWxS8GpADg== +3.3.1 [Build: 1563999377],OS X,6H3kBrosheF+ce6+bzJFnBeoMZ+qKXQVASW/xvSXqwL2IQDOC+2KZj9PvaDLqvZRLkXs5EHCKu9RTgSiTrXXCw== +3.3.1 [Build: 1564146308],OS X,zQYCeNs6rkDp/383oOB39toCbKwl6KgfPJps4v/3duXSbVpotOar6sb+4QgrlubK9T+ypuwExnNIZyaf/ScnCA== +3.3.1 [Build: 1564146308],Windows,2AzTbQOY/RXgTIISnT3vS25Wow1FBr3CLCU7f0hDFEO9FbFfFu2VB7GAmkd0twJkNKyG2T8uCjMmBeHibt5tBQ== +5.0.0-alex-scroll-test-1 [Build: 1564164327],Windows,K9aAi7XNPXDPF+rmgIUHOcDNXfTq/liLQWFZY90/1CxfH/IY/HK7UwQo5Xiny6ZKZnvhxU4oM2gTtqyhjaCVBg== +3.3.1 [Build: 1564391039],OS X,k0iL0DU3iIOnL0ZHyIPtOo6Cg7ESCzrSDoLflFjO9/hrn4PvFBtb5gsTpj4Q6Ua15AEFYeemL2tqyeyzU5AxAA== +5.0.0-alpha291 [Build: 1564408069],macOS,JhaFJdvPijlh6tu9olWfJgB2Ps/FaG+bZPMDCBWE7uC3Citd+p9uyMrw7qefaEvKotJqRzMq7LsU5vgmrPSmCw== +5.0.0-alpha291 [Build: 1564408069],Windows,IGd5L2DM5Pn4EKhWmxB4onfII0UgZ2gE6mFX0KSoQi2DENuVE0ymnaj7dSd01wabiyYkSiuDyUrqqIgKNOkIDQ== +5.0.0-alpha292 [Build: 1564497029],macOS,PNWDdpHthSNKYCd8w3yCljxM8QBbdVN5f4hC04p6LZrS9oCQXwaNFirbRd+qUxwdF/ZaCGz9W8IQUvQiqOodCQ== +5.0.0-alpha292 [Build: 1564497029],Windows,jlFBHcHdjFMn3nYnFUK3CgL3uxtb2BQQ4Dsc+gqIYOMrUPzS0CsMD6kuQJFUOF7aIKQ8y9euFKtuv9G57fdyCQ== +5.0.0-alpha293 [Build: 1564586764],Windows,ZT9k6ShVBg3ZF/koi55DJttu1vcI8AmZcULRfN8YhGQa9fEkS9qIpj3gP6HKq7fh9dESvoKksRORq59RiH8xBQ== +5.0.0-alpha295 [Build: 1564653261],Windows,BFrjFCQZRX/dPiHhIqOYj7oUZ9TXeNUdZEengJgfEvTboZ9t4ztVG4DWX6wORiior1Xc7e3+BtUxWq/FronKAw== +3.3.1 [Build: 1564671328],Android,0IDm4WX5vzyGfNrXHxd/TU6t5AC+AuWx3KF8Bh3n5R+adbrroIi/uHqg0WV8xxWThupRDp0UlqyH2STRuu50DA== +3.3.1 [Build: 1564678999],Android,kPqHuXEgLxpThXc5XYdvTLk+iaY0AL99jf2WJIXKBJuCJmD0pfW1Ep/zYCxU2NGsu4HIHMMXnB0d2lkr7AHiDw== +3.3.1 [Build: 1564695891],OS X,U8tvJN1f5SnXikUJLzobwuWqA1N3eS+1GRFcVnztpJOwBOFT//wee6I1WSAoAUHFshK7HSrWnGJUBnXT1Sd9Aw== +5.0.0-alpha300 [Build: 1564750918],macOS,xc3aQ7iiWOI3VZb4gHBg9OhQcTxqSu4HgdIBj9N58JhrYz2ioXkSZaNmjRoTjmlIrcPSHawMMozKkjQ4cfY7CA== +5.0.0-alpha300 [Build: 1564750918],Windows,1dtJaIlnJj8SMM4fdL9APze8nljwAYtEPNFiUT5J3v5E2h1pW8aJnnljBCWSYcFGgKL3Jrj5okC/Ix7gR86cBA== +5.0.0-alpha302 [Build: 1565122993],Windows,0pF71saHDtwBs+WntxBBjIdZhSyNBpsth8qiqDBlKCf54et7bN8zvhlUFuySO2nQQQTaC6Nbn+H1PeY2ERvuCw== +5.0.0-alpha304 [Build: 1565173045],Windows,ArizbxJu/9+vi4QrBLWeCneB4e7+do6z4PAcGymxNGtL/aLQPqmAkhpCGs++YWndtZp6HrysrKAYwP0vB04EAg== +5.0.0-alpha306 [Build: 1565180063],macOS,vRWUMMtf0bOSVNxCOlXrvw/e6YLHCzcLqocEb3SkSmG7OtXrMSzV+qp7UyhM40YdYi0zQblZjCMo9cVJDBKyAw== +5.0.0-alpha308 [Build: 1565255370],Windows,reS/VSqXlHry/XR+hg3j8nSp25o5gmuJnlKM0IbC/FW/ufVNo68qhVOgtqYY+8VZbf4f3Lf40CKh3MxPwyYuBQ== +3.3.1 [Build: 1565359284],OS X,X2zQPJvqLMIHhFOqg2VK20pz3th5+x3MRYNq9fSu4YeH2RQ2yuiVA+gutHOGfaHJfHXddGi9pHbmfqsG13tiAw== +5.0.0-alpha312 [Build: 1565621064],Windows,oF7DxSVLcG/rzTMH10g10mc0yg+MRY0TICPdBoU3zOmMwDm/9+gZWsvL8if3ifCSCAmkSQ34lB7rb/3Sah22CQ== +5.0.0-alpha313 [Build: 1565694680],Windows,+OscPH6RxOtkhFOBunnFBI8QsoVLZOLuLfTMf4CZpJRdwwlly3QbUL9Prx/M0yaYpPozJ4vKMajyWxlXAmJ0CA== +5.0.0-alpha314 [Build: 1565805211],Windows,cWjRa7Z0tIYKF7HUQ6Z52Xgm6P0GnD9vn8yi1Tt9HZYgREohgPIssdpqDCkPx7Kwi9hxfBnp9sjnJ/Z/ZzC7CQ== +3.5.0 [Build: 1565805756],Windows,0SzCC2IGgn+ovlPoZUAeyxxSsuqQjyJkK1m2be+PfjniFU6F37cw/KpX1rBrllnaMrv2DFiG54ub1IHF5j/GCg== +5.0.0-alpha316 [Build: 1565975113],Windows,7jKMe5MDxTa+5KZ3luvBCJPG/xkh8t7bx8PitvtnNTVedQmpZUECONFtP/ceM1+Flq5x8OCkXT8tnF9E7dz7DA== +5.0.0-alpha317 [Build: 1566233926],Windows,bOlLrOlFsFwvXk4YEjcF4xZoB/T7MTpsHlOqzNYBGeY1dvk5ShiHobmDVUSjNVoHkvyYC6Jti3FlJdTIq5viBA== +3.5.0 [Build: 1566479450],OS X,Mqkms76I9VfgFUELEursGojag6/2ZFrELtGs/VwmDFxLVFJ134pfsobaCGljdOPJc61wUA39A//hqXuN/ZQRCg== +5.0.0-alpha319 [Build: 1566479610],macOS,ESvw+cfkAgZRjlh7X3GRMhqZq1N+w5iTm3dQbFIbIFuBFwWgoyYk9RQVo9ZjjkEBT92Xm5gSp2/dCK6pNZp+DA== +5.0.0-alpha319 [Build: 1566479610],Windows,W9DQ53AWolbst7XISRwIZHzOYfm/Y/Dmxi/wD6oUIM63SCjLBuGYpUoLlLIdkWe2bTRZxfysv8CMiiAhoFCpBA== +3.3.1 [Build: 1566673023],Linux,IdO00q19oqEwf9CB1R2c+2ZALMrUC6YPwTohdmD9abnDzpfDH/P/p70oDolrL+pRLoh1LjDiLtUdKRETLbeqAw== +3.3.1 [Build: 1566673023],OS X,dNpW3zyuLCNdhCJpCbaCHWob9xnHSbrRNyJgNShwAPQfyclrtarPLOiTYN9IgQbIGxTu1Yo4fra59VHzpHhaDQ== +3.3.1 [Build: 1566673023],Windows,utZjz6KhPiaR9zdhS3NvbLpi4oTGH/vseHd9/mUrLxYYD5JvfeeHH6nzLf8H3manoNrQnONsCcqUOvYglCotCQ== +3.3.2 [Build: 1566767614],Linux,UhiFNnz8npgT22qkLXlZJnX3T2n+a8usv/0cTh+tgybrgsFd2WIuI3eabWCibPeU+AYeHLaeYR+x+pF4GX/NDw== +3.3.2 [Build: 1566767614],OS X,JiKoykMS5BExaAEMpIYB3JRH+YturPua/Q+VTQxJGRi002zni9b8ReitLaJJQt2EMcNAbDpl57um4mekqFvGBA== +3.3.2 [Build: 1566767614],Windows,fAjM3pPl95eGXrhFcsvCXgdI6Epr8XpafOJZlYbFws2VMllYy/4DUleSVzPuVqu/TCgrTaqb0wP+KANse3/vAw== +3.5.0 [Build: 1566810730],Windows,KJlE8//AeT9nmBTs0EIjEZT7+W2Qc/J76Tevu+QlnP8jqG+079SUeJ9jZkl+L9I0MwBTyrCSkpUoDGv6MH3CAg== +5.0.0-alpha324 [Build: 1566898458],Windows,cfTebCrUaA/YvCMbLPXC2Q94+9Hs1RssCo2w8zyw9psLJ6x6A8JGiYBAB1VFiRdh0Roc83q3ghAYr7ia1ay1Bw== +3.5.0 [Build: 1566914096],OS X,JiMiehYrCDP2x8U49KEBRtBtD7QgCxqJ6ALhs1Mt/IOtSluOuR2XhuCBUOoTRe20WfgDfHhlUk/AbAdKgdmyAA== +3.5.0 [Build: 1566914096],Windows,dRC2UOZSRcleMujmFMWtN33/AqfFuZeM8M1bxPckUnLWugC91nv2DqFC9ohTKCzlCy6fE5Pnm+FUF2ZpYip8Dg== +5.0.0-alpha325 [Build: 1567003912],Windows,Gt1OMdHeKcWpo8A6sfuMM4MwZITOgy8xJo2t263rsLRq35pbtgr6UtjsAeMqxlIZRGKnJsG2l9qGZkYihwBMBQ== +5.0.0-alpha327 [Build: 1567025817],Windows,VYcfgvRKy7btgTQgxpfSYRupK8dAAmlayqa3bs3x7gWrwZXLQH11OSRY4HBOx6Bs3AMMGdooTs1FXpFWbpMrAg== +5.0.0-alpha329 [Build: 1567160967],Windows,VLAHSsiIyvBC+Xr9NWSjR29chi/aJ76IRG4lLUZoec93cr0KFraQOFIZZUJqF4wASq0wB/Xb6cWdiCS+XUrOBQ== +5.0.0-cef-77-test-9 [Build: 1567209083],Windows,QlubfeDQgkhhd6vk5zvqg81BdItyEp04TbS0hj8WHxab/lwBy9ell8EuTyU65+xMDdliGb8jmyi3UZEJ7Ee2Dw== +5.0.0-alpha330 [Build: 1567246409],Windows,ZdPf2YHlMX9moxzE82/zKZQ2QPqThxPa08f8rLzgYCrtLafjQcY1LjIfev0tB2hKGKzPd9aRX2UhCWRaPAGvAQ== +5.0.0-alpha332 [Build: 1567435866],Windows,KOKtxZUj/qQ6GAh6HyRtkLipFrfptUa72zl548InSwGziz3s+METYqEX6ghqlxtmjPjopdKeozY0kdBCp8VjAQ== +5.0.0-alpha333 [Build: 1567450575],Windows,92XoD+2CniLMhP+aopIUMQWGrbrFtdX+CaNja4ZKs4CSAg6JuiPtKX9JHldnl03IXPUT5exxBbEojsWkuOd8DA== +5.0.0-alpha334 [Build: 1567590370],Windows,+F0kmE8CmGE7gz7r3VaW2Qb2HmVyXCNwMO7LVdHJN+4dlYNu6taoWfa78HivqXUZH4s+zOfjweol3tyJ3x5UCw== +5.0.0-alpha335 [Build: 1567603533],Windows,iifdsQpgwFyiN1LpUq4oCvA2oMPTfhO19Ic367PJDxoJBErlM3COoW/LJyaR+/AyfoEPYVPzK/HVsgm2VH94Aw== +5.0.0-alpha336 [Build: 1567680535],Windows,t/bEfvxvDT2TZkLmU42Q0Mf+yXcOqizJ8G15RNOO6UgTjSnTjh64bJAwAayko6IMN/xZpIDgx9m/9hMhGcPICA== +3.5.0 [Build: 1567687511],Windows,c6+vv7Rp1fQsFxkKlYfy4kaF8/5Xh4I+ZwHw+hqV4qPo8AsPc5ZTwcWtK6Q9/6WKs3i2msq6p47mg6sBHSa6AA== +5.0.0-alpha337 [Build: 1567692133],Windows,vFDmsTT6gI1njnCOJv3mLt9EIJERoBubpEiadmZLBaXdXmbsqC655Ywq1Zsnt9/5axOLobOt5/C6ZHJfuWOVDA== +5.0.0-alpha338 [Build: 1567761846],Windows,I3ifOYOw5lNb8+vHLgbFQl0/SGNSw+1w7E0mCT/Zh5GHYbbrpxQDR0a9SdUHi7TKQ55uxTAt0Sc68fhQBEABDg== +3.5.0 [Build: 1567775523],OS X,d5asvnlZOJucbg1E3A2JUJ2IrxJ0Q4pJlrMwvZhsvxTK5D2dW4TUJIcQmDnndgC4FKrk//VMHsnrtFIfhhrCCQ== +3.5.0 [Build: 1567775523],Windows,496shsf4bckjKJsMYlJW1p82rWxuL08+GMZP9S171X/2rXeuXWpQ3AfkI7tMve95MiZ5/GNt6Vl6jn0/45h9Aw== +5.0.0-alpha339 [Build: 1567776032],Windows,1FwZpwSPVZQiwCkhSlzl4ki+cmhTc0C7LbzPSQTNKqFXPv/UMld0dw+05nCSng3UHVu+2MmuXUxfokIIA3GJDg== +5.0.0-alpha340 [Build: 1568047589],Windows,pNAG0mkBI8izK+bEW1bh5gEkaSo4ih6YAVsU89f+XsdXH4SvUq3PvWQy5aSuUSHAIgSChfIzFNbNa8Q5cmTFBQ== +5.0.0-alpha341 [Build: 1568138230],macOS,K1sdP0hCrN8CVI6urHRI9GBCbKg0GiaVfxt/WQR/x9qTzUj2Q2sFbJL3DEh/dadOY3gI4TAGUji2mFiERYfUAw== +5.0.0-alpha341 [Build: 1568138230],Windows,foVufjNlvsZPOejfZEUgAi8ENTHOsijOF+qAULN29FoUpWFKNgBFeDYOuy1Hf0pVkv8y9ariYjh0OWhcY5OnCQ== +5.0.0-alpha342 [Build: 1568216929],Windows,Vd6t8B66K91JwqEAKqitP6gobwsIQg7Wtg5ffH6CBGN2TWKg7BGCDJabCUHjnUI7hm6eCtWBqr0lFv9GTHxACg== +5.0.0-alpha343 [Build: 1568303604],Windows,MuWpPz3L+MIN7HAwbI+IeA5fUcHjzyIsGlQ/QrajpoWEkhfk4Fl9yB/q9BWJwDxDiRyT//KpRzPmYVK5ps7jBQ== +5.0.0-alpha345 [Build: 1568462524],Windows,hFUXangYNdyo7ENnEJ7Czi6JFRBRMreoB6cqWCWesvfoasY5VR6Wkvy5JyziqT9EHO7E7V+f53e/BpeV2wQFDg== +3.5.0 [Build: 1568483207],Windows,P+9QNU8aPVwf1Hk2oiZUUckRg1989KnGXj6FB2AV1GxGoeaGb0e1PYhhP5E3eTIjFDr0W0k9ELrcoo1+i0/IAw== +5.0.0-alpha347 [Build: 1568498600],Windows,p19wMaSxX8UXuvhlDlxIc/KrSdfJ9+o8wAXOtMRcprxu9z3nvcmpmCWMUIIOYQg64hyr7nms6hrGkIYH98CxBw== +5.0.0-alpha348 [Build: 1568542448],Windows,P53ztJ8EKNZT2cxr7InF0xFicDlGGHXyM8BOcxWv/kqm3VLVxLQCVE60XVY+ar1SzZ2KZ7ZD1Rt6NyI42wR5Cg== +5.0.0-alpha349 [Build: 1568550521],macOS,/risCZ6WJqff77LQA3hZqIMaL0XfeC/haaErc6bY7fuGwacTbtc80G6ZEGfFpnJ1NUscfHALAujH8VxDavWgBQ== +3.5.0 [Build: 1568734736],Linux,YU9jsFPaBFg9CEr4g2lUBhZj6e6f2l7EFI9grYLMB/BLPWu9B7k+aGzAe9OkMHXpT3Q0cqc+k+N7XSxXf8x0Dw== +3.5.0 [Build: 1568734736],OS X,cD1hdW/GpYEHd42RTeKVVqTPbMlcGNNYLbsrjE3bX3NNyBEw+EFDn6JiXjvJ2nlgkwt/BG1CqTjeTPxCWhg4Cw== +3.5.0 [Build: 1568734736],Windows,fyTB0CPBTj0jVd4NTUy8oBJ1PiGhrHpano2wGvEmzzZxb8A0A1BkRdmCyZP2hxJI8iLMnpEIy3SEXADl8kjRAg== +5.0.0-alpha352 [Build: 1568742967],Windows,rVdkwzZbfhuqxr8XrVT07NmI7KWh9yuKukRAeeVnA6TSiZlnDzVpKsFeZ+XRvQqlg9f6NQjM6mOGJFd4Z/TwBw== +5.0.0-alpha353 [Build: 1568828473],macOS,F+3xGce0D7mujDxL179YtEhO61SY6iqu5Fa2bKhWRY9C/cUGGSXDNKrn4A1fe5M8NkJDH2HsnuNCSQHssQnlCw== +5.0.0-alpha354 [Build: 1568887729],Windows,Uh8IYEDWqgJWvm0n3CW6wLZwxNtL2wQWxuePrBJhkLGWT8GFjB1DjPRHknHoDSBUgae+TDzkle57owFienMLDg== +5.0.0-alpha355 [Build: 1569001691],Windows,2HjF3/5YQt6TXdHAv4g1wXlt5fm3ffpmW42MERDz0lWaAEfgE0VsfwAAHXmiBl6Sgjt8ExN0kjGlNtUg3p4AAg== +5.0.0-alpha356 [Build: 1569007610],Windows,KDYbc9yRky+5ene8ASeIA8xawtKV+2FatCqvNOb13kVM1xNTmgC6atTmXbfGYxppEnmBwl23wfcieQlZgblNAw== +5.0.0-alpha357 [Build: 1569014091],macOS,ArZMgswMs1SK06P3JwW/LpDfEeeG9bnbxSI6QJPDIFgckqXrFZ/tkDFsH2ZO8/VqS/CnlUvEqEtqITjlOajAAw== +5.0.0-alpha357 [Build: 1569014091],Windows,Olo878lO79Q+Rgs+yh4Y1b8rbo9+GOBXg2ydwU8tVVkJNh6HTDSGKdx7BP5cko8eca2cXCyjlwVIvDjvvrmLBg== +5.0.0-alpha362 [Build: 1569439429],Windows,oiMZEu9yAdpPcbQiHC5QX2JLkndvZS+yjJp46DQnuG/7iYgwP5JlDHjyP393FQZSQMNClXwJ17jBXXGAtpOXDw== +5.0.0-alpha366 [Build: 1569577640],Windows,b50/TxvYKGnC+1+rKRPnJ1PCfKNIbsvAXdPeTcjn8BEYk3eYOT9TTMJ/Qg93H2sJJYWm01bb1SCqG546/uX8Cg== +5.0.0-alpha369 [Build: 1569852696],Linux,9EOn5V3u/349Q3dZtbouoo2UwQn6Oq1AOvXj4jBcZjgoLoDq8UfofVgYNOxs814RMEc60SsBOcvxYJAS8yciBg== +5.0.0-alpha369 [Build: 1569852696],macOS,AE+kHmgA+aHt7i23Q3+ghDBcHJUX26MgVoBcuMjexFcghUhvHI9ooRcR6S6LNPjfqfuPxLU9SOrC6beImJMDCw== +5.0.0-alpha369 [Build: 1569852696],Windows,IhRZBIxx+luuBhNtQAjfrAXS6plahEzfX4Jvxd6+c6WnnSlIvFC4z5CZ8aLyTis+1s/BlO/4vMs3RewsShHlAw== +5.0.0-alpha370 [Build: 1569948695],Linux,JwzqAbSxXDTD9VLF4BZhOFYu2etYzwqg3TmN/50WSejPvs0Dkb66wu6llyhRBVTE/GB5o/vQxlsFjrP2rM3ADQ== +5.0.0-alpha370 [Build: 1569948695],macOS,3Nu8NJNG4Jx5WTaZkuja1UMm5x1zPQjH/MMAwvhXcEDPLgPjFVMCW8vqrQU5GeiCehB9sYdq+IdAFYNfieEFDQ== +5.0.0-alpha370 [Build: 1569948695],Windows,hRgqeJvTICIg/tR9/7zjb7uu6nSaGR2ypyvj52sOXp0N1wq8WdZgvs80dlC/+eLnmWDWkFIpbq/AgBYNaleWBw== +5.0.0-alpha373 [Build: 1570024161],macOS,d6q4l+SJBwfp3WmDSRdr1CSPH3DwBFwLQUQQnRne7UgbhacrmbCAleroUBqSPKUay9QdPaECatzRu5GM4o6fDA== +5.0.0-alpha376 [Build: 1570136727],Windows,VMsCdtH4U0FpPSQ61J3hGt/tYL3Ys3N3x9lgOUiS3nlYdltNZ5PBfvL4Q64VpTImK2rj/8u6JKKTdXdgDuZsAQ== +5.0.0-alpha377 [Build: 1570211017],macOS,UPuXS+zY1OBoib5DYjuvgoeaFShhm8s9k38pkMY9AvHm8dy6AghFFkUT1YLdMO/n1ej4TUo8/lP5BuhRYl21Dg== +5.0.0-alpha377 [Build: 1570211017],Windows,UExsYhgJK3YjzwIZhm2ztveSGNpruZ7rpP0kS/d1lNTsIezasOw3uoiYq5Tj1GIyZMrVV+dZNzyCnsjtdpfDAA== +5.0.0-alpha379 [Build: 1570306886],macOS,hsSZSM2saFnDrRcrJdBGhqPNDC1EGopIoFnjKXe7K9bwtyEt2gTZ7uRasA46YQX2sTSKHCBDiaXj07WVH5ooCQ== +5.0.0-alpha379 [Build: 1570306886],Windows,lmAAKNKEjYw1MVqPiQpTP+fgHkZBr4YI7PVk92XUPweb+/qAHqrIAGGjRSaDqEfrYnWhtXMnJ8O+wGyZ9DIlAg== +5.0.0-alpha380 [Build: 1570376142],macOS,5aM0m+9G1SWQmfYiRzNNBTjUg5wlULAq5aVVQbVvL/LseEGRLafgTChu4K7Vn5avJK5dVbEyP852EGrGveK3Bg== +5.0.0-alpha381 [Build: 1570394174],Windows,kIadWcCh+5r216TvDS4+FVpvG1xWSVjJAcaKbKecdJS2isBlUogVLn/xcvq89GRrg4kZgIMuf4YCPFx6vPFgDg== +5.0.0-alpha.383 [Build: 1570427845],Windows,ZicJJDvBhYeB9CNIzUUPr5vQeJ2PQ4MZsrUqzrk+cwl8qO8hVyVoUa5BD+dqE+8I35/Kjh4k/VraNCgxQQEyCg== +5.0.0-alpha.384 [Build: 1570457406],Windows,6FmjeQaMhIELrglADHocwtXPH8XWODz5UOJDwa3wDDuVMX/K9Vnyh6+MrSR9UT+TuGBnVXtSYGpNeKL7i9LNCA== +5.0.0-alpha.385 [Build: 1570480817],Linux,8+c1g72+1sHXfYz5SHYO9ylwbOkoY0IthOd2Kl7Kuj4jR87mf9ATLqsKlZCfZ1nIbLs6do42CDhxLldyKgisDA== +5.0.0-alpha.385 [Build: 1570480817],macOS,tgmX8pvk2XSvVlmTNlSF7zteBfSdG+vQujanrpg73B6TZVpIMW52aC8E/p2X+jvYm09DNm8MVeUOPglfGtadCA== +5.0.0-alpha.385 [Build: 1570480817],Windows,RFB5R9JktLjj/ttr65Aq++U6gR56H3uccY2P6RoioahY1YT6UFr9rym+7tX4g6CjnQjXxhkYekewFr2Luqn7CA== +5.0.0-alpha.389 [Build: 1570642878],macOS,jQxZ7U0XmElM1Mg3UEtU+16RIZM9svvghZ1Pgluca0scXBbkA1v1x9tb94pDOvBS5UyANrFEUTv31PbMXAV3DQ== +5.0.0-alpha.389 [Build: 1570642878],Windows,WkxMeVeRlBaZkz1WVicXimyHKf7xBjWxOaFG1QmkMsob4ohzvz6qUZqwZ3QZKH61okE+T37rvl31mxZVtP6jBg== +5.0.0-alpha.390 [Build: 1570728651],Windows,UBZr57UKwatZBGZF8p8ZDtqy4dg/1lsnXyLgTrNLLvydRq6aOdFTsbzvZgcW8LwzojK2SKxM67VT5idB7VTIBQ== +3.5.0 [Build: 1570810399],iOS,RdN1+nQ2YRxJi66Yd8ta7CXUMsisWTU64qGNDTyuV2vdO/+vYQz6qOUaWjwDxzw3JAXr8FfCPcPaPo3suJj7AA== +3.5.0 [Build: 1570811287],OS X,fNbZJmz470itRKI7lejb4jOMbnorqw2KlEgagkG/tFtxDyBxTlb1yb6VbJkik86ybDPiMvIRyEhlYF7Pg69GBA== +3.5.0 [Build: 1570811287],Windows,9SgqZFHFIVXhObnqoJCEQuB0XHKVjFE+hrpEmOwj5f0xr5wTeznFeysUPP8g4cmhFHHyEzDt1EJu4ZCIEvZZBA== +5.0.0-alpha.392 [Build: 1570909746],Windows,NxrgnbjbCzhC9DI/MiwZTgXtm+9CzaqfANOGB8xcFQTPGZV1lk3hoDjdWOmr/7xF0Ulyx01eeQIgVxOALwHOBg== +5.0.0-alpha.393 [Build: 1570924185],Windows,TlIOn5sV9djXtDcUrJX1CnhAELO9L92SUeWbKw9CCpL+BDcFVRerGOcUfSL9fG02/xszfwOHSYyhtimRbUBcBQ== +5.0.0-alpha.395 [Build: 1570968752],Windows,eJ4aaEhWHVMI+7SWH98ufmfhxw3PrZ10fo3e2e1Xn95tx99D6TwP35tuj1hdyN4SjSGAiNrWri9yptT1sOfxDA== +5.0.0-beta.1 [Build: 1571050541],Linux,ojPTLLbwu5JAnFWX0To1uPa4dv2tX0CZ8a1kQIyvev+60jdiKxCY5ohN9VBvGaPenb/YJQinaZkjKbd4I/rfDw== +5.0.0-beta.1 [Build: 1571050541],macOS,f7PTrjSUlknBxanjdmAMamgzYdGSY7LDRCDg8Hi7Miml0TnciOgn5wukGCeayjT7bpw/DeV3kwnSaoEDZ7PiBQ== +5.0.0-beta.1 [Build: 1571050541],Windows,bIXuHNwfc/yJbpkrXYicrha6lmCC4jzXJuUSZjd14vMhmAsI66KW5n18Pg3TGFG7iKKhrpj0trc/4gpmDecBAw== +3.5.0 [Build: 1571080050],Linux,glUVQf9FU2STvK2jzW328FkF1AhrPLj27sVo9TzEC+2Qg7phv5UpczW9SGTyp3H0KCofYfmTR6OW/W/1tCoeBQ== +3.5.0 [Build: 1571080050],OS X,64wKoleYoqOwO2t4bCHaQevSlv6HyvU5vpOF+yjuIrbqT1um1VoIQuL3L9BKt10Em2sd6VR1/IciCVuTSNd+BQ== +3.5.0 [Build: 1571080050],Windows,4XIHXqnhLM6dRNFzdkNcbWxK/nX6iLBECc+6UJPX4PooBDyWOzul6yF1NKe/fg7bZDigZir1+OENu+O/tLwHDw== +5.0.0-beta.2 [Build: 1571087114],Linux,0ROgVlI/3lI0p5bm0sABq7zfG3U7E7qZLtOfPwf2RflkOygvVgKdlgEsKqpQT340tUcF6NuWZqiwoYXyyZnwAw== +5.0.0-beta.2 [Build: 1571087114],macOS,0S6T2tVpyvoBfPlsM2S1GiF8ookfbqNtFV2ZS/c3EM51ncuVEtD6YrlYC5tGvBPlggbEXawRFQAmM/BwnAZMDg== +5.0.0-beta.2 [Build: 1571087114],Windows,6zuLZzAe2WoM2BpYkEpG3u2zgsuzpWossd8O87wj+z+4+zeVTx7RvIZbW5Zzz3qZX46Rimz312PRcoXhQ+SLBg== +5.0.0-beta.3 [Build: 1571155625],Windows,yd5c0kDs0E94yjZ6uP+LPtoU0gUXddjPoTLQ0ZJBYGgmtGNE92qlHN+OOINwoae0UNCJD90JVua7CJDeF/FlDg== +5.0.0-beta.3 [Build: 1571214214],Linux,ymBfVBW72lTqkUUXWZmcahBs7nBG0hGEvAjEpp38iDQ+EIqI/VwVOPOgzVsFATumKCilmiIt33Pxj3+mePFLCA== +5.0.0-beta.3 [Build: 1571214214],macOS,eLT0AWXP9u0tzMpJzJKLpjFx/9FyU8Wrrk1Zg4AKaPT1539RmbOqd7QxKV6r61PBWfE0U9y5GHRuivCi1P8YDg== +5.0.0-beta.3 [Build: 1571214214],Windows,Gla9L+BRb4Y5Am8TbK0kvTTZ05G0HiACtO915NiP7rAD6Sd8+lXFsHK2REL+5akjvDBbHdU1BEwPBlu6RNaSAQ== +5.0.0-beta.5 [Build: 1571252771],macOS,eySiC0JfF4VFxQPa3XO3eoM088PLWJqNCY7gdScCbdBy3nHiAb5qz07yXkmme9r3egVKl/8S2zyvo9dJDMPHAQ== +5.0.0-beta.6 [Build: 1571338027],macOS,Mq+To2AHXyAAGfIGok0R2OaYavb6fprBhrMVKCNZBf/iHs8ORQnE+1ynozoWM1vIrtkRjl+qBBWMF0kghSnCCA== +5.0.0-mute_test.1 [Build: 1571396541],Windows,+ZNWBfOjbwPZfhgGq2AQKTZBdibC9z8WKOAQUWCCatoHvK2EmKkIYsu0xZ4uk2n121AnCOeJU9ZhZejN2W9sAA== +5.0.0-beta.7 [Build: 1571421490],Linux,XzAJwiiURMVqlo4UXDl/svVFxc5ne1VutLhkZDT2UG2QWsvFUMqTej+6EAeoaAimyN5zzoO5/mR9TBEsedFFDw== +5.0.0-beta.7 [Build: 1571421490],macOS,dNz3jnxhGwSLKTRi+R8nWAiotG8y3o/MtxcAVUGl5WgSCOBPIh6W9Lffeqdi2mq/NAq/n5b/w9rNuTIPK47eBA== +5.0.0-beta.7 [Build: 1571421490],Windows,0KhU3qhKUZSX8xAWLgCaPXu79njWsy6aAyHW7n9keeCwd3lLdcn+6i4kb9GefC6Q3jZOslTCCAvtBw+jwOliAw== +5.0.0-beta.8 [Build: 1571671044],Linux,ANXPHY1ZJlhEPAxngYChDm3XRU0XZntITzHlnZmBGRQOednkyAeZV+/DthWmYmgd0diJt1+qTnI3LNyB8PcUBA== +5.0.0-beta.8 [Build: 1571671044],macOS,d3Jh4QELTkUXMJBunpw6816XB89iHxTPONFDXCMaiCIlthWpmYpN4mOi4+RZKlTtyzShP6cyQ/quN9Lvpm5iCA== +5.0.0-beta.8 [Build: 1571671044],Windows,heRyC/ws7xD/RCMv+voQ69zpKKx00pAnPpQGSp4DqZvwmInG3/5jDaDbD+dD47BlDlpPmd7Qj9/qHkty1VtwCw== +5.0.0-beta.9 [Build: 1571949734],Linux,b6ksNapJZndbf5qa1dcvqRgCdcgay0KQrnw8IYkPAXY/OvccuoJ/LUfg/a01nXbxbh45kp7h5gTk9l0L9NVPDQ== +5.0.0-beta.9 [Build: 1571949734],macOS,Y+qroeb12dDsCO+OTuoERTLgTUWihZ076cODxmo6iyNPPVS9xy1zq8hv1lEtc4UcC3EAqusBRS2ikKY6PnsdAQ== +5.0.0-beta.9 [Build: 1571949734],Windows,m04/1RI/r2RM6aHwRrvENlB0/Px6UnZwE2Lqo7IgQiB4MpFRmAgMu7g/gVB9NdWeMdhm5ulsM5lyYrcu7dyfBA== +5.0.0-beta.10 [Build: 1572213852],macOS,Xtdmc5N1VOdedl10R+vZfxpNR1mRiuraEvP/wzZanttYkhKWvjR5kciXG3lLhLvb0D6q3lKfz7mBB4ejbhhvDQ== +5.0.0-beta.10 [Build: 1572213852],Windows,2xg5JB8a1KTy9R/kXvnsW4rBpGzOPnUSREf80r4vM9KYSj0qj0x4dvFU5Ny/w3Kiq0OKAlvG24cSiKk0R0TjDQ== +3.5.0 [Build: 1572274459],OS X,lRiaeecTWNnnipJ/O+n4DjHUK0C8hOc/3/G9ekOvhudNIkU8XwyXGuT+fR1l9SBO7VqwaZHRQcSJX0Nc0wVjBA== +5.0.0-inbox-update-test-3 [Build: 1572358097],Windows,94cs11YdtF8xxTa/aOrdm1JE5RPkZSQCo1l56qXiMpovFIqnVWisJ45Uv0FHEZCQ71w7NOQylK4u8Vz+OvOJDg== +3.5.0 [Build: 1572367939],OS X,a92Ue4WtLHiAxcVkZK1egx4W8vMCrvlWZQFtj4FO+ouYMiICWZbMtT0MWrnEtwq6OBqkkWBTYZje0893k/rFBg== +5.0.0-017dbfce [Build: 1572429535],Linux,Q3lpSvOgLIPQywUWX0okUdBhUD6W90OLbTEYwSFDKBQ+5neHf/ziBLoJ2jDegMXO3KShpMgsJIAS/qjsP73tDQ== +3.5.0 [Build: 1572447082],Linux,/5nJG7aByRNQKpUapx+cd7EQS80iEA9B+8z1bQgkrkopYfpYJD3PioUaI4oNCvdyq5I2ROheOcaHMTI9M7duAw== +3.5.0 [Build: 1572447082],OS X,H20O0S/45t4TerVsFDNAOXr5yD5VrI7Ps3Nx0RFyPwubYUWXDiIj+LO4wu8wbuxag9V2VJKxtAax1OVWYZssAw== +3.5.0 [Build: 1572447082],Windows,igVHTt+UUyZDHQpj8sEm3fGw+r+MDVkspQKPS/+fsxiVJr1vy2LpDQlpeZ7Yr6C6eECtCx7He58DXALTQD7JAg== +5.0.0-test.1 [Build: 1572609725],macOS,axyql5RDoqUxtZkbPY+Jw7uJgd0n/Rz8LeBbdu+Tj6mW3A0U0u+wPpc7qg2OWA5dRHQ0Ut+VF9okXbsI5PKwDA== +5.0.0-test.1 [Build: 1572609725],Windows,MJvx4bAduHXmC1AAX+w6Lv4vHAUatzBXfKhtJIV9SDKd/q98BIJWEkGCuBXEdBzk9VXfcTpLUefz47BPSQ8RCA== +5.0.0-beta.12 [Build: 1572868115],Linux,IjTT7wlPMm5/hORA7KY2Jl1WmpzUzVyGW1hn0lBfzfkCyHk0N+9S/T2l75CvsNf/oetkzyr6J4YNK/XUszbqBQ== +5.0.0-beta.12 [Build: 1572868115],macOS,SGNeBOp9Gy2rfT83IWOy76J1EK0h5GMEdXNZ6Hiuo22Bk+6UVRCVYUkrC0iyIdlxqug6Oy6xLTVn/IDQ97pCAQ== +5.0.0-beta.12 [Build: 1572868115],Windows,w8i8mSIJ3y6wnFxSp8Gh6CRl3i8Q5owzchsHefG3kKYqzm2oyYsMDOsX61FVELbyiQoQea+QJZgGHY+MZCTCAQ== +5.0.0-test.2 [Build: 1572958346],macOS,mtAt2UpaOYxOgoNkcMyCGvvRCRHjCd+kRpCeFT5s4lQZQk6E4WCc5Sy7pdAB2SMTqBGljlLijbVq8R1EdTwhAQ== +5.0.0-beta.13 [Build: 1572974727],macOS,YD9BfBDOgtH275S4yvRKehjnWropCs+PLjQXVFnCFYMiR+cNdp93LAABFqjFIA/oilR3CyhqZj3gFHxNbHLWBw== +5.0.0-test.3 [Build: 1573037288],macOS,+AqLKfemvASC0sYMz7/G1J5Yhf2/M3Te4/kYrsCgsq39zUxcViLJoJ/B0Poz3R5Q6vpugSpYvzGM4g2x3eBWCg== +5.0.0-test.6 [Build: 1573147021],macOS,7NY9EOPggMqcGPW66i0sl/xJPCPm4UIZoMbOGoYRbr0+SiiMu6LMj4+PnHyaLgEQgf6dQNYsCXLgs85/1DbPAw== +5.0.0-test.6 [Build: 1573147021],Windows,3DvO3eqDDRQmch2WEvZhf398j2EcTDzZl/IlDdWUVDO5HvuIxsAsiOQIap+Kgow8IpsE18psIPXxQReaVlR6Ag== +5.0.0-test.9 [Build: 1573214586],Windows,euaWnuS9dG+QcbOdxXl3EjVvw4C429+vPih5iqSvKGHiFP4lWRfhokHxMhl/6GXfdH57ofTEwaEYQ+SYiPMfAg== +5.0.0-test.11 [Build: 1573316935],macOS,b/eiifmXVqQ63MEYo99zmBU+ePyZxYjHapCp8lRxxqay4S7IYmLO/L0hsuUwuhufU3NRXBgSafPXY/qM72MQCw== +5.0.0-test.11 [Build: 1573316935],Windows,bLObW+PicJcWKpi+RsTc9v+sdNokL+LuKvkB9zbT4LDb+C7ygKZxW36eF/tnlOz+k/c+1K6pw2WiGYWEAr8BAg== +5.0.0-test.12 [Build: 1573502287],macOS,aSZbUd87Fm8nZBGZBGlrBevVtnS9kh1FLzAMdux9xL+4XT72WSdw/xxvrseuY/QRxLhQXjDIfrIk5r3A9lXSAQ== +5.0.0-test.12 [Build: 1573502287],Windows,fmzYSYWzKZv0BuQ8UZaTqjAEEnURd2BuD+cXRtNJU3GaI3OdDQ2/1CsbaqoMaA7csc4Q7Mmwp06CddRRGoj1Cw== +5.0.0-test.16 [Build: 1573563185],Windows,GtKDGT9AZueVNfCXAggCQVlRDO+SaDiy0gbhJvDkp/uSmhD9oO1PUcJUG1ma9yuvykxaIQNvd8PjgIlUux8jAg== +5.0.0-beta.15 [Build: 1573580845],Linux,WQu3TToFKUCviY0m91nruqCIcGt4tPwz0oEiyv80ujabD17rA9F7JK24BytwdmsDaVGVuUkMb6VXfWo9HldqCA== +5.0.0-beta.15 [Build: 1573580845],macOS,h0a42YDAzJnIYoU36COe372buvPI0QDwVW77NPy3XYrg2LjxkJH86sNmE/tkG13Fbtl9jgczFADkVxR7nDSgBQ== +5.0.0-beta.15 [Build: 1573580845],Windows,h4X53sXhFBAewG3RJPqxj/LJHjSeheMtFp1/ZIJ3uYrpJ081SqCHqdmabg5JdKiXX81jQFBy/v7l+mtEbX/hCA== +5.0.0-test.17 [Build: 1573581231],Windows,FbaymngIJXw8PmYIM0AeSyK/589RSgjoc8J4/fN2pdKL0J1W+LKHq0NIOY9CkltrDASyHMOTLU2XAk6iZj6gCw== +5.0.0-beta.16 [Build: 1573593194],Linux,vrwdwFiG2FGhjkfzAS08poN7aU6Y+JT8XQODY4z9QauNe5FWVQlQBCasZe161c0vlEw5CEtN4ObnYu7BtAHRAA== +5.0.0-beta.16 [Build: 1573593194],macOS,FdJ/YMChBoySv+ylNpmi8IFyh933MNTw51ymfks8BiVoAkEn2v9ieBLlApm/2XhhvWbe4TQdd/STu3SeEMepAA== +5.0.0-beta.16 [Build: 1573593194],Windows,/rYy1w+7+Ifb3k9PADIRdbDP+3vISZIFL0q9yh9+6xy6XJV5lJm2U+WqC9fKKto3J+y7pT4tqHnICzSUzcVnCg== +3.5.0 [Build: 1573741018],Linux,K69Ycxkm2mMkmnx2Z3H/tcexuwhxUCKdCf2HR+2ZYUysEssCI/xCMV5IyVeNtseX/Rj2rKFyU202XvtZvwuHAQ== +3.5.0 [Build: 1573741018],OS X,6fE/E5qKkXV9fMMEZoz2RqdHKA1jLAP3pRGDcFgIWZWhAgJ62S7zpjbjfyu5ei8zTf0uKrU6z0X8e+rb3M1/CA== +3.5.0 [Build: 1574093735],iOS,bCdY6e88YBCF7lpScGsVO3AWhKFHvj4TiaXftRC2RKDo1N/5FS3QS3/A9KAQDx55P4CdwN1qfbMmlFJQcXJ2CA== +5.0.0-test.18 [Build: 1574258541],Windows,LlcASnWNx904WXYagFMJtawQmlhxr1BVexhXUHPeIuXl9GNKs+dZvT9PhzM93yUDTLQPQ2TzPl0vx9+yxZX1DA== +5.0.0-test.19 [Build: 1574273002],Windows,26qGf4496+sTJsj36BNN1Q2Vt51DCgwddXGM0zwM4/RQo94/xtxEM0jOIcDoudkQU9Yh/dAUY5V+N/E809mxCw== +5.0.0-test.20 [Build: 1574327385],Windows,rdeWaZq1Nej5HjEMi9mCKUiQCJAdTxyaCZY9zaTmZu0H6tub28Tn1LXmsQ+9tcKSrJNGbNfjzC8d20DLNwkUBA== +5.0.0-test.21 [Build: 1574343180],Linux,ZtHZonfg6g84zkbp3aiiv5wb2L0G76UusiNCJkAS3q3RXHNQ1zCLWiCRbfskIoXlGqn3qJBQdNy92HSK4tbjAQ== +5.0.0-test.21 [Build: 1574343180],macOS,fsSlh0n45LwmkUsZ56OgzhKtAmX5DU04Kzxl4EuytwD4Q8HQ4660V1ue1rBNQx/YIFKLlC7FIF3qMTT6LBjwBA== +5.0.0-test.21 [Build: 1574343180],Windows,IK5/oVWmpkDcN2q1Z0Or79aHtWBZEIVtiVssQhpNQUItD5KBbsv36pDOwFRwuVPgngv9Rq2XJKOd0kL/yGSCAA== +3.5.0 [Build: 1574357871],iOS,9m9E+yrIfJKmRDvujRH5IsbHXClEbgm9zRms+iL9ikLhiM1gzIBWBVVUKFqmtpSSZDq3lnmkN9DmaC8gxhvPBw== +5.0.0-test.22 [Build: 1574873227],Windows,6m8Nob+e14ECagLHedtLc2iiNP8lm2eTOH1E5xBq8EW8EYpvUaWFsErg+pcjCDDruwlzlrrryrvJUGnhEKzjAQ== +5.0.0-test.23 [Build: 1574935289],Windows,n06nZYaCKCoqwYGi1pC6/v91SgojFrNXazJZzz1DJm4XK+utmCQikAMzJdXe76n0rfeNvAs2BQ35wiKAlSodAA== +3.5.0 [Build: 1574942993],Android,hfTN8OfwUhPZSgkDgLGZROwUfolrK8/ep0wXOIcSk+RM3rB9nrh6tpISemmJJDfUV3Cl99ySF/vs4WjIlICoCQ== +5.0.0-test.24 [Build: 1575287495],macOS,i40fx8lABCbJkHxFNh4HYYXXLJXM/aouoeC/Wfj3G9IOCc7D9twKMAgm8l2Zbay2n4Xk56V+L0jWctasVc59Ag== +3.5.0 [Build: 1575318320],OS X,srhE2XU7hB2WWBdzywlnH3q+cSWxBTBR+oISy8+jHHeCKjg0uUHIFUtqpnk/8xbvpykRJs6rW6e17ax4AiPeAA== +3.5.0 [Build: 1575318320],Windows,NSByceYLl/b8kB8+gDgoFdUJkfavpCHQ4sWv0qpP6qjIHT6izqx3IuzAR8Ma6opV117yASpr9R2RrOZBN/lhAg== +5.0.0-test.25 [Build: 1575368044],Windows,BOP7V84ukRS1fs/wuAMfZC9qM/c17Kpf7bkuHnzSjCbVu+rMlxrb/6uWE/wCR31pUS9/oUMQIDwCOhbkUTbIDg== +5.0.0-test.26 [Build: 1575420598],Linux,56IHXOCLPt3AgTc138PmVGMWpHwupetm2SfRtGezjVAs1O7O507sEGbpzTYbL7HHqXp7kAGv7dJB1AZNm1CJDA== +5.0.0-test.26 [Build: 1575420598],macOS,HJQkHM529e2eHdejAIEx4ICYpP9lqClnvyIyo3XMNKcR9Udw2WfUetfCD6VD0DmOygkU/vmI6O2re7EAC/MEAQ== +5.0.0-test.26 [Build: 1575420598],Windows,FSI7yKzzU96ftITn2uUKBV+S03rk4y/wAAdpLjoEMMzuVSoJrGAOu0hiu+TwaqO15ECbhKdti6ClYv49O59/Dw== +5.0.0-test.28 [Build: 1575626623],macOS,CXzUmy7PP5985/QDw7ysWktG/mlhYeN0NovrOYaBNVN6zqJOYskupSud5Pc5Nxj9PiY8gIBc/8fZJ+FSJGY7DQ== +3.5.0 [Build: 1575804173],OS X,VnPAOJE+AIi8WOMBz4ym+PCOQoFdwfp86rYX7u2VZK63OrUZ/aRpKF0v0Lwbn4jywPjL1bt3RJ+trP9+cdyiDQ== +3.5.0 [Build: 1575870843],Windows,RDv4LfYSy9Cr/uQmLh7zk5Smce5aYYAGYbZCAXJLK/tlOlXwzqxoCXor/Dtg9XhjAkVeXSdX+ZAaHwLuy1vvBg== +5.0.0-test.29 [Build: 1575906492],Windows,QCZAnoRiStjO5epvXlTvq0R3YHD3t6VMTOSzqdAdIooJMWiOMP0TMujDmDPZK344CJt6/wBTWz61cYge3nECAw== +5.0.0-test.30 [Build: 1575953901],Windows,rxTi0v79PMTDhbfdAZPol/BC/a+wFO5o1p75BbDJs+TDeM7/PjdkG5KySkkUbF+G5oDrLifSfANP/iUpvaenAQ== +5.0.0-beta.17 [Build: 1575970903],Linux,OxacBnZqUSwz5584fVxlK+odEKXG2RxUGVQVKNw3I5Hw+/vjLThjinxZcCQeoaQVJB8jQBCKpIqDBDAoueaTCA== +5.0.0-beta.17 [Build: 1575970903],macOS,c21ZfbMiZ9yWBhyXR5YzRWWyYAFYOgwSPbEkSEx0rnHkG59ovGEMjffBqB+a6lPItCjwep9poOrXdverrL4pCA== +5.0.0-beta.17 [Build: 1575970903],Windows,KTcasAx1nTBvGMIQt28UfyHmCRZzuzx0vIWR2FpCaytWPYyTVe2w/u9nWH5A+e9RFJw5pphwOwZC8EBrM5OCCw== +5.0.0-test.31 [Build: 1576066245],Windows,PdaEUU+pjbWv50o+rwnbC8VA9CtDLEZ3FW8s1jBbebebyNmMgJxJMbtwDii5Gh8J7KJUzG+kRTvx/KHqEY63BQ== +3.5.0 [Build: 1576090604],Windows,tPCBJ+gtkMQZI+EZSotMjoofEDY3AothGzxijDm9U8RNpZT9CLzr0eCfz70YVVwtg50j85iDVe/l5Ss22ef4DA== +3.5.0 [Build: 1576181443],Windows,XOVRDA3D2gvGUKmpuuCszuBCyyjUQUxvaGCN5EGidbNhOzJ6cPMPLgcAXXGn/itPGWjCSxZM8muucsgigwPxCw== +3.5.0 [Build: 1576513599],Windows,aVC4Jfjl8REU2dunFeHYH6KKp8jN0QEb6Q58VOveVMlm/YmaEPzNS7dDEew/rroLcDzN0XJkC6wqBtKdAt2jAg== +3.5.0 [Build: 1576585064],Windows,l04dlaw8vwImq58v5cg7C2ZbxCAEjStAsi334u6Wf6c668u9DuEDeAGLhxDSPe/ZjsSUAGavkYJXgqtdzTFoCw== +5.0.0-test.32 [Build: 1576586323],Windows,gaYHucbKUEFL3aHeeorqt2ECkTdBHR/A1onihLE8v07Kw1NT8b+/CWRnWMlXYxCQOyirWRFDRzJJSbRWfBXaBw== +3.5.0 [Build: 1576687348],Linux,rWCTNfEyCRtwYMxJXOZ6+i3KIxKvBjzSnzkmJF46CHEDBg39JrozRXa149Ognps9LLGbMhouXkVjdFCivN6qAQ== +3.5.0 [Build: 1576687348],Windows,ip1R1gGEy38Ce7qxs5IB53EBpuPqFg08mFw49uUzWWgsvdu0l87CTtNdDeF3kRxUeDvjGVqG30CVq12B7gd0DQ== +5.0.0-test.33 [Build: 1576756659],macOS,JiNrdoUplbYfox6cyRj3K2HitEzWdkKx91xcbpH5iPr6BlFQbmfsXfVGtNWol8YCls1EkDKXN1zPewVsN9KpAg== +5.0.0-test.33 [Build: 1576756659],Windows,qkP3ea5HOWUOvqK0OQYlB+IgAvwai412cfpayxiJ5k/UiFnc0wFDzIMXL+9ZNi/UoyMKWmjy/KcYuLFHGI8wDg== +3.5.0 [Build: 1576757477],Linux,lwBJK+yboe1k6rCKG5pg4AZhAM4heFMxqvvJMbhxaH3ORWOyPebQu2vkJBkVeRjGU6YUu6uS4ahlxlxdT4m0Ag== +3.5.0 [Build: 1576757477],OS X,2o4tJcBZ+m6evtUlAXzbPHzB1aqr4JdkKFs0sC5GTyIcW9runz58aEA5HxYyl1Y5Bua1LfO+856agJDIMFxBAQ== +3.5.0 [Build: 1576757477],Windows,QRpkkp0eeFNsdhg+8UpCwpTIqeMZbcmRkjRBAwjWklk5ycO58a/jxtkfl1vth1DvG5lRUd0ar/ZIEVwkJhalCw== +5.0.0-beta.18 [Build: 1576838043],Linux,dGtZXFeoReweKxKIr6O1xkaVvhucxgfDsmvotYQSeRww5k1GjWelPzBLC+tMxi+HjfW4pLbNl/zy/q+p4SGXAQ== +5.0.0-beta.18 [Build: 1576838043],macOS,hAVRVqR5Diiep7ON9a52mXbTIsXLrnXSDtYHWL0vI2vtmX2Cggl5OHTzXQdqpzlEPA4vB/oR6MnKJPwiaHz4Aw== +5.0.0-beta.18 [Build: 1576838043],Windows,hKp/R33NhawXiUKIRw4XU7ovpMDRK8YU4MLW+MwcA3a9TSJLahjZ8vWJaLHdexh4ehH13VpqLiKifjzEI9KyAA== +3.5.0 [Build: 1576948785],Windows,rDVnECt+GZtObMTx+reMnLI6Qpj09snDUDqEB9w8sfO9vZGvQEQG/WGZS+UdaT6RWeib21VD46YXq6nCKej4Ag== +3.5.0 [Build: 1577821118],Windows,eehDiOfKnpcqsAsAn+Bfw+WR2MQiLhQb5/acupyIqn4BNTAL9c9Ezd5miYBR67P1+cNEMb9OMO05XdKqN4nWAg== +3.5.0 [Build: 1578164171],Windows,ttMvW/20CHr6WYqUpz2uTMMsajuyHsvw4rHrMFwDBBd5yy+3wxbCgEMAZuFxqfUagsBIW8PMzowUMhSkjPvvAA== +3.5.0 [Build: 1578400308],Windows,8Jg14dG4+TkuBMbiSB58qV6zHmX3c4yDdjuwZ+5CO0wNkyrsUWcdMTUD501XnP3cPqTQViy+3uclUA2vkZSKAg== +3.5.0 [Build: 1578417881],Linux,ir3dtCoP7swQmDsEybluSgEAUApwZT2c626L6AqkEQd116EXoLEZvSJCNE0L+PyuTAJV07k3L89jdkCr1msAAw== +3.5.0 [Build: 1578417881],Windows,VSrAXQ1ps+hvIDAC9fzMjmG573M8XsIWD0JpV1BNmccZV9uMmL5EetGnDfaZDydxFj2g7wy5SEATDGuxwA7JDg== +5.0.0-test.35 [Build: 1578591798],macOS,jPdrG3UfkCYUOznEln0VYCSZyxY0PgpDDIIis7ucaIxkbuljSe+3aQVECug97tipn4C6KfHc8F/JtkN5iKViDg== +5.0.0-test.35 [Build: 1578591798],Windows,pvBDfcSsiVWZhIJaiJB/gmI0ELlD9+uZqm5WdmfZHX9aL3BNsPw88xXkafzN+ohC+UzcWDCfzm6aN4yyBVgwCg== +3.5.0 [Build: 1578609201],Linux,RIfBsaQu+bCZo8jT58X+VOruTMfsBZbMO8iWd7od+nGsonEGXgMY1W7iB38jpRa0JPY2TqOpDqk2NMWjtJLsDg== +3.5.0 [Build: 1578609201],Windows,qjxevyZi/HpxdfvtpRmRBQnHUhHh0c4QmwYsU0iaWl2oy0gqD1+onwfJQCLtHJoC0NixgI9Yl11aZXnXTztQAw== +3.5.0 [Build: 1578696214],Windows,cl3Ra0l/rKndWvhJRsmuL6c4/aKqea2N2N4URge35oYRuVu7QToTZuHjgM/xsSCxWcE5Jxud7PiBPkBxD52ECg== +3.5.0 [Build: 1578859029],Windows,NWE9OG8DuU1I4Ki5TIPge3d0WgMv5w/g87uZTnqmW/JhuMluQfc2bJz5P8Ny0VaURmIz+H7/ZactBIl77mdhCA== +3.5.0 [Build: 1578906268],Linux,1exAxKXS5X47jT7rb7PUDIXF+vSdRvJBPIQpHB2nLivjXLxq49gBnj+BLA2KU3fWLeCAv5u4cUnixrKsZ3dUDQ== +3.5.0 [Build: 1578906268],Windows,b2EdIfdzv5bFaQEq4gOnuT87moaTH6WhaMKDGNbGUjnrJ4Px69I3BcJtvatyaGvgeYaqjzDcjqK4MeVRSzvZBQ== +5.0.0-test.38 [Build: 1579022578],Windows,vVnfcWdAhVlpnba8sPH62U3R7hRGJh8wEyzbUDwjYhZdgJZj+e1k+4SINiy2XqIX8rkHeqQhLh9HKNz7xKVhAw== +3.5.0 [Build: 1579162934],Linux,+7j8+3pxJ9F8RTW3cwuyPZ/ECBjIEt7skiAO6vwYi0vEURCzaRboT2wAccb5+Morc1GJLQ3TWv1+F+/FfQj7Bg== +3.5.0 [Build: 1579162934],Windows,S7sriAuGvJAt/GqvEeU3qQrBbY1KabBwS6rdVr/MNkX7Qb0157vbK9UtNxe/6WaSVTWcTbU26EP6G1IL2ZHqBw== +3.5.0 [Build: 1579271398],Linux,WeJT/r4lHlsCD1SEpJ6EV+Aqfv2hVBz0sDfvfOZCQ0PIoU7NgyqeSuopvRv/YBnR5pcrTRPiUZKBXnECutiIBg== +3.5.0 [Build: 1579271398],OS X,3HhWtyi3ehFQrMJfa1s7YCKUFf4uEMvEWLv4tU0a5R2XNAaN5xM7GqWzxAT21mYzLVZEppl8dPQZ9W5IkzhvAA== +3.5.0 [Build: 1579271398],Windows,YQuBI583WrbI6REuuNi9xQ8qoHVBS/MZyIpzHXbJOFQcZvRIxxruvfJQChMpvc9/RehbZVe2KY8BW2nTIANcCA== +5.0.0-test.51 [Build: 1579367787],Windows,eCUrSXyKFRZXCfyFnOl7PR3r6VCDqzu7yytubUTTQb00jMoDbADYVHCnyc4ZUD51oHDlPWsStfczoF127BnTBQ== +5.0.0-test.52 [Build: 1579512204],Windows,CTql2Bq7+q3TVD0/sZh8MybbQyPi2z1ygWdkKDGMXHJ/Qhio/o9Z7AXMF3fhp2+rJrdGj6CCb9X3vT1MT6B7Ag== +3.5.0 [Build: 1579611798],Windows,p9AERgogemgDxWHzRVnq8laS/47iefIGxU+17XFXChG/gUzxHYzXA1BIPfG3zlXL/FWcuvNfWRdourPdM1JMBA== +5.0.0-test.55 [Build: 1579622615],Windows,ah6EIrqz/rbmYCF/PAW9qF1W5qS7De7LTGc76xgEC/HwYg77nWrAk3tYE5xYJN0YUuYL6vuZvtMI5iij7SRACQ== +3.5.0 [Build: 1579686935],Linux,IhWffkHKmt/jnYeL5IQxK8BXmwcdgNTiP9Lg6RMmiiMTFq6PHvQHjQGFNOrVZSgeLpEYuIIj+0cL78rPgGUoCw== +3.5.0 [Build: 1579686935],OS X,/TmafB2ePmpqRIcDgIyxzgSXioSQMPgiR8ATdt2AheNH4NP+MPQQ4DHtwNm5HVb7jTw+P5HfsOBVcST72kn3AQ== +3.5.0 [Build: 1579686935],Windows,TghaGBYGZwXlTXXvusH+/O0jdhOtWNdU3HcxVzg2Vsq/H5n9y6+zpHdfG/Ea282pZlPNmjAigJRPm2y/WmjeAQ== +5.0.0-test.56 [Build: 1579699914],Windows,r4aN1EBSyf5EBbk6wP4E7zoKDLY2tFphEp8tTATYQIFU7geA3h54fGznbZ894gMIrnrLV2Bv/CrmftLyH6VvCA== +5.0.0-test.57 [Build: 1579705006],Windows,LBxcwx72FKcPvfjLwtQHAuf+hcQPCRM6xQ7DV7Jxz/YAtNDdG5C7fAPrhj84XuJo1cufkQaE6fW/ucvao6s6Cw== +5.0.0-beta.19 [Build: 1579708986],Linux,sizcn7tabErfnzSilYrA0gFy/PPEYufUlAT+VDonx3RQz3/GE5NiM+y0Ovq6LEqMktIqkAqCfr7mAAcBgXZZBw== +5.0.0-beta.19 [Build: 1579708986],macOS,uyzckz/x5TIm4m6G3+vqrvZ2QGqRG5VhXZIx9OATLo5WOJbmW5zzXgiZdca3w09gvfo+ab4X/psJmayXJ7vlCQ== +5.0.0-beta.19 [Build: 1579708986],Windows,4hImRslbCAQhkjlbAWT5HWANA9yophaWEuE4AQ6YXh1/EY+XeyCI8+RBn1pqpDNuGE5FMBZWhGmGhoY/TaZACg== +5.0.0-test.58 [Build: 1579878094],macOS,BBuo+6vcCjeJ4bWkL5cvsuuie9dy+owt0zRBeroCBV+iHmHPirn6e29MW5qsCqMX9Vmm+GNIsxB9zgQ4z3KPDg== +5.0.0-test.58 [Build: 1579878094],Windows,lYrBlo3lKYXVFZDFaKQ1v7IfMFtoHU/BIlT5ebeAQOy18W7YyZyWoxB4EzFynmMiLTB/H7xpbqsYC2yzHCHGBg== +3.5.0 [Build: 1579960421],Windows,sCOi1sggRSo63qd6js7amPrQKuGs3Nr93DEuBgfCJSWMZxErXnXsAbSjhbl9UechjBx16qK61PdI5CSF1XQYDw== +3.5.0 [Build: 1580143599],Linux,nAUR3VnXvxdwdeZcgdljrY/CFl68sLKUfPp5lOPe+g7YWVpW1dR//Az2t6Q+WDACbfaJXVBkYwmMzJlSlW7QDQ== +3.5.0 [Build: 1580143599],OS X,DiIj0dFO8DYoCZOW/TfmMGkcaAdfLqqSgzbgV0nfz8/FCSnku7bpS8guaRINNQ9Majgq1Dfj9PVd2KMaucFDBg== +3.5.0 [Build: 1580143599],Windows,YRQLhax4q/VzwKpqkXWK3pgWIhuhJc4pv+Jd6yQxucPUiavIy7q5bWjQzAC/KsuDQSdKHqreUKjsOOl3jFFhBA== +5.0.0-test.59 [Build: 1580226872],macOS,h3DS6ezaHx2RAhXvuHDnPexpDvR41CO3Tm/NHltNinUbtzUOOzVIClX42WHAUS0mSqD7mFTrjkMjJJyST6RDDg== +5.0.0-test.59 [Build: 1580226872],Windows,7zZ5SSOInE7IVgyMw2doa1YgkptJpeVZGiFa9LGexY50HgZpG+UqqJUt7jBwbWIHxcxWIuTTrRGTpXTJfj+fDw== +3.5.0 [Build: 1580316377],Linux,rUbvG0+ZB8HoOkYDkThOPABe5URUWuFsCC+kS+c4ZpNtC70ju6uaLuM0FbG3AGiRcVc8SX9zMzagvs1cNVtYDA== +3.5.0 [Build: 1580316377],OS X,uRmSTbFGxBnghU7zAtS1624y8R3Vhvm9OWO5ZDwB4H9hxho+myT8ssHWwIN9VUWImXnwcFiuXS+lS1tjAV+3Dw== +3.5.0 [Build: 1580316377],Windows,2FEBFDRIkWw/cYRUbuSFvwADJGhZ1sCvFrZj7sZI72hrRRcCI1CYmTo/ukzWsEInAFz6rMf7qBaaOXfuU+6qBw== +3.5.0 [Build: 1580593763],Windows,PmLXQboEcpz7jB1v/Y112W7aFAJ3ltgXzg167RJF5UqXlWKeqLC6X8cq2tGYRauQq2RiGDaToMcfBrsKlU5UCw== +3.5.0 [Build: 1580672591],Windows,ssFQHF+iHGDizteHBEHI7It9t98RBUBXx4VuUPDsSWBPnpVR1/v5AIMnptFkSatOYP03JfTHH7ww52N9BdsMDQ== +5.0.0-test.60 [Build: 1580683977],Windows,8Zy0uvHADWR1i3FptlvwSPvLeKsJzBgLkFDw2QLDcBJykRASDJ8LP1VxxV/pO8KLemcwNnsEDthHvtnXo2c7DA== +5.0.0-test.63 [Build: 1580751860],macOS,A9h+7BIMYRncyO9oMUlQQFCsJVL0wq/ukLTBhXfF5s7JYVcmgDBaY/FGd6254ddUpJgB3aRKNhBpTuYWdx/ZCQ== +3.5.0 [Build: 1580753736],Windows,Z/6h7jb4vbZv4ERritKcJD51sxrd5Rfb4qTP6Km320A0Gw14OoqW9Qz2AvN6htjFtgcZc533wZYve+Tf9Jt8BQ== +5.0.0-test.65 [Build: 1580774583],Windows,Tk3I5UUdu8e4a+TaykPYeISia9SiSnYqvOFsLnCg3jx6tDH5qyPZgknB2YwVb1ULuKFOl2wHkKfYznrcyLJ0CQ== +5.0.0-beta.20 [Build: 1580775353],Linux,zmuCstKmjd5B33D80/ZzUJPnxGArcfFfsFa2ZeuRrxjbckZ+Q6VmIsJ1zY8sHaBq0hplbrzyKF7nfE2rhTWJCw== +5.0.0-beta.20 [Build: 1580775353],macOS,zVdI46BGmMQApIIB+wnhXrkOk0M68QwE/gwbqg27KFQqhDKBbMuBHqwA8lqDYu6cKiZIXNSEPtpriug94wlrCg== +5.0.0-beta.20 [Build: 1580775353],Windows,DgxH692v8HgBp7gZmvjovF5/ho7UIW/BiGq0rE9tCGqn6qWhD9UDV6h/mQs0rQ9xGkttvoXgjaXx8Jdy6wMRDA== +5.0.0-beta.21 [Build: 1580832125],Windows,m0or/uBBRVngzw13Vqg51y3tsLBsG4mAaHakIHCOEh3Dk9kyGavHeYYNq38i5AWRP0HKAzsngAST4yJWA+FnDw== +5.0.0-test.67 [Build: 1580844878],Windows,DvmmonitqHF6ElwmDmiJ07pEq6zWF1Ui5mk1D7256fDwVkxmjOlTWXeBAXQY2hTZi7e0i8UL8mKntx8Aa03bDQ== +5.0.0-test.68 [Build: 1580898716],Windows,+4HgRO1mbyi7Y7ERYf6rY2zl27PpOfOqqM2hplBpCwGYEXqk/kaDYgR2uzjE99tcJVPFkGabmRSKhpEkNuy1Cg== +5.0.0-beta.21 [Build: 1580909538],Linux,pxBYR/tOgH4jlnlRkn3r0KV8QDqMqgwn3laSnX7UlTAiuHsoWC/Ate/h3EJmErG5ZkrPpNfiQ/LwjF5XA716Ag== +5.0.0-beta.21 [Build: 1580909538],macOS,+onDe6gCP47nLw4O6h1YGfW/hcX2obp5lmbIssLC2QI+7ZM5zqlLVfadT/mlGEJQmkPwTbgfB7skWb2RNlSZAw== +5.0.0-beta.21 [Build: 1580909538],Windows,bIupsgUpyshmRXuk7BNbdyeVe2kaFeCzK7JYsAC42pTQd2c+BJ9d9k1s++98xUiawk02PJEMHHTOMbSzb0stAQ== +3.5.0 [Build: 1581008757],Windows,qD/zY2WGfK+bWdVtR9diH5Cd4gqNaQoGkyx/CXU9Uj1wcUoa1zl9Q4FyvKknWDUk4xMgW6TwV3/dqEiMCNrHDw== +3.5.0 [Build: 1581019294],Windows,OefT5cmBEGyvtnycUbFibrYGJ6fbfak/iWy9SkaPtDHs+6XVwuWF8QoPlpPxDVr35Gu0wf7CosU2tKM3cLinCQ== +3.5.0 [Build: 1581183683],Windows,iRBp5ZpaD2Rl+SBDz0FdDXULs2j/QOM5EQP46DZITMItEkve/XDRx06WeUvMg6F3QQbMGBM+A9XFCPwkrntfCg== +3.5.0 [Build: 1581524851],Windows,CAufZh4u1fgPkBO9ifw795k5uPG3jzzYZuUJF8ILt0549dOpptY5rPExQlN3DITn8PqYpY7KqmyxbNYGN9QiCw== +3.5.0 [Build: 1581573435],Windows,xsE0T9FneeP40ZYx0wSCCOp3m+4NPDpDJi6EEl0PL+N3f05rJg62yi3U0x5QUWZ5qTYWqgvg6xK+wxiiU/eXCQ== +5.0.0-test.70 [Build: 1581595773],macOS,nrbngLiQ+oFmVaiep1bqxvtbzhxs9aIV5099xsdzO61dPTMZzkv82QOivGQrrQFyJ9pAPY6NT7MYzUqiNfXeBg== +5.0.0-test.70 [Build: 1581595773],Windows,7hafwSRKQQ9JibQOLqkBY9Xvpcfee6W7G457dYfOAcw+7sVMDESgTZurizhGC48rLUAI5/EmHAHBX1t+0Y29CA== +5.0.0-test.71 [Build: 1581610274],Windows,Kx5AAFhCpA18Qpe8omponynjqyY+LJ5YOvLsFx0nyXT4ULXO7wOGj8zOuBnBmEfVdqNxp2D3g8h/+XtpETt1Cg== +3.5.0 [Build: 1581610500],OS X,oD3b4mzAO01Rna2kZQR99cacT5ga5wWb5Pbyb/amrmVB8pk9mBhI/lMd3RIZ2FOTIU+Whl+c19L1V6F2F9s6DQ== +3.5.0 [Build: 1581610500],Windows,YDLAfOb4eRCoIw9rfmwAAi2g7cowAb9UaDebmmRnnMnlgzmPWKEt04pavAHmISYUcUyVcgcN6Xd9TWGXkIp/DQ== +5.0.0-test.73 [Build: 1581688728],Windows,1kr/E/7znkikhDCNMOPP+e9EI1m5zxKM2UmvPw8myp05FKYYU4jT4qq03eDN9tXXsrVQo21cEaa2iCkx/DpMDQ== +3.5.0 [Build: 1581910955],Windows,V6WplfyLI3EUNzHpfH3fCsEQPvw+0ZOUjcul6/F7zdM8PH1mYUC/WabyXyZeYSFfkCL6ap8JUTpj/ndIbcLHBg== +5.0.0-beta.22 [Build: 1582011547],Linux,ujCBv4ax/Z1X1/kN5FRcbYx0RdBy910N6HXLMFiGCB/8FkSzn/fVnqGQq5c4j6hI+jxfnXazTVMR4P50G5N9DA== +5.0.0-beta.22 [Build: 1582011547],macOS,O0I6ny9At1k/tCunLjdOyoxmkAh00RkWDg4bMmgQtCgGUa2g9LsMninbuRgq/qEPBpA106to/Br7kCFtU9AiBA== +5.0.0-beta.22 [Build: 1582011547],Windows,lzu8BcTXHRlmB5KE+JFk+MvR00HKC+sMojtvZNTT8HF2IAYRQ8RYJTgoMICwVwXmqfnpeVWRm7nlN5aGc1w7Cw== +3.5.0 [Build: 1582117478],Android,vASJQFPECG2TpUh5ATsR2c/gVrvsuZ9QlMpKN51F+HnanYNH3oCSGoievQX6ACjsKH3OZihNFQZ6f5HRU/MAAg== +3.5.1 [Build: 1582118844],iOS,3ZiKmiSA9g1xUhb67wgAPz7duV97QCoMQn4OmjqXUffVN5cvztaUhIBm0oZ8n0DEXsgx8hulbqWBFIN8QgAIBA== +3.5.0 [Build: 1582288251],Windows,TfDGO2PFx40/+aYype6R4NymCpSmaVK5v5H0TPv/RJsQk9Eph9ImMtyScUfxi81Dm1QmUwAzUCYDT7oVp2d2Aw== +3.5.0 [Build: 1582632784],Android,WdEIgZGcvq/nA72e75D8Lg5XGpzM71uP3ACM9ytu6VOIpnhOvhDOBOEw5+BvdtczwU8mmfSBRp9YOe6weF5MDw== +3.5.0 [Build: 1582634532],Linux,q+AGeyyc0gKGc0bXXqYuv0Rbnk2OaOyrDZPYSLx6USPv1O2BE4ny6CH+cW4phg7zwQreJan4LwVPL9TXLscyCg== +3.5.0 [Build: 1582634532],OS X,HVr0/VEWh/5oMXA3nqYsdj8AMEtZs6lcMzTgxVg4vSPzi3WUOzLTgGx6SV3B47qzHdMlndRG+f8ez3VmUBo1Dw== +3.5.0 [Build: 1582634532],Windows,HIA8YsTxkbsOKakMQQtAwHvEm0fYR1vfpw4W5LJePO2Zi4H7DXPbW88jRS6YpyajE2wBrfDQQ4C1bcyLM4F7CQ== +5.0.0-test.79 [Build: 1582881429],Linux,v5iYqAuhZ2+dGwUdeVb7SLakgwbTgVyTHGA5aGUbpApvnsb5rGv5R56Oo23TbLJA+I8BG+MUAMPjTAq9bGphDA== +5.0.0-beta.23 [Build: 1583314601],Linux,kkzWsdmOEEe4NHmnfH0vZn3Bo0Lixigl/n91SaMpFVUj7sNmjuCnYYHHNC4lXOmk8jqiK2S1HCS9Du2SUhuWDw== +5.0.0-beta.23 [Build: 1583314601],macOS,ylP6xnnn2g0DOvkQE2DgwiDbhm6s1J85SIQRrTgY8JRa5H6FNniAFPgGaxAFmvfianclmn4k7Nm9/McVX1fTCQ== +5.0.0-beta.23 [Build: 1583314601],Windows,aQ38hj+f8Ih+KEy5a9Y+dAS8Pq9lecaVSRlAK+4+3FgTrl4vgooSRYfOsRl9sgP3bDDJ+mmYH/Wp45puckeyDQ== +5.0.0-test.87 [Build: 1583490334],Linux,TdwctqEYENLgcpBtOuCDIZzG1js/u7rsdHS8DkqAEViKsQ27VJTbCvW3Ti0z70mX6g6XZAWixxCeZEf+F81aDg== +5.0.0-test.87 [Build: 1583490334],Windows,zBVMxaWgifJDMm348f8rKF0fLrnI9w6mXLSDZ4pP183FZafhXqDKKVZcjvaTRv4G4wyt4pFHUaOBwd/ByTh2Aw== +5.0.0-test.89 [Build: 1584014675],Windows,AWXttmmIF6QzYfwuPgN7YT6+x00iQVE28oAB5kwb2elZ987qJe84FzkJZ6K1zaPBLeYn3VBqsCW+OdMg2CNHBQ== +3.5.0 [Build: 1584088288],Linux,9UVeO3R3xm1taUmEFTnngy0C1iQovwzWy1HwyFlIbBDDQaN9SHR0hK2GpNrdquliY0wtNSbAJ/7BtGhk3or9CQ== +3.5.0 [Build: 1584088288],OS X,wdYDalZQtOO0+HQAtq8xwMiWSS2bqXUltbyIGBWebrU8YWTFuIeqmhA9W/jo4W4yj6251qRLvxnFaO1SywptCQ== +3.5.0 [Build: 1584088288],Windows,yghoziODwuQ3LBpgUUHT2/kCTx6Ygbju2WxzM8bojYGGiuQrL/+Tb2XKETUhYJWfHZ8WH2PvIvB4MFZIcJO5Dg== +5.0.0-beta.24 [Build: 1584452452],Windows,iLM0f1OmaoBrg6IqLW0GlSJcR6kydwtJjlblwIbMmbzIXa2xzwXbtREgvq5eenK8VfBfckg2g/KZygGV2XOHBQ== +3.5.0 [Build: 1584525989],OS X,nX5cpDbTPvbzSivBfvqWGpjokX42n+1HlIKxmHBTBPhLbIl2Fn1f7znSY/31K3fj1hJPJVOyuOKyPsRHK/uXBw== +3.5.0 [Build: 1584525989],Windows,boQPV7FO3e0PJIxh1gSAG8Z3/NxLWbzVej7glvkQaSfvPWj3Bg385Ikn33wLHn6brcWHAo+fpdQdZskXFmj8Dg== +3.5.0 [Build: 1584610661],Linux,kHfR/JyZ6Ah06rW/t+dFIHkOgLGFth5CCbRr9T3xfPd2gqL5CeYei47LGBjA9K9GrVVRivF0L5eo5MrxGh/QDA== +3.5.0 [Build: 1584610661],OS X,RZJrT/fysauFMv9ugB82ZAZN/t/MSWeJmFLu35FXx/r+3O1QZrM8rDfU5Iq/moG68hPRcc12KloOvrlVTdfiBg== +3.5.0 [Build: 1584610661],Windows,8um3guYdjDlKHOUZMYqt//4nT9k+SBYnAAP/9CarVp5pUXEzYaTZlflyOi6hjYIDn5cQ7gdvrKmdXLOXBJiqCA== +5.0.0-beta.24 [Build: 1584621089],Linux,iTRafOxViAWbIg4Uc2je7KrxkNTdc8WjEtQvceCAsvPY/wL1tgd21Sy19iqASdAOJeQ302Kb06ajsq+8SdfhCA== +5.0.0-beta.24 [Build: 1584621089],macOS,eD5rtvlqnZOBDLN/2VKKh/DeNsPJMY/H1y5yn53MuFKJJDR8VKwnuTRXLHPShzgCEQrjo4EvoY5ksMFRpeAwAw== +5.0.0-beta.24 [Build: 1584621089],Windows,unVP5b7fNc0ZDXsA54GknvLR/FWIQM/obpQKGDUdTBJU44fOUk8p2Nq3o3HtcS44nwhA8Njxi6x2lsuOs8jwDA== +3.5.1 [Build: 1584725003],Windows,EPmzKEUtMuD+7bg4eEzU4sJTRI0wRB6kQx2T5GqCyQB+kgBZO96plC4uNcZUBtwSXYYbkNkyfQc9ZwgOp2CUDQ== +3.5.1 [Build: 1584726885],Windows,B19O3onHeCV8mc5mBqLP5PGof4VdvwLI8HFhxKsXRsDWOu04xbpJjkCy5RYTjMstCSo/Dkhl/WX0puT5/PEyAw== +3.5.1 [Build: 1584955996],Linux,YtR6uJ0zzFwlAXoV1ikV8DVD9y7ka0WCh46wvALArdCBw9zaBLE7ese6Uu3U2Dmg4//ook5cNvupeOlzHcGPDQ== +3.5.1 [Build: 1584955996],OS X,xk8NdgtqWPihDy1gUPGVtcLkfrl5Fd2lfigB0N7d9K0VGyCxC4ZvQOdX6kM/StTX1xulCnENp0wb+gqwjO5nBA== +3.5.1 [Build: 1584955996],Windows,LY20d0yqDFwknHND8FYADnvsKnq81kya6lAEnJEQ+87oN0k8KqTXMDpy/0z0yC54+B8Mo/P8kSjrpRugaVAPDA== +5.0.0-test.95 [Build: 1585049319],Windows,zhiNFDElBjkQIL6xELBUPjVIbYbECvby4qqq+8xo5r2RhF6ZfjebvmX2iqtEJsEyRoNqekcvAH7KGDUdzFaLAg== +5.0.0-test.96 [Build: 1585156359],Windows,w9C5vLHnbUcg7sypEF/GbrqiMnabQ/i1Xazcsc3fjF1STvHWHuBuRT2vBAXcGLIpqxQMz8J4l8yDqgBFzFs+Dg== +3.5.2 [Build: 1585741147],Linux,qILhBdVwjtE8enMjQL02b9i80CRybJgolFQWfQgLPjWLvgbNMeqAAFS+X7HB7FuF5VKq82biDYK2cuQJjTAbCw== +3.5.2 [Build: 1585741147],Windows,If7v4eV0QZjeSpH2ld/suq6dW08v0UZDRRTjDy0d/4mg+Ve+sENwGtggDZYPLgDj/3FEJLVuKZmBw0v1LUM7DQ== +5.0.0-test.100 [Build: 1585752032],Windows,VxWe1xx5ggANpg9NbR9NAG8Kn0KyJII7IphKVXElGKgVnCdHPSwINF+mnZl/l3e2P+EBvvLzTXK1I0wfbu+iDQ== +3.5.2 [Build: 1585812952],Linux,Fy5GNeXUzrP5chKDWhG4G7T3jj8tjg0JkoTNRl+tgrONOWNbNf1zBD+I2LNqJREJXvaSrXcMB1pOQQrWKIXqDQ== +3.5.2 [Build: 1585812952],OS X,VhEA3HpeSCbV06Dfh5wonQ+XMuC8dG96ZXvU5HCNLvkSatAfOsDGLaQNLfbkVZVcs0Hvf9oPFgWvAseSX96rCw== +3.5.2 [Build: 1585812952],Windows,6HIIG9j6bIUavbDFJR50Hk3hwl1j4BL/1hQS5Q4JfAS0oerwLNBbdAfXM963aOlE8yan9d/LWiXnuSKhQXAKAQ== +5.0.0-manage-permissions-8 [Build: 1585925917],Windows,NOVj4XEgHGfIgYhqXcryyaIOId/yVGGUqbJrWZ1tXSMog/lhiiuXZ0ULOibABIXD/QH08x1dln99AiZM/dLyDA== +5.0.0-network-monitor-1 [Build: 1586167450],Windows,LxpaUacQltAK5yxM++Vx3PJPtL0uC9YH9Qspyt3TQxUh0zBzmwIjRaNP3w+aNtyzN6JChinARB5b+LsPLim2CA== +3.5.3 [Build: 1586172156],Linux,GRdePYP+MJpGf6wtKmB2CEMZJ2x1wJLIX81CKqr9mVUDWyp8LTBzOJYxaldUboH+UGh2LOByHNR5EpHA3gdNCw== +3.5.3 [Build: 1586172156],OS X,8+NprKwynOC+wGqVZnaYc5g2A31f9MdoChKK3RYKd19lZEVRZngk5FFB1lIyI9TQKdNC4opfhGL3dvu9bAtEDw== +3.5.3 [Build: 1586172156],Windows,ujcLD9+x4JxR89dkHBEOf8ZxzX2yZjUNBu8mh5f9arIuNOBSbrrG3eRjG0qFNbQnRIUh058tSfes5TRyaF+kBg== +5.0.0-test.104 [Build: 1586348340],macOS,O29jwgoTOWgTnZYjhQobrMh607sddxbOlesu8xBU1oMtm74mLZ65dajvMJPb20jpsXhdCqk+KHt8TcMvNx5fDQ== +5.0.0-test.104 [Build: 1586348340],Windows,h/lwYRBPj+GeQZqUNyXOOvVfWlue4rr9FfGgHt7vMlPWCddPH2fNjDf9K7dNGoXMm5DDdVHUfPgcKfC6+nBWBw== +3.5.3 [Build: 1586353391],Windows,knmVmUvvQTTfOUCWlQncjWFWHXFqZMntUbIPIi/YLcxdW4iP3woJQgVTaIZPEiluMT5A7tb2lSk/r+Byh5R6Dw== +3.5.3 [Build: 1586853103],Windows,Ht2CRGb39a+QZ8YlnbfA8Ip8pQa9kRd2A8Nmj8veYiGMV4K0TaP7UG2bwuxxJC7sIdre1esb2mHric8ZD4hqDQ== +3.5.3 [Build: 1586955962],Linux,WxwBpvlHwS5fmiEn1S7ATpPU1oR8U/tdSzpZvAfoIOv78w+oL9UlTouDquVwrl6L0IXIZvRIDs+32EfbIZVmCg== +3.5.3 [Build: 1586955962],OS X,/9gsbyyJoyHW1okwykGgXrn2j29wvnEfnw6/Hvft2WS12CURxTv5L9uLuu36I5u3TzWOxyB9dEbD1FeZ201uCQ== +3.5.3 [Build: 1586955962],Windows,lnyUR4m/DQIpXkhOTqjrpH6zIxjo/gHgjoiQb4zDEuI039Ys+K3ST/fZV2n4u6/rJmV6fYgmoEKQ2OBjh9ULDA== +5.0.0-test.106 [Build: 1587037548],macOS,pb3fpCZJylNXmOsJcVMo5laRCtKWHrCBeUNGGCehZb76PC593skEWD4N6UmEAyPwoi6Fg6C7/cmbaWP4rtSpAg== +3.5.3 [Build: 1587566168],Linux,v5Qg6ng2ILr9Ca6iTgjfYnShBDwioRf6fyA6iODHsNUhutwq7yXoU8z64NJRGNuqLKVbS95Fpm7Npu3YAfm7Cw== +3.5.3 [Build: 1587566168],Windows,k+/YQOZz+AlZt6h9/XFgHDI49rx2ce/Ngewj4pvGpFUmI1c/4bP0bAeeK9Q7P1JIzzdwp4qh0CkaSDbVYLjDCw== +5.0.0-test.111 [Build: 1587633723],Windows,60DETVUkR9veo0Cc9WCV+t3r0w836CfRZTgw/sZH0LL6AwtAab8sbcYNcOBybSssn+QgZI37kdc7B9YViszgCw== +3.5.3 [Build: 1587971024],Linux,59chu1YQ1W4DdVj+yJOVmwhJK7s9p9FatqIjQRxEDmIb0CcDDO/K8CrbVnBHbD67/cExJbC3PjC/o/n0pDbiCg== +3.5.3 [Build: 1587971024],Windows,Kvmj7qX6wJCPI5GVT71samfmhz/bvs7M+OTXWB/JWxdQbxDe17xda7dzUWLX7pjvdJTqZmbse1HBmTxThPKvAg== +5.0.0-beta.25 [Build: 1588064367],Linux,L5rpK9OLT84Hgpg/NXSCwpHfrRc/JTtMa/kFfaD2rlF7c/YHiEnly/4+A9y0iowA70+5JEzyH6CBjkniiz4DAw== +5.0.0-beta.25 [Build: 1588064367],macOS,+Y1iB58sLO38/4AI1YRUlEhXhhrbkAVbaSmOcZj0IrTmQm1eY+prEYJPQgF8StFdjWmAGmMG3ezzb0wEzRE3CQ== +5.0.0-beta.25 [Build: 1588064367],Windows,VnoQXCs1i1iEe7miGKqxKkxkjFAPIryo5cSf+eBLBmiBMOnJjrsICg+HxHEHcOdUL4Hu7VfP+8F4tYrN2TmxBg== +5.0.0-test.113 [Build: 1588173300],Windows,hTPLObkRW1TRRym4E6fJC7P9ngYa5IuFwe75RJSdu0Cju76VHNIBKzLBrU59IgmD3MChY5sEiCBML3V7IM1RCA== +3.5.3 [Build: 1588250739],Windows,arEooa/3dcP6Ck10yN65zk8z/Lt7QnxgApOi+IoPafYFKo0b0QeZ48qT3Kmtu2VseU9YI7JQrfpfvOF3YZrvBA== +3.5.3 [Build: 1588261372],Windows,MwZT29nmkJekgubjZGJV08bDegfP5Y481bThFRBna0UDhECDEfLcdW/0BE6YTC7aCvbcx5EZMXE/R+jdRUnhAA== +5.0.0-test.114 [Build: 1588589210],Linux,YEEYWLVRGDSB/SfAgUEl5K8J8kZ6m+PkgLW3L3R0pxAmRhttvM6Db/Fxc1CjE0ShWMcIQmxb8qlDTTOxxew0Aw== +5.0.0-test.114 [Build: 1588589210],macOS,pNeLWGmMtRvfHj4GrfOZP4c1yjustIsh2rjddFWDaIZX2n5cO1ivnK5jzDkjX1hANUMlPTrIZReLIYi5k3L+DQ== +5.0.0-test.114 [Build: 1588589210],Windows,P3dUXUfUWuT5TXGcCP53CEQLJkAfiJQDH/ojNxyyrLnfbNUR1bX+Dr9tirPYjuOIMF4iVvNXTYiSHRO5ENs4Ag== +3.5.3 [Build: 1588756070],Linux,bWiXMVa4E++lbV6zpRywdvKilqfi1++nTZd1NbPnMUfQfVW0JNk5U5a2vkGft8Dd21RNDHKBt8t77G/PAEA7Cg== +3.5.3 [Build: 1588756070],OS X,/Z0BeU58BQwf80NuLOC7q5lUUcscztBUVePMpKSsUxumpJJQX34NsGw4N0DMekVEg9Ds8RQJk+xMopD+fsY0DQ== +3.5.3 [Build: 1588756070],Windows,WY2De4HPPvwdiO6ZglSXQ3zq6HkeL0ZQ7GjZSMXN2X77p9KDBxE1O5QdSTQjrXfl5RUkEA7hcgjWfTxOcI5mCA== +5.0.0-test.116 [Build: 1590740393],Windows,70tCpJiGP2b5zKIt6HzTREBqE0njaUyWj/dCVd+DUT/QvhB8j8coh7BZ+rEWzS0bco4uBWJBCPFY7RGekwh0Dw== +5.0.0-test.120 [Build: 1592228855],Windows,UJaqz8lXzZrmF7/nWZF0aMUcJQYyDluinAxDKxZNxSMeTLWUShnBHIXs7EL8yqjikqTTdwsMzEvNAZ1CsMGqBw== +3.5.5 [Build: 1594109255],Linux,AG3H2BCe5B2B8gQoYBhLymU2iUaaVth0hnUMk6tHK2Wa/q6Y5KEktbHEJxRE84LGttm7kzZbvNzFx1SIbdXhAQ== +3.5.5 [Build: 1594109255],OS X,6pAN4KDU74hkqHQyJmaLnQZbxK9tPAKfoocmHFYggF20dCIsrc6yKGkaKN6OoSC0BGaOpg6d/JDCus9IZg2fAg== +3.5.5 [Build: 1594109255],Windows,RP85L3nZRJe1EmD2uN2ujwqoqnOudzh6mCvpvNxn3vqokKQ/RImt53JpaVfDQANdXRM3iiCy5K9ilILdbDScDg== +3.5.5 [Build: 1594213121],Linux,qcElldtu07fZwpqJibMXCuGjdzgk1W+bHOmtrMRQzUEo+qxkETaR/dUpUqrF3WUKQ0XC58E0wG584toQGk2jBA== +3.5.5 [Build: 1594213121],OS X,WYv9XAEAMJXYm56+9YiSEufC7iUFimD9AIgPqXBbjfYqu7VHw6btHiWl67r6Obric2J9E+fBihAH4AUCllD5BA== +3.5.5 [Build: 1594213121],Windows,fL4Bx3UDyN/wgrzE3fgwayKnvMhg3SWcQRzJdt3eKno3rM3rlcVujk7yeki1Gs1xh12uJC+kK0lyGjxCea0CCA== +5.0.0-ui-polishing-2 [Build: 1596738566],macOS,Era2fdPOli6XWa1zj5mAjO7caaeQZsnOIe3KVowly4P3Pv8NDASk0+vw3j+Hy/7jkyaFDj+zRbEB72MKDNPhBg== +5.0.0-tschat-test-7 [Build: 1597217264],Windows,A7kIbQ8i2LYwB5cIjO+fwkrJFXo5LPa8dPj31bL4CxoCSh3VBoL8KV7cKAKgi3zMGbIdQ44j/XaAmsFy/nVkDQ== +5.0.0-tschat-test-9 [Build: 1597240212],Windows,+kSSDzRWNgs7s6RDmpJA1UoNk0Vvd28KjVQ+DP/6U3elwMx6DC8TF2XjEuV5TXjB7ti52lm0aZonL/y5mdrNBQ== +5.0.0-ui-polishing-4 [Build: 1597390040],macOS,SP70Ec4DgG3EgDsSTQ+aWxKRTpr1ECxJoS7GENe9Xrc6hHnOKoqTHxPZ5vOgd4JwvNL71cUbPZhUHx1jHyn1Cw== +5.0.0-ui-polishing-4 [Build: 1597390040],Windows,617fWVNMxefDPrTGXNzjkMMAy0PBSxMJzlOGUdOc1CyEFWJfRlaPYKykozgskjDtOR4J76EGURz86IBMxVq8Bg== +5.0.0-flag-test-3 [Build: 1597393952],Windows,brM47NqjZLKE2MdYGPtf0D730zbenP5m0xhnG3100CXkguPX/a1lJjTS7wpyRmfoHqJn/840nMlUmusH+K9RCQ== +5.0.0-move-testing-1 [Build: 1597499112],Windows,WVLzzHFy/sN6kvXEtrv4zw+qyUMQSLNt8k2pFt1GvO0kOqZEq08u3wDCy1G8O/3mdIIrMNYAUQpIijMAOpwUDA== +5.0.0-move-testing-2 [Build: 1597522136],Windows,ULSMPYrWPPcxhmdxdnQvxRFvYAZXKR/BveIN0brlQ0Z40bTusc9sxkq3eeuZB67dIefF5xpCmXQiF1rpdKVLDw== +5.0.0-move-testing-4 [Build: 1597581653],Windows,YSpkYU2/uYwzDWmXdXQjgtj8uk3ko/ZQJhZU0NVXyj7yar0pm7g8NaWIQusd0fVQxlkRdhvt8FNqNpcZFvnPBA== +5.0.0-flag-test-4 [Build: 1597915096],Windows,CXeiOEZDQrd5Xmwl6zNlkmcyPw2SydkrcvUvc42fVqc7KZN46G9CZQJ6AlDv6N38xRd+Ugqnxvgtt6R7pDtEBQ== +5.0.0-move-testing-7 [Build: 1597931781],Windows,4bUyAdFhGoaaGdKjaiaKnHG/1S+6piduMJgqvAAzWOhHstEZbqUOLJqfENyN9bNgoZhJ+5rQV30FxzIay4jJBg== +5.0.0-tschat-test-11 [Build: 1598016546],Windows,uSqM3SaZZFMQ+wu5WMDO1bsSVS8UO0RiK0ClQQqxGTa3/wSYId1nNeFo6uNEPfbbMMRddfplzGoquRAshCWhDw== +5.0.0-ui-polishing-5 [Build: 1598262399],Windows,ovnKt/9eEjZWmF9MEMmLchAQ+Dlror+Dnz4ULrYU7FmjpVZZgjj+U4qXzdeGkHnMSIq5NsNj+IPQwBCHfcKBAA== +5.0.0-ui-polishing-6 [Build: 1598444718],Windows,R/P/PtSOH7fiN7jcQV4ynXlWQ+mu5dszFutDCPxSbX94KiQDOyuKNRx6wbGIFCbKUbFsqfSWtQpdNLXSdxA5Bg== +5.0.0-ui-polishing-7 [Build: 1598531141],Windows,6EtepyA9GZo4oopLY4/eGNsXkBtcIRYFBd9eL7jBvefO/aWmpWUqPLUsXTdfxxiuDLqaAxUpjFFH6ys8UToACA== +5.0.0-4f3ac28d8 [Build: 1598636763],Windows,ipbprZW/Wj+awfG+YTkQ7qoWkxCTk08wGrKhUUKindDZ8KA+0qKyfnChOgUPrpu4SoQQbArw8hLpBiFpclbnBw== +5.0.0-tschat-test-15 [Build: 1599059062],Windows,0omqloYB4FSc7j0jknZ2VPEWSbqfTtriAT1RaP+FSaI7tnG6CAqG5+1ZAw1ngPtaithbqHx5taLBU5Gi1Q1CCg== +5.0.0-cobra-test-2 [Build: 1599165810],Windows,U7nvm2ZCxB9dwSGyKt4TlVPDoBXYVfCamV9uyilR5CcHKXIExtFkH2W86HUKJtMnYtWnb5sZ3PePT0LqzEO2Cw== +5.0.0-alpha400 [Build: 1599165997],Windows,vAzgabsbFnHs5ceGGJw8y65cb/0Aua4dei3iOP/dJ18H6jVhfEhAaX9K3x6iEgBbJQVZ9DM9CJ7TbGXAmdP3BQ== +5.0.0-alpha401 [Build: 1599486917],Windows,mFkz+RiCfiBWzElK/xhVd9N6mlsAzu80fTVxqYTZWNky3lF424z2FY5w+AjpwJdQXJaO4476CNMZdCiKeciEAA== +5.0.0-alpha402 [Build: 1599557851],Windows,QBcatWqkPlr7DSTr8UGNPd3UnyaC3H5Tqf05fpMgsqX8LwFrlmH/nkVoNFDolAQEzvlvSbPTAlOfkeLxqTPVCg== +5.0.0-alpha403 [Build: 1599578655],Windows,Wd2+dE49zR+vcFRcOavZ31cVGBTpI0/PIVI6umJT4g5p1yRjG2Y1DqCY51TEyFMTdL3Ki82TKxz0TfRilNR1Dg== +5.0.0-alpha404 [Build: 1599669220],Windows,CMsTD2jD9+Xs5S2gKNX7vtHMO0GpbiiiAyL3MGzpe5N0KlLpUw2L2G2hB3gGD5YpfKG4WYn19ehfo2+eJMm7CA== +3.5.0 [Build: 1599755905],Android,uxDkYjha2wFI0YQqFbresfwTKfUftLNUI/nNxHfBo6TqlACwDMKfGrtwNmzVUwR0Rpv9OhOOvJ/AwyeCY2LUDg== +5.0.0-cobra-test-3 [Build: 1599769084],Windows,JpEr6MBZnRsh71PkO8VNi0X7w1ABPt8utVPSOyyn+tRa+q6AVI0i2dSblnfTsgBnN9DEYd0yNUVItXkzxOTLCw== +5.0.0-54c87064a [Build: 1599843538],Windows,Oadma4PaBgy+bwN4i9HTq1TlK/+597K79TC2vLjx+HRAvqmH8lOt2dpTM7FRzZXvSZZD2U7tpJPDtQ8FSsnKDA== +5.0.0-alpha406 [Build: 1599846284],Windows,8YQ2CFzDErBCL/4EAbJkbTH4yb22vET9ZZ8f4b1I9NrPyKJLLVPmiJhqeayqJaHMaxRmjUV0SliI22PcgcdsBg== +5.0.0-cobra-test-4 [Build: 1599917420],Windows,qyUPfMweT9jCmjq7+nOy92VShZ2nuIZKHPWcZ7e3x6nqhT1bQSWDNdvj+mIOfn2qMsUh0wScnSASHBetwe2IDw== +5.0.0-alpha407 [Build: 1600159955],Windows,MvvOPDyWEHaDiNQVvFqUC7b9xT7IypfBF1CCUQgYycJSHBTXieGB2vIo0vWfB29Ng4teXvUf73VyyywP+YSsBA== +5.0.0-alpha408 [Build: 1600254224],Windows,zU8VYYXa6Nj2zuI5cNsX4lu6sN7FlzOhFCNB+q+KUtVplKNnQnTuNIw6qykGj757kie9/UsXpxIqiCqZONNSCQ== +5.0.0-updater-test-8 [Build: 1600284324],Windows,cCCPTceQ2GqeV1MdPsF+HJjteOhK6sy837lQzoxLHYi92IaChxpsANQCGGJmpMPA8FfPRujMqUO2wxPdNRVhAA== +5.0.0-alpha409 [Build: 1600339559],Windows,KVyePfU2z8XNWWIl/iFGHIWthdaTWZGC2qouCghpPr99uhQ1P2zqXalwJXwDE8mFhGP1/K3KiB4P+RM+MdxrDA== +5.0.0-alpha410 [Build: 1600365598],Windows,qN94hYAUzrC4037xTz8PKgs+YUpn/tcvMH08WvSOmZIXHC7wNrYZYZvHZ8uBmrUZe7YJfhrWgLxWxYZDfot2Dw== +3.5.0 [Build: 1600439598],Android,V5VxAFG1qIozePu/NwA7GC6Lkv/qcNR5sSQf2luqnwra1LmahG1B8HxSd43WHHS68bXLY0lepDjX6by1i5JICQ== +5.0.0-alpha411 [Build: 1600469361],macOS,Hufdiya9ezgpPW+tv5I8w00Scx3BbSYFBVBV5VL8z/Wyj0LrSE4y+na5XLmS2JUUl4cMVuEnimhzE7V0opqYAw== +5.0.0-alpha411 [Build: 1600469361],Windows,YioE63QY3Xo62SeFh9+y9YDqdBUacYEk2AHNbJiznOt0QfFgGaXKs4+OiZF4QHB0dkY8tnK0u18JQbFMti43Ag== +5.0.0-alpha412 [Build: 1600599064],Windows,7T7c8XivXygpk+TFtLXIGcBaLzr0+ut/RlOBY3/r+ymNJ4fMXr1jwNZWm0LTUnoRfl11dLwJFIQ1THYz5X7xCw== +5.0.0-beta26-rc1 [Build: 1600686231],macOS,l5WNBZhy1XSkDaIjTEqWexk4rWFND4krcMr7miKW2n4cCzuDO297wiD+JitHQ4WlrrH56ba2iYzXEQ7XCJExAw== +5.0.0-beta26-rc1 [Build: 1600686231],Windows,xuSjmrIAg0QFnqNa1h+93d3Z2pK1U1ZwZeR9G9obHsGFnDvw8a+JHGUDDyUew5rTSP391wyE+jaFoF9yEoCzBg== +5.0.0-beta26-rc2 [Build: 1600787359],Windows,ryvuIgSkD9wxkyGgviy6IKWiUCkTWXYt1EB9BGmtb7cO9wbg/YMgmhLFyxjHBc/T27GA963bTo8YPeN1fW6hDA== +5.0.0-beta26-rc3 [Build: 1600861922],Windows,dcReQuakK5hux2rvz032Ol4Xg/32ErtopQG9Ue05z+Br4o6EkWou3SOFXLs7+wEQODFCdWMwyHULG10ja/UpDg== +5.0.0-beta26-rc4 [Build: 1600948191],macOS,t3c1xpHIuySi89cBf6fQyatdpFsjy3FByJR2wAabHXXHdavLTAUWKDEHgypRBV7USjYAXaxyQKy+gJZBc623Cg== +5.0.0-beta26-rc4 [Build: 1600948191],Windows,T1o1pShuaBXz0ikD5yxHG85ZlScEp3yq+QZh7VbpvOwWRtsjvKfaQQ3wZNNzXEzvxHBrHdrxDQXwnoLKSpKlAw== +5.0.0-beta26-rc5 [Build: 1601022865],macOS,016WaAPU1cQq5tcgppr8UJLISyhRraHRcIBt1Zt5ivD0JTS2E5bnFeJ1599+5hAYtBZaR3r+CyBxdd2kbrjPDA== +5.0.0-beta26-rc5 [Build: 1601022865],Windows,xC/f1gV4UFzN1zRwSHmn5kYhRcJ9XJIdR32QlhNaf/GhM4uk2WOxo+AaFXpfVN8Zjf+YepOpecVTbajUF6m+CA== +5.0.0-beta26-rc6 [Build: 1601285793],macOS,kO9K2RgUzoU339T315xm6N/hdEM+4fyX0bfUWogr5y1SL9F6gE2mfFpuZUJjlc8DxUR93hZ6nq6gzjZCHhCcDw== +5.0.0-beta26-rc6 [Build: 1601285793],Windows,VK6yvfCpPk2VbqU0MStyWK7OKbGWqFy1ckLGTYZ2+pbpJAhuPRnFhEAfy9SOoN2McczquLt0CNzi2dt8MSkTCw== +5.0.0-beta26-rc7 [Build: 1601384917],Windows,7VKnNQeltTiOk09y8EORDrgcg2JhANV76y2bO8lt+RgOK91OVTBQcFtV7+Ph+mFPnVsWeeMdZqDHPihUX5NrAA== +5.0.0-beta26-rc8 [Build: 1601393829],Windows,T/Iwhz5+9ADH+uG4bTaSdFJtTpaEjQXt9c4SQRKR7sTOvLmOMMcI/aecv2zots5sUrb0loVA/6XKfVpOaDmCDw== +5.0.0-beta26 [Build: 1601452077],Windows,5Ky3eRSCxlef+IKraGDsCDGOuwVS79IReK3g0z8s2H+E/v+KRaw/l+cXjyBqGDUrLQAGmG5UmHbIiuAhz6ZFDA== +5.0.0-beta26 [Build: 1601476259],Linux,8JoozxphOv+RXiaqutCgokpg1+ObD1+7+JvOsPA5aeVU9eQAxYtWKIcZm6QvbFkMkcJY5HQ6V3loP3+m0TMWCA== +5.0.0-beta26 [Build: 1601476259],macOS,YwqNu9i1wmtlS2GNUE+wRHnzLXNFB8rUx/ZYhWm7PDBnzEbqMrZA/6n9Sh9/zQ5mbc67b6Ms+CY/N+T6jJYLAw== +5.0.0-beta26 [Build: 1601476259],Windows,bgzGTN3/lKVdabzBu+fMaaeETaZtRiM7Iou/juKI13o5dY4inVOsPXDmO5flq2/sQ9HicCIHBZO+aReIu+FnBA== +5.0.0-cobra-test-5 [Build: 1601543268],Windows,duCYmWU/OHzBDFMNDjEKLNfrvf4sltic0IhpsrDPHoqzuNkY1Xko36ZfQfDvbUHRFXYVVYR3thQILuCwEFr1DA== +5.0.0-cobra-test-6 [Build: 1601558370],Windows,XsbQghGaprnZaMF6snKzGXBChAq25KOllmkjlN9WDFPJEhaJdt0f4wsWVBOQ9KFIhkE6d0+Ie6tS0XVqxcifCA== +5.0.0-beta27-rc1 [Build: 1601630484],macOS,Loaqp/e/iy/3qRRdqTPdT/MFGjiQhzPqCkzOmdYcoMVoRt3dwv/Vi/ipaCpHNaSPKg0aIS7LdQoFGfputapUBg== +5.0.0-beta27-rc1 [Build: 1601630484],Windows,sQY12C5m0GDUhxXMsAH88dyt+pwZglSRq2hsHTzlh6CCHFFh2jMBWzolmZX2LCi2Y3sIkZZDWdeGAQ7a1rftBg== +5.0.0-beta27-rc2 [Build: 1601922246],Windows,XJjYehJ/lhThfRD8UIe+4zMQy1LEAtFY3qf1rcOYtSW0aExaM2gpLVVsoEUz+vGrkabk/zSiCF0dfw/owtsjAA== +5.0.0-beta27-rc3 [Build: 1601985868],Windows,81lDEQYZk4t4Rmw6Lm9pQVXQvXFY87viiM6cNxHr1VfQi567R7a9oEpLGi4aNs5tN56k8jwajo7SnHoasW1XAQ== +5.0.0-beta27 [Build: 1601995137],Linux,R0dzSefvqoYfC5BBia6KL4A0SWbQk2/JVTsJjgtf0nD9fID593Myv34/oyObKr3MI9dyggNGiLJBGucK3UcPDA== +5.0.0-beta27 [Build: 1601995137],macOS,DcfxKwqnole3TzHXGi/vgXJ+HSlN6v5SqpQfcKW7RqPft1UC20Om1Iyt97rREgE8VWpkvgOTfCjO0wM3O6j5DA== +5.0.0-beta27 [Build: 1601995137],Windows,AGF1tTgjMDW8/1R0NiTg3kTrEJ26NIY/HAmrBIotBjCePmFtemvEge/Ap8LqLblmnfnYwuNbF2QDlornXstsBg== +5.0.0-cobra-test-7 [Build: 1602056579],Windows,P3Qln4qvk5GsbwBxNd/rQeLFwJwPX6TnvRX4tx2OrjpZjse1LiymkUa0rJamE4OigA0VNUo5YqhWoFyowMrBDw== +5.0.0-cobra-test-10 [Build: 1602071823],Windows,4IReei/v9/1ZQ9LTNrZbRQBig1ybEy9oPZ0sgvcNjHyRU5oTlm8W1sH+gPb6X7TBaAlGTVwbxnzWeHj8nbxHDA== +5.0.0-cobra-test-11 [Build: 1602168387],Windows,14jQJo21vyK+wwLoAVe0s6HE+K8j/8gBUevO9yF/1byplcQKS/xwD1jakNCM7rJs8iLSo75vTkdTF1pQWJocCw== +5.0.0-beta28-rc1 [Build: 1602250328],macOS,An+eZ5ePOnilhs44F9Z0uGHGTFr5q7GaUkN2I1Xv2lPXbmRJS2ePiuLo7M7wAybymRwm/+eEB3bT/NVwCJQWBw== +5.0.0-beta28-rc1 [Build: 1602250328],Windows,8oW09UjVpXnQCDGBLJtyz3LzKQj69wPqBfHCCkGSkWcFOp3zqYrDQttOFjd7628rq8SczY9oiSJ85K3VwHPUDQ== +3.5.0 [Build: 1602492685],Android,lKoOgVcaAsMGEpVjJi181o3H37beWguSR5efJmIJMsMZ/n8Vf2QKxpV+gALOJKgFlciZDL+e3VOd81uyhuizDg== +5.0.0-beta28-rc2 [Build: 1602580552],macOS,oIEegsz45Eqs3RDI8jC5wdEu25TsrliV6c1gMaJraLRjvaU2p17xOmXzG5dtL6Qx81OGDqRF82ooXXE6jgymCw== +5.0.0-beta28-rc2 [Build: 1602580552],Windows,Fvk4Xr/Z+HXAlO2MhB4dRN7Wi7X6IxwXSlXH8SFSkwxiPAnBKcNwvS1RonjilpxXNRwqhGemahkGewJAMtzfDg== +5.0.0-beta28 [Build: 1602660382],Linux,cBBzfORlQ7Hgo+bIysxOjBrMn8R8C/cz7HefCctDZeqW/9jtQgdmC4j0WG2z44zFkSQpKyn37g/I14C7cg+YDg== +5.0.0-beta28 [Build: 1602660382],macOS,wNdxosl+2z6YkNmd4jaLwWHQiuPDE+9NvGqN9Y/edJ3530ktACUE9/KbtDhLIhdk6Fgx+SwxKhuusqxszCOmBQ== +5.0.0-beta28 [Build: 1602660382],Windows,pQ0ZCYZovulw3eqwdvzJpq/2d8XwqcTnRLggziiDmRn+FxeOtkWmemhlRZbgljo/GFV2n1Xj4T0Z5ktgMKXRBA== +5.0.0-beta29-rc1 [Build: 1602672104],Windows,dU9SLOX6O8CnwmohtUrViexxDa40NeIoW5TWshyd0vuB4y/vyP69MRxcW7ma1Z4B9GgOO6MJo44M5FL6FvOyCw== +5.0.0-beta29-rc2 [Build: 1602840532],macOS,kHx3QjHof8thbn4Y6us8PdWEcs5+V7LnakvBLWvZEGUkOg16xUuYWuoFYs6bYBVKTVgoO74+XY3/KT4SPBK0DA== +5.0.0-beta29-rc3 [Build: 1603115757],Windows,/EBNwj3g8b4OHFSGkFRpCffr8AeWBXV5qGzviB/EVqGvBR4f8nCF4onxGVsf/Iezl6BtoqJ0OcNAU9FHGTU2Aw== +5.0.0-beta29 [Build: 1603199536],macOS,EZtK0haoikiJyxO3NQyLEvJLPiL3V8hRgD4jrKLzsbwGSbrlzQMjA/7k3gPaRi5GN6QJgavKi/XJ0bFu0PVKAQ== +5.0.0-beta29 [Build: 1603199536],Windows,szczHLDI5WYcdftBao1SMIrCeCt8Z54Rfiw3Vc+X1veNGKKo+V4gQ8WR0h4pOmve3Jp4J1lAk/zIhY1GHtPCBQ== +5.0.0-beta29.1 [Build: 1603277784],Linux,+W6wJ0uz+9pg36eWCM/dgcDfjiYBnvfd3befRzTCpMBBhXABn2p5biGB+xGBllaR8q0CkMOV2oPCORWrfPfQCg== +5.0.0-beta29.1 [Build: 1603277784],macOS,aIAisThgSbFhvGL9QxDWs3C8e3AcfhG6pd/9V/5VGw6sO4aEf51962byGzxFoidCYG+yz37I/MuX/P/FrSUvCQ== +5.0.0-beta29.1 [Build: 1603277784],Windows,OIPofb7scMCORX6+SsAk6T1ndB/GtUE1V/XnnwqdqFiVjXHPVHCfYnFG163sHCbkYxy+DQapPQzNCpink/RSDw== +5.0.0-beta30-rc1 [Build: 1603375915],macOS,VMzjKVxPX7C3LgziUDO+3cguPTvuTowhPXNbHBN3ktMUkPeyPN61dAY/keUxNzSB2RoQzp4LMYOxT5cdGUlkBw== +5.0.0-beta30-rc1 [Build: 1603375915],Windows,nwz6Oy9f9Z9xao1rNhcXbFn9mprcW4GFmtEDrUArG70HRjAHUgbH0nxVyJqCQ2n5JgY0MAG4h6sEyFdtFNc5Bg== +5.0.0-beta30-rc2 [Build: 1603714412],Windows,S2M4cvuUFJS5qOCIzn+IC93bmrc8l8E3PxElaIGS8g9VU2ScNs9xB3gt3SCF1u3lFFJvc7zXt/ZeA09f0ao5CA== +5.0.0-beta30-rc3 [Build: 1603793389],Windows,bgsEUyHjvTl55ve+tV3/FhWEyDBtyQimszKh4KZoLD8dTWkx5nAPkoqB6FZP51W98Zg0m6IItHXBMy+hAguTDg== +5.0.0-beta30 [Build: 1603882166],Linux,d4pjtaDVETsz9zK2Yf/19Dj8gKurV9YkPVe1gk+6sQS/E5IwgZN0WcwEGmMj7lHOqWCyLsgtvMe4h82i0u/QAA== +5.0.0-beta30 [Build: 1603882166],macOS,yPfkHfZ9LAXdHnFfc96rdLFkveU9tjZkRr+X6PLIBuQcWPS5kX0CfJRrL0vPNJm4Z3hrbFk8MLRoDWkZf4RNCw== +5.0.0-beta30 [Build: 1603882166],Windows,Sk7MrmeeytvFmIHJXrtYCTnPnXNXM+OYQdz/OsKvW+m6UQuqiEqWutvnGH+d7eO6ewOSD2AO+dyN177THrm9Cg== +5.0.0-internal-1 [Build: 1603899622],Windows,fTvi3sI024I7nRiOJnrJFF0VH2YMHkcs+c0yAXbLsBOinkIj+yVus7NjK7MuZh6kr21T5ekpCRqSvYLntZ4tAA== +3.5.5 [Build: 1604062410],Windows,YE7gG8tUil7L7o0kk4EO6yvPARRG3TNwTcQFQLm6kKBCbfiC5u7OYJR0sy3r2kkFiCF9GbLggJccicACEi6pDQ== +5.0.0-beta31-rc1 [Build: 1604069291],Windows,XUUFhBoCvBRmwkQ77W2K/gZ4oOO3ofea0r5Xi6/3A4Dn9dlTQfrhc0GeEBu4FgLeH6jggfe7UnW306ONqHUvDg== +5.0.0-beta31-rc2 [Build: 1604331167],Windows,nZ0rkauM6FZIV7k9Q/hTHA8H1234uLKgtbPBJteBJ6cCqUhP0vtqXfB8wN3t71LlHlxHI4wWvrNVlkBRRJN5Aw== +5.0.0-beta31 [Build: 1604481627],Linux,UdQzwtuA/9YF986x9YoKhCYQML5E35Xt6/bnXHI20CNa7Y9k5W7bl4WJBXUKbe91BmdaO798dp4nLgawHyZWBg== +5.0.0-beta31 [Build: 1604481627],macOS,76JLTz1/BXuV6aHKQhCVOGooXviJMoDsy3r6LUwjEbQb83P2RvF0taKke22V8N5cx4+gVj2a/sIdVMbRshG3Bw== +5.0.0-beta31 [Build: 1604481627],Windows,UrzzT7VDY5k55hPwaRZ1MmAA1xWWEqBWr3EqpEHxg4qtmJM1Mw9Q4mmR41pAiRHV4BHMvn9l6YePT3BZrBBlBQ== +3.5.5 [Build: 1604483867],Linux,JJFd41bido/K1U6JfzKQ+XOopaFiJDjJwub6tuHv+4ibyCyNzYlB7pKqGHUEmBoAg/hR+mqHhn1d1LQfeIF7DQ== +3.5.5 [Build: 1604483867],OS X,ZexDMFulps0EgC6eLh3yf+Z3hDWR/u1H1HyaLhBA5FM01fdsFxfB1QgnSc5N+KSzsOE5ErchWQLipTjTg9AEAw== +3.5.5 [Build: 1604483867],Windows,5pvFQlWp8tKMVQ/rQNuAQPc1ujNyl41gsC1utJy0gxhQ+0XjNRgJnYu0C2lAhzEc8feXxG42Q+YDargxtdM7AQ== +5.0.0-beta32-rc1 [Build: 1604501880],Windows,aeAVy42rf0tsg29Kl9jYejxwA1g2K2SV34LCqN0ILtp3VJnYKYhkKkE8a3CI3x3EhXn5TqwwxKyIf4aDTIEXAg== +5.0.0-beta32-rc2 [Build: 1604657081],macOS,45+foTPJrbahtZiNO7Gr8P5f8ZwJdeu/5Dj54Poley4H+cSnpyEvdbbs/g6vuhJOaI0FbUcC2KPnjK1tQmkICA== +5.0.0-beta32-rc2 [Build: 1604657081],Windows,qPVigZMZdpv4SRprBWwJ2o8djXiinFr/d5oUgQ1iy/mQZUzr6D8JTUuyJ8yV1r9+vVcSkKKe3O2Yg4RiguGnBA== +5.0.0-beta32-rc3 [Build: 1604936365],macOS,7i5hLTypUCCR4sGhIrkZfQ5yJfLBYdbKm3JkDtqXq7l2677XssCmMx0fqzKcSX5j3KR36CKnLHcZ5yH0c4AwDw== +5.0.0-beta32-rc4 [Build: 1605002654],Windows,/Ik/dAPEPC0D99aOGNDYvG/REbwmcYBlLXcFSZwHq2V3DXDzeNUOr43gHlL1AzMiYd2x0rZrCcXrn3fLYMd9AA== +5.0.0-beta32-rc5 [Build: 1605018568],Windows,kBeUGR/3y5FDIp9HwvM7RpDI72GTgiFLdDELhjJ34IOPL3OKNvLEez9MB4uiRRoh7jYIuZZQwdwY3OYuBB5CAg== +5.0.0-beta32 [Build: 1605097383],Linux,GoVvALlg86eqEfMeOwZ7TAYNH5O+UrsuB45tVZD0NbJ4m45Z9XApYnA0SPDX/gdgxUTw7WqsWUdQr50zDJMZAg== +5.0.0-beta32 [Build: 1605097383],macOS,h2c24ww5+HNInt+CzeNvGWWtxAKPSiUTFKvGKJGlviPtP+lvxzUsqTKvuBtOBDhcG+TM9kuxUY2U/7RUcWYWDw== +5.0.0-beta32 [Build: 1605097383],Windows,+Hzkhe5qVBsBkNGbDtqrGJheXxXTkjLEZP1lxO2yYbXf8XI4jsVrt9+Iy4EPAgQOgl48HnHpQE2/Ek/3BI5WAg== +5.0.0-bab0e5e53 [Build: 1605109329],Windows,+XLUGbX5E5bx0V7yrsD1DuyYm4se96DEXF/5uL6uJNkW1lw6ddglRR19c7MvvbR3uFi09RzQVXEKUb0IvNP5Dg== +3.5.6 [Build: 1605182235],iOS,7hXO+2TSz+nHL30cI30zI5XlpZqjowOcsaaGWY0CkpAK/IdAheS1QW5EKUuvwLPQZ5SRoZirpM+EX25NgsnnAA== +5.0.0-cobra-testing-11 [Build: 1605194844],Windows,VzJPVfF+dN9/FshBgVmptx1nRSxXITOGH5KrTpjBSNn6IX+EMBx7Sczgz/8+fi4hqv39CwGvfeaYnI3cPCsuBw== +5.0.0-beta33-rc1 [Build: 1605268533],macOS,91JFloed7+rI+CgAwk9F85W0dsi3T0HfoF/nuEHrfsD34Rajyv4xNg3zDM1l/KEjEkg/2YCHnZ7Ht53X1pizAA== +5.0.0-beta33-rc1 [Build: 1605268533],Windows,RAQ5R5NtgheSxed32RtPvVGP+g7a3yqkrYWeDwrR3KthQMErlvdXy6tpOixlLtMH/lC6DrHrfLXz1+6esbe0DA== +5.0.0-test-icons [Build: 1605393546],macOS,1rnOEpGr6oT3yTCVAawE3dv5PUKSOk6Bq0lzcTwEin+OqX3BTklCgHG1MtLriqmo2WPCEGQj2CPa23zBdrxWBw== +3.5.0 [Build: 1605605389],Android,trH8DtnmPwjwv0jpx+tgryFK8RiVvyKswC8MH+HxIqgD68WooDxdn8R9xee5HkwV+Q38o2F444uqTMdAOk6SCQ== +5.0.0-beta33-rc2 [Build: 1605608215],macOS,1JEraSCVPRpNwd+gNLIlr/3C8Pkd1OvEt0IzrtzCVUXLzV8h687TDXNpbkgW6qBBGKrgvso9KTQcvA0wxaYlCA== +5.0.0-beta33-rc2 [Build: 1605675336],Windows,zNPcQJ4fFK2GiBIdWfOATig5IRi5lCCiT8yP/zsnZGJkk9uLkOrcc2Rfex0wA1HxyxRdNJ7qQfDJtTNs9LKnCA== +5.0.0-beta33 [Build: 1605693829],Linux,gYYNWFtZRyNugi6KEuE0t2zqPwOBQq9dAHsvsc1t2sJrm+L91I++gOnus6cmkP3fBdVs9AyMVHlKG/F1OlpgCA== +5.0.0-beta33 [Build: 1605693829],Windows,2s/ug5ZCiGXIOr25RPtEvtod1l/eb5IwpRZNLBDelBtuSvoiUlF/f7SyWx8m/VSmbihT4zMaSiCC7OyoO6koBA== +5.0.0-alpha414 [Build: 1605720501],Windows,n9V/ZCUORS6ffCe7+ctw8sV3sjw2/IhugPVPyu3d+Xlv0XGcFAVH1pLNiiARpUc5pcqETTE7/a7csaj2Y6PxCQ== +5.0.0-new_certificate_test-2 [Build: 1605794034],Windows,BPbfHIp2UT8AY6NiSTWixjRY1aSdag7CPBn9cVtzRRWzST1rOFXf3+47IgUYZjBCZarUXY4jotvgXV3N8XQNDw== +5.0.0-prev416 [Build: 1605888535],Windows,UBynqR4ifIHweVzma4KDs3OjY4iq72u+fmHIyHNRvp3jqjFFqK7jK9hS2UpL0aXl4F4iBub+5r0lPw2Ls7IACw== +3.5.6 [Build: 1606093423],Windows,pjDmXGaZrhbMk8bUoN4/RAJTYnmwLJeyMHm7uH9rXpg3nVlm73kM5BlZwh1ndd2WycxnM3Ubjmhh2cT1AxbgAA== +5.0.0-beta34-rc1 [Build: 1606209261],Windows,c+PIL8IDyRHJqEPSCuHXqB2F2b5US8RdbcTufggerigzxGcZ8jC8J+CAzakRco8UtvzfFYzQ0fJ8qPRfSRxlCw== +5.0.0-beta34-rc1 [Build: 1606232731],Windows,Ay6sAHt/gjkRPMixIOuIuSXEqU0b+xqIVbqYPkyL0Ty5y//RStK12WilFGynUgisjb9OI7+DcQX3CD7+DWA2CA== +5.0.0-beta34-rc2 [Build: 1606259476],Windows,7M3OtL+owcF8B4uWLRUdw5d+F5838V9HXx48u6yH/vX5jgZDuUz4nM3AGY/SGXNumxyY2cvV4Aca/+xR6O5JCQ== +5.0.0-beta34-rc2 [Build: 1606303040],Windows,CQI1dcjeQZ7bpqMuqvHanhfXE6O8kjxEQ7kyK3l8Nel0QgY95lMjR9fyH7QI0svRjTdyYTspLODFf1GPJLO2Cg== +5.0.0-beta34 [Build: 1606310756],Linux,D6XRdF0v40le6gVyYmhbPzgm3AB6FQaErQst3urdiHnDuV++K8TZuOQGvF93LElexj/0xr1lOvJH9EjERq8PAA== +5.0.0-beta34 [Build: 1606310756],macOS,orRhmHrTr7yWhhb9cEtHOSzKPrFYPz7de0SZ7oQ87hPoYoQ6EtMXqYVgdiySDmf0Sc91hTFfem4svMHICy59AA== +5.0.0-beta34 [Build: 1606310756],Windows,wVeg7QRNsmcZY/3Mu6iFNB3tlyzLLoECXy6oXU/f+ioCOdRTN0Vz6aJ2uv5LdBnpu8MnJZzvvI9vCEj6I8B/Ag== +3.5.6 [Build: 1606312422],Linux,qMOwz9/kR+NHyL6AcBW+EnA9rvoWCgnIXH8vIGYtDNPHUR8cxPqPoFKH5nq+7I0F2hrK6k+ynkffjYKmmQt3AQ== +3.5.6 [Build: 1606312422],OS X,AamXAvJnm3Wx/O+2LHgxesEZyF1GuVONvqmaCB+1hFdgWR8w1aot41Z4Cd2Q9wGBCNkMYzmD8tXus2sF44LXBg== +3.5.6 [Build: 1606312422],Windows,I5EAPoSvsZ7nic6nCFUw+WdFCNf1NYuOTzrR9A7x0S9J1NYp2zrzktmr2jkhVy6huytftxEOeOOVz+CO10tbAg== +5.0.0-qa-1 [Build: 1606395781],Windows,lOb+Byvfl5q4SWM7MpUELtoF99xsxSkukJv0HeuigRXcU7mAlZqVohvPqLnzfL6PARdAvuC+DNhWGJCZpjCTCg== +3.5.7 [Build: 1606519399],Windows,9pGLtJ0cZsQD9+6dF95Xo8b2aaOet+Iojt0etvdh+52cOA75R4YylSx/d8zxPDxTucQckxdXE/VWaDVl8m37Aw== +3.5.7 [Build: 1606578603],Windows,C79G/8lxs/UjWynS0oUfdy0x9uxSsQ5ZyJ/5PCTHDpW1slXYpYuyK6idx9Q3WVvGCqh4gwEVKWjK95GZh0BmBw== +5.0.0-beta35-rc1 [Build: 1606766504],Linux,Z4364TYcGtzQ1vdteQiRT7+/8rVFrxYGnOMKzx7Q3Hm7l06vg0c/e+cdmcQzOv58dNCfiJ13NfskL0NT89MTCQ== +5.0.0-beta35-rc1 [Build: 1606766504],Windows,StQamBy80FwOQExWnWkJlhh7Uj+VrWA1H4BEZI3HOJu085HhB0fEFGo4x2JDqB6/KvySmFGtJC/WvbGAZWSKAQ== +5.0.0-beta35-rc2 [Build: 1606832721],Windows,YeVsqKnNE01vrPDdqBhPyPrvwlShOxyzx5pZEK8EaXGgGGVNPMgJeNRasLIeuuPpg5fndnzMDatbrzI9UoCHCA== +5.0.0-beta35 [Build: 1606908024],Linux,U3+3R1uwwRHWYwCjuZXR/nYo9tKKTLsTeYW6Am8M94rHE0tOa4c+qHKka8KXx/6expxE7TOsegPO2V49mDzkBA== +5.0.0-beta35 [Build: 1606908024],macOS,ShAz+0gQkLMPJXkUAdt+WTiz6Av8XA++9VxEPsyKzyH1W5NW+riKeN8cutzlbXjR92/6YbxQSaLR6HpkmzT0Bw== +5.0.0-beta35 [Build: 1606908024],Windows,plojmhz1rW1PRgIv9/aYgM+TYTX/vS5Y0iAl3WdbOGQ+5mvZvFxdXAsf2fTGIXYfnRpuSuFkdqCKZPLgr9chBQ== +5.0.0-cobra-testing-12 [Build: 1607080844],Windows,OubSgh/L2aojRfR2VnloVTiqop7ZpL1aEXiXEcWrIXcPBoXCH75Gmgz+TSaNkLYdZXq9WM0AMovRs0zmMgCWCA== +5.0.0-beta36-rc1 [Build: 1607093951],macOS,05nGKBwK3J8Bs9clvybUT/9zwdD2TLWXP9UPuWhbV7+u/WKTdM2hn+7op5ySNXwycvhp2pSDHq19EThFVg9oDA== +5.0.0-beta36-rc1 [Build: 1607093951],Windows,Po++JwnBihgUIaS1dsExjMNm9Bj6N6CIIN9f8/l5fKuJm5KtQKefRaJ2M8xTVJvmVatAFgaukVFRStGs0lGfBw== +5.0.0-beta36-rc3 [Build: 1607430517],Linux,JFWNtdiuetTrzjkylKVCazY1jEkAZL8Hraoo+19Ab6ARHS2YuCJABjFqtajEVp0FQBNTpv0J5jJqLc7eIP/eDw== +5.0.0-beta36-rc3 [Build: 1607430517],Windows,P5AF2va7qMnlJNd5FzMNT5sbSVffXSa16i0nCHJSy2ZZ/lMdajkh8q+Pbo6ojWTjoDgAnjyWiCWpE1iBPWCbCg== +3.5.7 [Build: 1607443312],Linux,m57O4tD7r4fjDBMaspzMepMfRvzioE+m6D39a7ng+1b1PUSQ8avMvGnHTsKtWSbatV04NuJrugMPQn9nqUq9Dw== +3.5.7 [Build: 1607443312],Windows,OPT1d2hY3OQ2ttnvo49Z194xw/4Gga9z17XpjJewz1VOOnjccxyRZ825dCHOFr98uXPaqz2qrF8e34h5yV7gCw== +5.0.0-beta36-rc4 [Build: 1607500856],Windows,38FCIdIPrGjOnWK4KM/caY4o3m/39ERRArrXJKf7eV+wYgxPQAt+S8QX1vkO+BaesVDnS+W/iODefXopulm8DQ== +5.0.0-beta36 [Build: 1607523167],Linux,Pn8itVGKVYc0zhUm1KizpQSXOc+WlP0InmlqQOG8JSL0GxddSAlyIeXr5kS4aRLpUZQZbS6PUJp8jSOB6LdqAA== +5.0.0-beta36 [Build: 1607523167],macOS,1UCA/1K9xISm7O0AyS1TVoxY4nsm/McOOkUlT5wB+JSswUFarJIZ1e9haNhkSLyFSb6wThqLdkYXdk4k5vHKCg== +5.0.0-beta36 [Build: 1607523167],Windows,t7cctqp5xDsGv483zVlCTNWR9LcM1d5zuNzUlSTtDWyCF9ZelngfcemmRQkvnanf7TTk8Pf/S87nFiNQQAGVCA== +5.0.0-qa-4 [Build: 1607596631],Windows,P/zCNJDTm7PrpvywBjW8mkudAOqJy6YGIuN8lkSVleIlacUkcg3Pf2D6WNrI0ypzpDUjM49O9RT9Fpcso6joAA== +5.0.0-cobra-testing-14 [Build: 1607689476],Windows,OMylK9JqoSXD7lRUQCurbbbVSKQWGrgZLKUlaCbKoSgaFklkXg+W8nJa1VkZVK20F3XjUCuT8xr+NAZayPDXCA== +5.0.0-beta36.1-rc1 [Build: 1607948316],Windows,uAQOpxqBN443sY1/OWWS6FO/KAGZPZ80oKMD9KNnxJivR4OfSlNUJ0jEQ1RoUSCU9c1+bi3QJb81Hz9PnuFbAg== +5.0.0-beta36.1 [Build: 1608110690],Linux,7A5o7obP9A51a9lOr5WH0+0NHk7sTf16pGsWytcm6VZgmEvPNcLyGW5RELWw0nBjvz3IV1M6gvbsaLQT9S87Dw== +5.0.0-beta36.1 [Build: 1608110690],macOS,PjpkGLcBzWNTfAYM72zXim6DanVRtUQoJitqYswSjimqNQMzbqIhZ8UeWDQ33wRlhNyNkur0hXic+1+5iuFRCA== +5.0.0-beta36.1 [Build: 1608110690],Windows,STiDCl7Kj1EjmOp5+7NK6l0llqUi/s23HpSomIrHpsOR/2Ldt+oMlb71/P/t1UMzvZwsmVx6KL12K+145jxHBg== +5.0.0-qa-8 [Build: 1608135862],Windows,qYz1+vWdonG84Y3a+LE3Hs+DnNiNZtiiESsMNCKuYU5DkyD4QYIuiWT+uHTg+RYRSVWFNHFN0AuX5sNIAdleBA== +5.0.0-cobra-testing-15 [Build: 1608206477],Windows,svRhaBEAhUo98qG241fzuYIrWntfHcmJkN2GDVAbX3TOOxK3H/rjYnwVDzvFB7xYV0OWzB9i2bFwuZU4ygI/AA== +3.5.7 [Build: 1608224421],Linux,bC9tQa+Zp3Xd6tC6eQV6qBzlgktKps0EOD5UjQl2MK6yriAppcDZJmB9Dl9ov2RKe8XtzsGmplRGFUqQThnBAw== +3.5.7 [Build: 1608224421],OS X,62bxnpUQY/CcupgUFjVDKAjNxKFBS8WkqtLMBBRhekLhjMsuQFMhrhJjULWKUYQ50hJ60ECxYLZJF3UDUkvXAQ== +3.5.7 [Build: 1608224421],Windows,JNCW+UhoRIQdkVVw3scJ+8elQLRZDrUzdV467950yuIJmxD/egLBV9fFMHo3puP3xpxZtVH6Z1I4UzWViGs5Dg== +5.0.0-qa-12 [Build: 1608565516],Windows,5SbZhNARPlPnXG70s6MagMv/UVCcCILkHsma4WEgg97s+E1v+aimSf6p31ntJ/VvGjqUrOY5NqZzlwJaYQQuDA== +5.0.0-qa-13 [Build: 1608646134],Windows,8Nb+pKZMN7Vm2a0qRZ75qnBFA1vphunnXAGiyiPPXEI34K5CifVZS0Pyj3d8ToCJF5PjuiCCCBdV3PhWZeovBQ== +5.0.0-cobra-testing-16 [Build: 1608713116],Windows,51G/VI7TJMQ3RK7+x5X4/aRgR/UFkj9eozJGVrIWfwddm/9MALTMxX/FpyjE0WAenztutNb7swdV79G0J3eABw== +5.0.0-qa-16 [Build: 1610030909],Windows,5WWukoB3E68xz0323iWLmBUP+uZr6eHqnnoEyAhcvPr7BUTvKfg3zJ9Enq7lBTI7S+XzW6OuixdtL8ZjNgBXBg== +3.5.7 [Build: 1610311072],Linux,3IEt+rUBL8IiwS96zAZuG0ut3nBnb1aNZUUgz/NAi8fk/9ZFJeT6HVO4eEhP0WusLlOBSDHGMaTrpy/jY1kWCw== +3.5.7 [Build: 1610311072],Windows,n/vzqeISJJ5y9IqIkq54fKJbuUwBtzIwfKg6iAQfetTtrLgSCg/U6wI1oXkL1RmYb0x4M5C9Si6P+K4Mr9JzBw== +5.0.0-beta37-rc1 [Build: 1610378934],Windows,ZTrRD70O7gGT9rOMiIm3VJDsHAhv89ynoQu2NGRkCTog7wFlUFoH69217QuQh4VahLZnqxG0EGXAcQ4M7H5TCA== +5.0.0-beta37-rc2 [Build: 1610414299],Windows,qN94HkW71COjtJnjcOX5SCxoA0iHjJpIjK38lReA7AU9/9ML+ZRJgAcXnnQ67FvaaxcBX/AfhVK78ws+eGeHAw== +5.0.0-beta37 [Build: 1610450631],Linux,RLHIBAUIoJtUad236IQMd0vXMW4B4s0FFGlMECTDxIHzr46COc05cH7I3FEJnR7rYZP/SI/hKXHZHpkGhu2vDg== +5.0.0-beta37 [Build: 1610450631],macOS,j2yR9VA99by1kMMzXucsPOPeZK4lhOGtDgHtUyZwPFbpaMGhpEoD0fWRP0itYbN5/pVctEj65pHtmbOdn3uVDA== +5.0.0-beta37 [Build: 1610450631],Windows,BeV97Z10p287D+U+2VvwcNqsvct9+un7qWB0xtVDXliwkFD1QhUAiTYJJK4V7Q/f1CbuHrfJvR/UCdBnCR+eDg== +5.0.0-beta38-rc1 [Build: 1610453987],Windows,Fyp9Us6JCwqmi6gVMicMNwBf5OVeDJZCOML12WotGCUeA5o1LHm4Th9OaETekLrGBrXQ9ZW5qZP1Bj+6kXdqCA== +5.0.0-qa-18 [Build: 1610541782],Windows,rMko21JaGQNIPBoh4nHU7e+g+pZ4JS6PfZkPbzb+pBP/n3TgStBAYV7G5zASWyNTvQg+FTIq+DvpBqDdTRetBA== +5.0.0-cobra-testing-17 [Build: 1610555339],Windows,CPnazN0TB00PjwXdKs15Sg1k04Bf+k2PK1jlqRhoJA1m5JRY7S/hwVS9qax4/rbPiLSqoVjnVWQKDLgaYsLwAA== +5.0.0-cobra-testing-18 [Build: 1610623794],Windows,EDZ1yruwOZ6ierSDnmF4bqTDxH2Hlg/fOEBnvigxAt6Iw2+QVLJCT3h5inT1Z8dI/jRJ6uboQWGeA0ct44z5Bg== +5.0.0-cobra-testing-19 [Build: 1610706840],Windows,RohNZcSUAocMBlL7hIPXEf6dNkwJ4gPSKyu2rWoIqqahSwkUZMZJd7oOxo48pLi4FCK6Yios0765hTjB5a3bBg== +5.0.0-qa-19 [Build: 1610957172],Windows,PHke9RTp7JY4Z3M1v0W38XuiSfeIcVBRi/SFBZLomKeEvgImMLtFCIoXLctCg0jEYOaFZOaiLdBoaqB4khJjCA== +5.0.0-qa-20 [Build: 1610968143],Windows,kk6gWzbJON42PZ3H7C/OgLeUuBdimPk4w0shBmI8m/mMzwmdbZt5LID6runNtOxDDqgRgy1joSLH+Q0nluUxBw== +5.0.0-beta38-rc2 [Build: 1611137742],Windows,dCDRgusRRRn1dqKZ+ZsNS0+E/DhRyMrINX0kXz3RZ6dpcLqPxkz261aln5R2RhVr8+ZNGqJxUyx/aMyeeWotDQ== +5.0.0-cobra-testing-20 [Build: 1611147479],Windows,1f+kVrqWb2uEQskZ/68uyy/kfA4IgI+XAq0/qcA66N1Oj9/BmZ0J95PmsK1QI4K7lWF6x2MnMRcFfTIx3yOgBw== +5.0.0-beta38-rc3 [Build: 1611148781],Windows,2Kz0r4ytX3/aAowczPp4nLV8M4Pvq7f1NZdMRJXvqOWnF5rGkkylHYLdZO4v1PfR5dANVTSHEQCR5lhI1h6oCg== +5.0.0-beta38 [Build: 1611230438],Linux,J1FpevvYQURafe71i7Jz8yPz81k4l/4xjNFSSndRyH/ldJ7OekJNWDnoKtyZQpuYQJZw4yUI/6kTSMu8yeBrCA== +5.0.0-beta38 [Build: 1611230438],macOS,eSMRqqp8atJm+SmYTYqxYwYGn0lvX3TTda/yfUcdAQzZSSUY9gPp3cz/WksllScLqDVrmHSvUCsKjySyC2RZBQ== +5.0.0-beta38 [Build: 1611230438],Windows,fqO3H7ytHO7VPdyKmTc59j9/9o4ItdKyTrF+zGtkhlim2aUpILK8Qktho54xICnrpjW27PiPCOLiZppo0yZDDA== +5.0.0-qa-21 [Build: 1611242317],Windows,TjEBonIoo3jsUZ71EgJTaNdUu9Uv1IrRN31uEkD1hVOV5j53/Rkl8p5tBqLIqr9kwrZyDTUTnUc8BBZZi/WfAg== +5.0.0-qa-23 [Build: 1611337907],Windows,P6Pj1Wwenc6M2tEH6kMzu+NVmrONbCK1lR/v49VVxx/N4ZoKg7eGHuNr/drlFfpXT93ADZ84txx1nPiGRbeVAQ== +5.0.0-qa-24 [Build: 1611589480],Windows,CK1DKUzcEkbg8lnZI5vdR5hH4Otpcex6I5RnIgBaidMQHYETVA854WvFMt1TwDIsmMZUihSnoV8adoYSwLp5Aw== +5.0.0-qa-25 [Build: 1611659620],Windows,ZNi9tp2NHMe21jrutl7ZIBSA0ATNLxivdxiFwOCp+djwPi9rQZJkMk/Pv/tM1FJ38w3oyadodfsXnrbmK6mbCA== +5.0.0-beta39-rc1 [Build: 1611678252],Windows,AzvcyZhPgfBbzkbwxscmdX53szAoGUwy3iXSaksupa+zOBhk7B+mFo7e8VoTaf2dujaJc4nbIwUjDY9ftT83Aw== +5.0.0-beta39 [Build: 1611686251],Linux,wjuefnSTU0/bsIz9U+YxaIPeW9VB322MfAd0Uo0EMvwAODvtvCI/fJDThceQdSD7rGK7oPZgWv/aAOZV+chSAw== +5.0.0-beta39 [Build: 1611686251],macOS,CjwaeaX4sBFya5H4Xe6W0sWzVXVgHUqnwi0hXWe2CIIV33OQ/7BwUAL1cMDpkvHO+SatGBUVnHMV7rpjJye7DQ== +5.0.0-beta39 [Build: 1611686251],Windows,Mfng59TemCnyhg5QUeqL2FpynbknmDJw+EFo+lG9SzeFTLmOhFDCnBAFls4HihYuNNQpVMWCQfQjE1klB5wXAg== +5.0.0-qa-26 [Build: 1611743375],Windows,6eNLhzrKjbbDxu5fAq4E82L2d47JM9k2NyQdndKd+a3CjUoMniuabVYpiaAKQ9hvQI594wykfWBL/0IyfOtBAg== +5.0.0-beta40-rc1 [Build: 1611825049],macOS,Y4bdkXf1Q6a0g3TcLps4WBzbq9H9bpW5POWxypnk3mhnF7dG0F7fqCgnYjrM/M6ToUxzCoIGzvo8PkRMmWzMDA== +5.0.0-beta40-rc1 [Build: 1611825049],Windows,XCNVtUtw8x2yw9sdtunfwxnhAaH+rgJl0A6gK9o0Z3PVvUNqrxTkj63VAb6E/e/UpM7P3+UI2Dr92bF/ToUzDA== +5.0.0-cobra-testing-21 [Build: 1611838875],Windows,HmDuoodGmKHyS0UIGnxw0IiEX6MTAALiEsMglkNomIq+kCDedm4j3Cn0aMuWtreEZT4iKsMzHYXW/VgY1TxyAg== +5.0.0-special-build [Build: 1611839196],Windows,EP6Me3j4qAPcZFk5twKQu25wsMALNriG/npsD74eDyAsF0KDrwghNgr8dyKARKXz1OElq/dmVneXfX0aIS39DA== +5.0.0-pin-msg-redesign-8 [Build: 1611846460],Windows,EfGt6AcI1rDMATuhyuAzszC2W1FsmR14sIG9/ny5XeSMTCtj/ji4E/f7YKgjqLcJoQD4OjmfItZHCn4mV5AlCg== +5.0.0-beta40-rc2 [Build: 1611855045],Windows,3T71oJon1fHnUNo8ow/GFjv6EsWwN3oX9pfhlqpSDXV5q8jwP8sLt8I1PML64FY8nLvw3TqcnA3MhIodTI1tDA== +5.0.0-beta40-rc3 [Build: 1612189982],Windows,dZ/TGdsIrRjB30IXDftr84VKyrfjPmOJmWsUL1k+57tDea4MGYDxJX+JHr8rbBlFNXys04Ryha7XezgBm2ThAA== +5.0.0-ava-4 [Build: 1612264282],Windows,h7KjfWKWtI4n6PnNOGXf8CqjFPpiUE/AqNTtgPzx+JZQBcwk8D7fd+ZVULQ/5vF8IhMZ73jBzUgTVH8sA/fhCA== +5.0.0-beta40-rc5 [Build: 1612288104],Windows,lyGduWLlcO6DkaVAabs1oJKJLqNcb7AHbJJo5ZjKELkprjarxBZPERNaucHofSV25ctXZiV2O59dpykaGayVAA== +5.0.0-beta40 [Build: 1612346973],macOS,2opndwKGTKntwjcl7XsPFAyGgXd4V08lniVSiThWI4lyQ//G3hH6pIlDdtP2heJaeDPgYxaOTZN+n2YzgY90Bw== +5.0.0-beta40 [Build: 1612346973],Windows,GR+2Y3eTHeZHfwm/CS+BB09dzmbUH6CdU70wpxPXVJjYoJC8e9pXyq15uxSusnw/fSoFSmxBcppCGS1SoJeaCQ== +5.0.0-qa-29 [Build: 1612453131],Windows,wwOcA4QHPFSmDdo9q7Et2ulwCBDGpAJdUz7XDftEnacwXlOv8XJjXGhWJLd4iMkjFO9MLz7V8uvHYBRDZxw6CQ== +5.0.0-beta41-rc1 [Build: 1612527693],Windows,y+pLyCo6Jiolyth/huD5jLokYhugNgCX8gpxgz/tqdf8YbZln01Xp/ffqAv+O+wwcCb+g+3PtUT9RUIyqWjSBA== +5.0.0-beta41-rc2 [Build: 1612782198],Windows,QOCKhkXWxuOr0n7cLYAOWO3256NlMUe1qjHZI2wbpyulspGmc0AXxM5mJvlNCgvLCt2DhRlSXz/fVXcKzZgJBw== +3.5.7 [Build: 1612783432],Windows,IXYGZC3DW9nJgxfUL9bkxA1zPjoI4IEFNRXL+e2aWvjeHC0uHIgJBf7K03Wldj/NXxAcLPW7+LImlaV5MktiCQ== +5.0.0-beta41-rc3 [Build: 1612799472],Windows,Hitalp5DXJZmXEGFxurBAZWazJYuwj14/ydZJfYX17yLVMoOAqaJxnOgyPmGuSsLsENKWig2Vyfru/+CB0iyDw== +5.0.0-beta41-rc4 [Build: 1612811479],Windows,/bkW44XfGwbDEcVcnQl7ZZvco4Ed4RKHk1ZNnDlInWxrq117B+yYiqLi3AjJEZrhZetn2FFlWyr7bqQsVr1cCQ== +5.0.0-qa-33 [Build: 1612983552],Windows,8Kcg9pKMuM9DBQE6mn2H2Nc2ihBAN0XuF5GZZlFPFcEiknpe2C9uHQiLj50YIgupAIsSlpzdd5w8DTJj6QJPAQ== +5.0.0-beta41 [Build: 1613053158],Windows,arM5NK+6GukhOocniKYs4fzH5tSCZJf3Tag0fNeKRgezH4EkJzc1okAfY6DHcn2322Tlp7gp6MM1olz2QzZODw== +5.0.0-pin-msg-redesign-9 [Build: 1613057624],Windows,ucYWz+rDavEaGYCTjEn6roFlehswmEumokjKCx95Or8sSMuhkUbST5mA2lDnkhUs4awanSZrdyq8xhq0NaRzCA== +5.0.0-beta41.1-rc2 [Build: 1613065465],Windows,2Y2okcAvPB/bGunIziLC16gEBlm+JANHuI6MjoAy5XW8CF0SMIBI1ZyKQ6t8QhvoJ3ftfHjIATsMcDwppgRgDw== +3.5.7 [Build: 1613066709],OS X,HFQc4teHEP2poBhHpuT4Iin+oV7vuCHrtiQow3w3FAeFXT4EeRT23tKzgOZ0aoLEg2A5kuBC1991UDW/Y62sDw== +3.5.7 [Build: 1613066709],Windows,Md4ix51veF2pnYqgZLsLCDc+vyqkh7L/Zh+8FdnZLB1WwWZJSw0Esyq8IzMxLrIl/MjStvycGeYDvwDFRja2AQ== +5.0.0-beta41.1 [Build: 1613126021],Linux,PG91XlooLYpIMNMAU2k0HOUn074wy7XAEqqV+KpqPuqXjQxaDfAZKJSpW6yPDYnPAwTjqZeC9p/WsjdI1wSWDQ== +5.0.0-beta41.1 [Build: 1613126021],macOS,e+cvnmV/pxmReDcrxH5b0j4GsXERIeanr8AK6429elCl1oilJZ1J7y2/Hi1ar+AGVkeXq/TueNpKPaM1onTkCQ== +5.0.0-beta41.1 [Build: 1613126021],Windows,+8yU+kc5XZw2bmEgNDx8HrVLrUhJrNU3zyqeaUgNHGA+uALvkXAE0iJDpyc0GdKC/SXy/8RtQvUtuiuMvtQNBA== +5.0.0-qa-37 [Build: 1613394573],Windows,wuh38TmceFuGCLh4LOzCa123mtA4u5kURmpisOwx2ct2acevllTnEjO97DBLJ6mP/4pvhbj6UVUYRy6QfAOwCA== +5.0.0-qa-38 [Build: 1613482789],Windows,9q/muRilnIEL5gECvId5LtQpmrVUpeu4bP+NLLwgxYI2WV+oasj1V4eigh5WQaQjBhz9hVtVbX8G8WpbEHzZDA== +5.0.0-beta42-rc1 [Build: 1613498559],Windows,68ojO5AuFDoHKLouHafJveWK381IpwGKXMMGSkhrItnIROuw0RWxvOW9hLRWsUTLq6U88TlGuTPwGbVArJc4DA== +5.0.0-qa-50 [Build: 1613574228],Windows,8KhK5Ez3Ed5Y5wlKE+ZWF1jIU9Yasqb4QbTxtKfVMNWskBPtkUUPsxfuzrV6kfVYfkLmkGNN2HRiI6jpz7JrBg== +5.0.0-beta42-rc2 [Build: 1613574920],Windows,lvA/yy8fuZx3TW4qlIDzTVjxNR5p1ezB12XSLNFZ9fK+PLbUGkkWP7cvWaQCpI/6KXUL+XlEGbDTWAFYSIcPCQ== +5.0.0-beta42 [Build: 1613641112],Linux,nrUQ2ldbv3wXRmve1gcEM8WjZPGlwUYKBd1Lb3uE5H7pg0nNBqdI+ofu9CiOO84EHd7cRV4L0yjUw1snxaH1DA== +5.0.0-beta42 [Build: 1613641112],macOS,fmtt+6+LYCHj/6KPUMGj6CyN2mFiiCg0mIFb4pWe0FtptIOpCRxc3u0SGdrw7UbG7ZOURc85WboHW0VTtupRAw== +5.0.0-beta42 [Build: 1613641112],Windows,qdkx8XgseysaZ1QER1Y0hv0LBYbhUSWWKJ5iVS+Lo9nj8d0jA3+WDXG+NeBR+mtUuEMDVstMEfV+sJlvRI8gAg== +5.0.0-whip-6 [Build: 1613731286],Windows,vOMV9Rxl7jpWU/7yYukL1dhyVljqa+j1vLwyj0ibLo6UFimew4pEGG8GYGR3zcbM53bjWlUkRaEkRl0VQD24DA== +5.0.0-beta43-rc1 [Build: 1613737602],Windows,FllNVg/BjC3xRSwsDDhNV+DLxApIY/qxq0ZXJlHQ0caWTmz+VdpBoq6PrQQqC86mx50mp9jT1XAkupuf34rOAA== +5.0.0-beta43-rc2 [Build: 1614094754],Windows,aElzPFeKnlfr7bIz81EFEP4uyox78XAiwQdlbL3Dhlq3HpF69PoS2qBwhxAH57Qc7Ja4fltLO6Uqg3jvQzd4AQ== +5.0.0-beta43 [Build: 1614165699],Windows,H7/zMsrN3Bo/jBXEO/b24XWZDquhQIFP7HctK/PV16UXY1eGqma13mvjOdZaZVB8uh3bIdQ6TzV6doJyoE0FDA== +5.0.0-beta43 [Build: 1614246086],Linux,NtXpupFRBip1oD3QVwIhhJv+lrGro8Z/bL2FgUbgF121zZNRtf6Om9HW7R1ggqBkHz4UQuyppEUymnrj3BDaCw== +5.0.0-beta43 [Build: 1614246086],macOS,xXnqateFI77kyYSzIhJdHoqBIR+d+4OCen4tVVs4dRtIyjN1h1/ZjGvx4yljC99/KChI7bPe9VQUJ6wG0DjeCA== +5.0.0-beta43 [Build: 1614246086],Windows,9XWWaH3/QaDOtWIzjQDX5/9X4YQ91ITBIbYidq1+Ym37f2wfV75OQQu0q1ivCJ6OEJ4z1Z/vCPbqXVSxMYNMCw== +5.0.0-beta44-rc1 [Build: 1614332025],Windows,ixE9oYlD4lGWR5F2Hg6PISJqZM+FxP/3lPyiTUCrM1oFEpHkUxVvAwZLXY+z2Csp1jlA7qGxTs6pmzuKa8mUDA== +5.0.0-beta44-rc2 [Build: 1614595863],Linux,gI0yE2iiF3KOVzBXYhdSFHwQFuPzxK0AYojbuF3W/TuysDOFWRrxESpuVBD2LJu0din44O6X5XXsqHAFG2KfDg== +5.0.0-beta44-rc2 [Build: 1614595863],Windows,sAGJ2R9KI9W24RpR8FEswZrvuC5YqSXOyMbn6sJrSeUdjcEYzxnKWd0VbH+W5dnUqZxo0wJN8d3kQCpaQZv6BQ== +5.0.0-beta44-rc3 [Build: 1614674773],Windows,3c0qKcQsJAN5qWbSC/ASSh1A/p3hcYPz2z+OLTsTe3PRM5zdJHmC+2PVeiIX230pYHSgvXFYJpD1wnL5La6KAg== +5.0.0-whip-7 [Build: 1614690487],Windows,f5lUGaB2clMJ+gOVozjC1UsXOiYLLZEWCBeSxfoN+L9ynh/eFaffzqgG7qG1Org0BOaOBrnrbzRh0J3LREiVCA== +5.0.0-beta44-rc7 [Build: 1614789085],Windows,RGjZDlrzl6nElqfjkq30CTQS+m2ouJgvtg01jU8Vp/sgCvL49IeT6+urGfWy9iGZ4pXiRPV/mbj7yJREGIxpAA== +5.0.0-beta44 [Build: 1614848974],Linux,woqXRoIuWTRM45KqrrOJ7EXtWWvyK16Vv7TSrByq5ikJGRARRVhsUZY1MKr9VISdyptODiCLfe4j7oUaorZKDA== +5.0.0-beta44 [Build: 1614848974],macOS,RO/GrBFbLE9ikZ/rXUI2zFjqigoZZ48DqPqjiMjinZqRAzMBuEvGLcP/R0HM8Eu6s1AE07Sym/a0ordbBjtKDg== +5.0.0-beta44 [Build: 1614848974],Windows,Iyu/4a0EaN/5hn8ElIOflqN7MsjMEJy5aI5Yphy2zRioZSpUdK5dvnrWT6tYBxRhQoXoLvwfQv+8es5DJndnBA== +5.0.0-whip-9 [Build: 1614852852],Windows,oUtso4eas4mA0QOFZAX9ec7SDjvwyY2xjaxIeK/j+wn8JTOpPyA+tBQOsig2Cc4Rj0zAGLvc+vNy+OSY0ly7Cg== +5.0.0-whip-10 [Build: 1614865959],Windows,u9D6EaeOzNu4t8jISUIAHoG8Nl22T3KjFr3EdyUYTvZTtqnxegCQU3KzvPKag/kb3zBQa7qOjqDw8rMUHENfAQ== +5.0.0-beta45-rc1 [Build: 1614934599],Windows,K6Zv9Ei7tMnFaIDPYEbtEfjpREEbV9caIlNFS5B8e7yTYxMBbiVFJIayw/Qz3ol1AknD+PjTz+AJcz3sC0CQAw== +3.5.7 [Build: 1614951001],OS X,dLLLDFIfyHq3IPQf1a3TNPQulXo7fdEzIvSXLO2hyaam8nUUBCLx7T/jCTJTx4D9quZ50sVcSacwNRX7n2CsCQ== +5.0.0-beta45-rc2 [Build: 1614959212],Windows,J8GhEHSiJdoijyP/yYuoqbeXjaQTSLWTIPaxuZnoA0OJauLShdmzjI2OvKJlUKCZyv/OW5n805PajYyuR1aCDg== +5.0.0-beta45-rc3 [Build: 1615238124],Windows,3KFwVs4/I//ENFqs6rlGjF9vaWbAKXgKDUeS/1gXwx9J2a7WmBJvc0anisRTBhE+dobtZgZFd0o1Z7IJAq73BQ== +5.0.0-beta45 [Build: 1615368890],Linux,sAzpkX9kjAM5ur710j0mQzI9srFtslieQuyP/QPVdOFhwwxt30RaagY8DT3+vBbiWFCULMvO76Jj4zdwgCutDQ== +5.0.0-beta45 [Build: 1615368890],Windows,jym8S5RDNXOdHTLaxwPuGuMt/Ceg+tkCoW7eYEmmuLfe/bP9MiUv0Z1NnxOwcUEr4tLaG4dFk/MwSGq4edToCA== +5.0.0-beta45.1 [Build: 1615384896],macOS,BMAV0hDzcjK9qGKlVNVf24TPt870h1ekUmVs+avbWSuWuJf4vNrJh4dnwFoDbqHi9FOcXVtV74t7ndQF7qpPAw== +5.0.0-beta45.1 [Build: 1615384896],Windows,eyjTSk2QIfp5l3bvJPG7Iqxj6SbV/53PrvwYRjyPMha4qu/avV6+4ZpjoFLyoIJ7yCsZBalitXuIYSdlYiFXDQ== +5.0.0-beta45.2 [Build: 1615454854],Linux,XYeUfntCzUZPNzBsTe8VT3tOzDG/ixJ7erjR6nEXkvXK1wip6vKD1omVfIphIHb3RnqJ15VvndpdwYBOKDToDQ== +5.0.0-beta45.2 [Build: 1615454854],macOS,w4rCfN66Hw0BGSV+aAzPhouaA8+i0UDA8cPhGqzpRYP+mM2MJbUdGOIXRPRV89/0q3C+ksj8nN6h/Spwj5I2Bw== +5.0.0-beta45.2 [Build: 1615454854],Windows,6ttI8HoOkFLukISvSd6FlXfFGdVAHfmNFZkYpzdvwJahKJnJHd3CZ28Wr/mAYOqJUcmSI/LOF4Iek3yuhK8wAg== +5.0.0-beta46-rc1 [Build: 1615454969],Windows,E3B4dHkeuNQJ0xMQ4ELVKVNY6fKm9fWe0aqH/kH7Fb8ptozWG8DffUGVZhKdHDN/GaK+xI9hzHtAKp/wFaJ6Dw== +5.0.0-beta46-rc2 [Build: 1615547095],Windows,vHL67ZSWhPQDMQQPhUAjB7J5+cpz6RpYYjY7B5t6PG4J7M4pWgqn4MRA7vZycA53LLds8lyGjqdv1QJ676iADw== +5.0.0-beta46-rc3 [Build: 1615974917],Windows,HnlUN4wDtU4+yRVWi/EN6P+SBBKg4ni3iDcLZU5tqJnTOsc3N5RUbo/kReNOPl3B4goPaDXztIGBWlgUCodPCg== +5.0.0-cobra-testing-30 [Build: 1615991576],Windows,bQf9i6oQe72eYT806ilmadztpSX9PkW6/Vzqmf8xtw0pfsjYK+oVPZGrWNKlWtLLQFrKlsD77YHNn0kk1C92BA== +5.0.0-beta46 [Build: 1616059671],Linux,fdo0xRlkgr9pXnx7pwm93fbrB6v77tKjs4amTHIc42mD/bX5b9RoKUH9jpjSoWrz7vJbP2eKq/Noiu9wCaQHDQ== +5.0.0-beta46 [Build: 1616059671],macOS,tvxeVCyEmqifQUW7Q/J1CD0wk9DF5pMNXcc3Go2MwpmboOaBKBE47vLNjFpzNhbK/9L7vbC/MFTiXsXPT48xAA== +5.0.0-beta46 [Build: 1616059671],Windows,v1Or1Lajx76cAcCLKXELMiDxYW+akC09u0ZnCmoBK1uB2/Rp1GRLF3LGCMYtsxphGuHQRZKtLKYKx3kjoqYnBg== +5.0.0-beta47-rc1 [Build: 1616085242],Windows,q4NCcjigcATvxgLdvXHg2Uyrs2hmbA6gG4YQqnz/FRLseGWfqi2YXAwC8oHQyu4i2uhDtRZk/fwn4HXQFJLRAQ== +5.0.0-beta47-rc2 [Build: 1616094254],Windows,h1t7AYO2K/vEuFTFykiZzTVrgV1f1wt+fKYOAzkKFgW3G5r1EhEjgSsi+eDK3dAY7RfdIir2w614axyo3dAECw== +5.0.0-co-1 [Build: 1616188878],Windows,hEUOcdrheJeNr6Iwbyv5k8ct9vUckqGXgAXCyuq59pLQwzlNvOR0kPzkYuCGomhHF83FtpzqWennSrxRRNJTDg== +5.0.0-beta47-rc3 [Build: 1616533310],Windows,7DDJzx/BUON+0MrgBXu3tTbFIRM9ldVZ0DF+KF/q+ra5VRGG2o4FP29yHL2lO50SSXamDl9VhHJzGtDRa2eBBA== +5.0.0-beta47-rc4 [Build: 1616586931],Windows,8/FtnNJyBa7aAHjO207Ri1HDryFjg0lxunZb57N5PfOXbxRg+02lVrPusnQ/2fyW4jJiB5umSBNoZzQQpZTHBg== +5.0.0-beta47 [Build: 1616598274],Linux,y6b4+TK9FF5TrEuHm/YRxk0y0O4PKJeuRd5RX6kun3mOdej/qT0mfEUiAd+kLrR9kaXZbDi3eecHz7tmr1QRAw== +5.0.0-beta47 [Build: 1616598274],macOS,OSyCUJbA2yHbXcRRmXKHNzTBbEaNKCc4b02vvwJlDcncj2ytkxGfClnj8AROlEK/fcVQPnB70WrTCnIzk4e9BA== +5.0.0-beta47 [Build: 1616598274],Windows,pLqGHf0jAp8bD5faDZR+3tM0+1f11spbb9LPtp6Ai3BljnhUj1xTuP5gldLYE7DXOHbi0mO4vmfPOfLQg4jOAA== +5.0.0-qa-48-1 [Build: 1616670396],Windows,TvzMODwIax0PwvbZp0iRRMMpiYIT+Xn85i/o3Z6qURz6mxcWS9x43IpQLVYWaYlLvmMz/0CSjX6R4FMKHDZiDw== +5.0.0-beta48-rc1 [Build: 1617015983],Windows,QC4hPp3j8hAEseYwLLGw14ED4IhJtWJiJ7lQ9M8GC8eiXo0VFhNzj85yEd+q4f5WKB2vsk5oA1Ze5wFHcvfDCQ== +5.0.0-beta48 [Build: 1617183427],Linux,y+dx7mr6oUkKQ36Q1I/7EqiiZGjd+bAQBkN34JYkQMUZ2GjK2WnDhlLUA8MIQlHgiGh9USpL3wC/m16/t/QpBg== +5.0.0-beta48 [Build: 1617183427],macOS,c9+re8CmXHQ935zGNTsowtaYVaZMXUqPfUomZyuK0vm4Um4TG5IkviDdCdWHXKf9I7EZpUkeruQKGoXyrMFBAw== +5.0.0-beta48 [Build: 1617183427],Windows,2MYWzoZBjDBhGCmD8y4RsBybuSRtu9fkHyOV8lbgOAKLaYMDPe9ST171hXruA1JltG/ZFlLdJ8eXAiK+aIVCBw== +5.0.0-beta49-rc1 [Build: 1617889801],Windows,lPA6Ofr9yDHjXSBqn6SdlR0UZk/iAE3AXDwtxzixJ6t4ZIuIwD8GS190yMFcxeef0G1DpNL8gRt9+hTtTidLAw== +5.0.0-ticket2000-2 [Build: 1617892719],Windows,3qxvr9U4RlqErjpv7y/3RMRhXzT2ITHDAVA4kJEyuNN4nBviBIFSfcMpj72+l3xRroql5l8hWY1JQw+QLBarDg== +5.0.0-beta49-rc2 [Build: 1618219716],Windows,IJQ3Cwo8HcL+rOGHx8sPU1g2pS+2X7OcVgnhkcV8uahLWtDrPf3t6nxbifP6SqRpz6AFV3Uoff9TBLJ9iswIAQ== +5.0.0-ticket2000-3 [Build: 1618230451],Windows,TQYGy9qe7jgJDUPizDnXHhmrpqtr1mHqrok9amqzpVh0BtmztH/6oJfrEIwUy6e10jak6AzlVE6uPeWxvo7fDA== +5.0.0-t2000-4 [Build: 1618303999],Windows,IrwaQDZ5MGRvSund7xNRBS15/I3kZ9tgpnb5wObTMG6P2HT8Q09Vy6OLKMd7QPnod65yi0xgthMz9XlO+K46DA== +5.0.0-beta49-rc3 [Build: 1618310180],Windows,UO+41jnHZ1PdAw6yrs0Oko7Ve/b8AWObnjCAgN+sm2t6/gvhoev5MnNQWIEP5HCRixApCsupHUSZxNRqC7MzAw== +5.0.0-qa-49-7 [Build: 1618321773],Windows,GMmmiusTijlAUSVDpeEv9YExpEFWdN7aOXztp6uspvgbDF0XfGSbTxDph0OX81AUH0G5C6LOIpde/1Yr6WnJBQ== +5.0.0-beta49 [Build: 1618401668],Linux,1fnGYinBukr6lBQcjRAkdqqr4M6hBm4e6e3ncZyYdNObK20gNfBGZ58qBUBbnfDKi1BuOkUj+/qsDWb+CdkXAQ== +5.0.0-beta49 [Build: 1618401668],macOS,V0edFhIRDAK66rJ+8e6hDdXdkA5rf3cOjUS1RD3vwO7yXNuJnx/BT2LXORl6zPLrmtpCxMeR4x6Q8JPXhK23AQ== +5.0.0-beta49 [Build: 1618401668],Windows,FnrKgsYT2TlyqBDnBO6RpjrobB5adNC+gsCAOHOWROMDMNeCfGlSDqErldRkkJHbSOA4CZqtDevGI6S53uSkBw== +5.0.0-shorturls-2 [Build: 1618486773],Windows,866uLGWsRihCOSp7NcxQB+EYqdA0WF7UONcbU+Y32Yp0VmdKo48X3gKoE+GUS55Rn/PUuVEsn/MmMZuzhRs8Cw== +5.0.0-beta50-rc2 [Build: 1618505526],Windows,qlPx8pbXRFZ0fLHRMTk5FzTHsYrssAUg+2Hvnc5gehJu88qtlY/kI27Z+4H/pXps5oxPMAzNUQA0TnLqP+H0DQ== +5.0.0-beta50-rc3 [Build: 1618776916],macOS,NxxwMZETqUi3jYVyV6kJmv9IBuxohfkrqFSiAXjUESF0b0s7kAztHkv52RC4XzhAqW1Gdk2RruSzStun7MXRDw== +5.0.0-beta50 [Build: 1619006474],Linux,TqKfFh0zIEADZgnU5FJhOR8vps03joP9lXV00UgTVHcYSiPHrOqZeYmwHfSVA2ekR/f1x/mPQ1i46NIQmigMAA== +5.0.0-beta50 [Build: 1619006474],macOS,7svnOYiCRugAZ5EeVZp84uva7fDjMzRMWZf3M9nEkrnJ/jcs36en0WeFAyieKg+OMzt387C91cze56Qq1y0SDQ== +5.0.0-beta50 [Build: 1619006474],Windows,6C2xLq1VsibrY2G3DFfx70WWQ3SLbS+frhAMkt6+d5f/actmMj+gHRt6KOazAhnotW5Ei9UPvP48WWZu0QOSAA== +5.0.0-qa-51-1 [Build: 1619041054],Windows,IhCj67HuwJytBnMDjAw14WZw8WWUv8eoUwLikLyghipDOpx0edYKY/4c/OmbN77PsNP/2ASm+YFdvHDkfLsGAg== +5.0.0-beta51-rc1 [Build: 1619190183],Windows,3f81wSWrc6ozo6Me4FaMfefSwov3O+ypfPEgEWvqL/MA5EUB50nn+5poamylF6C3RM6HnQ5T5myuiHEZmzjEDg== +5.0.0-beta51-rc2 [Build: 1619364080],Windows,m5VL90gBU8XAETjrBEl3mL2+FpTunI6V7SA98v6wk/Xxedci+VfrVF0yT7nblfiXbcP/aoY2TonC53c4COuqDA== +5.0.0-beta51-rc4 [Build: 1619371671],Windows,dCJndDHM9dFMXKbErOL/illlMSLCWWMA+zw+CSmDzIW18l3lJPVsSOCXjfcUJfL1/UGV8SgcKIk2e7yHwW96CQ== +5.0.0-beta51-rc4 [Build: 1619462790],Windows,ZyYVsQbax1a0qqCBplYXVEOS7+t5dTr2M1NaHChO5ZrA1AwqJ4IaEwcvJ7AAFRN/eAsp1wu5mYx0VWVFoixTBA== +5.0.0-beta51-rc5 [Build: 1619624829],Windows,/QgpIU1qA8KRBBJ8XuiuNhxvd8wslV8rzjS5HJ38lrpowE9kng7L6ZfD+LSpm6lDy2bbsIdmXIcWEIuPwLBLBQ== +5.0.0-beta51 [Build: 1619681979],Linux,3jQfwAlAsCcdiPYohGKJMKXzzgKZEH9RJJUdN0P5GMyKFrXQTqo9c8Q/oDr+ZDaNaXTbcgZ89g6HP5y7eN8lBw== +5.0.0-beta51 [Build: 1619681979],macOS,chXOmkLwweeaCamsCbNGoWSWqMCHITNYTLoGWIRO/CbIydEXBXadY3JwWjMuLcf1VtcMpWVbYKZG7pNOYunPBw== +5.0.0-beta51 [Build: 1619681979],Windows,cBBnWIxmjY2sv1/CR1XZx8qCWTuRE6r85tKom9M3nHtGQwvO/IM0Z3V6CPZvTwt5FrFoxPQKo413pGFgWh8KBw== +5.0.0-qa-52-2 [Build: 1619773339],Windows,gbfc3mE+7/pgfh16Yfivq29Wm+JnCAtWzfkJcwQ5AwKJUq6vi7fy6mXOoE5T6GDjW3PsGTbf9jphdvQcYv/FCA== +5.0.0-qa-52-4 [Build: 1619890509],Windows,P3TAWnIRWhRs1ngJi6O9bfX/ea616AfhLRRgZ4rt82WxtHsym/+01U7JRNCGIOwvN22XqjnbwlGQ/0cz32MKAg== +5.0.0-beta52-rc1 [Build: 1620060486],Windows,1NOx+woysTMhas7SF3CHpG62/9aC3yP8TUEUabTPY56Z8397kAppX7XrSvFdcXffse01DCgJtwal/5Rkq1JgBQ== +5.0.0-qa-52-6 [Build: 1620142606],Windows,aT/Y8d1/H0y1+aFqZwlJDGUhdY+Y+jVJNPNOxxmv1Y8da+ODp0wCda/WDn6/b2EKNiMDx0levRpfWvRPkE+oAA== +5.0.0-beta52-rc2 [Build: 1620215337],Windows,hW6LrgfZbN8e+8a8A61FfoWRvZzNzhXar5edvn8vu9SJ1jMF79/k6jF78LMReS4EybixEj/IADwD0hm0N7FkBA== +5.0.0-beta52 [Build: 1620308356],Linux,M0Pu4YVZ23UMLdXaAMyXdMGnmSsBUGvXRmz0VN1o6xpL0dj+cN6CRWPMnvO+oGfOgA0EE9wIDPICba+PAYKzDg== +5.0.0-beta52 [Build: 1620308356],macOS,fbY56gISJ/pccZJtcXbEidpbzqlCyKvi4lqoQMAex/L7rEm3jfn2Eil9AYD1VhDP44NkiHqug40DNttOKB5OCw== +5.0.0-beta52 [Build: 1620308356],Windows,IdwOkU/80PcmgWroJQoDxlHjFVnsqO+znSf0ZJ5jYIky98t7seFEsl0ln55E5t+z1twPgdjWqU8InnluFDIpDw== +5.0.0-beta52.1 [Build: 1620389196],Linux,J5D3tI8h5q4322hALB0Ok9heqVSNWKDdDvUr+Fq8dkrdI4LtT7lmYq19GOCxSRHAXPSfy8UxjqFJ9IjGW7LWDQ== +5.0.0-beta52.1 [Build: 1620389196],macOS,aYyUiF51mtkNR0ufTSaufl8fYbWSxn+mxqNi6YMsDK3pDIvJDa6fMKehrHpXaJdY8v1Z7MxP0MHbUQ1m00ESDg== +5.0.0-beta52.1 [Build: 1620389196],Windows,QGIR1wmxFFFk/Rg/+AZlQ11FgtEtIqrD4Z3Rn+VPbwZF0XINSHEt2ouq/KVs38ndVDQONt5HBMZbtw9nRVLCCA== +5.0.0-beta53-rc1 [Build: 1620391678],Windows,sMAID1GuMgzVAIWci9+i2MXMqrKD/yt2LtHcaQk3JD/MgGxafAKShIOjHM7c7dTnWDrk2xJbo+pUPsWvOmzyBA== +5.0.0-qa-53-2 [Build: 1620406854],Windows,2Fsfz4ks8JQL05v1bNN17YfsyW0Oh9J3D24g/u/C0RMm5O0afpmNTkWVbIVYnBxrAbBpWE7gKVM67/X1AoLWBQ== +5.0.0-qa-53-3 [Build: 1620466424],Windows,1XLrY2RFM466+Y5Tb966Fbx+mNgr8MkyMIXJkxa+43MqFcFHIhJVTh7jlzVLmMXhZWgBqfYhpECkBe1PX+0FDg== +5.0.0-beta53-rc3 [Build: 1620751751],Windows,9PzIuMOVKatQJ06ih4P7KLSp9526xYXgJqVZiI3OL0SJJ098q5QQUCM3281maVL8nJUzCzyjAUjQm1VITAsEAQ== +5.0.0-beta53 [Build: 1620812712],Linux,FIJQMQnZ5PtFc4qVuw2DTpOOtJW1bisXq+m6mNRwQ18kpsFfi2+Bewyf0RZUbvWk5gJCwAFavsCKUn+Dcf2VAg== +5.0.0-beta53 [Build: 1620812712],macOS,WGo/nY+Lgdto74deJ1aOxXK0PBT5+ECe7Wu6c4AxdrUMM53w8Tbd4AXkvPjTll+xuYkT1m1b9b/AILP//8IXDw== +5.0.0-beta53 [Build: 1620812712],Windows,I/3f7dKsxA+4Tc+84dCEQmj44t6x0IcCDlum4OHpSB9dg7Pz4OjJEOsLf3WW6iPtG9EF/XrRj0KGee1lrguzBA== +5.0.0-qa-th-7 [Build: 1620837606],Windows,oXkTeSdu+Rp0bQsJX4r+0WkVHJcZZP9nno+9Ch7U7js7wDjRmoN55CxxGYWuV6G3qJef+5NwdUAC/X68BrhsBw== +5.0.0-beta54-rc1 [Build: 1620990757],Windows,EILW7wizaSkBoFcvS3n+In64H7jZ6GiNaIoA02iO1+R1z0ty+qarBRlLbGCv2rI6hNnTmfm1fz0UXieaDw2TDw== +5.0.0-qa-sea-3 [Build: 1621467933],Windows,TkF2YHH7RfJm26M1AW5gmLjxE5Gh2MY2APnr2BPsYsnQcdwmO0/68Tt9/OI/bYoa+fRbIeOCnu3yxuQfcf0fDQ== +5.0.0-beta54-rc2 [Build: 1621608154],Windows,urRSFRAlyTZTf/0Xa8sETDs1m4xjU2k5GAZzTr+sktNMAaaSkBqgM6tuCeYmrQvSTuidxxHMvYi4fUn8mfXBDg== +5.0.0-qa-ex-1 [Build: 1621780734],Windows,J0OeeXYoRwc81sSDvfeK0CFcBqwHH0pnmE2HDLyH4FGxv6QQUGSynDc5sOGmu6JhmBwRQw4dJ7L9+CFi4+K7Dw== +5.0.0-beta54-rc3 [Build: 1621966258],macOS,77zX5UWHKZb7aztyIM8SXTzzHeohDuv9cEZClv7bRIHXJ3ULog3gpm0NlhIuFW0NtuhnvCBb+y0bsk5Z00sfBA== +5.0.0-beta54-rc3 [Build: 1621966258],Windows,d0KY0/Lr6abJaMm88UyRaWHc2hmQBjDWz3XGPbbGO0Y861aOZFH8Q5h2ker+aGph+XgqL1nNOvsuxkX7tEzqCQ== +5.0.0-beta54 [Build: 1622118640],Linux,HCR8uUkq0kVQAW8wckYN+MQWUjKFnSWijRpYHLL6PkY4wQNByKCXYC+ojcFO3DpBt0sh/TvX4y5/s91wu/rMAQ== +5.0.0-beta54 [Build: 1622118640],macOS,/tnQ4PpOkREsO7cLHAWWA9AUHRNpZmtgRUtp9ggd2S8kXAUHNdbccerHTeMcsAgQ23Xnd7KDhWy2y4NJ8oI9DA== +5.0.0-beta54 [Build: 1622118640],Windows,PWa8uSFhmI0+PkOqtGz4RyRy2MAHXJyEIKp/2iJEcT8yesOBuvstu4NS3t3mbSh0wxIbEAqLxz8Sml7qAZYtDA== +5.0.0-qa-55-1 [Build: 1622144487],Windows,P4wWKbQLZt1n/O58icE9zu+QEubXmMqOg+Ge8oCmF9z8qIowtgXLPTJ8n/Qs2jnnE+kIKld+VYIE85k4CtG5DA== +5.0.0-beta54.1 [Build: 1622193586],Linux,JVanVTTtN1HE4HMpeAGku/vjoXKrBTPokMTei686c4u11hOWB59mtHTtFUkCoyAq70ESFmAt73B5mIRqoN2VBg== +5.0.0-beta54.1 [Build: 1622193586],macOS,erjNFR3QtPTD533YwkguumPja+LiuqvqqwgPPqLkirRejBQEfkL9LE2kuh4V1TQRILTXHpxSbrFxictQ7S+/CA== +5.0.0-beta54.1 [Build: 1622193586],Windows,4NT+15Tj04x37T782oDzIenlmu8B/agc2zuRLKH5L4myzbrJFiUFRSjgV4qIqwOjeGRAea82DSrFEO/RcvXkBw== +5.0.0-beta55-rc1 [Build: 1622211570],Windows,1tSlxxY6iaptmif4rlkotuA0Lg8oXAcjYb07GThuC9CahBVR0qztUvmT3R9HxT5cPMLtIq290O4laleZN1ZaBg== +5.0.0-beta55-rc3 [Build: 1622558414],Windows,FVu+gEIcFPAWnGwtB+egdQ7nJ6Wy0cF2ZDu/QdyyB0A/HiAh9vZc0nR+1V5VGGF8pmA4LeJ6gU0+EUTccHrOAw== +5.0.0-beta55 [Build: 1622638893],Linux,srcT6h46YGQHSHpRYHtkB3IypX+bK0Ej1/3OjBZmbcI5PMLGlmsog/Yc+nKh7A98Ri+lniDLXSs9Zr9b24yaDA== +5.0.0-beta55 [Build: 1622638893],macOS,2gSuGZAel3Q20QvrQblEYo9EzPs8eNcizIqsn1eKi0E5Flmz3nMYOSoB2dtSYoJscfXrZDY9u3qhG4D0dCU1Bg== +5.0.0-beta55 [Build: 1622638893],Windows,3J+O2VQDxn3Uv1Rap/iEEY13j0nrzNTNQ51qXdyaMk1QeHrE1q0KQnRyi0hHnhkD4M3EfX6kKNBlJE4xN4AOCQ== +5.0.0-qa-56-1 [Build: 1623069200],Windows,HCnoX2J8AXpbhroYOGJB5tHVWfYUe2JHXonRuB6X411RBMnaVM9c5BU/rUjYjx1D+cISBiB3ks/Hq62efPFmDw== +5.0.0-beta56 [Build: 1623148575],Linux,d9h/sV9KB4sJS3POH0MLBiugngBRNhLvWMD20btZ6eEV4d2UHgKd2dxmd6MQ8arQOk93RXMmRM7x2pUjShV7Aw== +5.0.0-beta56 [Build: 1623148575],macOS,TAXyB1fdhYHwkKyN0cSGqYebYCHJop34rLRcBZRkWWMhif3qzL2ifdQKLlujnUbS86cOLOKmkzYut1Rj7s5xCg== +5.0.0-beta56 [Build: 1623148575],Windows,+42FcuaeKG6BKSMW6IHyu+AxuGcFTV8fPfbBr85Zb6U7RRJQmV5eY/q7KJag0JNgYdaH4cjxK8A73p+lFxUFBQ== +5.0.0-beta57-rc1 [Build: 1623161118],Linux,hz+mPLe9T7wtKNdiY0fuGBEpyqXNpBwZ8Rg3Z5+C9M26J365jnyT06YBEEm1rn/IPAoYlhjLyFstDByTPxSYBg== +5.0.0-beta57-rc1 [Build: 1623161118],Windows,XXrsCn5LVz88fH6MHwb8UINFHHOFz+FjeACUfcryMydYk1t5wsweBuQKlhw1cyFyIrpcujzacKaX2NsurX6gDQ== +5.0.0-beta57-rc2 [Build: 1623419125],Linux,HUpyxKD7u8KNS2DJSA0aKqyQqQRGLNpIHLjXtqzOj4xlkvGyAFE5bsWPrZ9Hf6noRXPwLtwiaw5rlG/K3+aPDA== +5.0.0-beta57-rc2 [Build: 1623419125],macOS,i/v9mxtaL7CDRCV9iZl0X2koxaPh9n/I+yJJFPCYK0HdMMLl//ycPwTrDhuoap2kBpAxKmv7vUxGo/TkKZ4pBw== +5.0.0-beta57-rc2 [Build: 1623419125],Windows,kn4sz9UrXAM07VKrgUDtdmhzf2ovkS3GCvGjYDnMGqLG9Y7vfCC+vbVY835ywmhuRAU66OD5PjeaOqQpfdDEDQ== +5.0.0-qa-57-2 [Build: 1623680173],Windows,1CS4vp7navBSNTNntt89PBiPS23UvF2xZtxcYuV5NO/t3D66rr8VE8H5QAwLJohb4cpA4fg1fthRUNRW7Zr4Ag== +5.0.0-qa-57-3-1 [Build: 1623703105],Windows,RpsilUqhdtlAuG7+DxhoyWm6M3qNE/T1+0rqHY/KTFXPRpHHCbst0ptk0c8io5oiCczUgHGCEGqNyuIsTZKRAA== +5.0.0-beta57 [Build: 1623800045],Linux,4mlATVye7twoeQt/01a3jekU84Cgqrvq3S2BESJqn7z6GlKWioikxhqAf9Uixp68jngoYRbxczFWZygnOEr5DQ== +5.0.0-beta57 [Build: 1623800045],macOS,jB9zs897RiF+FPLKIOyzMc6PsVck1ao0T1bc3QIqxlQiu4mlOtqqQKblbLwKxsHaPRfi26rddW4kZv+uy3hHBA== +5.0.0-beta57 [Build: 1623800045],Windows,f6P6tAWc0csS3J6z4ZoNI2wF+czRe3Ncnx3R/+hnExxBK+7DBAFyHE9MwVYeSSN4xsOA4vtaCUtwCLFrvjg/DA== +5.0.0-beta58-rc1 [Build: 1623801564],macOS,6xcgBUtFJYVhcexJEj5M+ittBqiUqyE6dN7NOUVNUKFlPSW6WOItyfhMThfaKvWSx269JXGhstDNLDlMfyHGDQ== +5.0.0-qa-ex-3 [Build: 1623837149],Windows,HmWWH9D3rROfkK/IzLSueEh/tlDmhMGnuoimwUp0CvWiR9p5KVMVtfqUtcgbs1+yMH47pICya0OsFBtAXSxLAg== +5.0.0-beta58-rc2 [Build: 1623852877],Linux,OZzSs8Ewad603y5RVcKgDrBxvsLlae2IyAHqrXDKydOHaLgWqUrpgXMdFNfdc4AzKlCoPB4FMxjaEZ01tGP+Bw== +5.0.0-beta58-rc2 [Build: 1623852877],macOS,gajkW7AbAOCohBsnBLMcT8S1Y94ZFvcok6kL+qYcHBED9nFu5K3P+8EpEhlkE1VZcn9Z94+Tgk189DBoKVNOAg== +5.0.0-beta58-rc2 [Build: 1623852877],Windows,D+/TAor1uNx+HQMRnNlUt8CMMe07ZNOrWCR/0boroIZI5CoT0A6sxNSG7y3KrqkiA6AIPaW4qm1BKMvk2yDUAQ== +5.0.0-beta58-rc3 [Build: 1624026633],Linux,P+rPi0kjdb4ulRX2laTuc76kV4212iqpNiD8qX6DTFfArKWpieuWJN50vMTKC+nuLZzH1A5qLzkvPxMyewaHBA== +5.0.0-beta58-rc3 [Build: 1624026633],Windows,WMq45OVM7rnpUwuTfh9y9WG3fwXJ43Dk0qbSuBFC7f3AzRbg1EUds5I5S34rGgGIQ9SdkcmQRNRkIMwfchm0Bg== +5.0.0-beta58-rc4 [Build: 1624036539],Linux,AkxU9a8nfSze9gL4gi+QyWM5DlLXr8dGgRDE/IuRY9ZlhmD3o+z0X1qbPDILrRQPczehB/XpXr//2+LciNVBAA== +5.0.0-beta58-rc4 [Build: 1624036539],Windows,heTHLhy1J59lfdBAHM+ecgx2v5xe3t+Xx8yq6+98n7Lij0HC0q2zdiU8IUHTsOwe85hp/OPAmmCdnPEzZAKKAg== +5.0.0-beta58-rc5 [Build: 1624277263],Linux,bWckVdW+pjHN+C/aUtNxwGC0l5j7UsxFQwdYXK6Q84KfT5Obnouw5wV5OHIGsZLQZOTzIQuldnS/H8eLAjhsCA== +5.0.0-beta58-rc5 [Build: 1624277263],Windows,OQheemlgDUJl30ASzoE7udK5TLjrMXtwsr0s/xNN6RvAdJThDgXHrc7eJlX1onOh55QYJ7D5i14L2y8wzAEnBw== +5.0.0-beta58-rc6 [Build: 1624358903],Linux,BC3qch2uaVLbdJTcah5Q9QPwF4EuZvoW2/pX1sr77zYTWbCKI42+numvUHLzw1lHUdDetcWuX8CrAE85/aIsDA== +5.0.0-beta58-rc6 [Build: 1624358903],Windows,TqxAa0e7Udtw41Zxiq+FsDeAZd6a6yGzgoEChUTmAWAMxVOZyjguex+CDRqD2uT6Y4zFXpZAZK6RTLr9XEeJCw== +5.0.0-beta58-rc7 [Build: 1624443135],Linux,y/vxPOYzgYE1ENvSMRLNOG6L0VZnDGVSCicVBp1XYh+eLRN3c3E7A2YrY2ieR0CWlsSnaxlZV8sjwFvA14OGBg== +5.0.0-beta58-rc7 [Build: 1624443135],Windows,AGBGNWmorqdMMS+1fB96g4nkGKNTc6247kL0qI+mwKZTfwr1+TzujBuMYmIj+J1PfKbIC59PgJqX6CKr3ExrBg== +5.0.0-beta58 [Build: 1624455116],Linux,jfouQH+p0WODpGqWgGhC2a058Fw2R23aAeqzXGF3bcurwPteQC+ry9qxzxDNgEgLlNfR2oKI9KtgA9rQSzQrAg== +5.0.0-beta58 [Build: 1624455116],macOS,nhsrLH/r0PgQ7DFotJyUHlNeV9ODPRJ9S08XmIt1Kv8f6IZ4RrC6FGZK8FUSsjo9ZKS/G1cjzkmoq79Mhm8ABA== +5.0.0-beta58 [Build: 1624455116],Windows,QFUj7EwAWIFHDDwtUZVgxwc0O1yAvT7EISiq1djSXuackwNNwz8oF6HbGp41oYGYHIrDdmsEt1ElSD3kNRVeCA== +5.0.0-beta58.1 [Build: 1625041456],Linux,dev3UTiE5hsVr0VRElPtXNiipt4WpbeEElWiYq9RZSrJAXZd1qsg6B6uCDkkyuvK0AoerVyU/c6DzRp0kNJPDw== +5.0.0-beta58.1 [Build: 1625041456],macOS,7nnuj2cd193D377ldCy3Wc07DYBLjfgNoYrEAyOUeh8hZ9Vrw0RxKuTrMO3T0E8t6/uadGd1vjb3dLlnQctvDA== +5.0.0-beta58.1 [Build: 1625041456],Windows,JiV6OaRnC+Mhp4JHWXL4cMlOuSYDMmco9gJxccSRLxc2bWg7LvrlEtp/BT0UTge0r5bTPgGLYmdbZHtvjSZcDw== +5.0.0-beta59-rc3 [Build: 1625125975],Linux,m0ySGjCY+/24C4E4iBhJtUB8Ih9xCK9puPDfFOXz4SJ6ujL6Zrd0YKi3NcOzuZfEX4Py+mPUNv31bCGNtDhtAg== +5.0.0-beta59-rc3 [Build: 1625125975],Windows,8sGyQ/Q8N6v/4faHlpUEDqxBRqRIFhjvtRKWy4k2LakQJxEyKt7xnCYCAeB+3B8U6TVUpMxtOhqD/c8Ut3jqBA== +5.0.0-beta59-rc5 [Build: 1625222996],Linux,jmH2WNbLL1N4Ksd2fnv8f67EbIkUpBbSP90vJ2z1fqd897qgFk9GyeaB6oNiEOrRMCCljAoSiA4d3RqSlTxYBw== +5.0.0-beta59-rc5 [Build: 1625222996],Windows,fqd6gm3Jm+Ve4JblcOltdDF3HJlJbzib8+M5spAb8xLVX/VqcAizl4l7Mwtx8zfn/UIFS2NKJPwh6Ms29vXoBA== +5.0.0-beta59-rc6 [Build: 1625281448],Linux,BHdeMnjdTGSufoVpfsItgWhVYPpmpa7/GPxgG2uZ7AWbc2aGJXalQDuseQNS4sTuFl6Q7tvu2VGpDNH3loZaAA== +5.0.0-beta59-rc6 [Build: 1625281448],Windows,pyIvf+Wz+aG94jRRIjf68suzIDZgpmPF3lYNiI2LnPqbBYPlQVI55Y7eEIOKauS+B7YTPFyNZ5tD4xpc5huZAQ== +5.0.0-beta59 [Build: 1625645480],Linux,LApcwrOY7fJC+Wz9PjIbi5nC+IUueI2dfjWVgTgzBUcP2VJeKgGguxe9JOiEZlPLJ/si6373CnQRFkqqVZTICA== +5.0.0-beta59 [Build: 1625645480],macOS,Xp1bEbN3q24cAGtudGE4QSCDjCBJRe7r7LQsRc3HMaL2TuskcgvkYZpxvDcScyiP+pIpTGVEajet8mcB8i5cDw== +5.0.0-beta59 [Build: 1625645480],Windows,xPJZ36s3ym/JpRqX1SKdjmrTEsdvWhBg0PZhSKxeShCa4xN6QfZCaTI74DYHKRlkVk1mCg/48RAqXSqFK+SRDQ== +5.0.0-qa-60-0 [Build: 1626366283],Windows,uUVj3p8rTKE28iUmqvdUKHe2YL06jiYiq9EFuUhlWFf9L8dYeF2UyZPKWCZxuFND+5AZjStqrRhTAhD8VUMXCA== +5.0.0-qa-60-5 [Build: 1626875020],Windows,7RDryAgGn574+k74H/9SQ62KB2Xk8ETUR8r1A00I28PjKwSz2sW6QPvDtpy0iFxwFkamMLv7InNjJMCG/KExBA== +5.0.0-beta60-rc1 [Build: 1627029564],Linux,rQc/sgqxYPz3LEEk9sooKNV6D8sy9pyi9i6gK+M+8tT7atD14NfBkwaZRGVriuAZFbJsYok1u7AosWMm9CYtBw== +5.0.0-beta60-rc1 [Build: 1627029564],Windows,UKVg25AJjOyGTyqg5VZkjhLQtUGtuhUJMxtRFH/cYnJbBWxiHNPB/lU/Z373d8PbbPe7lQg3qItRu8eW4NG/Bg== +5.0.0-beta60-rc2 [Build: 1627281941],Windows,MF6QJ9AALuRoZXX6nuNH9P/nHzlUekyTm5s5AxwxCKauWlXZGlFSDC/0BZvaqJ+3OKLJP0O3IVqsl4FKBAH8BQ== +5.0.0-beta60-rc3 [Build: 1627315911],Windows,5PlNPQFVeRwyN6l1h72/aNs5MiLkhLdZZC3tyLeUdxBwsNaiBwi0YYn2sZAMvOMjDY1qfoYla32XYmvwsNXYBA== +5.0.0-beta60-rc4 [Build: 1627382772],Windows,s1S2p4xxCZrGMlTyBfvEVxkBHaOM5cgxg7BFvRMvj95KbH0oD7QHnmvSMM9GegJMJkXwOr3pDUa0Edo1rCScCA== +5.0.0-beta60 [Build: 1627453078],Linux,pFd5WxdwkUwPqNk4gz/OPDDKDqH7rtS0mRTYUzzQ3k+bYTrphkDGEs3Py85G0Yww56axzZU4d5TeZXJMt4+IDw== +5.0.0-beta60 [Build: 1627453078],macOS,qZCDpzLg+j2asXImiwE0JR3mkHQZOmuvm5TFQCP6kPxE057A+dP6Vh+BhG5SDo34ost/2FaDb101zqw59g3/AQ== +5.0.0-beta60 [Build: 1627453078],Windows,jSI9eORmJ0xiFCBTvwJk3O5Iz3T4USd0ccgX1cTaQna9ZjL1e0nEandMq9hlTsd8NmBsh3wuVboK2KpvBRuQBQ== +5.0.0-beta60.2 [Build: 1627557732],Linux,RNOFeDyPTNnxH1XloujSn0RqYlxDDShp64JJqM4TEQqQjmUcmNlWc+zqMMRx3cwiiLZJi+Q8jBwHYu2xvjCuBA== +5.0.0-beta60.2 [Build: 1627557732],macOS,AjgLY0OCGCcXB80BDoVyf7Es75R3zW5Dk0wrf2UZDiFrQoVq9KNT+LOuW+vLmsxiLn9h9q5tysEgcNNS50E3AQ== +5.0.0-beta60.1 [Build: 1627557732],Windows,q897lxfc2eM+/G2Eho7YZYIwNyiGS4OemqqDQUW5kjji/117n485HjeO33G0rmevcMZtvd+SK5RwpAskgrMVAQ== +5.0.0-beta60.2 [Build: 1627637709],Linux,Y0yeGGgL8MqP/TbvPioyN49sZRTF9mfA3f81FLXcfVFUBI+2wmtv7HFO8sjdV8E/eCCHGF/aSnfgycLEqG1xAA== +5.0.0-beta60.2 [Build: 1627637709],macOS,2vQ+zKtyWmOJta0Pp5nLB4zJhJqsbe2FaJhWGDkm6o2Z7CLxnOWJtGr+EFx0Hwc2LxGSTB/80E7iMpVezw5bCw== +5.0.0-beta60.2 [Build: 1627637709],Windows,H6zjHdy2vQfbtwqMFDKzvGF+NuCi9hfbd2FnPwHKs6G+I+rEAkzcwlq/Zy0SiQbGiXstqzJIitv0GQnlXcFPBw== +5.0.0-beta61-rc1 [Build: 1627995830],Linux,GYGothXGxbeONpib8ugLs4EvX3KiVO15n+2tlIccbahX2onTAnp8KkierFhw3er3yOlixNsbS7fkUjxrb5V5Aw== +5.0.0-beta61-rc1 [Build: 1627995830],Windows,AvO7IWx1bq6c5xrbu4xIJheY87QCjeNwp2D/SZaFvwb+/h0RaBPC3aqGYdzZQCW3OLx3xPyJpY21hvV6aWsaDg== +5.0.0-beta61-rc2 [Build: 1628243130],Linux,vISDWJ16G4kopHt4RA+EF2yo39pio1+zUfN5RuLwV9YLk8d04MOnZbX4Xxtake1xO10BbYmdKd6ChRvwrgXxBA== +5.0.0-beta61-rc2 [Build: 1628243130],Windows,KbUmvVj/ZkoJxZoWQkKGzShkQgG5pzvWtqyfOLIH6Fh4hAgifCiEEoDDjR49rur9suBEJXqTq3MEvAX/D0ZWBw== +5.0.0-beta61-rc3 [Build: 1628513934],Linux,cVnjrAppfEj6S+GWGCROE10p28si3SPmdDpoOREP7i4PFatQsiBHe4mtqSUZRwJCB3pmcfCMnFOm/rznmVOyAg== +5.0.0-beta61-rc3 [Build: 1628513934],macOS,W7mtneojI+IR88Jfrj+uAeidF1ABdB4nAPju/zmfyzh47+1rtD5ZbH3NpVsPb7+XkgQlAX/COCqMCMNvH9LpCg== +5.0.0-beta61 [Build: 1628671407],Linux,UXVnT6nMts902bTVvyz6lElUpJMs1Mfu9KmQ1JqNvipmGo7UBOIYk895ar5LvCv2NubiqhHcfzthK5r7Rs1CDg== +5.0.0-beta61 [Build: 1628671407],macOS,SWaizGVBbnu76+sk+Ci9it9zM/zNd1yvHexIdsGFD9mTqJFESy4Mp3o2rhu3WUmuQ2IS9O2+5am4og7j5HOXCw== +5.0.0-beta61 [Build: 1628671407],Windows,nNxZolc7hbuY/VqOT4yPyss6yyV/P4WtwARdxk6pMSKu2bjqcoruLS4q326dMn2LURoUosTDzSNkG9si+h1wAQ== +5.0.0-beta62-rc1 [Build: 1628769114],Linux,D7VUKGHrIS5j9woksZrVrm0TZ572X57RJU+GXw83iZH0emr7wmTk7X5uRkkwbCtYJyPnE+8Nq9L37v49d3rTBQ== +5.0.0-qa-1925-8 [Build: 1628773544],Windows,srPGPy3iqROXxBlFWRlQzT2d2suarS3tSYyp0sxhxYKOAauiLC5JpduVuihpYCal/UNbnzyxs4y1RkyzYLEFCQ== +5.0.0-beta62-rc2 [Build: 1628783944],Linux,hJ+87Z+9l4RbtW6IUSd0glOld6vJCQESdH3SFQ2aKnPlz79ucpxecsvnnoPHElLyP+UrlfbFTQDCs0N1ts1sCA== +5.0.0-beta62-rc2 [Build: 1628783944],Windows,M7bVp7Q3P56amidg44+Dxx2a+Sned/Sv7e99aVW9Og2cCoF/pjjJ1AAij8tkdFcIgi7aehNVw5etU9S0rqkaBg== +5.0.0-beta61.1 [Build: 1628848434],macOS,xsGyh80SYE8zarooLP+9ascC2V8ilxEa99gDe4umCJJyVSVIw5wDPCTjur88aqNJnfO57qUZKgEJ+UCIaP91CA== +5.0.0-beta61.1 [Build: 1628848434],Windows,dHRBtVTXv1vR4stDUyubTFTl0GpttNMOewqOFe2hUbzqCWtLflzNCf4rqTMA7OqH6pjYOkM41Z31QhRPoPZ7CA== +5.0.0-beta62-rc4 [Build: 1629103760],Linux,SzRKkIeq/Vte/p8GrqQIUn9AhNEBU2SXZSt5NP30giQYJvMjhWI/eHqOjQA3twPJP4kaWIlCn6pIXDJjWOgoBA== +5.0.0-beta62-rc4 [Build: 1629103760],Windows,2zOqY8mu2gVTRMo4+fG81TQ+/GazCBqYue4It7tr6ghP5X0CgBdZnG7oEuSj3L1pNSqlMbT+lMrDwC01cigyAg== +5.0.0-beta62-rc5 [Build: 1629121366],Windows,oOUGiICrDiHuDcferglab4Un/d6n5/Grh5Kbp66csJJarwjsG6h5B2YA9GBfBaSWXzwP3jfkow/FTQ4DnPNADg== +5.0.0-qa-1925-10 [Build: 1629205202],Windows,Vf2gq3er4aXUpejhr4qIF6zbXRdObg/IqU2srtwih6IMH3dkzs4b2mH6qgmjw90T8c3MAxF5WrU5i/PjRkEtAg== +5.0.0-beta62 [Build: 1629207214],Linux,EMgW07cDBM3c/WPPTJwGc3aDWHvoG+aqo3dtE5YAd1Bmia8wpD9YOERxetdp+zhmj7Mhi3JHyBl3VMQlCP2mDA== +5.0.0-beta62 [Build: 1629207214],macOS,Rn/wdm6PcpPv75tAhlFJe1qf8fmettbn8aWSgSBNe8rxcn3Gnoo2RIJ0E05Nt9TQ85A44OC5WenuceMGb/IABQ== +5.0.0-beta62 [Build: 1629207214],Windows,B8zwVN7MrzTaAE3FOmwuAqbI3UO5bU0aFEWBcBVBXU6qRArFhjfzCazSW0qClZcTgjCtzGVRZ1KgYv+yEzCECA== +5.0.0-beta63-rc1 [Build: 1629878569],Linux,ptpUHmBo1Oft9FH6IsFCSWG4UzfoZy/HvP1hilSE5G9WKK79auBC4OHroaryAXhTiv48fyRo2J9Tjz/1pMszCg== +5.0.0-beta63-rc1 [Build: 1629878569],Windows,hWjdfWfqXVT4y29UUpEs1VTQs92SHMyYmZpZkLFXA67zerpQVj6IcNqxKraUz1LPr+gGN9+JuvnpB+gcQRTdAg== +5.0.0-beta63-rc2 [Build: 1629993565],Linux,VOq4OeSuOfB8LQ9+m08sWq3m1uclLoV+nRIUVxTtnwnw/TsfNzRdTkUYBfwPB4SS0pat/WCzmJPVsPcl2pXsBA== +5.0.0-beta63-rc2 [Build: 1629993565],Windows,4cFmNGL9tn/MfJa3OxUbC9qZfZbxU/UXRrKnIufEOuQf8LbFOLS2fV22afjtgvkHTU6wioGFzAsFBMD408raDg== +5.0.0-beta63-rc3 [Build: 1630066856],Windows,DkoURrQZ/arH2s4IzoEFQW/y8z1T2THdNCS1c1BGrpcv0H52soLTAD01APwmdATxcVeBNaxbzq9vSd5pkGSXCA== +5.0.0-beta63-rc4 [Build: 1630324970],Windows,FObv14Ezz0Ul6g6fxHRNE6SBsgf/2fTtmfNheSYFJ7SBPJheJ95XR4vZkMz3z5rMDPacz5U9483bXkrVea90BQ== +5.0.0-beta63-rc5 [Build: 1630417664],Linux,Yit88zeNlcO7/jJUbGOXLRlYvx41XlaembvpwFd7ijb6jF41+zU1EGsISgctd+u0GySlrUtpdAmeQm58tfOhBA== +5.0.0-beta63-rc5 [Build: 1630417664],Windows,Nh9rSb82sfovpCjNlviF9ekL4y6kinMhVlRr8hNqXSJUKRpdg3SCoxhSFrQ0MJ5MFtMSf80Ey//sYPPR8F+xAQ== +5.0.0-beta63-rc6 [Build: 1630672687],Linux,NLw9AYJtn2ui46lAZIVtCeabaJiYIswd7y70iGhxytNNyVjt50/A08PYMYpolwyFo3qVwmjYillg5qBQ6cZ6Bg== +5.0.0-beta63-rc6 [Build: 1630672687],Windows,5wPn6pom99AbhEeBdmhwvamGiX3oJfdsfAN/cAqojiYFQ3NL8AxEm2qyPmCyuPrGm5O95iwSYXgsfuMw0VVmCg== +5.0.0-beta63-rc8 [Build: 1630944479],Windows,TEVmPlLUW0JeIJFSsDjnkFiYI2rsqs6BtLWsxBn7iIeF219KL6SIX1eZHhvdwZk16OLOCOH56UX/0X/RtWY0Aw== +5.0.0-beta63-rc9 [Build: 1631005853],Linux,V6Re2QIXf87/eWjxz9rJEo2mqK+4jrrY94FkdLeK9Ouprp1daynqQqm2Al9I2ac1QBnnxCZe1LWgcPefh/e9AQ== +5.0.0-beta63-rc9 [Build: 1631005853],Windows,btkblgqZvb66caWCIE85HOQu9ULbfSjAfixSVSy6YMBMWfxP9AQWt1lzezjuclA4lNVilWFSm5Uhcl+R3/kvCQ== +5.0.0-beta63 [Build: 1631042126],Linux,aEfO8lGf8WVEg7+z4EuuNWkzlukz89ke7eIGs1rVY7cmUcSti+Wfds1pf16MesYno/E6xfsyIGrWB9lFl0E+BQ== +5.0.0-beta63 [Build: 1631042126],macOS,F5ZFNd6RE6zzBR7rjfw4IJFcAEPfa2ECcaHgSD5QORBvsvQxHZcEnEXXcLmdddZW2ppiqrdzEKtB/NaVdjRIBw== +5.0.0-beta63 [Build: 1631042126],Windows,MMX4vnmOgjnSdSBidViX7KO7dd73INKb9rw8dHVCPxqKNeMcLgLst1nFedIqxsr53n97rkmfFcRtBANghSBrDw== +5.0.0-away-test8 [Build: 1631200786],Windows,Irhvv+WQjL5450UmlAOVY/0UdYBSwUl+UE9kCYpaL0S6IjnJ3LRhgO50mAsJQchcdwJGjdATDsY9TMcO/BUPDA== +5.0.0-beta63.1 [Build: 1631268231],Linux,KgpMkgrD4QZcSd1mYi9qVMgUfAjf3VVbKYReVU/nwR2xKAXOiFVAgqZ5DZF16Aq91e5xQvZxQhl8i7umPROZAQ== +5.0.0-beta63.1 [Build: 1631268231],macOS,kEEqTmZ24fKwAohaUYEvWz97fI2yp2MC9RJgN34F3Y9gUNzc1t/DOyD6xHL4wQF4hWfY3WjIA7lM69Rwt153Aw== +5.0.0-beta63.1 [Build: 1631268231],Windows,HSr40GiVRivm/l6YjTKCNP+njvR7EhpTlkxByOiieI3jedQRyzdS/uxbcIupS6TDWdDsSS0URBTgH1n0FqUKDQ== +5.0.0-beta64-rc1 [Build: 1631271008],Windows,UMxEnfB38gV2FUYiokuJ9hYK1u7ObwA5zoRXa+oAtC5OxEf+PEpsMxBspdKqPllFVS3k+xX0XWx2Q5Gi+ANmBw== +5.0.0-beta64-rc2 [Build: 1631535074],Windows,6zYgWnTOR1wRFV+hrAf4muv3pplVUBcrRBnKN97kRv/aEuy1Mgn5ez11EnXFR57dbU9AQjDGPBQRUpJFNj7JBQ== +5.0.0-beta64-rc3 [Build: 1631614018],Linux,rtoVgZuDu9uXrV7xB8aSn5O+El99KxSvz6xwWzpN3mBG48dlLqbmmNGp61lkezyjXq+hgWhT28du6q9WDfduAQ== +5.0.0-beta64-rc3 [Build: 1631614018],Windows,kGx0a1FrSsYrWJ8BcIWoQo1nw9F4yrO1EuO65uKYO9ZRrrINJrgwaHUZwx5MRc9ajsJFaQdUsXhumCKZKU9hDA== +5.0.0-beta64 [Build: 1631702252],macOS,6JEBPkYHc1bs1KhrZaRzCHo4u871reAODdt1XVu/uGgMnj+tNLmL6dGJ6YaAuGG2leyFQ436PqRqRQVu7ZeCAw== +5.0.0-beta64 [Build: 1631702252],Windows,SsYcBVnP67XI5dKDbSOlWRns8968Y+V2DXeQUNhwKI69eyyB76eBrMgRTZ91rdgyQqaZCJKNiU1AIaPbV/XbAA== +5.0.0-qa-66-1 [Build: 1631885355],Windows,s+Lg/dUq3gTn1KbVtO3jC9KNhjVPKR5htkO+SIrGyaR/ToW7nr3KRE3PnF7P3tb/0wGIZ8JEz2Mta2hjSdIpCQ== +5.0.0-beta65 [Build: 1632210487],Linux,ChmllHZUolNrHhaBK+FHMfOBF4X56zaGeDMJ0qLzUZJz54UCuBiIEYiUhn02F6RKrBCM6fQ9I/MMzYOv0PdWAw== +5.0.0-beta65 [Build: 1632210487],Windows,CkKf8FYi9nWa5jRxOUQfvAy/2MYnSVE2Oaa2cOrOKYqRahpzUmsy14wwd0+ZSMLVqfG08EOpaVzeHr+7ySpqDQ== +5.0.0-beta65.1-rc1 [Build: 1632234637],Windows,QYXj/5id/Kzjb+dbkRltV/ki7JpIRoJ2/nx7SNbXzC47XBT/iiQ5EiLI0F9G0g5V3UuGuepBnLyN7CeGrX0eBQ== +5.0.0-beta65.1 [Build: 1632399768],Linux,+wjy0tnkSfyxh/vRP7WqudF88ZPMjdcRC6MJWrtGbAJMBxbok1FP+3mUNyexlzcG1ZVCIv05LZ8CGAYzunNRCw== +5.0.0-beta65.1 [Build: 1632399768],macOS,GsPT87agljBvFnlOSNWoNV6kLegxdYeKp/o0eeGLNV2e+4E0S+YE/eEAAS8kZK3F8b5rDR3MdvVx3W8QYxbwBA== +5.0.0-beta65.1 [Build: 1632399768],Windows,pSqFVqZhNQVc1GcMzMV9MyynGj8wLNf/xW/QcymXtsGJO11dIqdgqhEIYrdadMyqnUhhMjNAMJeqcxop+pI9CQ== +5.0.0-qa-66-4 [Build: 1632410203],Windows,k+dlfbWu3GtyDXonTUkRK/qxEbl/Uuwo5ZWXDnIvKud3mSm2VX0VUyFzf5PGYoXpxkgJ1HtyOP/UhMqQ8uX5BQ== +5.0.0-ms-2 [Build: 1632754860],Windows,/3SnS+0+R6/HruDLsfIs7d8IpfVMM9u013uTY9ImYpIXOFOINGMUUjTRhwA+oZPRaqEQf18uAZ93EzXOJbQ1BA== +5.0.0-qa-66-6 [Build: 1633006583],Windows,p+DpdQ4Fi8tdnMvVP8jCS7IO33hVftvHZZD6v+szW3HzUJFA4Ueg5gz+lCaMcb5yZsPxDdIzS4QWV47KB3qcAg== +5.0.0-beta66-internal [Build: 1633604766],Windows,PGkf4H8G/y5n19h1JmwUZpDt07U+BjdXurYzaUyGqW5J0bdZSVJlR5teIb690XAFGdyFX6R15e3bH1XqXQXRDA== +5.0.0-beta66-rc1 [Build: 1634917358],Linux,rVTAulwEQD1FGNG753/mCrbMxZyG0ZBYBt8vkJiJYcGO+y6Q09/y059jMxqXAARspIDUNhEgoIUt/jnYNZFXBw== +5.0.0-beta66-rc1 [Build: 1634917358],Windows,f0+4Ff3AmbkzP1J2fQmgdp3WwaYJ0A5UcMGKG+ze+PxhNMEWAdM0XzixD9wj6lDR2XiOzVR1i2Q/tFVv8Nj8AQ== +5.0.0-beta66 [Build: 1635340287],Linux,KIEvK+JNGlzOIN4wzetVEEpr1/Gsy035+kRP4uUANv6efNYe06yTDHqwk13GDCu2Z03dO8XBs/ZVMhDIEdWQCA== +5.0.0-beta66 [Build: 1635340287],macOS,FNlzmJhKg0RKPI5GpYR0ZVZlxcFtYpAd20mCBVv1XKzGyR+kaccsaQhecq3aclEgKHziHMDolS892C2hOcYyDw== +5.0.0-beta66 [Build: 1635340287],Windows,81WF3pCS63ISYJOQX+OXXxITSQjd0pu/Ofpp1cZu3E9VWoMimP1YUCaSBq7kAeZwcNrbVJJ4C6sUJEIDx3Y0Dg== +5.0.0-beta67-rc1 [Build: 1635512518],Linux,Lz6odZRsICbIOwjBalAYBU2fwc+raJDgPi7XM620u7C1A/+OoGKuxMthkOWZ/JW9dlnYs7d7Z8QyLop3Qa2uCA== +5.0.0-beta67-rc1 [Build: 1635512518],Windows,e6F3H0g2IlMkeMCJyNZYgMFW1OSRRC1SF5uWN+gx1zghfUWUtp08zux9tH2ySBl1e5YyWIP8mOBXgxwFJgvdDA== +5.0.0-beta67-rc2 [Build: 1636124060],Linux,4ERq1ihEy1ArHecbrYZfnQMvHFrInBYYsZnmMupkdpoDaRiviSbVlTXY5U1q9njYrzsj8s4EI8c2A6x0PV46Cg== +5.0.0-beta67-rc2 [Build: 1636124060],macOS,P0Iy6rBbnsYHOVt7y7/nbepH0eoopP8PzLc6JMvqOUE+uoInlQmRcy3mTfNyaQSBgZ2NTqw2NFbBP7Kv+h9QAA== +5.0.0-beta67-rc2 [Build: 1636124060],Windows,prboyJmD3J7qhFJ2/tnLxVk2Uf0moxggtCLZyEpUHhJiKiDKR6QdeTx5K4u2TwBuvK0tFtvj058Z85s219DMCA== +5.0.0-beta67-rc3 [Build: 1636470636],Linux,cS+PB8d4YtslCr9Z3jlNfNhuSdqbUfufnn9wbbDl2/h4Drb3okxvRS+2pDjZASYGkOC3Gf+VUkGmZsrDg5ftCw== +5.0.0-beta67-rc3 [Build: 1636470636],Windows,dXRBa//M5qWE64qfdGybN84JnOLbMrCJIReuv2c6eViWtjyE5AcLVE7X21DW5MtMGXeXZB/qwxbBzPHKErxrBQ== +5.0.0-beta67-rc4 [Build: 1636703696],Linux,sLNPLyXWN9w+p4qhmmWJeYy2qiD1GYpBUuJVY9BYuzM6Znm56zpseQqFCvS43of5B2zb5DsCgm87WWx/+3kOBg== +5.0.0-beta67-rc4 [Build: 1636703696],Windows,2wcKHWrzsPtLLv4QZTTfKZCc8narFgsSTlq7z9w8egpfx4jt4Y0ZLQV8usasdO4AaklKY/Y4072tJiTcP3XFCQ== +5.0.0-beta67-rc5 [Build: 1637773695],Linux,G9yoF9j+CgxEDcDpFJjxtokCXYQxxPuMwFKHuceK/p2xtae6CufhkZh5ebCYKHHqOzLJ8SshC8IlAn8QQgRmBA== +5.0.0-beta67-rc5 [Build: 1637773695],Windows,IRTxy8FOruwU0CtxGzE/ix3zE8IBztKfdcjy21C5kScKp1Ne/r8NpOF8r4H1PYX/FQw0PVkQY+/8kK4uVXS+CA== +5.0.0-olm-refactor-1 [Build: 1638283086],Windows,uUXlxNlsH6NampO9EAjYT1r0/yKZPyaGtP986lv1JMGsMq3sPz4OEqCjyG0p+eJT2sLx8N7pXoiFw6K0e4lRBw== +5.0.0-beta67 [Build: 1638359901],Linux,oywbpFbPkRymBLBhZM1a1LPY+6oAtqA807kBF0EyB5rpEsqulMXJzTlECjVf4eiWHLTGL/VkpyLy+3yjcTMfCA== +5.0.0-beta67 [Build: 1638359901],macOS,P8sgAyL2yCinMHqSJ3chgCRS4D5rN9TvAyuloSeildT9lEivLK+5mxvAWndFn8uOvf8bZTDi+TxSmfAzQ/NVDg== +5.0.0-beta67 [Build: 1638359901],Windows,nlVdu01SISGsf7cPVeYc+1kTHhEsnD1sZtaqeZaMKUpPFCAreuDsZ3ECqm+DbVg7C3ZbKcxszlVwVxwroBOADQ== +5.0.0-qa-68-2 [Build: 1638544382],macOS,G9sFGBu0WBzKRAlGGeVJM0bOzUSsHiEZb35cVTfcvt1xtsNtsRsnw9sMuweDGuB26gzE7ajuYEdBX2FbMRwyDg== +5.0.0-qa-store-update-dummy-fix-1 [Build: 1639400688],Windows,SlypMzSvf7FKTZceC2SgvNaZ9fOEZu2cV7mQr6Hf1CVSAKRXZkmlucUvKlqyU9Rj/2s8RZoLwiYrKjMLwILYDg== +5.0.0-qa-store-update-dummy-fix-2 [Build: 1639646105],Windows,wUm+ktQaSeaEYWwV20nSPC4ZPERsA57UeCJx8BJYTxiEGCKEYdBZrsAm+jIrwwtrO4KD/k3ICO0xS9jzQX1YAw== +5.0.0-qa-th-16 [Build: 1640003749],Windows,bjPYVLTJYZk2Ssn3yrNftHm9azsSAajfr9VLP+RAWueV4AN3gqIq3wg6htQu4AJkjY59cJZAOEdfrpF8C6k7CA== +3.6.0 [Build: 1640259570],iOS,4Bk+MYCta3b2SlKl7cVMrRgNTCOGv4qPOVpQ84c3ueaDrOzXcI0REIjLJ/Pcp9jhIJ+Jb1ODZBT8dZxbm2w4Ag== +5.0.0-qa-68-7 [Build: 1642008173],Windows,lBXxbwIGhA065UoLqw7or4St5qssnkFb4Nw0B01OLNdPxGvGiWgBd4G9Q7J1EnX86g7KqLYRY8PPbiP6jr1BAw== +5.0.0-qa-68-9 [Build: 1642074370],Windows,HaUTRwyKMGRUAK1SJcnCy8sPXh3bx8qi+LsKuN9bPVfV1R7eMymV2Zx5BUVbsLJxINxJZ23bWUH0eejtIgQgAg== +5.0.0-qa-68-10 [Build: 1642155836],Windows,Q68Iwg2vo/mfH078GGj2OzRIXiucddLud1txjNkH2ptxDvAfClENMBKjLpfoEtoiZm5XYwIxeyTskNc9C3YOBg== +5.0.0-qa-68-11 [Build: 1642428288],Windows,QyavWsP9ouGPX1I36sB3aWXbT2d8OwZRUDoHkY8OBNvJbGiTXfOrVrvR4LD+bgvsc+VuOVlSjx0II4pk8GljAQ== +5.0.0-beta68-rc1 [Build: 1642505026],Linux,qR7e88rbZLNH138DTrg91DtKoOCnsQ7yTgmVBXlc7WoIuJ2nd7Ucjn00AzM9GM6SZkfFvF3D0HynflxcxA4hCw== +5.0.0-beta68-rc1 [Build: 1642505026],Windows,EwORWPWSYjN1l3RGQFWFcJ+fBCcFj8yHW40nb9srtQZ1iLic1qfPiKF+7jzNLHJS1iS6Qx7UuBqONZLSz0X8CQ== +5.0.0-beta68-rc2 [Build: 1642605878],Linux,UfX2E2kPPWRGRrTzEbKJDwRVOh5HEFX8pg4vjxwA05hn7F5xEXb7+b0yucRD10pQBq3G/jHqVfJ1RlvKNNO+Dg== +5.0.0-beta68-rc2 [Build: 1642605878],Windows,4yPatak9NIsDMyCODgDOuaQNO08poDm9+qDgd58GC7wsvtxt99iT26gZ5YmNS8vYk5GdfQCZEy2QzfMRs0FDDg== +3.6.0 [Build: 1642760631],Windows,YtVPmw3A0aPfTqOU8OyQVoDuKtPBCtiFrJgA1oajXRLchnKBYSCiK2K6Q/mQs+cn7cmVp1ZV0+aYGvUJRQLNCA== +5.0.0-qa-68-20 [Build: 1642762634],Windows,Sx7RQEHiEnKpD/CGZ2V9StXKVWrsvgDePlkUvBhd1VcQnkQ8ShPauJGHic1MiAIv4+9VKCuF2dMuOUmzjJTZAw== +5.0.0-beta68-rc3 [Build: 1643385351],Linux,DHKCUoEm36bI1t7wBpq+ju0HyVXUp2eRgjV58n2C5a8kAHDz/jgiZzKSJeLPx0bZuAd10Gv2pNqEeb5UkVbIBA== +5.0.0-beta68-rc3 [Build: 1643385351],Windows,G5+2JSGlehLUwn5DzNDL9/8zDGmSdHAY7Cg930aOeufmUyJmXgpzS87hkhaMAByDArp+Td+WLTkJxn2wE1HrAg== +5.0.0-qa-68-26 [Build: 1643637044],Windows,WNcgfD6kvSXSzUeQaxVxIiX0e+xv/rKBdqSm/ORXeimArty2EoCA5sm65xpcy0FHOG5BciX9JJjvkSIdB76gDg== +5.0.0-qa-68-27 [Build: 1643641086],Windows,hTifgq7hQ1G9S/ULyEr2NHSteil5T9KC8w65e+UwWkJqhHSWgaA0ICUOSB5J9/yd0alFJU/6XpjoqSFW5WTwCA== +5.0.0-beta68 [Build: 1643723246],macOS,hnLrqXS21edeNiHiaU2V/Q8TGloQKp9dxh1Of+NiLEJB1koDfY1bW9H31oVLrSSH8U35kC3WnIdcb/J7h2/mDA== +5.0.0-beta68 [Build: 1643723246],Windows,CW57oWrfk7qPSrRifg+pNIUoFGl/7fjoCcEClJqRRNtAK0CjCnx99/auvO3BSB9rPRRWq41C6q9VuhVugKP9Ag== +5.0.0-beta68.1 [Build: 1643727795],Windows,jDTnopWRErSf1sO1vH6Yx1qxZPNv7hwZFQRvFdeqe9Z4hQHrY4Mgt7lhHDG7Q2H3ss7wZ0D8H12CnXC5RNB5DQ== +5.0.0-qa-69-5 [Build: 1643982067],Windows,UyXxYq75NUY2oTdYgKFBj/FrXjbVVgzO7ly0CBIswihoyUm5UiBiUMZ3TVIparJA9JOnuleiDkih3fhXQRiEBw== +5.0.0-qa-69-6 [Build: 1644241206],Windows,0P04q5dEPdCWHifYv7HSlrRWM08LeiQ09+1D8U6kU9gzf1cHJXw+5+FRG6dNb3dzzS6sQnTZtsVjbAF4h5uvCg== +5.0.0-beta68.1 [Build: 1644243684],Linux,cDEN9t3q4YMtjOQ6a4Yp+7YnsdxDE/1lfhqFjSBUrpoyEqKarLkqGLgNop3vJ59trCSzqJzXskIHFWXtggZtCg== +5.0.0-beta68.1 [Build: 1644243684],macOS,1EiWEK4KR4b4/odYwBhIy1b9dSj0ffNkN23RJUDem2JCFVSOExCkVx98HEH/OhO+OzThC43LX4++0eGvoDYkDQ== +5.0.0-beta68.1 [Build: 1644243684],Windows,vONV07+8AMY7TPSRMH0PB79b1b6jY30cMoS6X29yfSp0U/S8eNTyfXz9fHrUhqdzm2jcfYSrWNCjjMIfGPq1Aw== +5.0.0-beta69-rc1 [Build: 1644575557],Windows,mgxRbc8omXUpB2Zxs7oZfL7ocjuSlcUTH+lV0RY60rY2LLIdmLsitPDYQbMkzMSdIwCMGhmKWJPUN3LaSy4LCw== +5.0.0-beta69-rc2 [Build: 1644595314],Linux,TOhCAXR02A4yFiLwABZARKrnamhVM5mLhmL8aV6tzyFlfaHwUbuHYcIPkaewSyaOCEgD8i3spZ/+XqS+4n6pAA== +5.0.0-beta69-rc2 [Build: 1644595314],Windows,NaJjYxfhehKp7xp3cRHdFFL4fl4LKuvMEL55y+6SvBwfIsjVx6MFCUNgAqc39ZPsGQbCXNa7d8Ik/wmyrBQAAQ== +5.0.0-beta69-rc3 [Build: 1644660819],Linux,p/nRODqs/OFcPMhstqmAvft79CLf1Cgnn6NAslbf6NGPWZykMI98FLeblPR09k+PoeXi0hj78v41qRGVFPIABg== +5.0.0-beta69-rc3 [Build: 1644660819],Windows,GB3DbCn/JEGuDJ6jdafCkzIl6u4O5zDWsUdQUfGyPMRtjF/63foso4f49B0sqsaJUIXe5wpgQC5LGqVOsGOADw== +5.0.0-beta69-rc4 [Build: 1645087682],Linux,smuuiUwigzbiDd6+qu27VH9mm7PzuTmOlec4rsqND2Y9RDrZewkl15Svx7ZFApXZGYPdMOfRnnXX6Un1Tph/Cw== +5.0.0-beta69-rc4 [Build: 1645087682],Windows,NqR1eiD/HyG4Z6/OdTMdkKdA6SnjHkvx4ZPt/wVMdD0lTL3QMpkxkl3/iHvb4ZmZaUFnsZUiWgoG/tWorkDgBQ== +5.0.0 [Build: 1645113667],Android,z2LG+Ab8slNy0covF7NttNzwHPhF14hu+EMkDZwjIsdvU2BU4bTXjtkI2gjow/N/p/ba42SE9MLTiFglXuThBg== +5.0.0-beta69-rc5 [Build: 1645448271],Windows,9rCNmBrEhBaX2bzyrW9kx2S8umP6AELtt11uPclBC2DNaOW2aSUJSA3LkZ1m7Fu0TPeD908+XXDnWlsHvRUYCg== +5.0.0-beta69-rc6 [Build: 1645527496],Linux,4NIKPJar37y8+PnVe/mTc4xluPyi4gSXvK5ZWku0epo2XgQuJ0+AoMDmWVTyfNue/VupYBUdzEfiDifxYc6BBA== +5.0.0-beta69-rc6 [Build: 1645527496],Windows,/clk64cVjel/kF3YlDgiWAJkN7PkFrjHKyMCK9tfcxeV/+08Fot14sXLSaW1B36qo9qFF/kUUZGt/Ku+eZn3Cw== +5.0.0-qa-69-12 [Build: 1645630715],Windows,UnIsz7yDLr3lnzt2pYKAZNC1g8oLqv3ekuTqskM0ZGeso0Y7GhhDMZARCFrJMWVDccA+fzpMI25PoPD7KfCoDA== +5.0.0-qa-69-14 [Build: 1646064573],Windows,DHlU9hofr22th7vP0Kii0bnJpVf8yh56ctIPD8U4l1IKY+Yc2a1cw2Mw3q0fT0e73W4uskbgUkhUflSW4QHDBQ== +5.0.0-qa-69-15 [Build: 1646165194],Windows,Hev8vdybbsX2FIMW/aXpfbmYJGg0pgYi0nLHxeMk5i7su+dcVNKAXByM4+De8wcJEQ+nO5klrtA/B1HayyJABA== +5.0.0-qa-69-16 [Build: 1646319264],Windows,S7EflYS+8UCKLTYgWFM+pjDy61/4E04kqRevUmIEu1sKhbOVpAWlawVboUUybjoGOaCxauMFnjablj4Q5NpYBw== +5.0.0-qa-69-18 [Build: 1646666161],Windows,TjHJin1ghKvzLubbMJXy6ePCPcX2tnVlVzS2cZYcT/gx2uYSQVLhZxF1pHHC0ZgOcF+HIUgmY0UbU+oj4JikAA== +5.0.0-qa-69-20 [Build: 1646829751],Windows,NpmWEkUZ1rW5jSnCktzCnU/7A+uaUBQ0b9oyo8IRgOihNQL2i1CsEPgssj0auVU86lx/1SS15CI4uNjOhRMfAw== +5.0.0-qa-request-chat-7 [Build: 1646854452],Windows,0iRGPzh37MelxPeKE15K754jAi+yXJ2bu+pXV1ErOFbEF504WtUZaAIoFVHBNheIVdSCrxuWFF17xG1w2gSICQ== +5.0.0-qa-69-21 [Build: 1646935163],Windows,06E3t4+OxXNtYQMQO7p87FnjUFzsiRyBG41nbdoavLuAz9aPmMG1Hu865qRfAXIUioQgVlLY0nJj8vdZtntqCw== +5.0.0-t-2915-2 [Build: 1647254017],Windows,1mnBwJhwdrkWBtHRePQtlYRjFmGnQmyglqRrtsmTb9sj6guDUY4Aw/i98feAP7O1hZO461QvAgtNfXmMq015Cw== +3.6.0 [Build: 1647511767],Windows,S9Ow15joaTizvIJ4xTf1FYpkn9jHIzO+ShPU9Va/g9UsF70+LfEQBgneDx0llRzzbIglcXAQOvm3VKOPTVASDw== +3.6.0 [Build: 1647530723],Windows,cwRrfUAx3jpu2AC7UmX2z5PrjSEijHFVmwoh8W+6y8mmxHQMu6CJvrr2Mf/OCNmGor82fCjWqXwLSK2McVx3Cw== +3.6.0 [Build: 1647595742],Linux,jyIo8JaV2sSEeilGEIGEdjm7q5zA6GT6kZH0QcbtJNzuzgjQ8FwSbJnOY5crSys9zdQNIEaaUrZliJowClUnBw== +3.6.0 [Build: 1647595742],Windows,MVrkchf+oadHXHVZGRrY/WYg2QH45rdt2MRgZ+0UA6c15L2P+05u/5YiG+4Zp82XLsv2xZYSuM99xcOoLxaqDQ== +3.6.0 [Build: 1647855949],Linux,z1lAocn2kKnQ24Pt5pOzfRx6Tp+vKSxdb7BINN7zYaWceYi2cnugGMBGzqN6MkStI0ROHx7RCpBqRWKub+YaAg== +3.6.0 [Build: 1647855949],Windows,xPqml2CxNFCbEI+ZcyCcIP8CrK7S+IT4I2f8DyY41UIae6WX+wujSflbGXWrzssEmsYh5vLoSn1b2TmHyIdPAQ== +3.6.0 [Build: 1647921962],Windows,gx/meu4ewDSqByAxHDJ8ordqoUyqC/lQEeV0NzgWZvAtQScqDGCEOtNzDly0zKfRQ3HBidT4EUJcLZIxIho2Cw== +3.6.0 [Build: 1647928456],Windows,redEKXeLBo6GOtHjP5Rd/A8zadfkQe8kk6eM5EawvWHpShAB/xRWtNuZPuJzZQbhO+cytH/CM68huBUCgKN5DA== +3.6.0 [Build: 1647939487],Windows,dN1D99vIPuicNDyZfcy//Pm+IZpvRZtE7eaB2oPuj3UuMt4zSTlZY83gNwysucxzNLPTnFIWgGG1HXzaceyRCA== +3.6.0 [Build: 1647949292],macOS,0U/IWJ1DttzwFIzBp3R7xfNJZsaOFDx6iBLo/A5SevQLE6FsAIfY2OpQe+qi3fFjMF7pp56l+fdR8UB6wgSBDQ== +3.6.0 [Build: 1647949292],Windows,kQ/P5bPJ2ier+LCRZOmnNeD0WKmFrLT9g3gth/Jv+EE0cBliQB1t11uxV1nclPWVsVIVIxQlyvl7ryV/cMJDDA== +5.0.0-qa-69-26 [Build: 1648062270],Windows,Mgd0GL5Ui6UiGQN0nSTkDy8d5fxqRKtohpazQWJrycewP4D8/iOafBpaBn5tKacy0nc6Q7Zbx9+MSnwdilP/DQ== +3.6.0 [Build: 1648153885],Linux,cjqAPjXF/Nk3PVVcns8aKSJoVLkSe2Y+1gxMiUCsG8ZEOi2tixm7HDfLCrBwfxuwD6LOOPaaANnjeb5Q/GSPCA== +3.6.0 [Build: 1648153885],macOS,Gcb6nEkVgdA0jyqR1O5xYWNHL4LLJw8al++hABOFmO4gUbuTL4iVUD5tOsSLAVdpKKcjDlBoA8i+d2WFMWWMBw== +3.6.0 [Build: 1648153885],Windows,j3B9t27eIoSbAiLqV4YwLoPIeIp1Hq1lNKpArE1MI1LPtkLF9llUAERFtkhcQH7Ofxld2jPnVphYYcfkcPZyDg== +5.0.0-qa-69-27 [Build: 1648222308],Windows,aztxNBrsEXa2jMs1rQzl0RQjFsdZgfU9jBGXRKAwxm+gigqm2hsGkDZbwasCR1evWEekf4Oo/guXlCkbg4BQCA== +5.0.0-qa-69-28 [Build: 1648740980],Windows,yjCmepdVF4RRCBVDcq1dcLe4pmFAxAbIoZoqHWlAXZjy9OMUrW3dqqs5u4BsbJOAA9/WJ+5apc85umalkEmAAw== +5.0.0-qa-69-29 [Build: 1649081557],Windows,AbKy5mV7Xwtt7V7QWeXRPoTomTeK74zmx7XdQ1o+mnRDNig6Yi6HzYMRUoAj0kzRxLFke7ASg8mjWNLjP7CZCA== +5.0.0-qa-69-30 [Build: 1649229901],Windows,jsY5tIebotP8ZhB1ZCCd3GYhbP/P2RnhObM2VQEElO/5mMOgnvofcDkvhWbPDKbhvq0cIXBjix4PzR2nrO8WDg== +5.0.0-beta69-rc8 [Build: 1650464356],Windows,bBzPQVPQTxKvaRyAT05saGpau2J4yDZ+YD6fEaPSuwGllmGqXm6i9DM0WihlZsc1utRuTotgPyPE8wRXm9dkCQ== +5.0.0-beta69-rc8 [Build: 1650474918],Linux,NokeLRYpWfaOqddwSter/EQ7Q6rzByReNAOIeapvIxmQZvtqKUlA4NNLerGaN91hyX/X+zVhOX6Eai0aTRX+DA== +5.0.0-beta69-rc8 [Build: 1650474918],macOS,r4pznM4Mn9nHYbaNz0Ogmg0V868DmLr608lxehO16noWx+Xe/7yl7nAeAmVJ7NWr7si3B0nwSTofpCcW5cW5AQ== +5.0.0-beta69 [Build: 1651157621],Linux,Hte2iR5GHhNzFg/i7sZ6ERsYeJMy9wxO7AqDP9jb95XKTwEku3QJMkQHUH+2o7oV/wktCYrEmfIFZ0rEwxy0CQ== +5.0.0-beta69 [Build: 1651157621],Windows,Pwxtu+IgA90au8FGqOrRKWgACB/LZRaUrB5sLVHyG063GlJRlD4eHv9tJuojYqAppJJ7cMZW/br/FAXZNiNJDQ== +5.0.0-beta69 [Build: 1651486956],Linux,KlhsXgQKcjUalgrpqepGAjFdT95gjzPmV/SRDFn2qf/I/YcEw62GMNv/BxjkJ48gzIhgKxOtghWJKmzbuqMSCw== +5.0.0-beta69 [Build: 1651486956],macOS,Z4zx1kgCpeoOUM2OYW507UacXR2qU5dHjtJz3W/KZdB4B401MloZc3jKsU8Bc+L0NHkqxZBT3/3xWaleOZiODQ== +5.0.0-beta69 [Build: 1651486956],Windows,aPVvR6zqJNAuTtOa+t8OmUOljU9GwX2SovmNyzvbJV+tMbZP27mHoBSyl7ejRly9E+2QW68pBejlKYjZBMXRDQ== +5.0.0-qa-69-34 [Build: 1651687542],Windows,wxe9CeISam7/fSMQKO/zwzxXyGAvZ4tCTrZSY7rrkqJRjIclDrqFMjIFy6BQfRF7LxxMWstp+LLglMYOd3Y0BA== +5.0.0-beta70-rc2 [Build: 1651730595],Linux,ybhQnvk252kC2QPmGG8BqBfEU98t/nlyCIbN/HnAPbM4EpacsZLz3ouiwpBMa1/xfox8BMbFVW4XJQ83lQryAw== +5.0.0-t-2915-7 [Build: 1652106526],Windows,NuSMkmw5YsKd8CKKQkoXnc99UDgvZCWuSXNp/IE3+8tyrZ3t8wur4jqUfnBRx3x5gzuFDp9sGOfryJVrWTmDCg== +5.0.0-qa-70-1 [Build: 1652113760],Windows,tgaxJYO8MasDp8oq/vRZ3pMDEYMejSzpOA3nt/8+BViY5XyrcwPOppheuKFv5Me+3IHtWL1ssu9CZoufB0auDQ== +5.0.0-beta70-rc3 [Build: 1652281502],Linux,YRJLYVeUXVtz5bvcCALhEqRI4LZtk9+chwJLIhXhy5oojQiR1gqT8KaOVa5oN7ugJRBHPx73hh6hplwnLtEMDQ== +5.0.0-beta70-rc3 [Build: 1652281502],Windows,mI7gWzwqSXQ4RKQE/KxsnhYTBhCVVQ8r4c3ApE5naXa232IsFH5hPHAdQrekexULRQ4Qn3Dh0pxbXVheIb/7DQ== +5.0.0-beta70-rc4 [Build: 1652448464],Linux,8G4ARIsaABohBur+uvAXxA1WtuaiKE7kCF7Os946xAiGou99vykuzDx9lEAh/FHtD2QLTHj2BMbpATiLGXy0AA== +5.0.0-beta70-rc4 [Build: 1652448464],Windows,JSogOYppjLZmIzz4FRt2eBciuZaYdS/LdoUsq2KvF4D3sFByBC8QdHpuEqJPmTKwCgleWPY2fCkPrCLVCliVAA== +5.0.0-qa-70-2 [Build: 1652873884],Windows,nmWG+1gGxxoCku43Bzm5M0h7pcg9IlZNChTjq+mRVmdcQXAZ2+tKUSncP40qiGyKlJMWPUwDbB59AEdb6x3fDg== +5.0.0-beta70-rc5 [Build: 1653042652],Windows,hrPP8RAT3TtakXdRpu+OpvlJqxMg3O/xjeAC7f0aYvumQCQm3CztZ8fbAmTyxZob2TSKzbVZvPIcDlpc9GN1AA== +5.0.0-beta70-rc6 [Build: 1653467861],Linux,7qYi15DersnRo9GTgqVyhGhvHsGOkBuHYWlHIKJ5WBSHlwx2xve3GrKazde+ioJgSOv47RtxU5g6xQYfVqZOBw== +5.0.0-beta70-rc6 [Build: 1653467861],Windows,wk0OOY+kxOsgsTAbMUtcXU80quM3Zq2CyhTQqww0c9xzZx8jHr+8A93DRyDp/JVO+vhqpvvyaiIWAhsT9VJ6Cw== +3.6.0 [Build: 1654006450],Windows,t7q7tpbKMrsrP1iK+FWDRXAPozSTuKipEH9eRqzcAezF1aLTfh08YMhw8RHOZHaCCC3n7qxtEhzXP1cwS6UbAg== +5.0.0-beta70-rc7 [Build: 1654093906],Linux,3AIq0BeGphKoauDyphnBY3HkIa7Si02lf+dsTSFh1lGBiUxUoPcbmkDDFQ0ODyNc99YHwNkUZMhtpXr/g+WBCA== +5.0.0-beta70-rc7 [Build: 1654093906],Windows,ZP9eAW6S8zldlCaIO5EF89Efb91dUMVQs1VLfcOZkfMoifuCz4zCqNR9kEfEzTTniik2CapTK3klbgZCnJ9RDQ== +3.6.0 [Build: 1654160172],macOS,s/wew7fOQzeywZuGOlDfV81SZBV20Z5o/8MoHfYDyaA7d22NXxn1Nb5VMPbiJVxcJxNBuJaMP2BvZEed543cAg== +3.6.0 [Build: 1654160172],Windows,hWniX9AkswRWML0/YinmyDFFoSLc78sn85HTjgZQh8764NhKIc4lKTfsSpyVov9VSb9SE/Yjf9WA0N2Q5x/oAQ== +5.0.0-beta70 [Build: 1654676785],Linux,n43ssyQtR7el6jnlpNEazxzOyZ44M6RkCSehiTFUFh95ie/XXDFBEw7uDsyamktGqNFGdt1IGJ4sy5S++vMsBQ== +5.0.0-beta70 [Build: 1654676785],macOS,K0h0JufWHcKF8a6b725AyV1YXJIOqbvW5JSHaQdxxcgxEsNhQaVCnJiQCcp7TGDTvgIgV876z3dLIk8xfG0OCA== +5.0.0-beta70 [Build: 1654676785],Windows,/KFF7obhEgt2aJbZOCUiR824u81lUPlELT1CY32GJwwjap0RTu6LezXfejDdM8nJoUrDYQmXMu+dBVshNLulAQ== +5.0.0-qa-2913-2 [Build: 1655205340],Linux,N6AztmwqY4uAU72SYYo+AQKMktUPLNwzetFmBsgMbNu0K1yBc+XdKtGpPk2nM6NW42GY+Zf5UTl3e9JTTNqkCw== +5.0.0-qa-2913-2 [Build: 1655205340],Windows,sVMWX0mvYy53XOm3APlfxWE+wSDxBie3UeiurJo0SWUrPEV5gOn03d0ZD0OqNPcwIzCKOC2pxQ+rTQ91OCWrAA== +5.0.0-qa-2913-3 [Build: 1655733884],Windows,rLEgbE1A7AZAjdgoEkQSkEAcogHJnnz0TigqPPQ6mwAIHKpbJIIpaIKc0hyVn7ELl6B58W8XQ0/T00gt6lg3DQ== +5.0.0-beta71-rc1 [Build: 1655990880],Windows,+fye+X6BDMa3nOA90wBTAqZQFy0O1wIGu1/cpGM5+iyFhLS0JYUk9xu3RlXviShDVMazH2JZ0BJ0eDcobT5tCg== +5.0.0-beta71-rc2 [Build: 1656340141],Linux,gKBdAhcdB/S/cXy/oGXWdTvxjubFr+hadQ3ONE6XVp6dMzWNMLP4MgTOBIxGu5TbEMlSeUHHdZWHrpr2CUD0Bg== +5.0.0-beta71-rc2 [Build: 1656340141],Windows,C2Wq594czOp76S/4Pc4mtfEX8o862BJmMkmlSMe+Tco7xgykVcLyblHrE3kp4qeYC+71Hr2q3/Og5C9YdEBNBQ== +5.0.0-qa-71-1 [Build: 1656589081],Windows,mKtr9xGv8lQRCJFt8+TKF3sWtlN6uvkGYXepfiGfk5I9TZQsQqrmJ3Ji1xB/BSBVqJoRAQR7fN8uflwKPiLKDA== +5.0.0-qa-71-2 [Build: 1657105351],Windows,DxobPbJpTnYap0LcyOL3+XvYi0ji1715HukXtOn/OUSL4lIyYUh8bhNNrs1adxe12+B8gnb//YjHBNNMmOxeAg== +5.0.0-beta71-rc3 [Build: 1657116184],Windows,D2rmZyzrtXmDDFoMsmSMtLwZp5GjHKsr5E0DAmery/c6THt3qUgq+Ft25Yd3J5BchiHFXW0b/IjYqxPZn4vzDQ== +5.0.0-beta71-rc4 [Build: 1657196441],Linux,dJz/qSD5sUDoZRZhsAN9XeqVPIcnq8i6rM0wwfFFrMc48fN13j+sMptaFh2TonzDo/S9/2UAytN6UUDrF5nxAw== +5.0.0-beta71-rc4 [Build: 1657196441],Windows,N1UhStcYNBaiPlFb1DvBha6wCFx9SdCWnXdh2ZMRc9WYzKFHXVu59GUn4IxAAH1M67dVwIYRJQpefDsas3rOCw== +5.0.0-qa-71-3 [Build: 1657550670],Windows,LlG39Ix9oFdfIjrjw40un1b/k4rYag0XT0yi7Lp5AQxQ/WqJCiPut9oO8HZZ1Xxoq/XJJywfnjwxKQOpN2bIDw== +5.0.0-beta71-rc6 [Build: 1657710601],Linux,h7en9dun2t8UOPN3jRRJlf4qLI6Lj2xr4UhqZdIs+H9QqD4Ox9C4Iwl0kjgldi4GV1AbuwXi5Fkfe72AwHP3CQ== +5.0.0-beta71-rc6 [Build: 1657710601],Windows,Fo4k9MsMV7HQkoUxNDk9jCd7cKEmFXCj0bS83yij0Q7IyBRvcg2PU1bpL6YPxduJ5ssCOjS6AdB4h9XS3cdBCw== +5.0.0-tra-09 [Build: 1657880771],Windows,7tCcJLRtLuVGl8SVAdwpsqX5c9k+cNuQsuAjXTcvk/DVfITmZZet7mSh99qb75T8yZnbcfZOiyd8KW23BEXtBg== +5.0.0-beta71-rc7 [Build: 1658908364],Linux,1DxbHsONSNvnCT5VHmwjx1r7+E6WkbNdoJHQK+9Yo9hLviUbJ1SyGk1okkYc45y5rYUOls5/9A0yLhmn87X4Dw== +5.0.0-beta71-rc7 [Build: 1658908364],macOS,lqXrUQqxwOTLO+hAH0DoMiOKJtDGE/oO4p7dkWudsZx+VNpepuRMLzTff6RA2XAqGqd+McHK90ohBDW77ZUYCw== +5.0.0-qa-71-4 [Build: 1659089293],Windows,kmmMWX1liFabpUSxVFnt9FcWylRrqJmEQmkaQ/Fv6EB4vak5Y9ld2gkoqpp4ahWSf4+OLQ0YE0/sLO71yIekAQ== +5.0.0-qa-71-5 [Build: 1659598962],Windows,6/S2eqmQq+4D6OcUY/FqbPo++n1aM4NU6NUJhe26v3IIYXU0igeF22Qw8TgxwXufeRQjR+F/LoX5Q8X+6VaVDQ== +5.0.0-qa-71-6 [Build: 1659957641],Windows,hdcRpNOH7DTDDVINjARSm8dpsp5UlK/YmaTzHPZIEXZcrf6qiJeEvW/5vrlGg54GXjUmASNFV3MAVXLWFYupDQ== +5.0.0-qa-71-7 [Build: 1661262442],Windows,L9risxlPhXSqSx8wFpUZz+e+YHA+AEN0n5EPebpjF18hYiGJGUlirLBbbF5QP/URzZD37/3I5KnR0uNw1JhCAQ== +5.0.0-beta71-rc9 [Build: 1661354034],Windows,1PPbMKaszRT2LZOOZJeyiomDd+P6j45NhycdYdBo1AW+1xOQYC4ZG4nTUSprOsAuIjxjSWf4Cb3iVFolMlK4Bg== +5.0.0-qa-3231-7 [Build: 1661783707],Windows,c/OT4xGrILSDLZkndPPdOp65ME/YRJREHRlqySctGfM4f/1T12dNZ0ESjCAAMwN3F3+8/GhpgAulW39R2tO2Dw== +5.0.0-beta71-rc12 [Build: 1661967524],Windows,BoSYWcyXQT0Ry2hfU1wXpGyEie9ZGFNbDy8jPk9Mv0wgs+IPQNx5HtHeFjE4dtAKth04fgJdejDXVI7GZU8dAA== +5.0.0-beta71-rc13 [Build: 1662123474],Linux,rEk3lv0SxO824CyQYSAzIKaR6GxWk251J2NytRRL4pUFagb5UcKsznyhPV0qO2Vn8JdfdU5zMfTX2e3MxDkFBw== +5.0.0-beta71-rc13 [Build: 1662123474],macOS,VkCcAk5+kRgY31T3BlX5fRo68isELG+RyQEO8ZZSh1SBhbmY9RTVxHSQZ4mODJKTsn3qNCSaCWKpVXBdd1+JAw== +5.0.0-beta71-rc13 [Build: 1662123474],Windows,zynXO8tH7q0COrhZJZD//yA223JzNu6nPnN/rt9YwI9Jq2QUNSaDzE6gHJMTv4X7vHsab+Z3g0VqUPIPTyINBQ== +3.6.0 [Build: 1662544077],Linux,9j6NSQpYSE0imFRgcJJKxUBc35bofwSZze00ftKzNspjh63/B899VbJ+zASN4IUm6GK13vNLiOkRyz8SyoEECw== +3.6.0 [Build: 1662544077],Windows,qSw1K3cyE/P3KDtGLB8OHU387sdFN3Ps2ztPfkPAZx/44/uaYl4Zh5qxuQWmOza/KbyefWBkJPxMjN9z2zjCCQ== +6.0 [Build: 1662544077],Windows3.,qSw1K3cyE/P3KDtGLB8OHU387sdFN3Ps2ztPfkPAZx/44/uaYl4Zh5qxuQWmOza/KbyefWBkJPxMjN9z2zjCCQ== +5.0.0-qa-3305-rc13 [Build: 1662565498],Windows,HCuDHsiQvNAn9tNHi8Ws3m06EQcChO3zh0+nzWWhpOaog/QD4PECVR/KKivIh3FTXpsgUzMgRwoZYlQNKcpoCQ== +5.0.0-qa-71-8 [Build: 1662994626],Windows,sYcKDUwhl8ZfrgyU7Xw0yJKV86RXvjnIfLrTQammSnqYCf72Hg1GnVBdWEOURngerrqF7WBW0frUpkYi6d5OCw== +5.0.0-beta71-rc14 [Build: 1663228073],Linux,4HTdstOwcwrKLIokg4SVrMkRtNLj35qfVfSryRYXU6YKg/fIQkvDw7LWVBfxSfdh42k609KuIA8ElXCtc91cCA== +5.0.0-beta71-rc14 [Build: 1663228073],Windows,vWB3J+ostQ8z6ydFxCOe2vp32jgGYpq38asWbXe7gLvPQaNx9gQrc/dPezrauZoUv+7SyAWnuqyQncAb7nnQBw== +5.0.0-qa-pre-crypto-fixes [Build: 1663230086],Windows,CIkiiGfRaghePf9DU3YkDA5gdS4YqcIz/74nNwZ6ic8q+1FxN4R3XYwDnAL39F6S1FAbVM1ulbGgazaMAIGcCg== +5.0.0-qa-crypto-fixes-1 [Build: 1663662700],Windows,HlXCMwcwTIdsnM7xHi9mnVvaru+8QII8ZmhWhGZSuV/hVeDL9BO+/wgdtqp7d9Ql4EyN0AYLOhMBbC0kWQLsDA== +5.0.0-qa-crypto-test-on-rc14-2 [Build: 1663768885],Windows,WxA1UVobQ6diOypmuEYoBZk6wOvfSiPM0/0wZ1dno4LWz8Y9qFu1Y1s4VhleGCVpTHmwNZvaPAxa/GHOSFmPBQ== +5.0.0-ui-polishing-11 [Build: 1664554487],Windows,ClAwrssS0bu5TJrLDm2s+g4TgA77Dmr85W+nhoJq6sLg6aZ2KRB6n33KD3NTKw2lUL1T8xOdEmILdv9I8+S9AQ== +5.0.0-qa-crypto-fixes-3 [Build: 1666096977],Windows,h7dOdFSWU2EZA22ZRtDOl/FxKmMPOAeYlzmcqJG9EwvWZHwpWyFshxWWygCtNAOTECxa5+qbwbgCUSFalBvUBg== +5.0.0-qa-71-9 [Build: 1666179837],Windows,XF9j3k9qcKCXkcBpKek8toKZMBNG3gCj983pca9mT2AS8c615qvRkRIImnSnQQAq4s1EYzLljcnFEMkzcxnVBw== +5.0.0-qa-71-10 [Build: 1666256439],Windows,MvDLE/Sr1L8Pa+y+eHEye5hsE9dIdeWDpZnjXwv7lNE1L10NRAhJHTizhErqU4XyOoSqF/O/6Akss1FSpVTGDA== +5.0.0-qa-71-12 [Build: 1666360320],Windows,KgnXG1mnZ507h8mkOPmIXHsSIowFJMhPm/hdykmd8tSUfp19csom/yWXT4QsnsKUjfjtLXBCjr1murCQgskUAA== +5.0.0-beta71-rc15 [Build: 1666706353],Linux,NAGcBwzMD/GF1Gkyxi5LvDcQIe9wY2ZKMMXVjGEy1meRAY6nyzgcavGVOnO9dxOVgd1bqfllj6HzuWXMTKMCAg== +5.0.0-beta71-rc15 [Build: 1666706353],Windows,UhMZLawOeXuCky3TJPgLHXIPk3iTIR097hwl6755oQhslTUeTtLjZ/GJPowq7RjnJt0zAvOjWSJwxSBhZMNTCA== +3.6.0 [Build: 1666781655],Linux,PdBDIrgplpy9//chwhIRbrLyiQarUll/uEh0xdCcvrLHjY2LG+B/N/RpDJfSZkrXoojRHyjcTPBV47/HXc65Cg== +3.6.0 [Build: 1666781655],macOS,0GQU2HS1HYA14STZx829IzPug8yXuWL9O89x+WSWvJTBhNovmSk+G8v4nzXpfz+B85tBrCdhBSFIZW2Meo6FDg== +3.6.0 [Build: 1666781655],Windows,cKMK6yn54MkK6J46AUfQyuHVij9TYGyOGgWeJYNPBMUmvv5Qr9GUxoeSnNBHTCqV89Et7v01H7Kzie4+tNgsDQ== +5.0.0-qa-3230-1 [Build: 1667372765],Windows,lXuPP3Y0x5qjfNL7Yp8BeGImy7oS95yEmalinun3Yxub7JX4E8ru1xU8HAW8/xVKhYzlOeVrYEwvV4bZwh/HBA== +5.0.0-qa-71-15 [Build: 1667384582],Windows,wlf/D1ISErk9dDTYuhFdOPI5Tv9snRg01RFoFmvd0v1m49HF89HR8DpsM02zOT6M1g3iC5afB7Y1QgEpL1U8DQ== +5.0.0-qa-3230-2 [Build: 1667811609],Windows,QdlYsyxyqIyE6wIXGOCKxjt6IeMXGgtAGBzU8CRZwf/+R8Xbda5jIfrcV87uxinWpFD3Fgx78zgDdRSDOfMPAg== +3.6.0 [Build: 1667819930],Android,DMxIGKedSqo66DGSTd/vCa4bP0QQPP5TYXQcjML9KARTXD9cUmsSzWVSuZN5L4wQQRDcKJ2w9QWxHZP1KQrRCw== +5.0.0-qa-71-17 [Build: 1667845499],Windows,Tp1dTr/0K+XDkRIHTsnROsZc1n3viE0eWS14E39VVcBs51o+1jZtpspWWvTbcCEWmRHx53CPzCRIw+uE1jmjAQ== +5.0.0-qa-71-18 [Build: 1668000845],Windows,WUvAlTTuoTXCFa/st2hB0dc3hKjuIP5EMrTGrtMRUXdSIX2P3aER5AcTyOf3p2BLmoUyNPXUT619x/PlFoB7Cg== +5.0.0-qa-71-19 [Build: 1668103173],Windows,ehpTF8nUjAKywymSuCubQs21DDqyuJugOXuv9dtWSxATiGZ53EzuUkj2Wj4hiiWScEv2VZ5btjr4YSui3DI+Cg== +5.0.0-qa-71-21 [Build: 1668448738],Windows,VlC4gvRTuUkY9H9QktlbLg8qPVmX2ibrrV5Xtle83CQNUZnAj119TCgTPDhE147ZdN1fLO7GrPRNgSfeE5+2Aw== +5.0.0-qa-71-24 [Build: 1668688049],Windows,AqJemaMYTMwn76j+AG5DkGXfmb79ytLdH5tmRpMTkMQ41s4vjr2j81LrYojevsTc8elodUT+pW3LicVJ5/yHAg== +5.0.0-beta71-rc16 [Build: 1668705307],Linux,S8QjXs9J1riVIW/eMtHE5tjV+iHgWZzB2ts7G/K21KEdlsjEk2TR8FTd+C2ouj64loIwhzl/Rilu26ewqC1/DQ== +5.0.0-beta71-rc16 [Build: 1668705307],Windows,j661q6B0F7v1EWt3fnr5rkBaSgP3v1LZtKOfhSsbnNz0E5+MuoDPS71GP89uWdf5g/rvwh8gXTNRqgt64+EzBA== +5.0.0-qa-71-26 [Build: 1669036474],Windows,akylWlFzsOJVvpbNZG0AaDKN7zYfykkto7ZI08ws8MmecZgDidpndxPcfp8/3My0AglFPuRKakSrONWXjo8/Dw== +5.0.0-qa-71-29 [Build: 1669300286],Windows,0PJ3NnIAyxuRQJuO7iHGOysZDEQn9Vf1S5LHyfRQLbbAiiwcnU5RQNtyu5eaWsFOfnqGwI97GbWLAysQqqbjDw== +5.0.0-beta71 [Build: 1670237565],Linux,5+PHxwb9AgALL90T6PtIl6H/En+B/x7RuAtwtsVfCLDgKUEcBNAjW4LTzZR/I64STXv5QbHFrUBBh28VgtO9BQ== +5.0.0-beta71 [Build: 1670237565],macOS,FK2fuBMl6iutX7Zb490ged1StULGIUbNA+i9HH6hqVm2RdmuLQ27q0SzI2i3n2lVh9pP7SZBgItxWcYNAp9IAg== +5.0.0-beta71 [Build: 1670237565],Windows,AGYCEceJGMGnWX3PkCUS4Kaso8LyYZNt9iALUTVg/11505ulqPBlQPygsG6X399SF2FD6jCR4bCOxSTzLlKDDA== +5.0.0-beta72 [Build: 1671465207],Linux,uI8R806y9u77z78GILvKmJB+f3ZXP+by073xKtIJCmNJKXFTTlHqRADAuGEUWbqI9+NaDtSlFHywb5VVxEYcAA== +5.0.0-beta72-rc1 [Build: 1671465207],Windows,wCy5wBohgq/a1VU630R4Vm7XjMincMH4gwFMxZlejhexDhq1jx+D/7fw2LOroNib7R9nURSHbKj9prZG8AtKDQ== +5.0.0-beta72 [Build: 1671465207],Windows,P7cFw4WFvfGRtGtfGUwM5KpF1FK1M3B1aK91ZX3wwWBht8J1fp0Spd11HhtgzXNrHD88yXbBdLqxpxgBxyEHCA== +5.0.0-qa-73-3 [Build: 1673952226],Windows,X1dCHqr0/4KQJe5vRa4F+TG6yFqJls4Pp+x5mAuvKSHMKQ+6bIa4jNVNhlBSMGoxaOQwhObFzHqMb49C4YKLBg== +5.0.0-qa-73-11 [Build: 1676933790],Windows,xSD6HeHTdSi2lt1aMKz+QiaFjaLk8++hczMJvatTLlqIn8Gm6y8kmu43rwdTyanU0H5EQW53mMUcIlV+bPCbAg== +5.0.0-beta73-rc1 [Build: 1677076356],Linux,tTaatH5xdPJ/ObMlbbSDBiov2+kdtlEVw8MF3K4xFLrug6lerU6Xdqalcsa9sAQqhOogDaifRAVpD6oEes7rCg== +5.0.0-beta73-rc1 [Build: 1677076356],Windows,WndD7PSfy+gl/haCDKGrD3lbam0i4l4AFpbFVc5GwVeteR7nzpjE99SvDn0CMMAYk3vYBKjMP+nsAWiylbYJAA== +5.0.0-beta73-rc3 [Build: 1677756122],Linux,3ugSo0Eq1aEVI4LG3+E3CmtvLBxv6qH5hYZLZu17uJC05okFcmdDRRBG3Tj5jKEy2v6y1YOsLMwArDp1xZfTDg== +5.0.0-beta73-rc3 [Build: 1677756122],Windows,A+TukrQZwCKghG/xlGk5Bo8wi0WAKNK/SPfOMZNeCC3G0ZDN1h3/lcbiGtuSpBu5tYd5n+/Q0Pjh3WjvYOEVDA== +5.0.0-beta73 [Build: 1679397420],Linux,7b8MXzq0z59NIrR88V3l/oCfUaMfpNAtosNBj20zWC1fh0vVvf/O+tyG6XiiJfQyEHc+OJ1gbx/z7roErekWBA== +5.0.0-beta73 [Build: 1679397420],OS X,weeF0ZNGrlUvB8vIQCvfLqcNV53aWJqPaqwo+hACJoomwdqZ7n1+VW1RxSedMy/ii/GtgyTbUiCojhH2MCAoAA== +5.0.0-beta73 [Build: 1679397420],Windows,EWhqEP8V36cleD0Cl7AQnG6M82KMDwQbiEObDmcDC5AAF7l13BbWje0j4yNivIOnAwkvneUmRe8RK0LLP9CHBA== +5.0.0-qa-74-1 [Build: 1679398750],Windows,A87gwqv6WCQAVkKmLJo11jss00zFyC4Yh3gTRnAng5vOxGHB8zclsJTizu12iT0Mwpa4sYTHPIS2f+zqEcCpCQ== +5.0.0-qa-74-2 [Build: 1679472836],Windows,AXcwrSeKswE5Yd/sQRd2bqH6NqnEba5l2nWoMHL/3LvZRCAf4QElRuHtLvNAZbntlEQ8/GOe+g+8ejCn83rAAQ== +5.0.0-qa-74-3 [Build: 1679578894],Windows,25zH3oeWqo0eYSWiUWxFHNlK3NK5qZPUVH8yEEaXHquGF6xoZPB9QWbjfkEaLB607j3Us1mviH7/Q47/3GpvDg== +3.?.? [Build: 5680278000],Android,AWb948BY32Z7bpIyoAlQguSmxOGcmjESPceQe1DpW5IZ4+AW1KfTk2VUIYNfUPsxReDJMCtlhVKslzhR2lf0AA== +3.?.? [Build: 5680278000],iOS,XrAf+Buq6Eb0ehEW/niFp06YX+nGGOS0Ke4MoUBzn+cX9q6G5C0A/d5XtgcNMe8r9jJgV/adIYVpsGS3pVlSAA== +3.?.? [Build: 5680278000],Linux,Hjd+N58Gv3ENhoKmGYy2bNRBsNNgm5kpiaQWxOj5HN2DXttG6REjymSwJtpJ8muC2gSwRuZi0R+8Laan5ts5CQ== +3.?.? [Build: 5680278000],OS X,SttEnjoWE8jqIM6BOHSfiZP9DGjW0EP/ajU4bdKqgGMV4aYq/kzwVA9gxbmdIzV4lbaokvXBqrRjfBHrTVh8Cg== +3.?.? [Build: 5680278000],Windows,DX5NIYLvfJEUjuIbCidnoeozxIDRRkpq3I9vVMBmE9L2qnekOoBzSenkzsg2lC9CMv8K5hkEzhr2TYUYSwUXCg== +3.?.? [Build: 5680278000] DEBUG,Windows,FaA10gndI44f19ZThYJX2OSM8ESrx9/vJ2uY+rON4enzzPsPR9kiPhsUXtMcC5szzTu6F/vLCiNNEhCr70CKCQ== \ No newline at end of file diff --git a/crates/proto/tsproto-structs/declarations/ts3protocol.md b/crates/proto/tsproto-structs/declarations/ts3protocol.md new file mode 100644 index 0000000..71c774f --- /dev/null +++ b/crates/proto/tsproto-structs/declarations/ts3protocol.md @@ -0,0 +1,864 @@ +TS3 PROTOCOL PAPER +================== + +# 0. Naming Conventions +- `(Client -> Server)` denotes packets from client to server. +- `(Client <- Server)` denotes packets from server to client. +- All datatypes are sent in network order (Big Endian) unless otherwise +specified. +- Datatypes are declared with a prefixing `u` or `i` for unsigned and signed +and a number for the bitlength. +For example `u8` would be the C equivalent of `uint8` or `unsigned char` +- Arrays are represented by the underlying datatype in square brackets, +additionally if the length is known it is added in the brackets, separated by +a semicolon. Eg: `[u8]`, `[i32; 16]` +- Array ranges (parts of an array) are specified in square brackets with the +included lower bound, two points (`..`) and the excluded upper bound. Eg: `[0..10]` + + +# 1. Low-Level Packets +## 1.1 Packet structure +- The packets are build in a fixed scheme, +though have differences depending in which direction. +- Every column here represents 1 byte. +- The entire packet size must be at max 500 bytes. + +### 1.1.1 (Client -> Server) + +--+--+--+--+--+--+--+--+--+--+--+--+--+---------//----------+ + | MAC | PId | CId |PT| Data | + +--+--+--+--+--+--+--+--+--+--+--+--+--+---------//----------+ + | \ Meta | + \ Header / + +| Name | Size | Datatype | Explanation | +|------|-------------|----------|---------------------------------| +| MAC | 8 bytes | [u8] | EAX Message Authentication Code | +| PId | 2 bytes | u16 | Packet Id | +| CId | 2 bytes | u16 | Client Id | +| PT | 1 byte | u8 | Packet Type + Flags | +| Data | ≤487 bytes | [u8] | The packet payload | + +### 1.1.2 (Client <- Server) + +--+--+--+--+--+--+--+--+--+--+--+------------//-------------+ + | MAC | PId |PT| Data | + +--+--+--+--+--+--+--+--+--+--+--+------------//-------------+ + | \ Meta | + \ Header / + +| Name | Size | Datatype | Explanation | +|------|-------------|----------|---------------------------------| +| MAC | 8 bytes | [u8] | EAX Message Authentication Code | +| PId | 2 bytes | u16 | Packet Id | +| PT | 1 byte | u8 | Packet Type + Flags | +| Data | ≤489 bytes | [u8] | The packet payload | + +## 1.2 Packet Types +- `0x00` Voice +- `0x01` VoiceWhisper +- `0x02` Command +- `0x03` CommandLow +- `0x04` Ping +- `0x05` Pong +- `0x06` Ack +- `0x07` AckLow +- `0x08` Init1 + +## 1.3 Packet Type + Flags byte +The final byte then looks like this + + MSB LSB + +--+--+--+--+--+--+--+--+ + |UE|CP|NP|FR| Type | + +--+--+--+--+--+--+--+--+ + +| Name | Size | Hex | Explanation | +|------|-------|------|-----------------| +| UE | 1 bit | 0x80 | Unencrypted | +| CP | 1 bit | 0x40 | Compressed | +| NP | 1 bit | 0x20 | Newprotocol | +| FR | 1 bit | 0x10 | Fragmented | +| Type | 4 bit | 0-8 | The packet type | + +## 1.4 Packet Compression +To reduce packet size, the data can be compressed. +When the data is compressed the `Compressed` flag must be set. +The algorithm "QuickLZ" with Level 1 is used for compression. + +## 1.5 Packet Splitting +When the packet payload exceeds the maximum datablock size the data can be +split up across multiple packets. +The current protocol only allows `Command` and `CommandLow` to be split and/or +compressed. +When splitting occurs, the `Fragmented` flag must be set on the first and +the last packet. +The `Unencrypted` and `Compressed` flag, if set in the original +packet, are only set on the first packet. (Though commands always have to be +encrypted) +The `Newprotocol` flag has to be set on all commands and therefore also has to +be applied on all splitted command packets. +The data can additionally be compressed *before* splitting. + +*Example*: + +The packet to split has the following flags: + + [__|CP|NP|__] Packet Id: 42 + +it must be split into: + + [__|CP|NP|FR] Packet Id: 42 + [__|__|NP|__] Packet Id: 43 + [__|__|NP|FR] Packet Id: 44 + + +## 1.6 Packet Encryption +When a packet is not encrypted the `Unencrypted` flag is set. For encrypted +packets the flag gets cleared. +Packets get encrypted with EAX mode (AES_128_CTR with OMAC). +The en/decryption parameters are generated for each packet as follows + +### 1.6.1 Inputs +| Name | Type | Explanation | +|------|----------|---------------------------------| +| PT | u8 | Packet Type | +| PId | u16 | Packet Id | +| PGId | u32 | Packet GenerationId (see 1.9.2) | +| PD | bool | Packet Direction | +| SIV | [u8; 20] | Shared IV (see 3.2) | + +### 1.6.2 Generation pseudocode +The temporary variable will have a different length depending on the result +from the crypto init handshake. The old protocol SharedIV will be 20 bytes long, +since it is generated with sha1, while the new protocol SharedIV will have +64 bytes, since it is generated with sha512. + + let temporary: [u8; 26] OR [u8; 70] + temporary[0] = 0x30 if (Client <- Server) + 0x31 if (Client -> Server) + temporary[1] = PT + temporary[2..6] = (PGId in network order)[0..4] + if SIV.length == 20 + temporary[6..26] = SIV[0..20] + else + temporary[6..70] = SIV[0..64] + + let keynonce: [u8; 32] + keynonce = sha256(temporary) + + key: [u8; 16] = keynonce[ 0..16] + nonce: [u8; 16] = keynonce[16..32] + key[0] = key[0] xor ((PId & 0xFF00) >> 8) + key[1] = key[1] xor ((PId & 0x00FF) >> 0) + +### 1.6.3 Encryption +The data can now be encrypted with the `key` and `nonce` from (see 1.6.2) as the +EAX key and nonce and the packet `Meta` as defined in (see 1.1) as the EAX +header (sometimes called "Associated Text"). The resulting EAX mac (sometimes +called "Tag") will be stored in the `MAC` field as defined in (see 2.1). + +### 1.6.4 Not encrypted packets +When a packet is not encrypted, no MAC can be generated by EAX. In this case +the SharedMac (see 3.2) will be used instead. + +## 1.7 Packet Stack Wrap-up +This stack is a reference for the execution order of the set data operations. +For incoming packets the stack is executed bot to top, for outgoing packets +top to bot. + + Send Receive + +-----------+ +-----------+ + | Data | | Λ | Data | + +-----------+ | | +-----------+ + | Compress | | | | Decompress| + +-----------+ | | +-----------+ + | Split | | | | Merge | + +-----------+ | | +-----------+ + | Encrypt | V | | Decrypt | + +-----------+ +-----------+ + +## 1.8 Packet Types Data Structures +The following chapter describes the data structure for different packet types. + +### 1.8.1.1 Voice (Client -> Server) + +--+--+--+---------//---------+ + | VId |C | Data | + +--+--+--+---------//---------+ + +| Name | Type | Explanation | +|------|------|-----------------| +| VId | u16 | Voice Packet Id | +| C | u8 | Codec Type | +| Data | var | Voice Data | + +### 1.8.1.2 Voice (Client <- Server) + +--+--+--+--+--+---------//---------+ + | VId | CId |C | Data | + +--+--+--+--+--+---------//---------+ + +| Name | Type | Explanation | +|------|------|-----------------| +| VId | u16 | Voice Packet Id | +| CId | u16 | Talking Client | +| C | u8 | Codec Type | +| Data | var | Voice Data | + +### 1.8.2.1 VoiceWhisper (Client -> Server) + +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+---------//---------+ + | VId |C |N |M | U* | T* | Data | + +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+---------//---------+ + +For direct user/channel targeting +The `Newprotocol` Flag must be *unset* + +| Name | Type | Explanation | +|------|-------|---------------------------------------| +| VId | u16 | Voice Packet Id | +| C | u8 | Codec Type | +| N | u8 | Count of ChannelIds to send to | +| M | u8 | Count of ClientIds to send to | +| U | [u64] | Targeted ChannelIds, repeated N times | +| T | [u16] | Targeted ClientIds, repeated M times | +| Data | var | Voice Data | + +OR + + +--+--+--+--+--+--+--+--+--+--+--+--+--+---------//---------+ + | VId |C |TY|TA| U | Data | + +--+--+--+--+--+--+--+--+--+--+--+--+--+---------//---------+ + +For targeting special groups +The `Newprotocol` Flag must be *set* + +| Name | Type | Explanation | +|------|-------|---------------------------------------------------------| +| VId | u16 | Voice Packet Id | +| C | u8 | Codec Type | +| TY | u8 | GroupWhisperType (see below) | +| TA | u8 | GroupWhisperTarget (see below) | +| U | u64 | the targeted channelId or groupId (0 if not applicable) | +| Data | var | Voice Data | + +``` +enum GroupWhisperType : u8 +{ + // Targets all users in the specified server group. + ServerGroup = 0 /* U = servergroup targetId */, + // Targets all users in the specified channel group. + ChannelGroup = 1 /* U = channelgroup targetId */, + // Targets all users with channel commander. + ChannelCommander = 2, /* U = 0 (ignored) */, + // Targets all users on the server. + AllClients = 3, /* U = 0 (ignored) */, +} + +enum GroupWhisperTarget : u8 +{ + AllChannels = 0, + CurrentChannel = 1, + ParentChannel = 2, + AllParentChannel = 3, + ChannelFamily = 4, + CompleteChannelFamily = 5, + Subchannels = 6, +} +``` + +### 1.8.2.2 VoiceWhisper (Client <- Server) + +--+--+--+--+--+---------//---------+ + | VId | CId |C | Data | + +--+--+--+--+--+---------//---------+ + +| Name | Type | Explanation | +|------|------|-----------------| +| VId | u16 | Voice Packet Id | +| CId | u16 | Talking Client | +| C | u8 | Codec Type | +| Data | var | Voice Data | + +### 1.8.3-4 Command and CommandLow +The TeamSpeak3 Query like command string encoded in UTF-8 + +### 1.8.5 Ping +Empty. + +### 1.8.6-8 Pong, Ack and AckLow + +--+--+ + | PId | + +--+--+ + +| Name | Type | Explanation | +|------|------|------------------------------------| +| PId | u16 | The packet id that is acknowledged | + +- In case of `Pong` a matching ping packet id is acknowledged. +- In case of `Ack` or `AckLow` a matching `Command` or `CommandLow` packet id +respectively is acknowledged. + +### 1.8.9 Init1 +(see 2.1)-(see 2.5) + +## 1.9 Packet Ids and Generations +### 1.9.1 Packet Ids +Each packet type and packet direction must be maintained by an own packet id +counter. +This means the client has 9 different packet id counter for outgoing packets. + +For each new packet the counter gets increased by 1. This also applies to +split packets. + +The client must also maintain packet ids for incoming packets in case of +packets arriving out of order. + +All Packet Ids start at 1 unless otherwise specified. + +### 1.9.2 Generations +Packet Ids are stored as u16, this means they range from 0 up to 65535 included. + +When the packet id overflows from 65535 to 0 at a packet, +the generation counter for this packet type gets increased by 1. + +Note that the new generation id immediately applies to the 'overflowing' packet. + +The generation id counter is solely used for encryption (see 1.6). + +## 1.10 Packet Acknowledgement / Packet Loss +In order to reliably send packets over UDP some packet types must get +acknowledged when received (see 1.11). + +The protocol uses selective repeat for lost packets. This means each packet has +its own timeout. Already acknowledged later packets must not be resent. +When a packet times out, the exact same packet should be resent until properly +acknowledged by the server. +If after 30 seconds no resent packet gets acknowledged the connection should be +closed. +Packet resend timeouts should be calculated with an exponential backoff to +prevent network congestion. + +## 1.11 Wrap-up +| Type | Acknowledged (by) | Resend | Encrypted | Splittable | Compressible | +|--------------|-------------------|--------|-----------|------------|--------------| +| Voice | ✗ | ✗ | Optional | ✗ | ✗ | +| VoiceWhisper | ✗ | ✗ | Optional | ✗ | ✗ | +| Command | ✓ (Ack) | ✓ | ✓ | ✓ | ✓ | +| CommandLow | ✓ (AckLow) | ✓ | ✓ | ✓ | ✓ | +| Ping | ✓ (Pong) | ✗ | ✗ | ✗ | ✗ | +| Pong | ✗ | ✗ | ✗ | ✗ | ✗ | +| Ack | ✗ | ✓ | ✓ | ✗ | ✗ | +| AckLow | ✗ | ✓ | ✓ | ✗ | ✗ | +| Init1 | ✓ (next Init1) | ✓ | ✗ | ✗ | ✗ | + +# 2. The (Low-Level) Initiation/Handshake +A connection is started from the client by sending the first handshake +packet. The handshake process consists of 5 different init packets. This +includes the so called RSA puzzle to prevent DOS attacks. + +The packet header values are set as following for all packets here: + +| Parameter | Value | +|-----------|--------------------------------------------------------| +| MAC | [u8]{ 0x54, 0x53, 0x33, 0x49, 0x4E, 0x49, 0x54, 0x31 } | +| key | N/A | +| nonce | N/A | +| Type | Init1 | +| Encrypted | ✗ | +| Packet Id | u16: 101 | +| Client Id | u16: 0 | + +Init packets from the client contain a version field, which is the build +timestamp of the client. This is a unix timestamp subtracted with 1356998400. +The unix timestamp 1461588969 (date 2016-04-25) is encoded as +1461588969 - 1356998400 = 0x063bece9 = { 0x06, 0x3b, 0xec, 0xe9 }. + +## 2.1 Packet 0 (Client -> Server) + 04 bytes : Version of the TeamSpeak client as timestamp + Example: { 0x06, 0x3b, 0xec, 0xe9 } + 01 bytes : Init-packet step number + Const: 0x00 + 04 bytes : Current timestamp in unix format + 04 bytes : Random bytes := [A0] + 08 bytes : Zeros, reserved. + +## 2.2 Packet 1 (Client <- Server) + 01 bytes : Init-packet step number + Const: 0x01 + 16 bytes : Server stuff := [A1] + 04 bytes : The bytes from [A0] in reversed order (not always) := [A0r] + +This packets usually contains the bytes from [A0] in reversed order, except when +connecting from some networks for a yet unknown reason. + +## 2.3 Packet 2 (Client -> Server) + 04 bytes : Version of the TeamSpeak client as timestamp + 01 bytes : Init-packet step number + Const: 0x02 + 16 bytes : The bytes from [A1] + 04 bytes : The bytes from [A0r] + +## 2.4 Packet 3 (Client <- Server) + 01 bytes : Init-packet step number + Const: 0x03 + 64 bytes : 'x', an unsigned BigInteger + 64 bytes : 'n', an unsigned BigInteger + 04 bytes : 'level' a u32 + 100 bytes : Server stuff := [A2] + +Note: +- Sometimes, instead of sending an init with step 3, the server responds with + an init that contains 127 as step number. In that case, the client has to + restart the connection by sending packet 0 again. + +## 2.5 Packet 4 (Client -> Server) + 04 bytes : Version of the TeamSpeak client as timestamp + 01 bytes : Init-packet step number + Const: 0x04 + 64 bytes : the received 'x' + 64 bytes : the received 'n' + 04 bytes : the received 'level' + 100 bytes : The bytes from [A2] + 64 bytes : 'y' which is the result of x ^ (2 ^ level) % n as an unsigned + BigInteger. Padded from the lower side with '0x00' when shorter + than 64 bytes. + Example: { 0x00, 0x00, data ... data} + var bytes : The clientinitiv command data as explained in (see 3.1) + +Note: +- `^` in this context means 'power to' +- To calculate the power of such a high number use a language integrated + function like `ModPow` or similar, when available. + If you don't have this function available you can multiply x iteratively + and apply the modulo operation after each multiplication. + +# 3. The (High-Level) Initiation/Handshake +In this phase the client and server exchange basic information and +agree on/calculate the symmetric AES encryption key with the ECDH +public/private key exchange technique. + +Both the client and the server will need a EC public/private key. This key +is also the identity which the server uses to recognize a user again. +The curve used is 'prime256v1'. + +All high level packets specified in this chapter are sent as `Command` Type +packets as explained in (see 2.8.3). Additionally the `Newprotocol` flag +(see 2.3) must be set on all `Command`, `CommandLow` and `Init1` packets. + +All commands are specified in the `Messages.txt` file. + +The packet header/encryption values for (see 3.1) and (see 3.2) are as following: + +| Parameter | Value | +|-----------|------------------------------------------------------------------------------------------------------| +| MAC | (Generated by EAX) | +| key | [u8]{0x63, 0x3A, 0x5C, 0x77, 0x69, 0x6E, 0x64, 0x6F, 0x77, 0x73, 0x5C, 0x73, 0x79, 0x73, 0x74, 0x65} | +| nonce | [u8]{0x6D, 0x5C, 0x66, 0x69, 0x72, 0x65, 0x77, 0x61, 0x6C, 0x6C, 0x33, 0x32, 0x2E, 0x63, 0x70, 0x6C} | +| Type | Command | +| Encrypted | ✓ | +| Packet Id | u16: 0 | +| Client Id | u16: 0 | + +The acknowledgement packets use the same parameters as the commands, except with +the Type `Ack`. + +_(Maybe add a #3.0 Prelude for required cryptographic values, if yes move the +omega ASN.1 encoding here)_ + +## 3.1 clientinitiv (Client -> Server) +The first packet is sent (Client -> Server) although this is only sent for +legacy reasons since newer servers (at least 3.0.13.0?) use the data part +embedded in the last `Init1` packet from the low-level handshake (see 2.5). + + clientinitiv alpha={alpha} omega={omega} ot={ot} ip={ip} + +- `alpha` is set to `base64(random[u8; 10])` + which are 10 random bytes for entropy. +- `omega` is set to `base64(publicKey[u8])` + omega is an ASN.1-DER encoded public key from the ECDH parameters as following: + + | Type | Value | Explanation | + |------------|----------------|-------------------------------------------| + | BIT STRING | 1bit, Value: 0 | LibTomCrypt uses 0 for a public key | + | INTEGER | 32 | The LibTomCrypt used keysize | + | INTEGER | publicKey.x | The affine X-Coordinate of the public key | + | INTEGER | publicKey.y | The affine Y-Coordinate of the public key | + +- `ot` should always be `1` +- `ip` should be set to the final resolved ip address of the server you are + actually connecting to. + +## 3.2 initivexpand/initivexpand2 (Client <- Server) +Depending on the server version the server will send a different init request. +- TS3 server <3.1 will send `initivexpand`. Continue with (see 3.2.1) +- TS3 server ≥3.1 will send `initivexpand2`. Continue with (see 3.2.2) + +If you want to support both protocol standards you don't need to check/know the +server version. The client just has to act accordingly depending on which +packet the server sends. + +### 3.2.1 initivexpand (Client <- Server) +The server responds with this command. + + initivexpand alpha={alpha} beta={beta} omega={omega} + +- `alpha` must have the same value as sent to the server in the previous step. +- `beta` is set to `base64(random[u8; 10])` + by the server. +- `omega` is set to `base64(publicKey[u8])` + with the public key from the server, encoded same as in (see 3.1) + +With this information the client now must calculate the shared secret. + + let sharedSecret: ECPoint + let x: [u8] + let sharedData: [u8; 32] + let SharedIV: [u8; 20] + let SharedMac: [u8; 8] + let ECDH(A, B) := (A * B).Normalize + + sharedSecret = ECDH(serverPublicKey, ownPrivateKey) + x = sharedSecret.x.AsByteArray() + if x.length < 32 + sharedData[ 0..(32-x.length)] = [0..0] + sharedData[(32-x.length)..32] = x[0..x.length] + elseif x.length == 32 + sharedData[0..32] = x[0..32] + elseif x.length > 32 + sharedData[0..32] = x[(x.length-32)..x.length] + SharedIV = sha1(sharedData) + SharedIV[0..10] = SharedIV[0..10] xor alpha.decode64() + SharedIV[10..20] = SharedIV[10..20] xor beta.decode64() + SharedMac[0..8] = sha1(SharedIV)[0..8] + +### 3.2.2 initivexpand2 (Client <- Server) +The server responds with this command. + + initivexpand2 l={l} beta={beta} omega={omega} ot={ot} proof={proof} tvd={tvd} + +- `l` the server license (see 3.2.2.2) +- `beta` is set to `base64(random[u8; 54])` + by the server. +- `omega` is a `base64(publicKey[u8])` + with the public key from the server, encoded same as in (see 3.1) +- `ot` should always be `1` +- `proof` is a `base64(ecdh_sign(l))` +- `tvd` (base64, unknown; only set on servers with a license) + +#### 3.2.2.1 Verify integrity +This step **must** be done to verity the integrity of the connection. + +The `proof` parameter is the sign of the `l` parameter (*not* base64 encoded). +The client can verify the `l` parameter with the public key of the server +which is sent in `omega`. + +Both proofs which are exchanged (the one you received in (see 3.2.2), and the +one sent in (see 3.2.2.5)) use 'prime256v1 with sha256, DER encoded'. +Note that the identity keys from client/server already should be keys +on 'prime256v1' as noted in (see 3). + +#### 3.2.2.2 Parsing the license +The license has a small header continued by a list of blocks. Each block may +vary in length and must be parsed sequentially therefore. + +The license header: + + 01 bytes : License version + Const: 0x01 + +The block base layout: + + 01 bytes : Key type + Const: 0x00 (public key) + 32 bytes : Block public key + 01 bytes : License block type + 04 bytes : Not valid before date + 04 bytes : Not valid after date + var bytes : (Content from the block type) + +There are currently 4 different `License block type`s used. +- `00` Intermediate. + `content`: + ``` + 04 bytes : Unknown + var bytes : A null terminated string, which describes the issuer of this certificate. + ``` +- `01` Website/`03` Code + `content`: + ``` + var bytes : A null terminated string, which describes the issuer of this certificate. + ``` +- `02` TS3 Server + `content`: + ``` + 01 bytes : Server License Type + 04 bytes : Max clients allowed on the server + var bytes : A null terminated string, which describes the issuer of this certificate. + ``` +- `08` TS5 Server + `content`: + ``` + 01 bytes : Server License Type + 01 bytes : Property count + var bytes : Properties, see following description on how each property is encoded + + Per property: + 01 bytes : Length of following data + 01 bytes : Property Id + 01 bytes : Data Type + var bytes : Content depending on data type, see below + ``` + + Data Types: + - `00`: Null-terminated string + - `01`/`03`: 4 byte data + - `02`/`04`: 8 byte data + + Property Id: + - `01` (type `01`): Unknown + - `02` (type `00`): Issuer of the certificate + - `03` (type `01`): Max clients allowed on the server, defaults to 32 if not present +- `32` Ephemeral + `content`: none + +Both dates are stored in BigEndian, when read you must add `0x50e22700` to the +number and import as a unix timestamp. + +Each `Not valid before` and `Not valid after` timespan must be within the range +of the parent license block. + +The license must consist of `2 ≤ count ≤ 8` blocks. +The second to last block must be of type `Server` +and the last block must be of type `Ephemeral`. + +#### 3.2.2.4 Calculating the shared secret +All elliptic curve operations for this step are done on the Curve25519. +You might find more tools looking for Ed25519 but keep in mind that Ed25519 +describes an EdDsa signing/verify operation and is not the curve itself. + +To calculate the shared secret each license block now must be processed +sequentially the following way: + + next_key = public_key * clamp(sha512(block[1..])[0..32]) + parent + +Where: +- `public_key` is the `Block public key` taken from the current license block. + This array must be imported as a compressed Curve25519 EC point. +- `sha512(block[1..])[0..32]` is the sha512 of the current license block. + Note that the first byte (`Key type`) is skipped for the sha calculation. + For the result only the first 32 bytes are used. + This resulting array must be imported as a Curve25519 private key. +- `parent` which is the resulting `next_key` from the previous block. + This is a compressed Curve25519 EC point. +- `clamp(num)` is a function describing `abs(num) mod B` where `B` is the base + point of Curve25519. This function can usually be implemented conveniently + on the number buffer like this: + ``` + let buffer: [u8; 32] + + buffer[0] &= 0xF8 + buffer[31] &= 0x3F + buffer[31] |= 0x40 + ``` + +Since the first block has no predecessor. +A fixed 'root' key is used as `parent`. +This key must be imported as a compressed Curve25519 EC point. + + [u8; 32] {0xcd, 0x0d, 0xe2, 0xae, 0xd4, 0x63, 0x45, 0x50, 0x9a, 0x7e, 0x3c, + 0xfd, 0x8f, 0x68, 0xb3, 0xdc, 0x75, 0x55, 0xb2, 0x9d, 0xcc, 0xec, + 0x73, 0xcd, 0x18, 0x75, 0x0f, 0x99, 0x38, 0x12, 0x40, 0x8a} + +The last `next_key` is now used as the public key from the server +(see pseudocode below). + +The client now has to create a temporary Curve25519 public/private keypair. +We will call them `client_public_key` and `client_private_key`. + +Now the `SharedIV` and `SharedMac` which will be used in the encryption, just as +in the old protocol, can be calculated. + + let SharedIV: [u8; 64] + let SharedMac: [u8; 8] + let sharedData: [u8; 32] + + sharedData = next_key * client_private_key + SharedIV = sha512(sharedData[0..32]) + SharedIV[ 0..10] = SharedIV[ 0..10] xor alpha.decode64() + SharedIV[10..64] = SharedIV[10..64] xor beta.decode64() + SharedMac[0..8] = sha1(SharedIV)[0..8] + +#### 3.2.2.5 clientek (Client -> Server) + + clientek ek={ek} proof={proof} + +- `ek` is `base64(client_public_key)` + which the ephemeral (temporary) key created in (see 3.2.2.4) by the client. + This should obviously be the public key part only. +- `proof` is `base64(client_public_key + beta)` + which is a sign of the client_public_key (the `ek`) concatenated with the + `beta` parameter from the `initivexpand2` command. + The sign must be done with the private key from the identity keypair. + +The normal packet id counting starts with this packet. This means that +`clientek` already has the packet id `1` and the next command will continue +with `2`. + +### 3.2.3 **Notes**: +- Only `SharedIV` and `SharedMac` are needed. The other values can (and should) + be discarded. +- The crypto handshake is now completed. The normal encryption scheme (see 1.6) + is from now on used. +- All `Command`, `CommandLow`, `Ack` and `AckLow` packets must get encrypted. +- `Voice` packets (and `VoiceWhisper` when wanted) should be encrypted when the + channel encryption or server wide encryption flag is set. +- `Ping` and `Pong` must not be encrypted. + +## 3.3 clientinit (Client -> Server) + clientinit client_nickname client_version client_platform client_input_hardware client_output_hardware client_default_channel client_default_channel_password client_server_password client_meta_data client_version_sign client_key_offset client_nickname_phonetic client_default_token hwid + +- `client_nickname` the desired nickname +- `client_version` the client version +- `client_platform` the client platform +- `client_input_hardware` whether an input device is available +- `client_output_hardware` whether an output device is available +- `client_default_channel` the default channel to join. This can be a channel + path or `/` (eg `/1`) for a channel id. +- `client_default_channel_password` the password for the join channel, prepared + the following way `base64(sha1(password))` +- `client_server_password` the password to enter the server, prepared the + following way `base64(sha1(password))` +- `client_meta_data` (can be left empty) +- `client_version_sign` a cryptographic sign to verify the genuinity of the + client +- `client_key_offset` the number offset used to calculate the hashcash (see 4.1) + value of the used identity +- `client_nickname_phonetic` the phonetic nickname for text-to-speech +- `client_default_token` permission token to be used when connecting to a server +- `hwid` hardware identification string + +**Notes**: +- Since client signs are only generated and distributed by TeamSpeak systems, + this the recommended client triple, as it is the reference for this paper + - Version: `3.0.19.3 [Build: 1466672534]` + - Platform: `Windows` + - Sign: `a1OYzvM18mrmfUQBUgxYBxYz2DUU6y5k3/mEL6FurzU0y97Bd1FL7+PRpcHyPkg4R+kKAFZ1nhyzbgkGphDWDg==` +- The `hwid` usually consists of two 32 char strings concatenated with `,` and + looks like `87056c6e1268aaf5055abf8256415e0e,408978b6d98810cc03f0aa16a4c75600` + but even empty strings are accepted. + On windows the hwid seems to be generated from a registry key + (`HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductId`). + On linux and macOS it seems to derive from the MAC address of the primary + Ethernet/Wifi adapter. +- Parameters which are empty or not used must be declared but left without + value and the `=` character + +## 3.4 initserver (Client <- Server) +The server sends the `initserver` command. + +Note: +- From this point on the client knows his client id, therefore it must be set + in the header of each packet. +- Newer versions of the server send parts of the `clientinit` command in the `initserver` command. + +## 3.5 Further notifications +The server will now send all needed information to display the entire +server properly. Those notifications are in no fixed order, although they + are most of the time sent in the here declared order. + +### 3.5.1 channellist and channellistfinished +The `channellist` notification type will be sent multiple times as needed to +transfer the entire server structure. + +After the last `channellist` notification the server will send +`channellistfinished` + +### 3.5.2 notifycliententerview +The `notifycliententerview` notification will be sent multiple times as needed +for each client currently connected. +This is the same notification as when a new client connects. + +# 4. Further concepts +## 4.1 Hashcash +To prevent client spamming (connecting to a server with many different clients) +the server requires a certain hashcash level on each identity. This level has a +exponentially growing calculation time with increasing level. This ensures that +a user wanting to spam a certain server needs to invest some time into +calculating the required level. + +- The publicKey is a string encoded as in (see 3.1) the omega value. +- The key offset is a u64 number, which gets converted to a string when +concatenated. + +The first step is to calculate a hash as following + + let data: [u8; 20] = sha1(publicKey + keyOffset) + +The level can now be calculated by counting the continuous leading zero bits in +the data array. +The bytes in the array get counted from 0 to 20 and the bits in each byte +from least significant to most significant. + +## 4.2 Uid +To calculate the uid of an identity the public key is required. Therefore you +can only calculate the uid of your own identity and the servers identity you +are connecting to. + +The publicKey is a string encoded as in (see 3.1) the omega value. + +The uid can be calculated as following + + let uid: string = base64(sha1(publicKey)) + +## 4.3 Ping/Pong +The server will regularly send ping packets to check if a client is still alive. +The client must answer them with the according pong packet. + +The client should also send ping packets to the server to check for connection. +They will be answered with according pong packets. + +Sending ping packets from the client side should not be started before the +crypto handshake has been completed (see 3.3) + +## 4.4 Passwords +All passwords when sent are hashed and encoded with `base64(sha1(password))` + +## 4.5 Importing/Deobfuscating Identities from the TeamSpeak3 Client +The TeamSpeak3 Client exports identities the following way: + + + 'V' + + +(For an explanation of the key offset (see 4.1)) + +```ts +const staticObfucationKey = b"b9dfaa7bee6ac57ac7b65f1094a1c155e747327bc2fe5d51c512023fe54a280201004e90ad1daaae1075d53b7d571c30e063b5a62a4a017bb394833aa0983e6e" +let ident = obfuscaded_identity.decode64() +let sha_part = ident[20..] +let idx = sha_part.indexof('\0') // where '\0' is the null-byte +let sha = sha1(sha_part[..idx]) +ident[0..20] = ident[0..20] xor sha[0..20] +let xorlen = min(ident.length, 100) +ident[0..xorlen] = ident[0..xorlen] xor staticObfucationKey[0..xorlen] +``` + +## 4.6 Audio +When the Opus codec is used, Voice and VoiceWhisper packets are using a sampling +rate of 48 kHz. An voice packat without audio data signals the end of a stream. + +## 4.7 Permissions +`permissionlist` requests the list of all permissions of the server. +`notifypermissionlist` returns the list of permissions and a grouping as a list +of `group_id_end`s. The end ids are excluding, so a `group_id_end=6` for the first +group means the first 6 permissions (`perms[0..6]`) are in this group. + +## 4.8 Channel Subscription +Clients can subscribe channels, so they get notifications when someone enters or +leaves from a subscribed channel. If a new channel is subscribed, the server +usually sends a notification, except in some cases: +- If the client server groups or permissions change, it stays subscribed, even + if it does not have the power anymore +- If the channel permissions change, the server sends a notification if the + subscription status changed +- If a client enters a channel, it gets subscribed but there is no notification +- If a client leaves a channel, there is a notification that it unsubscribed +- If a new channel is created, clients are not automatically subscribed + +## 4.? Differences between Query and Full Client +- notifyconnectioninforequest +- => setconnectioninfo diff --git a/crates/proto/tsproto-structs/src/book.rs b/crates/proto/tsproto-structs/src/book.rs new file mode 100644 index 0000000..693506f --- /dev/null +++ b/crates/proto/tsproto-structs/src/book.rs @@ -0,0 +1,207 @@ +use heck::*; +use once_cell::sync::Lazy; +use serde::Deserialize; + +use crate::*; + +pub const DATA_STR: &str = + include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/declarations/Book.toml")); + +pub static DATA: Lazy = Lazy::new(|| toml::from_str(DATA_STR).unwrap()); + +#[derive(Deserialize, Debug)] +#[serde(deny_unknown_fields)] +pub struct BookDeclarations { + #[serde(rename = "struct")] + pub structs: Vec, +} + +impl BookDeclarations { + pub fn get_struct(&self, name: &str) -> &Struct { + if let Some(s) = self.structs.iter().find(|s| s.name == name) { + s + } else { + panic!("Cannot find bookkeeping struct {}", name); + } + } +} + +#[derive(Deserialize, Clone, Debug)] +#[serde(deny_unknown_fields)] +pub struct Id { + #[serde(rename = "struct")] + pub struct_name: String, + pub prop: String, +} + +impl Id { + pub fn find_property<'a>(&self, structs: &'a [Struct]) -> &'a Property { + // Find struct + for s in structs { + if s.name == self.struct_name { + // Find property + for p in &s.properties { + if p.name == self.prop { + return p; + } + } + } + } + panic!("Cannot find struct {} of id", self.struct_name); + } +} + +#[derive(Deserialize, Clone, Debug)] +#[serde(deny_unknown_fields)] +pub struct Struct { + pub name: String, + #[serde(default = "get_false")] + pub opt: bool, + pub id: Vec, + pub doc: String, + pub properties: Vec, +} + +#[derive(Deserialize, Clone, Debug)] +#[serde(deny_unknown_fields)] +pub struct Property { + /// The name of this property (in PascalCase) which can be called from rust + /// when generated. + pub name: String, + /// The rust declaration type. + #[serde(rename = "type")] + pub type_s: String, + pub doc: Option, + #[serde(default = "get_false")] + pub opt: bool, + #[serde(rename = "mod")] + pub modifier: Option, + pub key: Option, +} + +impl Struct { + pub fn get_type(&self) -> Result { RustType::with_opt(&self.name, self.opt) } + + pub fn get_ids(&self, structs: &[Struct]) -> String { + let mut res = String::new(); + for id in &self.id { + let p = id.find_property(structs); + if !res.is_empty() { + res.push_str(", "); + } + res.push_str(&p.get_type().unwrap().to_string()); + } + embrace(&res) + } + + pub fn get_properties(&self, structs: &[Struct]) -> Vec<&Property> { + self.properties.iter().filter(|p| !structs.iter().any(|s| s.name == p.type_s)).collect() + } + + /// Get all properties, including foreign ids (own ids are listed in properties). + pub fn get_all_properties(&self) -> impl Iterator> { + self.id.iter() + // Only foreign ids, others are also stored in the properties + .filter_map(move |i| if i.struct_name != self.name { Some(PropId::from(i)) } + else { None }) + .chain(self.properties.iter().map(|p| p.into())) + } +} + +impl Property { + pub fn get_inner_type(&self) -> Result { RustType::with_opt(&self.type_s, self.opt) } + + pub fn get_type(&self) -> Result { + let key = if self.is_map() { + Some(self.key.as_deref().ok_or_else(|| { + eprintln!("Specified map without key"); + fmt::Error + })?) + } else { + None + }; + RustType::with(&self.type_s, self.opt, key, self.is_set(), self.is_array()) + } + + /// Gets the type as a name, used for storing it in an enum. + pub fn get_inner_type_as_name(&self) -> Result { Ok(self.get_inner_type()?.to_name()) } + + pub fn get_ids(&self, structs: &[Struct], struc: &Struct) -> String { + let mut ids = struc.get_ids(structs); + if !ids.is_empty() { + ids.remove(0); + ids.pop(); + } + if let Some(m) = &self.modifier { + if !ids.is_empty() { + ids.push_str(", "); + } + if m == "map" { + // The key is part of the id + ids.push_str(self.key.as_ref().unwrap()); + } else if m == "array" || m == "set" { + // Take the element itself as part of the id. + // It has to be copied but most of the times it is an id itself. + ids.push_str(&self.get_inner_type().unwrap().to_string()); + } else { + panic!("Unknown modifier {}", m); + } + } + embrace(&ids) + } + + /// Get the name without trailing `s`. + pub fn get_name(&self) -> &str { + if self.modifier.is_some() && self.name.ends_with('s') { + &self.name[..self.name.len() - 1] + } else { + &self.name + } + } + + pub fn is_array(&self) -> bool { self.modifier.as_ref().map(|s| s == "array").unwrap_or(false) } + pub fn is_set(&self) -> bool { self.modifier.as_ref().map(|s| s == "set").unwrap_or(false) } + pub fn is_map(&self) -> bool { self.modifier.as_ref().map(|s| s == "map").unwrap_or(false) } +} + +pub enum PropId<'a> { + Prop(&'a Property), + Id(&'a Id), +} + +impl<'a> PropId<'a> { + pub fn get_attr_name(&self, struc: &Struct) -> String { + match *self { + PropId::Prop(p) => p.name.to_snake_case(), + PropId::Id(id) => { + if struc.name == id.struct_name { + id.prop.to_snake_case() + } else { + format!("{}_{}", id.struct_name.to_snake_case(), id.prop.to_snake_case(),) + } + } + } + } + + pub fn get_doc(&self) -> Option<&str> { + match *self { + PropId::Prop(p) => p.doc.as_deref(), + PropId::Id(_) => None, + } + } + + pub fn get_type(&self, structs: &[Struct]) -> Result { + match *self { + PropId::Prop(p) => p.get_type(), + PropId::Id(id) => id.find_property(structs).get_type(), + } + } +} + +impl<'a> From<&'a Property> for PropId<'a> { + fn from(p: &'a Property) -> Self { PropId::Prop(p) } +} + +impl<'a> From<&'a Id> for PropId<'a> { + fn from(p: &'a Id) -> Self { PropId::Id(p) } +} diff --git a/crates/proto/tsproto-structs/src/book_to_messages.rs b/crates/proto/tsproto-structs/src/book_to_messages.rs new file mode 100644 index 0000000..3ed2331 --- /dev/null +++ b/crates/proto/tsproto-structs/src/book_to_messages.rs @@ -0,0 +1,344 @@ +use std::str::FromStr; + +use heck::*; +use once_cell::sync::Lazy; +use serde::Deserialize; + +use crate::book::{BookDeclarations, Property, Struct}; +use crate::messages::{Field, Message, MessageDeclarations}; +use crate::*; + +pub const DATA_STR: &str = + include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/declarations/BookToMessages.toml")); + +pub static DATA: Lazy> = Lazy::new(|| { + let rules: TomlStruct = toml::from_str(DATA_STR).unwrap(); + let book = &book::DATA; + let messages = &messages::DATA; + + let decls: Vec<_> = rules + .rule + .into_iter() + .map(|r| { + let msg = messages.get_message(&r.to); + let msg_fields = + msg.attributes.iter().map(|a| messages.get_field(a)).collect::>(); + let book_struct = book + .structs + .iter() + .find(|s| s.name == r.from) + .unwrap_or_else(|| panic!("Cannot find struct {}", r.from)); + + let find_prop = + |name: &str, book_struct: &'static Struct| -> Option<&'static Property> { + book_struct.properties.iter().find(|p| p.name == *name) + }; + + // Map RuleProperty to RuleKind + let to_rule_kind = |p: RuleProperty| { + p.assert_valid(); + + if p.function.is_some() { + if p.type_s.is_some() { + RuleKind::ArgumentFunction { + type_s: p.type_s.unwrap(), + from: p.from.unwrap(), + name: p.function.unwrap(), + to: p + .tolist + .unwrap() + .into_iter() + .map(|p| find_field(&p, &msg_fields)) + .collect(), + } + } else { + RuleKind::Function { + from: p.from.as_ref().map(|p| { + find_prop(p, book_struct).unwrap_or_else(|| { + panic!("No such (nested) property {} found in struct", p) + }) + }), + name: p.function.unwrap(), + to: p + .tolist + .unwrap() + .into_iter() + .map(|p| find_field(&p, &msg_fields)) + .collect(), + } + } + } else if let Some(prop) = find_prop(p.from.as_ref().unwrap(), book_struct) { + RuleKind::Map { from: prop, to: find_field(&p.to.unwrap(), &msg_fields) } + } else { + RuleKind::ArgumentMap { + from: p.from.unwrap(), + to: find_field(&p.to.unwrap(), &msg_fields), + } + } + }; + + let mut ev = Event { + op: r.operation.parse().expect("Failed to parse operation"), + ids: r.ids.into_iter().map(to_rule_kind).collect(), + msg, + book_struct, + rules: r.properties.into_iter().map(to_rule_kind).collect(), + }; + + // Add ids, which are required fields in the message. + // The filter checks that the message is not optional. + for field in msg_fields.iter().filter(|f| msg.attributes.iter().any(|a| *a == f.map)) { + if !ev.ids.iter().any(|i| match i { + RuleKind::Map { to, .. } => to == field, + RuleKind::ArgumentMap { to, .. } => to == field, + RuleKind::Function { to, .. } | RuleKind::ArgumentFunction { to, .. } => { + to.contains(field) + } + }) { + // Try to find matching property + if let Some(prop) = book + .get_struct(&ev.book_struct.name) + .properties + .iter() + .find(|p| !p.opt && p.name == field.pretty) + { + ev.ids.push(RuleKind::Map { from: prop, to: field }) + } + // The property may be in the properties + } + } + + // Add properties + for field in msg_fields.iter().filter(|f| !msg.attributes.iter().any(|a| *a == f.map)) { + if !ev.ids.iter().chain(ev.rules.iter()).any(|i| match i { + RuleKind::Map { to, .. } => to == field, + RuleKind::ArgumentMap { to, .. } => to == field, + RuleKind::Function { to, .. } | RuleKind::ArgumentFunction { to, .. } => { + to.contains(field) + } + }) { + // We ignore that properties are set as option. In all current cases, it + // makes no sense to set them to `None`, so we handle them the same way as + // non-optional properties. + if let Some(prop) = book + .get_struct(&ev.book_struct.name) + .properties + .iter() + .find(|p| p.name == field.pretty) + { + if !ev.ids.iter().chain(ev.rules.iter()).any(|i| i.from_name() == prop.name) + { + ev.rules.push(RuleKind::Map { from: prop, to: field }) + } + } + } + } + + ev + }) + .collect(); + + BookToMessagesDeclarations { book, messages, decls } +}); + +#[derive(Debug)] +pub struct BookToMessagesDeclarations<'a> { + pub book: &'a BookDeclarations, + pub messages: &'a MessageDeclarations, + pub decls: Vec>, +} + +#[derive(Debug)] +pub struct Event<'a> { + pub op: RuleOp, + pub msg: &'a Message, + pub book_struct: &'a Struct, + pub ids: Vec>, + pub rules: Vec>, +} + +#[derive(Debug)] +pub enum RuleKind<'a> { + Map { from: &'a Property, to: &'a Field }, + ArgumentMap { from: String, to: &'a Field }, + Function { from: Option<&'a Property>, name: String, to: Vec<&'a Field> }, + ArgumentFunction { from: String, type_s: String, name: String, to: Vec<&'a Field> }, +} + +#[derive(Debug, PartialEq, Eq, Clone, Copy)] +pub enum RuleOp { + Add, + Remove, + Update, +} + +#[derive(Deserialize, Debug)] +#[serde(deny_unknown_fields)] +struct TomlStruct { + rule: Vec, +} + +#[derive(Clone, Deserialize, Debug)] +#[serde(deny_unknown_fields)] +pub struct Rule { + from: String, + to: String, + operation: String, + #[serde(default = "Vec::new")] + ids: Vec, + #[serde(default = "Vec::new")] + properties: Vec, +} + +#[derive(Clone, Deserialize, Debug)] +#[serde(deny_unknown_fields)] +pub struct RuleProperty { + from: Option, + to: Option, + + #[serde(rename = "type")] + type_s: Option, + function: Option, + tolist: Option>, +} + +impl RuleProperty { + fn assert_valid(&self) { + if let Some(to) = &self.to { + assert!(self.from.is_some(), "to-property '{}' is invalid. It needs a 'from'", to); + assert!( + self.function.is_none(), + "to-property '{}' is invalid. It must not have a 'function'", + to + ); + assert!( + self.tolist.is_none(), + "to-property '{}' is invalid. It must not have a 'tolist'", + to + ); + assert!( + self.type_s.is_none(), + "to-property '{}' is invalid. It must not have a 'type'", + to + ); + } else if let Some(fun) = &self.function { + assert!( + self.tolist.is_some(), + "function-property '{}' is invalid. It needs 'tolist'", + fun + ); + assert!( + self.type_s.is_none() || self.from.is_some(), + "function-property '{}' is invalid. If the type ({:?}) is set, from must be set \ + too", + fun, + self.type_s + ); + } else { + panic!( + "Property is invalid. It needs either a 'to' or 'tolist'+'function'.Info: \ + tolist={:?} type={:?} from={:?}", + self.tolist, self.type_s, self.from + ); + } + } +} + +impl FromStr for RuleOp { + type Err = fmt::Error; + fn from_str(s: &str) -> Result { + if s == "add" { + Ok(RuleOp::Add) + } else if s == "remove" { + Ok(RuleOp::Remove) + } else if s == "update" { + Ok(RuleOp::Update) + } else { + eprintln!("Cannot parse operation, needs to be add, remove or update"); + Err(fmt::Error) + } + } +} + +// the in rust callable name (in PascalCase) from the field +fn find_field<'a>(name: &str, msg_fields: &[&'a Field]) -> &'a Field { + msg_fields + .iter() + .find(|f| f.pretty == name) + .unwrap_or_else(|| panic!("Cannot find field '{}'", name)) +} + +impl<'a> RuleKind<'a> { + pub fn from_name(&'a self) -> &'a str { + match self { + RuleKind::Map { from, .. } => &from.name, + RuleKind::ArgumentMap { from, .. } => from, + RuleKind::Function { from, name, .. } => { + &from.unwrap_or_else(|| panic!("From not set for function {}", name)).name + } + RuleKind::ArgumentFunction { from, .. } => from, + } + } + + pub fn from_name_singular(&'a self) -> &'a str { + let name = self.from_name(); + if let Some(s) = name.strip_suffix('s') { s } else { name } + } + + pub fn from(&self) -> &'a Property { + match self { + RuleKind::Map { from, .. } => from, + RuleKind::Function { from, name, .. } => { + from.unwrap_or_else(|| panic!("From not set for function {}", name)) + } + RuleKind::ArgumentMap { .. } | RuleKind::ArgumentFunction { .. } => { + panic!("From is not a property for argument functions") + } + } + } + + pub fn is_function(&self) -> bool { + matches!(self, RuleKind::Function { .. } | RuleKind::ArgumentFunction { .. }) + } + + pub fn get_type(&self) -> RustType { + match self { + RuleKind::Map { .. } | RuleKind::Function { .. } => self.from().get_type().unwrap(), + RuleKind::ArgumentMap { to, .. } => to.get_type("").unwrap(), + RuleKind::ArgumentFunction { type_s, .. } => type_s.parse().unwrap(), + } + } + + pub fn get_type_no_option(&self) -> RustType { + match self { + RuleKind::Map { .. } => { + let mut rust_type = self.from().clone(); + rust_type.opt = false; + rust_type.get_type().unwrap() + } + _ => self.get_type(), + } + } + + pub fn get_argument(&self) -> String { + format!("{}: {}", self.from_name().to_snake_case(), self.get_type().to_ref(true)) + } + + pub fn get_argument_no_option(&self) -> String { + format!("{}: {}", self.from_name().to_snake_case(), self.get_type_no_option().to_ref(true)) + } +} + +impl<'a> Event<'a> { + /// The name of the change, could be a keyword. + pub fn get_small_name(&self) -> String { + // Strip own struct name and 'Request' + self.msg.name.replace(&self.book_struct.name, "").replace("Request", "") + } + + /// The small name, not a keyword + pub fn get_change_name(&self) -> String { + let small_change_name = self.get_small_name(); + if small_change_name == "Move" { self.msg.name.clone() } else { small_change_name } + } +} diff --git a/crates/proto/tsproto-structs/src/enums.rs b/crates/proto/tsproto-structs/src/enums.rs new file mode 100644 index 0000000..a32cce8 --- /dev/null +++ b/crates/proto/tsproto-structs/src/enums.rs @@ -0,0 +1,52 @@ +use once_cell::sync::Lazy; +use serde::Deserialize; + +pub const DATA_STR: &str = + include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/declarations/Enums.toml")); + +pub static DATA: Lazy = Lazy::new(|| toml::from_str(DATA_STR).unwrap()); + +#[derive(Deserialize, Debug)] +#[serde(deny_unknown_fields)] +pub struct Enums { + #[serde(rename = "enum")] + pub enums: Vec, + #[serde(rename = "bitflag")] + pub bitflags: Vec, +} + +#[derive(Deserialize, Clone, Debug)] +#[serde(deny_unknown_fields)] +pub struct Enum { + pub name: String, + pub doc: Option, + #[serde(rename = "type")] + pub use_type: Option, + pub variants: Vec, +} + +#[derive(Deserialize, Clone, Debug)] +#[serde(deny_unknown_fields)] +pub struct Variant { + pub name: String, + pub doc: String, + pub value: Option, +} + +impl Enum { + /// Computes the needed number of bits to store all possible variants. + pub fn bitwidth(&self) -> u32 { + let mut leading_zeros = 0; + let mut value: u64 = 0; + for v in &self.variants { + if let Some(v) = v.value { + leading_zeros = std::cmp::min(leading_zeros, value.leading_zeros()); + value = v; + } else { + value += 1; + } + } + leading_zeros = std::cmp::min(leading_zeros, value.leading_zeros()); + (64 - leading_zeros).next_power_of_two() + } +} diff --git a/crates/proto/tsproto-structs/src/errors.rs b/crates/proto/tsproto-structs/src/errors.rs new file mode 100644 index 0000000..b73b559 --- /dev/null +++ b/crates/proto/tsproto-structs/src/errors.rs @@ -0,0 +1,20 @@ +use std::result::Result; + +use crate::*; + +use once_cell::sync::Lazy; + +pub const DATA_STR: &str = + include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/declarations/Errors.csv")); + +pub static DATA: Lazy = Lazy::new(|| { + Errors( + csv::Reader::from_reader(DATA_STR.as_bytes()) + .deserialize() + .collect::, _>>() + .unwrap(), + ) +}); + +#[derive(Default, Debug)] +pub struct Errors(pub Vec); diff --git a/crates/proto/tsproto-structs/src/lib.rs b/crates/proto/tsproto-structs/src/lib.rs new file mode 100644 index 0000000..2d9b55d --- /dev/null +++ b/crates/proto/tsproto-structs/src/lib.rs @@ -0,0 +1,398 @@ +//! `tsproto-structs` contains machine readable data for several TeamSpeak related topics. +//! +//! The underlying data files can be found in the +//! [tsdeclarations](https://github.com/ReSpeak/tsdeclarations) repository. + +use std::fmt; +use std::str::FromStr; + +use heck::*; +use serde::Deserialize; + +type Result = std::result::Result; + +pub mod book; +pub mod book_to_messages; +pub mod enums; +pub mod errors; +pub mod messages; +pub mod messages_to_book; +pub mod permissions; +pub mod versions; + +#[derive(Debug, Deserialize)] +pub struct EnumValue { + pub name: String, + pub doc: String, + pub num: String, +} + +#[derive(Clone, Debug)] +pub enum InnerRustType { + Primitive(String), + Struct(String), + Ref(Box), + Option(Box), + /// Key, value + Map(Box, Box), + Set(Box), + Vec(Box), + Cow(Box), +} + +#[derive(Clone, Debug)] +pub struct RustType { + pub inner: InnerRustType, + /// Include a lifetime specifier 'a + pub lifetime: bool, +} + +impl InnerRustType { + /// `lifetime`: Include 'a for references + /// `is_ref`: If this is a refercene, used to emit either `str` or `String` or slices + pub fn fmt(&self, f: &mut fmt::Formatter, lifetime: bool, is_ref: bool) -> fmt::Result { + let lifetime_str = if lifetime { "'a " } else { "" }; + match self { + Self::Struct(s) if s == "str" => { + if is_ref { + write!(f, "str")?; + } else { + write!(f, "String")?; + } + } + Self::Struct(s) if s == "Uid" => { + write!(f, "{}", s)?; + } + Self::Primitive(s) | Self::Struct(s) => write!(f, "{}", s)?, + Self::Ref(i) => { + write!(f, "&{}", lifetime_str)?; + i.fmt(f, lifetime, true)?; + } + Self::Option(i) => { + write!(f, "Option<")?; + i.fmt(f, lifetime, false)?; + write!(f, ">")?; + } + Self::Map(k, v) => { + write!(f, "HashMap<")?; + k.fmt(f, lifetime, false)?; + write!(f, ", ")?; + v.fmt(f, lifetime, false)?; + write!(f, ">")?; + } + Self::Set(i) => { + write!(f, "HashSet<")?; + i.fmt(f, lifetime, false)?; + write!(f, ">")?; + } + Self::Vec(i) => { + if is_ref { + write!(f, "[")?; + i.fmt(f, lifetime, false)?; + write!(f, "]")?; + } else { + write!(f, "Vec<")?; + i.fmt(f, lifetime, false)?; + write!(f, ">")?; + } + } + Self::Cow(i) => { + write!(f, "Cow<{}, ", lifetime_str.trim())?; + i.fmt(f, false, true)?; + write!(f, ">")?; + } + } + Ok(()) + } + + /// Returns a converted type. + pub fn to_ref(&self) -> Self { + match self { + Self::Struct(s) if s == "UidBuf" => Self::Ref(Box::new(Self::Struct("Uid".into()))), + Self::Struct(s) if s == "String" => Self::Ref(Box::new(Self::Struct("str".into()))), + Self::Struct(_) | Self::Map(_, _) | Self::Set(_) | Self::Vec(_) => { + Self::Ref(Box::new(self.clone())) + } + Self::Primitive(_) | Self::Ref(_) | Self::Cow(_) => self.clone(), + Self::Option(i) => Self::Option(Box::new(i.to_ref())), + } + } + + /// Returns a converted type. + pub fn to_cow(&self) -> Self { + match self { + Self::Struct(s) if s == "UidBuf" => Self::Cow(Box::new(Self::Struct("Uid".into()))), + Self::Struct(s) if s == "String" => Self::Cow(Box::new(Self::Struct("str".into()))), + Self::Struct(_) | Self::Map(_, _) | Self::Set(_) | Self::Vec(_) => { + Self::Cow(Box::new(self.clone())) + } + Self::Primitive(_) | Self::Ref(_) | Self::Cow(_) => self.clone(), + Self::Option(i) => Self::Option(Box::new(i.to_cow())), + } + } + + /// Get code snippet for `as_ref`. + pub fn code_as_ref(&self, name: &str) -> String { + match self { + Self::Struct(s) if s == "UidBuf" || s == "str" => format!("{}.as_ref()", name), + Self::Struct(s) if s == "String" => format!("{}.as_str()", name), + Self::Struct(s) if s == "str" => name.into(), + Self::Struct(_) => format!("&{}", name), + Self::Map(_, _) | Self::Set(_) | Self::Vec(_) | Self::Cow(_) => { + format!("{}.as_ref()", name) + } + Self::Primitive(_) => name.into(), + Self::Ref(i) => { + let inner = i.code_as_ref(name); + if inner == name { + format!("*{}", name) + } else if inner.starts_with('&') && &inner[1..] == name { + name.into() + } else { + inner + } + } + Self::Option(i) => { + match &**i { + // Shortcut + Self::Struct(s) if s == "String" => format!("{}.as_deref()", name), + _ => { + let inner = i.code_as_ref(name); + if inner == name { + inner + } else if inner.starts_with('&') && &inner[1..] == name { + format!("{0}.as_ref()", name) + } else { + format!("{0}.as_ref().map(|{0}| {1})", name, inner) + } + } + } + } + } + } + + pub fn uses_lifetime(&self) -> bool { + match self { + Self::Struct(s) if s == "Uid" => true, + Self::Ref(_) | Self::Cow(_) => true, + Self::Map(_, i) | Self::Set(i) | Self::Vec(i) | Self::Option(i) => i.uses_lifetime(), + _ => false, + } + } +} + +impl FromStr for InnerRustType { + type Err = fmt::Error; + fn from_str(s: &str) -> Result { + if s == "DateTime" { + Ok(Self::Primitive("OffsetDateTime".into())) + } else if s.starts_with("Duration") { + Ok(Self::Primitive("Duration".into())) + } else if s == "PermissionId" { + Ok(Self::Primitive("Permission".into())) + } else if s == "Ts3ErrorCode" { + Ok(Self::Primitive("Error".into())) + } else if s == "bool" + || s.starts_with('i') + || s.starts_with('u') + || s.starts_with('f') + || s.ends_with("Id") + || s.ends_with("Type") + || s.ends_with("Mode") + || s == "ChannelPermissionHint" + || s == "ClientPermissionHint" + || s == "Codec" + || s == "LogLevel" + || s == "MaxClients" + || s == "IpAddr" + || s == "Reason" + || s == "SocketAddr" + { + Ok(Self::Primitive(s.into())) + } else if s == "Uid" { + Ok(Self::Struct("UidBuf".into())) + } else if s == "str" || s == "String" { + Ok(Self::Struct("String".into())) + } else if let Some(rest) = s.strip_prefix('&') { + let rest = if rest.starts_with('\'') { + let i = rest.find(' ').ok_or_else(|| { + eprintln!("Reference type with lifetime has no inner type: {:?}", s); + fmt::Error + })?; + &rest[i + 1..] + } else { + rest + }; + Ok(Self::Ref(Box::new(rest.parse()?))) + } else if let Some(rest) = s.strip_suffix('?') { + Ok(Self::Option(Box::new(rest.parse()?))) + } else if s.starts_with("Option<") { + let rest = &s[7..s.len() - 1]; + Ok(Self::Option(Box::new(rest.parse()?))) + } else if let Some(rest) = s.strip_suffix("[]") { + Ok(Self::Vec(Box::new(rest.parse()?))) + } else if s.starts_with("HashMap<") { + let rest = &s[8..s.len() - 1]; + let i = rest.find(',').ok_or_else(|| { + eprintln!("HashMap without key: {:?}", s); + fmt::Error + })?; + Ok(Self::Map(Box::new(rest[..i].parse()?), Box::new(rest[i..].trim().parse()?))) + } else if s.starts_with("HashSet<") { + let rest = &s[8..s.len() - 1]; + Ok(Self::Set(Box::new(rest.parse()?))) + } else if s.starts_with("Vec<") { + let rest = &s[4..s.len() - 1]; + Ok(Self::Vec(Box::new(rest.parse()?))) + } else if s.starts_with('[') { + let rest = &s[1..s.len() - 1]; + if rest.contains(';') { + // Slice with explicit length, take as struct + Ok(Self::Struct(s.into())) + } else { + Ok(Self::Vec(Box::new(rest.parse()?))) + } + } else if let Some(rest) = s.strip_suffix('T') { + rest.parse() + } else { + Ok(Self::Struct(s.into())) + } + } +} + +impl FromStr for RustType { + type Err = fmt::Error; + fn from_str(s: &str) -> Result { + Ok(Self { inner: s.parse()?, lifetime: s.contains("&'") }) + } +} + +impl RustType { + pub fn with_opt(s: &str, opt: bool) -> Result { + let inner = s.parse()?; + let inner = if opt { InnerRustType::Option(Box::new(inner)) } else { inner }; + Ok(Self { inner, lifetime: s.contains("&'") }) + } + + /// `map` has a key + pub fn with(s: &str, opt: bool, map: Option<&str>, set: bool, vec: bool) -> Result { + assert!( + [map.is_some(), set, vec].iter().filter(|b| **b).count() <= 1, + "Too many modifiers active (map: {:?}, set: {:?}, vec: {:?})", + map, + set, + vec + ); + let mut inner = s.parse()?; + if let Some(key) = map { + inner = InnerRustType::Map(Box::new(key.parse()?), Box::new(inner)); + } + if set { + inner = InnerRustType::Set(Box::new(inner)); + } + if vec { + inner = InnerRustType::Vec(Box::new(inner)); + } + + inner = if opt { InnerRustType::Option(Box::new(inner)) } else { inner }; + Ok(Self { inner, lifetime: s.contains("&'") }) + } + + pub fn to_opt(&self, opt: bool) -> Self { + if opt { + Self { + inner: InnerRustType::Option(Box::new(self.inner.clone())), + lifetime: self.lifetime, + } + } else { + self.clone() + } + } + + pub fn to_ref(&self, as_ref: bool) -> Self { + if as_ref { + Self { inner: self.inner.to_ref(), lifetime: self.lifetime } + } else { + self.clone() + } + } + + pub fn to_cow(&self) -> Self { Self { inner: self.inner.to_cow(), lifetime: self.lifetime } } + + pub fn lifetime(&self, lifetime: bool) -> Self { + let mut r = self.clone(); + r.lifetime = lifetime; + r + } + + pub fn wrap_ref(&self) -> Self { + Self { inner: InnerRustType::Ref(Box::new(self.inner.clone())), lifetime: self.lifetime } + } + + pub fn wrap_opt(&self) -> Self { + Self { inner: InnerRustType::Option(Box::new(self.inner.clone())), lifetime: self.lifetime } + } + + pub fn is_opt(&self) -> bool { matches!(self.inner, InnerRustType::Option(_)) } + + pub fn is_primitive(&self) -> bool { + let inner = if let InnerRustType::Option(t) = &self.inner { t } else { &self.inner }; + matches!(inner, InnerRustType::Primitive(_)) + } + + pub fn is_vec(&self) -> bool { matches!(self.inner, InnerRustType::Vec(_)) } + + pub fn is_cow(&self) -> bool { + let inner = if let InnerRustType::Option(i) = &self.inner { i } else { &self.inner }; + matches!(inner, InnerRustType::Cow(_)) + } + + pub fn uses_lifetime(&self) -> bool { self.inner.uses_lifetime() } + + /// Returns an identifier from this type in camelCase. + pub fn to_name(&self) -> String { + self.to_string().replace('<', "_").replace('>', "").to_upper_camel_case() + } + + /// Get code snippet for `as_ref`. + pub fn code_as_ref(&self, name: &str) -> String { self.inner.code_as_ref(name) } +} + +impl From for RustType { + fn from(inner: InnerRustType) -> Self { Self { inner, lifetime: false } } +} + +impl fmt::Display for RustType { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.inner.fmt(f, self.lifetime, false) } +} + +fn get_false() -> bool { false } + +/// Prepend `/// ` to each line of a string. +pub fn doc_comment(s: &str) -> String { s.lines().map(|l| format!("/// {}\n", l)).collect() } + +/// Indent a string by a given count using tabs. +pub fn indent>(s: S, count: usize) -> String { + let sref = s.as_ref(); + let line_count = sref.lines().count(); + let mut result = String::with_capacity(sref.len() + line_count * count * 4); + for l in sref.lines() { + if !l.is_empty() { + result.push_str(&"\t".repeat(count)); + } + result.push_str(l); + result.push('\n'); + } + result +} + +/// Unindent a string by a given count of tabs. +pub fn unindent(s: &mut String) { + std::mem::swap(&mut s.replace("\n\t", "\n"), s); + if s.get(0..1) == Some("\t") { + s.remove(0); + } +} + +/// Returns an empty string if `s` is empty, otherwise `s` with braces. +pub fn embrace(s: &str) -> String { if s.is_empty() { String::new() } else { format!("({})", s) } } diff --git a/crates/proto/tsproto-structs/src/messages.rs b/crates/proto/tsproto-structs/src/messages.rs new file mode 100644 index 0000000..586b20a --- /dev/null +++ b/crates/proto/tsproto-structs/src/messages.rs @@ -0,0 +1,115 @@ +use heck::*; +use once_cell::sync::Lazy; +use serde::Deserialize; + +use crate::*; + +pub const DATA_STR: &str = + include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/declarations/Messages.toml")); + +pub static DATA: Lazy = Lazy::new(|| toml::from_str(DATA_STR).unwrap()); + +#[derive(Deserialize, Debug, Clone)] +#[serde(deny_unknown_fields)] +pub struct MessageDeclarations { + pub fields: Vec, + pub msg_group: Vec, +} + +impl MessageDeclarations { + pub fn get_message_opt(&self, name: &str) -> Option<&Message> { + self.msg_group.iter().flat_map(|g| g.msg.iter()).find(|m| m.name == name) + } + + pub fn get_message(&self, name: &str) -> &Message { + self.get_message_opt(name).unwrap_or_else(|| panic!("Cannot find message {}", name)) + } + + pub fn get_message_group(&self, msg: &Message) -> &MessageGroup { + for g in &self.msg_group { + for m in &g.msg { + if std::ptr::eq(m, msg) { + return g; + } + } + } + panic!("Cannot find message group for message"); + } + + pub fn get_field(&self, mut map: &str) -> &Field { + if map.ends_with('?') { + map = &map[..map.len() - 1]; + } + if let Some(f) = self.fields.iter().find(|f| f.map == map) { + f + } else { + panic!("Cannot find field {}", map); + } + } + + pub fn uses_lifetime(&self, msg: &Message) -> bool { + for a in &msg.attributes { + let field = self.get_field(a); + if field.get_type(a).unwrap().to_ref(true).uses_lifetime() { + return true; + } + } + false + } +} + +#[derive(Deserialize, Debug, Clone, Eq, Hash, PartialEq)] +#[serde(deny_unknown_fields)] +pub struct Field { + /// Internal name of this declarations file to map fields to messages. + pub map: String, + /// The name as called by TeamSpeak in messages. + pub ts: String, + /// The pretty name in PascalCase. This will be used for the fields in rust. + pub pretty: String, + #[serde(rename = "type")] + pub type_s: String, + #[serde(rename = "mod")] + pub modifier: Option, +} + +#[derive(Deserialize, Debug, Clone)] +#[serde(deny_unknown_fields)] +pub struct MessageGroup { + pub default: MessageGroupDefaults, + pub msg: Vec, +} + +#[derive(Deserialize, Debug, Clone)] +#[serde(deny_unknown_fields)] +pub struct MessageGroupDefaults { + pub s2c: bool, + pub c2s: bool, + pub response: bool, + pub low: bool, + pub np: bool, +} + +#[derive(Deserialize, Debug, Clone)] +#[serde(deny_unknown_fields)] +pub struct Message { + /// How we call this message. + pub name: String, + /// How TeamSpeak calls this message. + pub notify: Option, + pub attributes: Vec, +} + +impl Field { + pub fn get_rust_name(&self) -> String { self.pretty.to_snake_case() } + + /// Takes the attribute to look if it is optional + pub fn get_type(&self, a: &str) -> Result { + RustType::with(&self.type_s, a.ends_with('?'), None, false, self.is_array()) + } + + /// Returns if this field is optional in the message. + pub fn is_opt(&self, msg: &Message) -> bool { !msg.attributes.iter().any(|a| *a == self.map) } + + pub fn is_array(&self) -> bool { self.modifier.as_ref().map(|s| s == "array").unwrap_or(false) } +} diff --git a/crates/proto/tsproto-structs/src/messages_to_book.rs b/crates/proto/tsproto-structs/src/messages_to_book.rs new file mode 100644 index 0000000..392e628 --- /dev/null +++ b/crates/proto/tsproto-structs/src/messages_to_book.rs @@ -0,0 +1,263 @@ +use std::collections::HashSet; +use std::fmt::Write; +use std::str::FromStr; + +use once_cell::sync::Lazy; +use serde::Deserialize; + +use crate::book::{BookDeclarations, Property, Struct}; +use crate::messages::{Field, Message, MessageDeclarations}; +use crate::*; + +pub const DATA_STR: &str = + include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/declarations/MessagesToBook.toml")); + +pub static DATA: Lazy> = Lazy::new(|| { + let rules: TomlStruct = toml::from_str(DATA_STR).unwrap(); + let book = &book::DATA; + let messages = &messages::DATA; + + let mut decls: Vec<_> = rules + .rule + .into_iter() + .map(|r| { + let msg = messages.get_message(&r.from); + let msg_fields = + msg.attributes.iter().map(|a| messages.get_field(a)).collect::>(); + let book_struct = book + .structs + .iter() + .find(|s| s.name == r.to) + .unwrap_or_else(|| panic!("Cannot find struct {}", r.to)); + + let mut ev = Event { + op: r.operation.parse().expect("Failed to parse operation"), + id: r.id.iter().map(|s| find_field(s, &msg_fields)).collect(), + msg, + book_struct, + rules: r + .properties + .into_iter() + .map(|p| { + assert!(p.is_valid()); + + let find_prop = |name, book_struct: &'static Struct| -> &'static Property { + if let Some(prop) = + book_struct.properties.iter().find(|p| p.name == name) + { + return prop; + } + panic!( + "No such (nested) property {} found in struct {}", + name, book_struct.name, + ); + }; + + if p.function.is_some() { + RuleKind::Function { + name: p.function.unwrap(), + to: p + .tolist + .unwrap() + .into_iter() + .map(|p| find_prop(p, book_struct)) + .collect(), + } + } else { + RuleKind::Map { + from: find_field(&p.from.unwrap(), &msg_fields), + to: find_prop(p.to.unwrap(), book_struct), + op: p + .operation + .map(|s| s.parse().expect("Invalid operation for property")) + .unwrap_or(RuleOp::Update), + } + } + }) + .collect(), + }; + + // Add attributes with the same name automatically (if they are not + // yet there). + let used_flds = ev + .rules + .iter() + .filter_map(|f| match *f { + RuleKind::Map { from, .. } => Some(from), + _ => None, + }) + .collect::>(); + + let mut used_props = vec![]; + for rule in &ev.rules { + if let RuleKind::Function { to, .. } = rule { + for p in to { + used_props.push(p.name.clone()); + } + } + } + + for fld in &msg_fields { + if used_flds.contains(fld) { + continue; + } + if let Some(prop) = book + .get_struct(&ev.book_struct.name) + .properties + .iter() + .find(|p| p.name == fld.pretty) + { + if used_props.contains(&prop.name) { + continue; + } + + ev.rules.push(RuleKind::Map { from: fld, to: prop, op: RuleOp::Update }); + } + } + + ev + }) + .collect(); + + // InitServer is done manually + decls.retain(|ev| ev.msg.name != "InitServer"); + + MessagesToBookDeclarations { book, messages, decls } +}); + +#[derive(Debug)] +pub struct MessagesToBookDeclarations<'a> { + pub book: &'a BookDeclarations, + pub messages: &'a MessageDeclarations, + pub decls: Vec>, +} + +#[derive(Debug)] +pub struct Event<'a> { + pub op: RuleOp, + /// Unique access tuple to get the property + pub id: Vec<&'a Field>, + pub msg: &'a Message, + pub book_struct: &'a Struct, + pub rules: Vec>, +} + +#[derive(Debug)] +pub enum RuleKind<'a> { + Map { from: &'a Field, to: &'a Property, op: RuleOp }, + Function { name: String, to: Vec<&'a Property> }, +} + +#[derive(Debug, PartialEq, Eq, Clone, Copy)] +pub enum RuleOp { + Add, + Remove, + Update, +} + +#[derive(Clone, Deserialize, Debug)] +#[serde(deny_unknown_fields)] +struct TomlStruct { + rule: Vec, +} + +#[derive(Clone, Deserialize, Debug)] +#[serde(deny_unknown_fields)] +struct Rule { + id: Vec, + from: String, + to: String, + operation: String, + #[serde(default = "Vec::new")] + properties: Vec, +} + +#[derive(Clone, Deserialize, Debug)] +#[serde(deny_unknown_fields)] +struct RuleProperty { + from: Option, + to: Option, + operation: Option, + + function: Option, + tolist: Option>, +} + +impl Event<'_> { + /// Fill the id of a `PropertyId`. + /// + /// `msg` is the name of the message object. + pub fn get_id_args(&self, msg: &str) -> String { + let mut res = String::new(); + for f in &self.id { + if !res.is_empty() { + res.push_str(", "); + } + if !f.get_type("").unwrap().is_primitive() { + res.push('&'); + } + let _ = write!(res, "{}.{}", msg, f.get_rust_name()); + } + res + } + + /// Create a `PropertyId` from a message struct. + /// + /// `msg` is the name of the message object. + pub fn get_property_id(&self, p: &Property, from: &Field, msg: &str) -> String { + let mut ids = self.get_id_args(msg); + if let Some(m) = &p.modifier { + if !ids.is_empty() { + ids.push_str(", "); + } + if m == "map" || m == "array" || m == "set" { + let _ = write!(ids, "{}.{}", msg, from.get_rust_name()); + } else { + panic!("Unknown modifier {}", m); + } + } + format!("PropertyId::{}{}{}", self.book_struct.name, p.get_name(), embrace(&ids)) + } +} + +impl RuleProperty { + fn is_valid(&self) -> bool { + if self.from.is_some() { + self.to.is_some() && self.function.is_none() && self.tolist.is_none() + } else { + self.from.is_none() + && self.to.is_none() + && self.operation.is_none() + && self.function.is_some() + && self.tolist.is_some() + } + } +} + +impl FromStr for RuleOp { + type Err = fmt::Error; + fn from_str(s: &str) -> Result { + if s == "add" { + Ok(RuleOp::Add) + } else if s == "remove" { + Ok(RuleOp::Remove) + } else if s == "update" { + Ok(RuleOp::Update) + } else { + eprintln!("Cannot parse operation, needs to be add, remove or update"); + Err(fmt::Error) + } + } +} + +// the in rust callable name (in PascalCase) from the field +fn find_field<'a>(name: &str, msg_fields: &[&'a Field]) -> &'a Field { + msg_fields + .iter() + .find(|f| f.pretty == name) + .unwrap_or_else(|| panic!("Cannot find field '{}'", name)) +} + +impl<'a> RuleKind<'a> { + pub fn is_function(&self) -> bool { matches!(self, RuleKind::Function { .. }) } +} diff --git a/crates/proto/tsproto-structs/src/permissions.rs b/crates/proto/tsproto-structs/src/permissions.rs new file mode 100644 index 0000000..a32a3b7 --- /dev/null +++ b/crates/proto/tsproto-structs/src/permissions.rs @@ -0,0 +1,26 @@ +use std::result::Result; + +use crate::*; + +use once_cell::sync::Lazy; + +pub const DATA_STR: &str = + include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/declarations/Permissions.csv")); + +pub static DATA: Lazy = Lazy::new(|| { + Permissions( + csv::Reader::from_reader(DATA_STR.as_bytes()) + .deserialize() + .collect::, _>>() + .unwrap(), + ) +}); + +#[derive(Debug, Deserialize)] +pub struct EnumValue { + pub name: String, + pub doc: String, +} + +#[derive(Default, Debug)] +pub struct Permissions(pub Vec); diff --git a/crates/proto/tsproto-structs/src/versions.rs b/crates/proto/tsproto-structs/src/versions.rs new file mode 100644 index 0000000..d2c3324 --- /dev/null +++ b/crates/proto/tsproto-structs/src/versions.rs @@ -0,0 +1,94 @@ +use std::collections::HashMap; +use std::fmt::Write; +use std::result::Result; + +use crate::*; + +use base64::prelude::*; +use once_cell::sync::Lazy; + +pub const DATA_STR: &str = + include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/declarations/Versions.csv")); + +pub static DATA: Lazy = Lazy::new(|| { + let mut table = csv::Reader::from_reader(DATA_STR.as_bytes()); + let mut vs = Versions(table.deserialize().collect::, _>>().unwrap()); + + // Add count if necessary + let mut counts: HashMap<_, u32> = HashMap::new(); + for v in &vs.0 { + let key = VersionKey::new(v); + *counts.entry(key).or_default() += 1; + } + counts.retain(|_, c| *c > 1); + + for v in vs.0.iter_mut().rev() { + let key = VersionKey::new(v); + if let Some(count) = counts.get_mut(&key) { + v.count = *count; + *count -= 1; + } + } + + vs +}); + +#[derive(Debug, Deserialize, Clone)] +#[serde(deny_unknown_fields)] +pub struct Version { + pub version: String, + pub platform: String, + pub hash: String, + #[serde(default)] + count: u32, +} + +impl Version { + pub fn get_enum_name(&self) -> String { + let mut res = String::new(); + res.push_str(&self.platform.replace([' ', '.'], "_")); + let ver = self.version.split(' ').next().unwrap().replace('-', "_"); + for num in ver.split('.') { + res.push('_'); + if num != "?" { + res.push_str(num); + } else { + res.push('X'); + } + } + if self.count != 0 { + res.push_str("__"); + res.push_str(&self.count.to_string()); + } + res + } + + pub fn get_sign_array(&self) -> String { + let mut res = String::new(); + for b in BASE64_STANDARD.decode(&self.hash).unwrap() { + if !res.is_empty() { + res.push_str(", "); + } + let _ = write!(res, "{:#x}", b); + } + res + } +} + +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +struct VersionKey { + pub version: String, + pub platform: String, +} + +impl VersionKey { + fn new(v: &Version) -> Self { + Self { + version: v.version.split(' ').next().unwrap().to_string(), + platform: v.platform.clone(), + } + } +} + +#[derive(Default, Debug)] +pub struct Versions(pub Vec); diff --git a/crates/proto/tsproto-types/Cargo.toml b/crates/proto/tsproto-types/Cargo.toml new file mode 100644 index 0000000..e9ccf5b --- /dev/null +++ b/crates/proto/tsproto-types/Cargo.toml @@ -0,0 +1,40 @@ +[package] +name = "tsproto-types" +version = "0.1.0" +authors = ["Flakebi "] +description = "Basic types and enums that are used within the TeamSpeak protocol." +repository = "https://github.com/ReSpeak/tsclientlib/tree/master/utils/tsproto-types" +readme = "README.md" +keywords = ["teamspeak3", "ts3"] +license = "MIT OR Apache-2.0" +build = "build/build.rs" +edition = "2018" +include = [ + "/Cargo.toml", + "/README.md", + "**/*.rs", + "**/*.tt", +] + +[dependencies] +base64 = "0.22" +bitflags = { version = "2", features = ["serde"] } +curve25519-dalek-ng = "4" +elliptic-curve = { version = "0.13", features = ["ecdh"] } +generic-array = "0.14" +num-bigint = "0.4" +num-derive = "0.4" +num-traits = "0.2" +p256 = { version = "0.13", features = ["ecdh", "ecdsa"] } +rand = "0.8" +ref-cast = "1" +serde = { version = "1", features = ["derive"] } +sha-1 = "0.10" +simple_asn1 = "0.6" +thiserror = "2" +time = { version = "0.3", features = ["serde"] } + +[build-dependencies] +heck = "0.5" +t4rust-derive = "0.3" +tsproto-structs = { path = "../tsproto-structs", version = "0.2" } diff --git a/crates/proto/tsproto-types/README.md b/crates/proto/tsproto-types/README.md new file mode 100644 index 0000000..2cf6bb6 --- /dev/null +++ b/crates/proto/tsproto-types/README.md @@ -0,0 +1,10 @@ +# tsproto-types [![docs.rs](https://docs.rs/tsproto-types/badge.svg)](https://docs.rs/tsproto-types) +`tsproto-types` contains basic types and enums that are used within the TeamSpeak protocol. + +## License +Licensed under either of + + * [Apache License, Version 2.0](../../LICENSE-APACHE) + * [MIT license](../../LICENSE-MIT) + +at your option. diff --git a/crates/proto/tsproto-types/README.tpl b/crates/proto/tsproto-types/README.tpl new file mode 100644 index 0000000..7fce8af --- /dev/null +++ b/crates/proto/tsproto-types/README.tpl @@ -0,0 +1,10 @@ +# tsproto-types [![docs.rs](https://docs.rs/tsproto-types/badge.svg)](https://docs.rs/tsproto-types) +{{readme}} + +## License +Licensed under either of + + * [Apache License, Version 2.0](../../LICENSE-APACHE) + * [MIT license](../../LICENSE-MIT) + +at your option. diff --git a/crates/proto/tsproto-types/build/Enums.tt b/crates/proto/tsproto-types/build/Enums.tt new file mode 100644 index 0000000..6c50119 --- /dev/null +++ b/crates/proto/tsproto-types/build/Enums.tt @@ -0,0 +1,30 @@ +<#@ template cleanws="true" #> +<# for e in &self.enums { #> +<# if let Some(doc) = &e.doc { #> +<#= doc_comment(doc) #> +<# } #> +#[derive(Clone, Copy, Debug, Deserialize, Eq, FromPrimitive, Hash, PartialEq, Serialize, ToPrimitive)] +pub enum <#= e.name #><# if let Some(ty) = &e.use_type { #>: <#= ty #><# } #> { +<# for v in &e.variants { #> +<#= indent(&doc_comment(&v.doc), 1) #> + <#= v.name #><# if let Some(val) = v.value { #> = <#= val #><# } #>, +<# } #> +} + +<# } + +for e in &self.bitflags { #> + +bitflags! { + <# if let Some(doc) = &e.doc { #> +<#= indent(&doc_comment(doc), 1) #> + <# } #> + #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] + pub struct <#= e.name #>: <#= e.use_type.clone().unwrap_or_else(|| format!("u{}", e.bitwidth())) #> { + <# for v in &e.variants { #> +<#= indent(&doc_comment(&v.doc), 2) #> + const <#= v.name.to_shouty_snake_case() #><# if let Some(val) = v.value { #> = <#= val #><# } #>; + <# } #> + } +} +<# } #> diff --git a/crates/proto/tsproto-types/build/Errors.tt b/crates/proto/tsproto-types/build/Errors.tt new file mode 100644 index 0000000..e49d83c --- /dev/null +++ b/crates/proto/tsproto-types/build/Errors.tt @@ -0,0 +1,13 @@ +<#@ template cleanws="true" #> +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Copy, Debug, Deserialize, Eq, FromPrimitive, Hash, PartialEq, Serialize, ToPrimitive)] +#[non_exhaustive] +pub enum Error { +<# for e in &**self { #> + <# if !e.doc.is_empty() { #> +<#= indent(&doc_comment(&e.doc), 1) #> + <# } #> + <#= e.name.to_pascal_case() #> = <#= e.num #>, +<# } #> +} diff --git a/crates/proto/tsproto-types/build/Versions.tt b/crates/proto/tsproto-types/build/Versions.tt new file mode 100644 index 0000000..504ae7e --- /dev/null +++ b/crates/proto/tsproto-types/build/Versions.tt @@ -0,0 +1,41 @@ +<#@ template cleanws="true" #> +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] +#[non_exhaustive] +#[allow(non_camel_case_types)] +pub enum Version { +<# for v in &**self { #> + <#= v.get_enum_name() #>, +<# } #> + Custom { platform: String, version: String, signature: Vec }, +} + +impl Version { + pub fn get_platform(&self) -> &str { + match *self { + <# for v in &**self { #> + Version::<#= v.get_enum_name() #> => "<#= v.platform #>", + <# } #> + Version::Custom { ref platform, .. } => platform, + } + } + + pub fn get_version_string(&self) -> &str { + match *self { + <# for v in &**self { #> + Version::<#= v.get_enum_name() #> => "<#= v.version #>", + <# } #> + Version::Custom { ref version, .. } => version, + } + } + + pub fn get_signature(&self) -> &[u8] { + match *self { + <# for v in &**self { #> + Version::<#= v.get_enum_name() #> => &[<#= v.get_sign_array() #>], + <# } #> + Version::Custom { ref signature, .. } => signature, + } + } +} diff --git a/crates/proto/tsproto-types/build/build.rs b/crates/proto/tsproto-types/build/build.rs new file mode 100644 index 0000000..43ed46a --- /dev/null +++ b/crates/proto/tsproto-types/build/build.rs @@ -0,0 +1,30 @@ +use std::env; +use std::fs::File; +use std::io::prelude::*; +use std::path::Path; + +mod enums; +mod errors; +mod versions; + +use crate::enums::Enums; +use crate::errors::Errors; +use crate::versions::Versions; + +fn main() { + let out_dir = env::var("OUT_DIR").unwrap(); + + // Enums + let path = Path::new(&out_dir); + let mut structs = File::create(path.join("enums.rs")).unwrap(); + write!(&mut structs, "{}", Enums).unwrap(); + + // Errors + let path = Path::new(&out_dir); + let mut structs = File::create(path.join("errors.rs")).unwrap(); + write!(&mut structs, "{}", Errors).unwrap(); + + // Versions + let mut structs = File::create(path.join("versions.rs")).unwrap(); + write!(&mut structs, "{}", Versions).unwrap(); +} diff --git a/crates/proto/tsproto-types/build/enums.rs b/crates/proto/tsproto-types/build/enums.rs new file mode 100644 index 0000000..08e0b11 --- /dev/null +++ b/crates/proto/tsproto-types/build/enums.rs @@ -0,0 +1,17 @@ +use std::ops::Deref; + +use heck::*; +use t4rust_derive::Template; +use tsproto_structs::enums; +use tsproto_structs::enums::*; +use tsproto_structs::{doc_comment, indent}; + +#[derive(Template)] +#[TemplatePath = "build/Enums.tt"] +#[derive(Default, Debug)] +pub struct Enums; + +impl Deref for Enums { + type Target = enums::Enums; + fn deref(&self) -> &Self::Target { &DATA } +} diff --git a/crates/proto/tsproto-types/build/errors.rs b/crates/proto/tsproto-types/build/errors.rs new file mode 100644 index 0000000..cd9ade8 --- /dev/null +++ b/crates/proto/tsproto-types/build/errors.rs @@ -0,0 +1,17 @@ +use std::ops::Deref; + +use heck::*; +use t4rust_derive::Template; +use tsproto_structs::errors::*; +use tsproto_structs::EnumValue; +use tsproto_structs::{doc_comment, indent}; + +#[derive(Template)] +#[TemplatePath = "build/Errors.tt"] +#[derive(Default, Debug)] +pub struct Errors; + +impl Deref for Errors { + type Target = Vec; + fn deref(&self) -> &Self::Target { &DATA.0 } +} diff --git a/crates/proto/tsproto-types/build/versions.rs b/crates/proto/tsproto-types/build/versions.rs new file mode 100644 index 0000000..9ae1922 --- /dev/null +++ b/crates/proto/tsproto-types/build/versions.rs @@ -0,0 +1,14 @@ +use std::ops::Deref; + +use t4rust_derive::Template; +use tsproto_structs::versions::*; + +#[derive(Template)] +#[TemplatePath = "build/Versions.tt"] +#[derive(Default, Debug)] +pub struct Versions; + +impl Deref for Versions { + type Target = Vec; + fn deref(&self) -> &Self::Target { &DATA.0 } +} diff --git a/crates/proto/tsproto-types/src/crypto.rs b/crates/proto/tsproto-types/src/crypto.rs new file mode 100644 index 0000000..cc507a8 --- /dev/null +++ b/crates/proto/tsproto-types/src/crypto.rs @@ -0,0 +1,609 @@ +//! This module contains cryptography related code. +use std::convert::TryInto; +use std::{cmp, fmt, str}; + +use base64::prelude::*; +use curve25519_dalek_ng::constants; +use curve25519_dalek_ng::edwards::{CompressedEdwardsY, EdwardsPoint}; +use curve25519_dalek_ng::scalar::Scalar; +use elliptic_curve::sec1::{FromEncodedPoint, ToEncodedPoint}; +use generic_array::GenericArray; +use generic_array::typenum::Unsigned; +use num_bigint::{BigInt, Sign}; +use p256::ecdsa::signature::{Signer, Verifier}; +use serde::{Deserialize, Deserializer, Serialize, Serializer}; +use sha1::{Digest, Sha1}; +use simple_asn1::ASN1Block; +use thiserror::Error; + +type Result = std::result::Result; + +#[derive(Debug, Clone, Error)] +#[non_exhaustive] +pub enum Error { + #[error("More than one ASN.1 block")] + TooManyAsn1Blocks, + #[error("Invalid ASN.1: Expected a public key, not a private key")] + UnexpectedPrivateKey, + #[error("Invalid ASN.1: Does not contain a private key")] + NoPrivateKey, + #[error("Invalid ASN.1: Public key not found")] + PublicKeyNotFound, + #[error("Invalid ASN.1: Expected a bitstring")] + ExpectedBitString, + #[error("Invalid ASN.1: Expected a sequence")] + ExpectedSequence, + #[error("Key data is empty")] + EmptyKeyData, + #[error("Any known methods to decode the key failed")] + KeyDecodeError, + #[error("Failed to parse short private key")] + NoShortKey, + #[error("Not a obfuscated TeamSpeak key")] + NoObfuscatedKey, + #[error("Found no initial 'V' with a valid number before")] + NoCounterBlock, + #[error("Failed to parse public key")] + ParsePublicKeyFailed, + #[error("Wrong key length")] + WrongKeyLength, + #[error("Failed to parse public key, expected length {expected} but got {got}")] + WrongPublicKeyLength { expected: usize, got: usize }, + #[error("Wrong signature")] + WrongSignature { key: EccKeyPubP256, data: Vec, signature: Vec }, + + #[error(transparent)] + Asn1Decode(#[from] simple_asn1::ASN1DecodeErr), + #[error(transparent)] + Asn1Encode(#[from] simple_asn1::ASN1EncodeErr), + #[error(transparent)] + Base64(#[from] base64::DecodeError), + #[error(transparent)] + Utf8(#[from] std::str::Utf8Error), +} + +/// Xored onto saved identities in the TeamSpeak client settings file. +const IDENTITY_OBFUSCATION: [u8; 128] = *b"b9dfaa7bee6ac57ac7b65f1094a1c155\ + e747327bc2fe5d51c512023fe54a280201004e90ad1daaae1075d53b7d571c30e063b5a\ + 62a4a017bb394833aa0983e6e"; + +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] +pub enum KeyType { + Public, + Private, +} + +/// A public ecc key. +/// +/// The curve of this key is P-256, or PRIME256v1 as it is called by openssl. +#[derive(Clone, Deserialize, Eq, PartialEq, Serialize)] +pub struct EccKeyPubP256( + #[serde( + deserialize_with = "deserialize_ecc_key_pub_p256", + serialize_with = "serialize_ecc_key_pub_p256" + )] + p256::PublicKey, +); +/// A private ecc key. +/// +/// The curve of this key is P-256, or PRIME256v1 as it is called by openssl. +#[derive(Clone)] +pub struct EccKeyPrivP256(p256::SecretKey); + +/// A public ecc key. +/// +/// The curve of this key is Ed25519. +#[derive(Clone)] +pub struct EccKeyPubEd25519(pub CompressedEdwardsY); +/// A private ecc key. +/// +/// The curve of this key is Ed25519. +#[derive(Clone)] +pub struct EccKeyPrivEd25519(pub Scalar); + +/// Passwords are encoded as base64(sha1(password)). +pub fn encode_password(password: &[u8]) -> String { + BASE64_STANDARD.encode(Sha1::digest(password).as_slice()) +} + +fn deserialize_ecc_key_pub_p256<'de, D: Deserializer<'de>>( + de: D, +) -> Result { + let data: Vec = Deserialize::deserialize(de)?; + Ok(EccKeyPubP256::from_short(&data).map_err(serde::de::Error::custom)?.0) +} + +fn serialize_ecc_key_pub_p256( + key: &p256::PublicKey, ser: S, +) -> Result { + Serialize::serialize(&EccKeyPubP256(*key).to_short().as_slice(), ser) +} + +impl fmt::Debug for EccKeyPubP256 { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "EccKeyPubP256({})", self.to_ts()) + } +} + +impl fmt::Debug for EccKeyPrivP256 { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "EccKeyPrivP256({})", BASE64_STANDARD.encode(self.to_short())) + } +} + +impl fmt::Debug for EccKeyPubEd25519 { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "EccKeyPubEd25519({})", self.to_base64()) + } +} + +impl fmt::Debug for EccKeyPrivEd25519 { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "EccKeyPrivEd25519({})", self.to_base64()) + } +} + +impl EccKeyPubP256 { + /// The shortest format of a public key. + /// + /// This is just the `BigNum` of the x and y coordinates concatenated in + /// this order. Each of the coordinates takes half of the size. + pub fn from_short(data: &[u8]) -> Result { + p256::PublicKey::from_sec1_bytes(data).map_err(|_| Error::ParsePublicKeyFailed).map(Self) + } + + /// From base64 encoded tomcrypt key. + pub fn from_ts(data: &str) -> Result { + Self::from_tomcrypt(&BASE64_STANDARD.decode(data)?) + } + + /// Decodes the public key from an ASN.1 DER object how tomcrypt stores it. + /// + /// The format is: + /// - `BitString` where the first bit is 1 if the private key is contained + /// - `Integer`: The key size (32) + /// - `Integer`: X coordinate of the public key + /// - `Integer`: Y coordinate of the public key + pub fn from_tomcrypt(data: &[u8]) -> Result { + let blocks = simple_asn1::from_der(data)?; + if blocks.len() != 1 { + return Err(Error::TooManyAsn1Blocks); + } + if let ASN1Block::Sequence(_, blocks) = &blocks[0] { + if let Some(ASN1Block::BitString(_, len, content)) = blocks.first() { + if *len != 1 || content[0] & 0x80 != 0 { + return Err(Error::UnexpectedPrivateKey); + } + if let (Some(ASN1Block::Integer(_, x)), Some(ASN1Block::Integer(_, y))) = + (blocks.get(2), blocks.get(3)) + { + let field_size = elliptic_curve::FieldBytesSize::::to_usize(); + let to_coord = |src: &BigInt| -> Result> { + let (sign, mut bytes) = src.to_bytes_le(); + if sign == Sign::Minus { + return Err(Error::ParsePublicKeyFailed); + } + if bytes.len() > field_size { + return Err(Error::WrongPublicKeyLength { + expected: field_size, + got: bytes.len(), + }); + } + // Pad if most significant bytes are zero + bytes.resize(field_size, 0); + // Convert to big-endian + bytes.reverse(); + Ok(*GenericArray::from_slice(&bytes)) + }; + let x_coord = to_coord(x)?; + let y_coord = to_coord(y)?; + let enc_point = p256::EncodedPoint::from_affine_coordinates( + &x_coord, + &y_coord, + false, + ); + let enc_point = p256::PublicKey::from_encoded_point(&enc_point); + if enc_point.is_some().into() { + Ok(Self(enc_point.unwrap())) + } else { + Err(Error::ParsePublicKeyFailed) + } + } else { + Err(Error::PublicKeyNotFound) + } + } else { + Err(Error::ExpectedBitString) + } + } else { + Err(Error::ExpectedSequence) + } + } + + /// Convert to base64 encoded public tomcrypt key. + pub fn to_ts(&self) -> String { BASE64_STANDARD.encode(self.to_tomcrypt()) } + + pub fn to_tomcrypt(&self) -> Vec { + let enc_point = self.0.as_affine().to_encoded_point(false); + // We can unwrap here, creating the public key ensures that it is not the identity point, + // which is the only time this returns `None`. + let pubkey_x = BigInt::from_bytes_be(Sign::Plus, enc_point.x().unwrap()); + let pubkey_y = BigInt::from_bytes_be(Sign::Plus, enc_point.y().unwrap()); + + // Only returns an error when encoding wrong objects, so fine to unwrap. + simple_asn1::to_der(&ASN1Block::Sequence(0, vec![ + ASN1Block::BitString(0, 1, vec![0]), + ASN1Block::Integer(0, 32.into()), + ASN1Block::Integer(0, pubkey_x), + ASN1Block::Integer(0, pubkey_y), + ])) + .unwrap() + } + + /// Get the SEC1 encoding of the public key point on the curve. + pub fn to_short(&self) -> Vec { + // TODO Maybe compress? + self.0.as_affine().to_encoded_point(false).as_bytes().to_vec() + } + + /// Compute the uid of this key without encoding it in base64. + /// + /// returns sha1(ts encoded key) + pub fn get_uid_no_base64(&self) -> Vec { + Sha1::digest(self.to_ts().as_bytes()).as_slice().to_vec() + } + + /// Compute the uid of this key. + /// + /// Uid = base64(sha1(ts encoded key)) + pub fn get_uid(&self) -> String { BASE64_STANDARD.encode(self.get_uid_no_base64()) } + + pub fn verify(&self, data: &[u8], signature: &[u8]) -> Result<()> { + let sig = + p256::ecdsa::Signature::from_der(signature).map_err(|_| Error::WrongSignature { + key: self.clone(), + data: data.to_vec(), + signature: signature.to_vec(), + })?; + let key = p256::ecdsa::VerifyingKey::from(&self.0); + key.verify(data, &sig).map_err(|_| Error::WrongSignature { + key: self.clone(), + data: data.to_vec(), + signature: signature.to_vec(), + }) + } + + // For the bookkeeping + #[allow(clippy::should_implement_trait)] + pub fn as_ref(&self) -> &Self { self } +} + +impl EccKeyPrivP256 { + /// Create a new key key pair. + pub fn create() -> Self { Self(p256::SecretKey::random(&mut rand::thread_rng())) } + + /// Try to import the key from any of the known formats. + pub fn import(data: &[u8]) -> Result { + if data.is_empty() { + return Err(Error::EmptyKeyData); + } + + if let Ok(s) = str::from_utf8(data) { + if let Ok(r) = Self::import_str(s) { + return Ok(r); + } + } + if let Ok(r) = Self::from_tomcrypt(data) { + return Ok(r); + } + if let Ok(r) = Self::from_short(data) { + return Ok(r); + } + Err(Error::KeyDecodeError) + } + + /// Try to import the key from any of the known formats. + pub fn import_str(s: &str) -> Result { + if let Ok(r) = BASE64_STANDARD.decode(s) { + if let Ok(r) = Self::import(&r) { + return Ok(r); + } + } + if let Ok(r) = Self::from_ts_obfuscated(s) { + return Ok(r); + } + Err(Error::KeyDecodeError) + } + + /// The shortest format of a private key. + /// + /// This is just the `BigNum` of the private key. + pub fn from_short(data: &[u8]) -> Result { + // TODO !! p256::SecretKey::from_bytes panics when the data is not 32 long !! + // maybe create a pull request for that because das not good?! + if data.len() != 32 { + Err(Error::NoShortKey) + } else { + Ok(Self( + p256::SecretKey::from_bytes(p256::FieldBytes::from_slice(data)) + .map_err(|_| Error::NoShortKey)?, + )) + } + } + + /// The shortest format of a private key. + /// + /// This is just the `BigNum` of the private key. + pub fn to_short(&self) -> elliptic_curve::FieldBytes { self.0.to_bytes() } + + /// From base64 encoded tomcrypt key. + pub fn from_ts(data: &str) -> Result { + Self::from_tomcrypt(&BASE64_STANDARD.decode(data)?) + } + + /// From the key representation which is used to store identities in the + /// TeamSpeak configuration file. + /// + /// Format: Offset for identity level || 'V' || obfuscated key + /// + /// This function takes only the obfuscated key without the level. + /// + /// Thanks to landave, who put + /// [his deobfuscation code](https://github.com/landave/TSIdentityTool) + /// under the MIT license. + pub fn from_ts_obfuscated(data: &str) -> Result { + let mut data = BASE64_STANDARD.decode(data)?; + if data.len() < 20 { + return Err(Error::NoObfuscatedKey); + } + // Hash everything until the first 0 byte, starting after the first 20 + // bytes. + let pos = data[20..].iter().position(|b| *b == b'\0').unwrap_or(data.len() - 20); + let hash = Sha1::digest(&data[20..20 + pos]); + let hash = hash.as_slice(); + // Xor first 20 bytes of data with the hash + for i in 0..20 { + data[i] ^= hash[i]; + } + + // Xor first 100 bytes with a static value + #[allow(clippy::needless_range_loop)] + for i in 0..cmp::min(data.len(), 100) { + data[i] ^= IDENTITY_OBFUSCATION[i]; + } + Self::from_ts(str::from_utf8(&data)?) + } + + /// Decodes the private key from an ASN.1 DER object how tomcrypt stores it. + /// + /// The format is: + /// - `BitString` where the first bit is 1 if the private key is contained + /// - `Integer`: The key size (32) + /// - `Integer`: X coordinate of the public key + /// - `Integer`: Y coordinate of the public key + /// - `Integer`: Private key + /// + /// The TS3AudioBot stores two 1 bits in the first `BitString` and omits the + /// public key. + pub fn from_tomcrypt(data: &[u8]) -> Result { + let blocks = simple_asn1::from_der(data)?; + if blocks.len() != 1 { + return Err(Error::TooManyAsn1Blocks); + } + if let ASN1Block::Sequence(_, blocks) = &blocks[0] { + if let Some(ASN1Block::BitString(_, len, content)) = blocks.first() { + if (*len != 1 && *len != 2) || content[0] & 0x80 == 0 { + return Err(Error::NoPrivateKey); + } + if *len == 1 { + if let Some(ASN1Block::Integer(_, i)) = blocks.get(4) { + Self::from_short(&i.to_bytes_be().1) + } else { + Err(Error::NoPrivateKey) + } + } else if let Some(ASN1Block::Integer(_, i)) = blocks.get(2) { + Self::from_short(&i.to_bytes_be().1) + } else { + Err(Error::NoPrivateKey) + } + } else { + Err(Error::ExpectedBitString) + } + } else { + Err(Error::ExpectedSequence) + } + } + + /// Convert to base64 encoded private tomcrypt key. + pub fn to_ts(&self) -> String { BASE64_STANDARD.encode(self.to_tomcrypt()) } + + /// Store as obfuscated TeamSpeak identity. + pub fn to_ts_obfuscated(&self) -> String { + let mut data = self.to_ts().into_bytes(); + // Xor first 100 bytes with a static value + #[allow(clippy::needless_range_loop)] + for i in 0..cmp::min(data.len(), 100) { + data[i] ^= IDENTITY_OBFUSCATION[i]; + } + + // Hash everything until the first 0 byte, starting after the first 20 + // bytes. + let pos = data[20..].iter().position(|b| *b == b'\0').unwrap_or(data.len() - 20); + let hash = Sha1::digest(&data[20..20 + pos]); + let hash = hash.as_slice(); + // Xor first 20 bytes of data with the hash + for i in 0..20 { + data[i] ^= hash[i]; + } + BASE64_STANDARD.encode(data) + } + + pub fn to_tomcrypt(&self) -> Vec { + let enc_point = self.0.public_key().as_affine().to_encoded_point(false); + // We can unwrap here, creating the public key ensures that it is not the identity point, + // which is the only time this returns `None`. + let pubkey_x = BigInt::from_bytes_be(Sign::Plus, enc_point.x().unwrap()); + let pubkey_y = BigInt::from_bytes_be(Sign::Plus, enc_point.y().unwrap()); + let privkey = BigInt::from_bytes_be(Sign::Plus, &self.0.to_bytes()); + + // Only returns an error when encoding wrong objects, so fine to unwrap. + simple_asn1::to_der(&ASN1Block::Sequence(0, vec![ + ASN1Block::BitString(0, 1, vec![0x80]), + ASN1Block::Integer(0, 32.into()), + ASN1Block::Integer(0, pubkey_x), + ASN1Block::Integer(0, pubkey_y), + ASN1Block::Integer(0, privkey), + ])) + .unwrap() + } + + /// This has to be the private key, the other one has to be the public key. + pub fn create_shared_secret( + self, other: EccKeyPubP256, + ) -> elliptic_curve::ecdh::SharedSecret { + elliptic_curve::ecdh::diffie_hellman(self.0.to_nonzero_scalar(), other.0.as_affine()) + } + + pub fn sign(self, data: &[u8]) -> Vec { + let key = p256::ecdsa::SigningKey::from(self.0); + let sig: p256::ecdsa::DerSignature = key.sign(data); + sig.as_bytes().to_vec() + } + + pub fn to_pub(&self) -> EccKeyPubP256 { self.into() } +} + +impl<'a> From<&'a EccKeyPrivP256> for EccKeyPubP256 { + fn from(priv_key: &'a EccKeyPrivP256) -> Self { Self(priv_key.0.public_key()) } +} + +impl EccKeyPubEd25519 { + pub fn from_bytes(data: [u8; 32]) -> Self { EccKeyPubEd25519(CompressedEdwardsY(data)) } + + pub fn from_base64(data: &str) -> Result { + let decoded = BASE64_STANDARD.decode(data)?; + if decoded.len() != 32 { + return Err(Error::WrongKeyLength); + } + Ok(Self::from_bytes(decoded[..32].try_into().unwrap())) + } + + pub fn to_base64(&self) -> String { + let EccKeyPubEd25519(CompressedEdwardsY(ref data)) = *self; + BASE64_STANDARD.encode(data) + } +} + +impl EccKeyPrivEd25519 { + /// This is not used to create TeamSpeak keys, as they are not canonical. + pub fn create() -> Self { EccKeyPrivEd25519(Scalar::random(&mut rand::thread_rng())) } + + pub fn from_base64(data: &str) -> Result { + let decoded = BASE64_STANDARD.decode(data)?; + if decoded.len() != 32 { + return Err(Error::WrongKeyLength); + } + Ok(Self::from_bytes(decoded[..32].try_into().unwrap())) + } + + pub fn from_bytes(data: [u8; 32]) -> Self { + EccKeyPrivEd25519(Scalar::from_bytes_mod_order(data)) + } + + pub fn to_base64(&self) -> String { BASE64_STANDARD.encode(self.0.as_bytes()) } + + /// This has to be the private key, the other one has to be the public key. + pub fn create_shared_secret(&self, pub_key: &EdwardsPoint) -> [u8; 32] { + let res = pub_key * self.0; + res.compress().0 + } + + pub fn to_pub(&self) -> EccKeyPubEd25519 { self.into() } +} + +impl<'a> From<&'a EccKeyPrivEd25519> for EccKeyPubEd25519 { + fn from(priv_key: &'a EccKeyPrivEd25519) -> Self { + Self((&constants::ED25519_BASEPOINT_TABLE * &priv_key.0).compress()) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + const TEST_PRIV_KEY: &str = "MG0DAgeAAgEgAiAIXJBlj1hQbaH0Eq0DuLlCmH8bl+veTA\ + O2+k9EQjEYSgIgNnImcmKo7ls5mExb6skfK2Tw+u54aeDr0OP1ITsC/50CIA8M5nmDB\ + nmDM/gZ//4AAAAAAAAAAAAAAAAAAAAZRzOI"; + + #[test] + fn parse_p256_priv_key() { EccKeyPrivP256::from_ts(TEST_PRIV_KEY).unwrap(); } + + #[test] + fn p256_ecdh() { + let priv_key1 = EccKeyPrivP256::create(); + let pub_key1 = priv_key1.to_pub(); + let priv_key2 = EccKeyPrivP256::create(); + let pub_key2 = priv_key2.to_pub(); + + let res1 = priv_key1.create_shared_secret(pub_key2); + let res2 = priv_key2.create_shared_secret(pub_key1); + assert_eq!(res1.raw_secret_bytes(), res2.raw_secret_bytes()); + } + + #[test] + fn p256_signature() { + let license = + "AQBM0LZCVmZ7CX/\ + miewqdjOyuKa6kI78Fk43LoypifqOkAIOkvUAEn46gAcAAAAgQW5vbnltb3VzAABoruUa34pO9zy1Z5zIOmrkIO06lKg/\ + +mBrg6Mw1Rg4OyAPa7A3D2xY9w=="; + let server_key = "MEwDAgcAAgEgAiEA96WgYeYU8zoPqXJqicita+rR92FvnTlxYcUUyIDkQ6cCIE/\ + KPo+ms3BEzN/HBR71BJ/Z1Fv8918mdDKLetbOGKWt"; + let signature = "MEUCIQC+ececxC0NCcuCtrXHAO5h7qbh1s/TGP/\ + AaHa6+wV38wIgV9wwSppEdGjwuH3ETAME9tDj3aNkNvL25i0ikF9vs8M="; + let license = BASE64_STANDARD.decode(license).unwrap(); + let signature = BASE64_STANDARD.decode(signature).unwrap(); + let server_key = EccKeyPubP256::from_ts(server_key).unwrap(); + server_key.verify(&license, &signature).unwrap(); + } + + #[test] + fn obfuscated_priv_key() { + let key = EccKeyPrivP256::from_ts(TEST_PRIV_KEY).unwrap(); + let obf = key.to_ts_obfuscated(); + let key2 = EccKeyPrivP256::from_ts_obfuscated(&obf).unwrap(); + assert_eq!(key.to_short(), key2.to_short()); + } + + #[test] + fn obfuscated_identity() { + let key = EccKeyPrivP256::from_ts(TEST_PRIV_KEY).unwrap(); + let uid = key.to_pub().get_uid(); + + let expected_uid = "lks7QL5OVMKo4pZ79cEOI5r5oEA="; + assert_eq!(expected_uid, &uid); + } + + #[test] + fn tsaudiobot_identity() { + let key = EccKeyPrivP256::import_str( + "MCkDAgbAAgEgAiBhPImh+bO1xMGOrcplwN3G74bhE9XATm+DxVo3aNtBqg==", + ) + .unwrap(); + let uid = key.to_pub().get_uid(); + let expected_uid = "test/9PZ9vww/Bpf5vJxtJhpz80="; + assert_eq!(expected_uid, &uid); + } + + #[test] + fn test_p256_priv_key_short() { + let key = EccKeyPrivP256::from_ts(TEST_PRIV_KEY).unwrap(); + let short = key.to_short(); + let key = EccKeyPrivP256::from_short(short.as_slice()).unwrap(); + let short2 = key.to_short(); + assert_eq!(short, short2); + } + + #[test] + fn parse_ed25519_pub_key() { + EccKeyPubEd25519::from_base64("zQ3irtRjRVCafjz9j2iz3HVVsp3M7HPNGHUPmTgSQIo=").unwrap(); + } +} diff --git a/crates/proto/tsproto-types/src/errors.rs b/crates/proto/tsproto-types/src/errors.rs new file mode 100644 index 0000000..d201ad3 --- /dev/null +++ b/crates/proto/tsproto-types/src/errors.rs @@ -0,0 +1,13 @@ +use std::fmt; + +use num_derive::{FromPrimitive, ToPrimitive}; + +include!(concat!(env!("OUT_DIR"), "/errors.rs")); + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Debug::fmt(self, f) } +} + +impl std::error::Error for Error { + fn description(&self) -> &str { "TeamSpeak error" } +} diff --git a/crates/proto/tsproto-types/src/lib.rs b/crates/proto/tsproto-types/src/lib.rs new file mode 100644 index 0000000..84a69af --- /dev/null +++ b/crates/proto/tsproto-types/src/lib.rs @@ -0,0 +1,173 @@ +//! `tsproto-types` contains basic types and enums that are used within the TeamSpeak protocol. + +use std::borrow::{Borrow, Cow}; +use std::fmt; + +use base64::prelude::*; +use bitflags::bitflags; +use num_derive::{FromPrimitive, ToPrimitive}; +use ref_cast::RefCast; +use serde::{Deserialize, Deserializer, Serialize}; +use time::OffsetDateTime; + +pub mod crypto; +pub mod errors; +pub mod versions; + +include!(concat!(env!("OUT_DIR"), "/enums.rs")); + +/// A `ClientId` identifies a client which is connected to a server. +/// +/// Every client that we see on a server has a `ClientId`, even our own +/// connection. +#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] +pub struct ClientId(pub u16); +/// Describes a client or server uid which is a base64 +/// encoded hash or a special reserved name. +/// +/// This is saved raw, so the base64-decoded TeamSpeak uid. +#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] +pub struct UidBuf(pub Vec); + +#[derive(Debug, Eq, PartialEq, RefCast, Serialize)] +#[repr(transparent)] +pub struct Uid(pub [u8]); + +impl ToOwned for Uid { + type Owned = UidBuf; + fn to_owned(&self) -> Self::Owned { UidBuf(self.0.to_owned()) } +} +impl Borrow for UidBuf { + fn borrow(&self) -> &Uid { Uid::ref_cast(self.0.borrow()) } +} +impl AsRef for UidBuf { + fn as_ref(&self) -> &Uid { self.borrow() } +} +impl core::ops::Deref for UidBuf { + type Target = Uid; + fn deref(&self) -> &Self::Target { self.borrow() } +} +impl<'a> From<&'a Uid> for Cow<'a, Uid> { + fn from(u: &'a Uid) -> Self { Cow::Borrowed(u) } +} + +impl Uid { + pub fn from_bytes(data: &'_ [u8]) -> &Self { Uid::ref_cast(data) } + + /// TeamSpeak uses a different encoding of the uid for fetching avatars. + /// + /// The raw data (base64-decoded) is encoded in hex, but instead of using + /// [0-9a-f] with [a-p]. + pub fn as_avatar(&self) -> String { + let mut res = String::with_capacity(self.0.len() * 2); + for b in &self.0 { + res.push((b'a' + (b >> 4)) as char); + res.push((b'a' + (b & 0xf)) as char); + } + res + } + + pub fn is_server_admin(&self) -> bool { &self.0 == b"ServerAdmin" } +} + +impl<'a, 'de: 'a> Deserialize<'de> for &'a Uid { + fn deserialize(d: D) -> Result<&'a Uid, D::Error> + where D: Deserializer<'de> { + let data = <&[u8]>::deserialize(d)?; + Ok(Uid::from_bytes(data)) + } +} + +/// The database id of a client. +/// +/// This is the id which is saved for a client in the database of one specific +/// server. +#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] +pub struct ClientDbId(pub u64); + +/// Identifies a channel on a server. +#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] +pub struct ChannelId(pub u64); + +/// Identifies a server group on a server. +#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] +pub struct ServerGroupId(pub u64); + +/// Identifies a channel group on a server. +#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] +pub struct ChannelGroupId(pub u64); + +#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] +pub struct IconId(pub u32); + +#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] +pub struct Permission(pub u32); +impl Permission { + /// Never fails + pub fn from_u32(i: u32) -> Option { Some(Permission(i)) } + /// Never fails + pub fn to_u32(self) -> Option { Some(self.0) } +} + +#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] +pub enum ClientType { + Normal, + /// Server query client + Query { + admin: bool, + }, +} + +#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] +pub enum MaxClients { + Unlimited, + Inherited, + Limited(u16), +} + +#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] +pub struct TalkPowerRequest { + pub time: OffsetDateTime, + pub message: String, +} + +#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] +pub struct Invoker { + pub name: String, + pub id: ClientId, + pub uid: Option, +} + +#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] +pub struct InvokerRef<'a> { + pub name: &'a str, + pub id: ClientId, + pub uid: Option<&'a Uid>, +} + +impl Invoker { + pub fn as_ref(&self) -> InvokerRef<'_> { + InvokerRef { name: &self.name, id: self.id, uid: self.uid.as_ref().map(|u| u.as_ref()) } + } +} + +impl fmt::Display for ClientId { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.0) } +} +impl fmt::Display for Uid { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", BASE64_STANDARD.encode(&self.0)) + } +} +impl fmt::Display for ClientDbId { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.0) } +} +impl fmt::Display for ChannelId { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.0) } +} +impl fmt::Display for ServerGroupId { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.0) } +} +impl fmt::Display for ChannelGroupId { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.0) } +} diff --git a/crates/proto/tsproto-types/src/versions.rs b/crates/proto/tsproto-types/src/versions.rs new file mode 100644 index 0000000..3e5fbc6 --- /dev/null +++ b/crates/proto/tsproto-types/src/versions.rs @@ -0,0 +1,9 @@ +use std::fmt; + +include!(concat!(env!("OUT_DIR"), "/versions.rs")); + +impl fmt::Display for Version { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{} {}", self.get_platform(), self.get_version_string()) + } +} diff --git a/crates/proto/tsproto/Cargo.toml b/crates/proto/tsproto/Cargo.toml new file mode 100644 index 0000000..b4fd1af --- /dev/null +++ b/crates/proto/tsproto/Cargo.toml @@ -0,0 +1,67 @@ +[package] +name = "tsproto" +version = "0.2.0" +authors = ["Flakebi "] +description = "An implementation of the TeamSpeak3 protocol as a library for use in clients and bots." +repository = "https://github.com/ReSpeak/tsclientlib" +readme = "README.md" +keywords = ["teamspeak3", "ts3", "voip"] +categories = ["multimedia"] +license = "MIT OR Apache-2.0" +edition = "2018" +autobenches = false +include = [ + "/Cargo.toml", + "/README.md", + "**/*.rs", +] + +[dependencies] +aes = "0.8" +base64 = "0.22" +omnom = "3" +curve25519-dalek-ng = "4" +eax = "0.5" +futures = "0.3" +generic-array = "0.14" +git-testament = "0.2" +num-bigint = "0.4" +num-derive = "0.4" +num-traits = "0.2" +pin-project-lite = "0.2" +rand = "0.10" +rug = { version = "1", optional = true, default-features = false, features = ["integer"] } +serde = { version = "1", features = ["derive"] } +sha-1 = "0.10" +sha2 = "0.10" +thiserror = "2" +time = { version = "0.3", features = ["formatting"] } +tokio = { version = "1", features = ["macros", "net", "sync", "time"] } +tracing = "0.1" +tsproto-packets = { path = "../utils/tsproto-packets", version = "0.1" } +tsproto-types = { path = "../utils/tsproto-types", version = "0.1" } +quicklz = "0.3" + +[dev-dependencies] +anyhow = "1" +criterion = "0.8" +once_cell = "1" +clap = { version = "4", features = ["derive"] } +tokio = { version = "1", features = ["rt-multi-thread", "signal"] } +tracing-subscriber = "0.3" + +[[bench]] +name = "modpow" +harness = false + +[[bench]] +name = "connect" +harness = false + +[[bench]] +name = "license" +harness = false + +[[bench]] +name = "message" +harness = false diff --git a/crates/proto/tsproto/README.md b/crates/proto/tsproto/README.md new file mode 100644 index 0000000..f60fe75 --- /dev/null +++ b/crates/proto/tsproto/README.md @@ -0,0 +1,21 @@ +# TsProto   [![docs.rs](https://docs.rs/tsproto/badge.svg)](https://docs.rs/tsproto) +This library implements the TeamSpeak3 protocol. + +For a usable library to build clients and bots, you should take a look at +[`tsclientlib`](https://github.com/ReSpeak/tsclientlib), which provides a +convenient interface to this library. + +If you are searching for a usable client, [Qint](https://github.com/ReSpeak/Qint) +is a cross-platform TeamSpeak client, which is using this library (more +correctly, it is using `tsclientlib`). + +For more info on this project, take a look at the +[tsclientlib README](https://github.com/ReSpeak/tsclientlib). + +## License +Licensed under either of + + * [Apache License, Version 2.0](../LICENSE-APACHE) + * [MIT license](../LICENSE-MIT) + +at your option. diff --git a/crates/proto/tsproto/README.tpl b/crates/proto/tsproto/README.tpl new file mode 100644 index 0000000..25ba62c --- /dev/null +++ b/crates/proto/tsproto/README.tpl @@ -0,0 +1,10 @@ +# TsProto   [![docs.rs](https://docs.rs/tsproto/badge.svg)](https://docs.rs/tsproto) +{{readme}} + +## License +Licensed under either of + + * [Apache License, Version 2.0](../LICENSE-APACHE) + * [MIT license](../LICENSE-MIT) + +at your option. diff --git a/crates/proto/tsproto/benches/connect.rs b/crates/proto/tsproto/benches/connect.rs new file mode 100644 index 0000000..b053271 --- /dev/null +++ b/crates/proto/tsproto/benches/connect.rs @@ -0,0 +1,77 @@ +use anyhow::{Error, Result}; +use criterion::{criterion_group, criterion_main, Bencher, Criterion}; +use once_cell::sync::Lazy; +use tracing::{info, warn}; +use tsproto::client::Client; +use tsproto::connection::StreamItem; +use tsproto_packets::commands::CommandParser; + +mod utils; +use crate::utils::*; + +static TRACING: Lazy<()> = Lazy::new(|| tracing_subscriber::fmt().with_test_writer().init()); + +async fn wait_channellistfinished(con: &mut Client) -> Result<()> { + con.filter_items(|con, i| { + Ok(match i { + StreamItem::S2CInit(packet) => { + con.hand_back_buffer(packet.into_buffer()); + None + } + StreamItem::C2SInit(packet) => { + con.hand_back_buffer(packet.into_buffer()); + None + } + StreamItem::Command(packet) => { + let (name, _) = CommandParser::new(packet.data().packet().content()); + if name == b"channellistfinished" { Some(()) } else { None } + } + StreamItem::Error(error) => { + warn!(%error, "Got connection error"); + None + } + i => { + warn!(got = ?i, "Unexpected packet, waiting for channellistfinished"); + None + } + }) + }) + .await?; + Ok(()) +} + +fn one_connect(b: &mut Bencher) { + Lazy::force(&TRACING); + + let local_address = "127.0.0.1:0".parse().unwrap(); + let address = "127.0.0.1:9987".parse().unwrap(); + + let rt = tokio::runtime::Runtime::new().unwrap(); + + b.iter(|| { + rt.block_on(async move { + // The TS server does not accept the 3rd reconnect from the same port + // so we create a new client for every connection. + let mut con = create_client(local_address, address, 0).await?; + + connect(&mut con).await?; + info!("Connected"); + // Wait until channellistfinished + wait_channellistfinished(&mut con).await?; + + info!("Disconnecting"); + disconnect(&mut con).await?; + Ok::<_, Error>(()) + }) + .unwrap(); + }); +} + +fn bench_connect(c: &mut Criterion) { c.bench_function("connect", one_connect); } + +criterion_group! { + name = benches; + config = Criterion::default().sample_size(20); + targets = bench_connect +} +criterion_main!(benches); diff --git a/crates/proto/tsproto/benches/license.rs b/crates/proto/tsproto/benches/license.rs new file mode 100644 index 0000000..898f36b --- /dev/null +++ b/crates/proto/tsproto/benches/license.rs @@ -0,0 +1,58 @@ +use base64::prelude::*; +use criterion::{criterion_group, criterion_main, Bencher, Criterion}; +use tsproto::license::Licenses; +use tsproto_types::crypto::EccKeyPubEd25519; + +fn license_parse(b: &mut Bencher, license: Vec) { + b.iter(|| { + Licenses::parse_ignore_expired(license.clone()).unwrap(); + }); +} + +fn license_derive_key(b: &mut Bencher, license: Vec) { + let licenses = Licenses::parse_ignore_expired(license).unwrap(); + + b.iter(|| { + let derived_key = + licenses.derive_public_key(EccKeyPubEd25519::from_bytes(tsproto::ROOT_KEY)).unwrap(); + derived_key.compress().0 + }); +} + +const STANDARD_LICENSE: &str = "AQA1hUFJiiSs0wFXkYuPUJVcDa6XCrZTcsvkB0\ + Ffzz4CmwIITRXgCqeTYAcAAAAgQW5vbnltb3VzAACiIBip9hQaK6P3QhwOJs/BkPn0i\ + oyIDPaNgzJ6M8x0kiAJf4hxCYAxMQ=="; + +const AAL_LICENSE: &str = "AQCvbHFTQDY/terPeilrp/ECU9xCH5U3xC92lY\ + TNaY/0KQAJFueAazbsgAAAACVUZWFtU3BlYWsgU3lzdGVtcyBHbWJIAABhl9gwla/UJ\ + p2Eszst9TRVXO/PeE6a6d+CTI6Pg7OEVgAJc5CrL4Nh8gAAACRUZWFtU3BlYWsgc3lz\ + dGVtcyBHbWJIAACvTQIgpv6zmLZq3znh7ygmOSokGFkFjz4bTigrOnetrgIJdIIACdS\ + /gAYAAAAAU29zc2VuU3lzdGVtcy5iaWQAADY7+uV1CQ1niOvYSdGzsu83kPTNWijovr\ + 3B78eHGeePIAm98vQJvpu0"; + +fn standard_license_parse(b: &mut Bencher) { + license_parse(b, BASE64_STANDARD.decode(STANDARD_LICENSE).unwrap()); +} + +fn aal_license_parse(b: &mut Bencher) { + license_parse(b, BASE64_STANDARD.decode(AAL_LICENSE).unwrap()); +} + +fn standard_license_derive_key(b: &mut Bencher) { + license_derive_key(b, BASE64_STANDARD.decode(STANDARD_LICENSE).unwrap()); +} + +fn aal_license_derive_key(b: &mut Bencher) { + license_derive_key(b, BASE64_STANDARD.decode(AAL_LICENSE).unwrap()); +} + +fn bench_license(c: &mut Criterion) { + c.bench_function("parse standard license", standard_license_parse); + c.bench_function("parse aal license", aal_license_parse); + + c.bench_function("derive key standard license", standard_license_derive_key); + c.bench_function("derive key aal license", aal_license_derive_key); +} + +criterion_group!(benches, bench_license); +criterion_main!(benches); diff --git a/crates/proto/tsproto/benches/message.rs b/crates/proto/tsproto/benches/message.rs new file mode 100644 index 0000000..7e28716 --- /dev/null +++ b/crates/proto/tsproto/benches/message.rs @@ -0,0 +1,69 @@ +use anyhow::Error; +use criterion::{criterion_group, criterion_main, Bencher, Criterion}; +use tracing::info; +use tsproto_packets::packets::*; + +mod utils; +use crate::utils::*; + +fn send_messages(b: &mut Bencher) { + create_logger(false); + + let local_address = "127.0.0.1:0".parse().unwrap(); + let address = "127.0.0.1:9987".parse().unwrap(); + + let rt = tokio::runtime::Runtime::new().unwrap(); + let mut con = rt + .block_on(async move { + let mut con = create_client(local_address, address, 0).await?; + + info!("Connecting"); + connect(&mut con).await?; + Ok::<_, Error>(con) + }) + .unwrap(); + + let mut i = 0; + + let mut last_id = None; + b.iter(|| { + let text = format!("Hello {}", i); + let mut packet = + OutCommand::new(Direction::C2S, Flags::empty(), PacketType::Command, "sendtextmessage"); + packet.write_arg("targetmode", &"3"); + packet.write_arg("msg", &text); + i += 1; + + rt.block_on(async { + con.wait_until_can_send().await.unwrap(); + last_id = Some(con.send_packet(packet.into_packet()).unwrap()); + }); + }); + + rt.block_on(async move { + if let Some(id) = last_id { + info!("Waiting for {:?}", id); + con.wait_for_ack(id).await?; + } + tokio::select! { + _ = tokio::time::sleep(tokio::time::Duration::from_millis(50)) => { + } + _ = con.wait_disconnect() => { + anyhow::bail!("Disconnected"); + } + }; + + info!("Disconnecting"); + disconnect(&mut con).await + }) + .unwrap(); +} + +fn bench_message(c: &mut Criterion) { c.bench_function("message", send_messages); } + +criterion_group! { + name = benches; + config = Criterion::default().sample_size(200); + targets = bench_message +} +criterion_main!(benches); diff --git a/crates/proto/tsproto/benches/modpow.rs b/crates/proto/tsproto/benches/modpow.rs new file mode 100644 index 0000000..79a0d71 --- /dev/null +++ b/crates/proto/tsproto/benches/modpow.rs @@ -0,0 +1,42 @@ +use criterion::{criterion_group, criterion_main, Bencher, Criterion}; +use num_bigint::BigUint; +use num_traits::One; +#[cfg(feature = "rug")] +use rug::Integer; + +fn num_modpow(b: &mut Bencher) { + let n = "9387019355706217197639129234358945126657617361248696932841794255538327365072557602175160199263073329488914880215590036563068284078359088114486271428098753"; + let x = "2148617454765635492758175407769288127281667975788420713054995716016550287184632946544163990319181591625774561067011999700977775946073267145316355582522577"; + let level = 10_000; + let n = n.parse().unwrap(); + let x: BigUint = x.parse().unwrap(); + let mut e = BigUint::one(); + e <<= level as usize; + + b.iter(|| x.modpow(&e, &n)); +} + +#[cfg(feature = "rug")] +fn gmp_modpow(b: &mut Bencher) { + let n = "9387019355706217197639129234358945126657617361248696932841794255538327365072557602175160199263073329488914880215590036563068284078359088114486271428098753"; + let x = "2148617454765635492758175407769288127281667975788420713054995716016550287184632946544163990319181591625774561067011999700977775946073267145316355582522577"; + let level = 10_000; + let n: Integer = n.parse().unwrap(); + let x: Integer = x.parse().unwrap(); + let mut e = Integer::new(); + e.set_bit(level, true); + + b.iter(|| x.pow_mod_ref(&e, &n).unwrap()); +} + +fn bench_modpow(c: &mut Criterion) { + c.bench_function("num bigint", num_modpow); + + #[cfg(feature = "rug")] + { + c.bench_function("gmp", gmp_modpow); + } +} + +criterion_group!(benches, bench_modpow); +criterion_main!(benches); diff --git a/crates/proto/tsproto/benches/utils/mod.rs b/crates/proto/tsproto/benches/utils/mod.rs new file mode 100644 index 0000000..2025f39 --- /dev/null +++ b/crates/proto/tsproto/benches/utils/mod.rs @@ -0,0 +1,112 @@ +use std::net::SocketAddr; + +use anyhow::Result; +use tokio::net::UdpSocket; +use tsproto::algorithms as algs; +use tsproto::client::Client; +use tsproto_packets::packets::*; +use tsproto_types::crypto::EccKeyPrivP256; + +#[allow(dead_code)] +pub fn create_logger(to_file: bool) { + if to_file { + tracing_subscriber::fmt() + .with_writer(|| std::fs::OpenOptions::new().append(true).open("bench.log").unwrap()) + .init(); + } else { + tracing_subscriber::fmt::init(); + } +} + +pub async fn create_client( + local_address: SocketAddr, remote_address: SocketAddr, verbose: u8, +) -> Result { + // Get P-256 ECDH key + let private_key = EccKeyPrivP256::import_str( + "MG0DAgeAAgEgAiAIXJBlj1hQbaH0Eq0DuLlCmH8bl+veTAO2+\ + k9EQjEYSgIgNnImcmKo7ls5mExb6skfK2Tw+u54aeDr0OP1ITsC/50CIA8M5nm\ + DBnmDM/gZ//4AAAAAAAAAAAAAAAAAAAAZRzOI").unwrap(); + + let udp_socket = UdpSocket::bind(local_address).await?; + let mut con = Client::new(remote_address, Box::new(udp_socket), private_key); + + if verbose >= 1 { + tsproto::log::add_logger(true, verbose > 1, verbose > 2, &mut con) + } + + Ok(con) +} + +/// Returns the `initserver` command. +pub async fn connect(con: &mut Client) -> Result { + con.connect().await?; + + // Send clientinit + let private_key = EccKeyPrivP256::import_str( + "MG0DAgeAAgEgAiAIXJBlj1hQbaH0Eq0DuLlCmH8bl+veTAO2+\ + k9EQjEYSgIgNnImcmKo7ls5mExb6skfK2Tw+u54aeDr0OP1ITsC/50CIA8M5nm\ + DBnmDM/gZ//4AAAAAAAAAAAAAAAAAAAAZRzOI").unwrap(); + + let private_key_as_pub = private_key.to_pub(); + let offset = algs::hash_cash(&private_key_as_pub, 8); + + // Create clientinit packet + let offset = offset.to_string(); + let mut packet = + OutCommand::new(Direction::C2S, Flags::empty(), PacketType::Command, "clientinit"); + + for (arg, val) in [ + ("client_nickname", "Bot"), + ("client_version", "3.?.? [Build: 5680278000]"), + ("client_platform", "Linux"), + ("client_input_hardware", "1"), + ("client_output_hardware", "1"), + ("client_default_channel", ""), + ("client_default_channel_password", ""), + ("client_server_password", ""), + ("client_meta_data", ""), + ( + "client_version_sign", + "Hjd+N58Gv3ENhoKmGYy2bNRBsNNgm5kpiaQWxOj5HN2DXttG6REjymSwJtpJ8muC2gSwRuZi0R+8Laan5ts5CQ==", + ), + ("client_nickname_phonetic", ""), + ("client_key_offset", &offset), + ("client_default_token", ""), + ("client_badges", "Overwolf=0"), + ( + "hwid", + "923f136fb1e22ae6ce95e60255529c00,\ + d13231b1bc33edfecfb9169cc7a63bcc", + ), + ] { + packet.write_arg(arg, &val); + } + + con.send_packet(packet.into_packet())?; + Ok(con + .filter_commands(|con, cmd| { + Ok(if cmd.data().packet().content().starts_with(b"initserver ") { + Some(cmd) + } else { + con.hand_back_buffer(cmd.into_buffer()); + None + }) + }) + .await?) +} + +pub async fn disconnect(con: &mut Client) -> Result<()> { + let mut packet = + OutCommand::new(Direction::C2S, Flags::empty(), PacketType::Command, "clientdisconnect"); + for (arg, val) in [ + // Reason: Disconnect + ("reasonid", "8"), + ("reasonmsg", "Bye"), + ] { + packet.write_arg(arg, &val); + } + + con.send_packet(packet.into_packet())?; + con.wait_disconnect().await?; + Ok(()) +} diff --git a/crates/proto/tsproto/examples/client.rs b/crates/proto/tsproto/examples/client.rs new file mode 100644 index 0000000..3987cfc --- /dev/null +++ b/crates/proto/tsproto/examples/client.rs @@ -0,0 +1,67 @@ +use std::net::SocketAddr; + +use anyhow::{bail, Result}; +use clap::Parser; +use tokio::time::{self, Duration}; +use tracing::info; +use tsproto_packets::packets::*; + +mod utils; +use crate::utils::*; + +#[derive(Parser, Debug)] +#[command(author, about)] +struct Args { + /// The address of the server to connect to + #[arg(short, long, default_value = "127.0.0.1:9987")] + address: SocketAddr, + /// The listening address of the client + #[arg(long, default_value = "0.0.0.0:0")] + local_address: SocketAddr, + /// Print the content of all packets + /// + /// 0. Print nothing + /// 1. Print command string + /// 2. Print packets + /// 3. Print udp packets + #[arg(short, long, action = clap::ArgAction::Count)] + verbose: u8, +} + +#[tokio::main] +async fn main() -> Result<()> { real_main().await } + +async fn real_main() -> Result<()> { + // Parse command line options + let args = Args::parse(); + create_logger(); + + let mut con = create_client(args.local_address, args.address, args.verbose).await?; + + // Connect + connect(&mut con).await?; + info!("Connected"); + + // Wait some time + tokio::select! { + _ = time::sleep(Duration::from_secs(2)) => {} + _ = con.wait_disconnect() => { + bail!("Disconnected"); + } + }; + info!("Waited"); + + // Send packet + let mut cmd = + OutCommand::new(Direction::C2S, Flags::empty(), PacketType::Command, "sendtextmessage"); + cmd.write_arg("targetmode", &3); + cmd.write_arg("msg", &"Hello"); + let id = con.send_packet(cmd.into_packet())?; + con.wait_for_ack(id).await?; + + // Disconnect + disconnect(&mut con).await?; + info!("Disconnected"); + + Ok(()) +} diff --git a/crates/proto/tsproto/examples/decompress.rs b/crates/proto/tsproto/examples/decompress.rs new file mode 100644 index 0000000..c060928 --- /dev/null +++ b/crates/proto/tsproto/examples/decompress.rs @@ -0,0 +1,21 @@ +use std::io::{Cursor, Write}; + +use clap::Parser; +use tsproto::utils; + +#[derive(Parser, Debug)] +#[command(author, about)] +struct Args { + /// Data (hex) + #[arg()] + data: String, +} + +fn main() { + // Parse command line options + let args = Args::parse(); + + let data = utils::read_hex(&args.data).unwrap(); + let data = quicklz::decompress(&mut Cursor::new(data), std::u32::MAX).unwrap(); + std::io::stdout().write_all(&data).unwrap(); +} diff --git a/crates/proto/tsproto/examples/many-tsproto.rs b/crates/proto/tsproto/examples/many-tsproto.rs new file mode 100644 index 0000000..8264564 --- /dev/null +++ b/crates/proto/tsproto/examples/many-tsproto.rs @@ -0,0 +1,71 @@ +use std::net::SocketAddr; + +use anyhow::Result; +use clap::Parser; +use futures::prelude::*; +use tokio::time::{self, Duration}; +use tracing::info; + +mod utils; +use crate::utils::*; + +#[derive(Parser, Clone, Debug)] +#[command(author, about)] +struct Args { + /// The address of the server to connect to + #[arg(short, long, default_value = "127.0.0.1:9987")] + address: SocketAddr, + /// The listening address of the client + #[arg(long, default_value = "0.0.0.0:0")] + local_address: SocketAddr, + /// Print the content of all packets + /// + /// 0. Print nothing + /// 1. Print command string + /// 2. Print packets + /// 3. Print udp packets + #[arg(short, long, action = clap::ArgAction::Count)] + verbose: u8, + /// How many connections + #[arg()] + count: usize, +} + +#[tokio::main] +async fn main() -> Result<()> { real_main().await } + +async fn real_main() -> Result<()> { + // Parse command line options + let args = Args::parse(); + create_logger(); + + stream::iter(0..args.count) + .for_each_concurrent(None, |_| { + let args = args.clone(); + tokio::spawn(async move { + let mut con = + create_client(args.local_address, args.address, args.verbose).await.unwrap(); + + // Connect + connect(&mut con).await.unwrap(); + info!("Connected"); + + // Wait some time + tokio::select! { + _ = time::sleep(Duration::from_secs(2)) => {} + _ = con.wait_disconnect() => { + panic!("Disconnected"); + } + }; + info!("Waited"); + + // Disconnect + let _ = disconnect(&mut con).await; + info!("Disconnected"); + }) + .map(|_| ()) + }) + .await; + + Ok(()) +} diff --git a/crates/proto/tsproto/examples/parse-license.rs b/crates/proto/tsproto/examples/parse-license.rs new file mode 100644 index 0000000..f868893 --- /dev/null +++ b/crates/proto/tsproto/examples/parse-license.rs @@ -0,0 +1,19 @@ +use base64::prelude::*; +use clap::Parser; +use tsproto::license::*; + +#[derive(Parser, Debug)] +#[command(author, about)] +struct Args { + /// The license data (base64) + #[arg()] + license: String, +} + +fn main() { + // Parse command line options + let args = Args::parse(); + + let l = Licenses::parse(BASE64_STANDARD.decode(&args.license).unwrap()).unwrap(); + println!("{:#?}", l); +} diff --git a/crates/proto/tsproto/examples/test-decrypt.rs b/crates/proto/tsproto/examples/test-decrypt.rs new file mode 100644 index 0000000..9b717f7 --- /dev/null +++ b/crates/proto/tsproto/examples/test-decrypt.rs @@ -0,0 +1,52 @@ +use std::io::Write; + +use clap::Parser; +use tsproto::algorithms as algs; +use tsproto::utils; +use tsproto_packets::packets::*; + +#[derive(Parser, Debug)] +#[command(author, about)] +struct Args { + /// Print backtrace + #[arg(short, long = "debug")] + debug: bool, + /// Server to client + #[arg(short, long = "client")] + c2s: bool, + /// Data (hex) + #[arg()] + data: String, +} + +fn main() { + // Parse command line options + let args = Args::parse(); + + let dir = if args.c2s { Direction::C2S } else { Direction::S2C }; + + let data = utils::read_hex(&args.data).unwrap(); + let packet = match InPacket::try_new(dir, &data) { + Ok(p) => p, + Err(e) => { + if args.debug { + println!("Failed to decode: {:?}", e); + } else { + println!("Failed to decode: {}", e); + } + return; + } + }; + let decrypted = match algs::decrypt_fake(&packet) { + Ok(d) => d, + Err(e) => { + if args.debug { + println!("Failed to decrypt: {:?}", e); + } else { + println!("Failed to decrypt: {}", e); + } + return; + } + }; + std::io::stdout().write_all(&decrypted).unwrap(); +} diff --git a/crates/proto/tsproto/examples/test-ed25519.rs b/crates/proto/tsproto/examples/test-ed25519.rs new file mode 100644 index 0000000..655e0c9 --- /dev/null +++ b/crates/proto/tsproto/examples/test-ed25519.rs @@ -0,0 +1,39 @@ +use base64::prelude::*; +use clap::Parser; +use curve25519_dalek_ng::edwards::CompressedEdwardsY; +use curve25519_dalek_ng::scalar::Scalar; + +#[derive(Parser, Debug)] +#[command(author, about)] +struct Args { + /// Public key + #[arg(short, long = "pub")] + pub_key: String, + /// Private key + #[arg(short, long = "priv")] + priv_key: String, +} + +fn main() { + // Parse command line options + let args = Args::parse(); + + let pub_key = BASE64_STANDARD.decode(&args.pub_key).unwrap(); + let priv_key = BASE64_STANDARD.decode(&args.priv_key).unwrap(); + let mut pubk = [0; 32]; + pubk.copy_from_slice(&pub_key); + let mut privk = [0; 32]; + privk.copy_from_slice(&priv_key); + /*privk[0] &= 248; + privk[31] &= 63; + privk[31] |= 64;*/ + + let priv_scal = Scalar::from_bytes_mod_order(privk); + //let priv_scal = Scalar::from_bytes_mod_order(privk); + let pub_point_compr = CompressedEdwardsY(pubk); + let pub_point = -pub_point_compr.decompress().unwrap(); + //let pub_point = curve25519_dalek::constants::ED25519_BASEPOINT_POINT; + + let res = (pub_point * priv_scal).compress(); + println!("Result: {}", BASE64_STANDARD.encode(&res.0)); +} diff --git a/crates/proto/tsproto/examples/test-proofs.rs b/crates/proto/tsproto/examples/test-proofs.rs new file mode 100644 index 0000000..30df5ff --- /dev/null +++ b/crates/proto/tsproto/examples/test-proofs.rs @@ -0,0 +1,35 @@ +use base64::prelude::*; +use clap::Parser; +use tsproto_types::crypto::EccKeyPubP256; + +#[derive(Parser, Debug)] +#[command(author, about)] +struct Args { + /// Public key + #[arg(short, long)] + key: String, + /// Data (base64) + #[arg(short, long)] + data: String, + /// Signature (base64) + #[arg(short, long)] + signature: String, +} + +fn main() { + // Parse command line options + let args = Args::parse(); + + // l → proof + // ek || beta → proof + + let data = BASE64_STANDARD.decode(&args.data).unwrap(); + let signature = BASE64_STANDARD.decode(&args.signature).unwrap(); + let key = EccKeyPubP256::from_ts(&args.key).unwrap(); + /*let keyts = tomcrypt::P256EccKey::import(&BASE64_STANDARD.decode(&args.key).unwrap()) + .unwrap(); + let res = keyts.verify_hash(&data, &signature).unwrap(); + println!("Res: {:?}", res);*/ + + key.verify(&data, &signature).unwrap(); +} diff --git a/crates/proto/tsproto/examples/utils/mod.rs b/crates/proto/tsproto/examples/utils/mod.rs new file mode 100644 index 0000000..1af249d --- /dev/null +++ b/crates/proto/tsproto/examples/utils/mod.rs @@ -0,0 +1,101 @@ +use std::net::SocketAddr; + +use anyhow::Result; +use tokio::net::UdpSocket; +use tracing::{info, info_span}; +use tsproto::algorithms as algs; +use tsproto::client::Client; +use tsproto_packets::packets::*; +use tsproto_types::crypto::EccKeyPrivP256; + +pub fn create_logger() { tracing_subscriber::fmt::init(); } + +pub async fn create_client( + local_address: SocketAddr, remote_address: SocketAddr, verbose: u8, +) -> Result { + // Get P-256 ECDH key + let private_key = EccKeyPrivP256::import_str( + "MG0DAgeAAgEgAiAIXJBlj1hQbaH0Eq0DuLlCmH8bl+veTAO2+\ + k9EQjEYSgIgNnImcmKo7ls5mExb6skfK2Tw+u54aeDr0OP1ITsC/50CIA8M5nm\ + DBnmDM/gZ//4AAAAAAAAAAAAAAAAAAAAZRzOI").unwrap(); + + let udp_socket = UdpSocket::bind(local_address).await?; + let mut con = Client::new(remote_address, Box::new(udp_socket), private_key); + + if verbose >= 1 { + tsproto::log::add_logger_with_verbosity(verbose, &mut con) + } + + Ok(con) +} + +/// Returns the `initserver` command. +pub async fn connect(con: &mut Client) -> Result { + con.connect().await?; + + // Send clientinit + let private_key = EccKeyPrivP256::import_str( + "MG0DAgeAAgEgAiAIXJBlj1hQbaH0Eq0DuLlCmH8bl+veTAO2+\ + k9EQjEYSgIgNnImcmKo7ls5mExb6skfK2Tw+u54aeDr0OP1ITsC/50CIA8M5nm\ + DBnmDM/gZ//4AAAAAAAAAAAAAAAAAAAAZRzOI").unwrap(); + + // Compute hash cash + let offset; + { + let _span = info_span!("Compute public key hash cash level").entered(); + let private_key_as_pub = private_key.to_pub(); + offset = algs::hash_cash(&private_key_as_pub, 8); + let omega = private_key_as_pub.to_ts(); + info!( + level = algs::get_hash_cash_level(&omega, offset), + offset, "Computed hash cash level" + ); + } + + // Create clientinit packet + let offset = offset.to_string(); + let mut cmd = + OutCommand::new(Direction::C2S, Flags::empty(), PacketType::Command, "clientinit"); + cmd.write_arg("client_nickname", &"Bot"); + cmd.write_arg("client_version", &"3.?.? [Build: 5680278000]"); + cmd.write_arg("client_platform", &"Linux"); + + cmd.write_arg("client_input_hardware", &"1"); + cmd.write_arg("client_output_hardware", &"1"); + cmd.write_arg("client_default_channel", &""); + cmd.write_arg("client_default_channel_password", &""); + cmd.write_arg("client_server_password", &""); + cmd.write_arg("client_meta_data", &""); + cmd.write_arg( + "client_version_sign", + &"Hjd+N58Gv3ENhoKmGYy2bNRBsNNgm5kpiaQWxOj5HN2DXttG6REjymSwJtpJ8muC2gSwRuZi0R+8Laan5ts5CQ==", + ); + cmd.write_arg("client_nickname_phonetic", &""); + cmd.write_arg("client_key_offset", &offset); + cmd.write_arg("client_default_token", &""); + cmd.write_arg("client_badges", &"Overwolf=0"); + cmd.write_arg("hwid", &"923f136fb1e22ae6ce95e60255529c00,d13231b1bc33edfecfb9169cc7a63bcc"); + + con.send_packet(cmd.into_packet())?; + Ok(con + .filter_commands(|con, cmd| { + Ok(if cmd.data().packet().content().starts_with(b"initserver ") { + Some(cmd) + } else { + con.hand_back_buffer(cmd.into_buffer()); + None + }) + }) + .await?) +} + +pub async fn disconnect(con: &mut Client) -> Result<()> { + let mut cmd = + OutCommand::new(Direction::C2S, Flags::empty(), PacketType::Command, "clientdisconnect"); + cmd.write_arg("reasonid", &8); + cmd.write_arg("reasonmsg", &"Bye"); + + con.send_packet(cmd.into_packet())?; + con.wait_disconnect().await?; + Ok(()) +} diff --git a/crates/proto/tsproto/src/algorithms.rs b/crates/proto/tsproto/src/algorithms.rs new file mode 100644 index 0000000..f57b934 --- /dev/null +++ b/crates/proto/tsproto/src/algorithms.rs @@ -0,0 +1,452 @@ +//! Handle packet splitting and cryptography +use curve25519_dalek_ng::edwards::EdwardsPoint; +use eax::aead::consts::{U16, U8}; +use eax::{AeadInPlace, Eax, KeyInit}; +use generic_array::GenericArray; +use num_bigint::BigUint; +use num_traits::ToPrimitive; +use omnom::WriteExt; +use quicklz::CompressionLevel; +use sha1::Sha1; +use sha2::{Digest, Sha256, Sha512}; +use tsproto_types::crypto::{EccKeyPrivEd25519, EccKeyPubP256}; + +use crate::connection::CachedKey; +use crate::{Error, Result}; +use tsproto_packets::packets::*; + +pub fn must_encrypt(t: PacketType) -> bool { + match t { + PacketType::Command | PacketType::CommandLow => true, + PacketType::Voice + | PacketType::Ack + | PacketType::AckLow + | PacketType::VoiceWhisper + | PacketType::Ping + | PacketType::Pong + | PacketType::Init => false, + } +} + +pub fn should_encrypt(t: PacketType, voice_encryption: bool) -> bool { + must_encrypt(t) + || t == PacketType::Ack + || t == PacketType::AckLow + || (voice_encryption && t.is_voice()) +} + +/// Compresses and splits the packet data of a `Command` or `CommandLow` packet. +/// +/// Returns the splitted packet data and their headers. +/// The headers have their type and the compressed and fragmented flag set +/// to the right value. +/// +/// Returns an error if the packet is too large but cannot be splitted. +/// Only `Command` and `CommandLow` packets can be compressed and splitted. +pub fn compress_and_split(is_client: bool, packet: OutPacket) -> Vec { + // Everything except whisper packets has to be less than 500 bytes + let header_size = + if is_client { tsproto_packets::C2S_HEADER_LEN } else { tsproto_packets::S2C_HEADER_LEN }; + let data = packet.content(); + // The maximum packet size (including header) is 500 bytes. + let max_size = 500 - header_size; + // Split the data if it is necessary. + let compressed; + let datas = if data.len() > max_size { + // Compress with QuickLZ + let cdata = ::quicklz::compress(data, CompressionLevel::Lvl1); + // Use only if it is efficient + let mut data = if cdata.len() > data.len() { + compressed = false; + data + } else { + compressed = true; + &cdata + }; + + // Ignore size limit for whisper packets + if data.len() <= max_size || packet.header().packet_type() == PacketType::VoiceWhisper { + let mut v = vec![0; header_size + data.len()]; + v[header_size..].copy_from_slice(data); + vec![v] + } else { + // Split + let count = (data.len() + max_size - 1) / max_size; + let mut splitted = Vec::with_capacity(count); + while data.len() > max_size { + let (first, last) = data.split_at(max_size); + let mut v = vec![0; header_size + max_size]; + v[header_size..].copy_from_slice(first); + splitted.push(v); + data = last; + } + // Rest + let mut v = vec![0; header_size + data.len()]; + v[header_size..].copy_from_slice(data); + splitted.push(v); + splitted + } + } else { + return vec![packet]; + }; + + let len = datas.len(); + let fragmented = len > 1; + let orig_header = packet.header_bytes(); + let dir = packet.direction(); + let mut packets = Vec::with_capacity(datas.len()); + for (i, mut d) in datas.into_iter().enumerate() { + d[..header_size].copy_from_slice(orig_header); + let mut packet = OutPacket::new_from_data(dir, d); + // Only set flags on first fragment + if i == 0 && compressed { + packet.flags(packet.header().flags() | Flags::COMPRESSED); + } + + // Set fragmented flag on first and last part + if fragmented && (i == 0 || i == len - 1) { + packet.flags(packet.header().flags() | Flags::FRAGMENTED); + } + packets.push(packet); + } + packets +} + +fn create_key_nonce( + p_type: PacketType, c_id: Option, p_id: u16, generation_id: u32, iv: &[u8; 64], + cache: &mut [[CachedKey; 2]; 8], +) -> (GenericArray, GenericArray) { + // Check if this generation is cached + let cache = &mut cache[p_type.to_usize().unwrap()][if c_id.is_some() { 1 } else { 0 }]; + if cache.generation_id != generation_id { + // Update the cache + let mut temp = [0; 70]; + if c_id.is_some() { + temp[0] = 0x31; + } else { + temp[0] = 0x30; + } + temp[1] = p_type.to_u8().unwrap(); + (&mut temp[2..6]).write_be(generation_id).unwrap(); + temp[6..].copy_from_slice(iv); + + let keynonce = Sha256::digest(&temp[..]); + let keynonce = keynonce.as_slice(); + cache.generation_id = generation_id; + cache.key.copy_from_slice(&keynonce[..16]); + cache.nonce.copy_from_slice(&keynonce[16..]); + } + + // Use the cached version + let mut key = cache.key; + let nonce = cache.nonce; + key[0] ^= (p_id >> 8) as u8; + key[1] ^= (p_id & 0xff) as u8; + (key, nonce) +} + +pub fn encrypt_key_nonce( + packet: &mut OutPacket, key: &GenericArray, nonce: &GenericArray, +) -> Result<()> { + let meta = packet.header().get_meta().to_vec(); + let cipher = Eax::::new(key); + let mac = cipher + .encrypt_in_place_detached(nonce, &meta, packet.content_mut()) + .map_err(|_| Error::MaxLengthExceeded("encryption data"))?; + packet.mac().copy_from_slice(mac.as_slice()); + Ok(()) +} + +pub fn encrypt_fake(packet: &mut OutPacket) -> Result<()> { + encrypt_key_nonce(packet, &crate::FAKE_KEY.into(), &crate::FAKE_NONCE.into()) +} + +pub fn encrypt( + packet: &mut OutPacket, generation_id: u32, iv: &[u8; 64], cache: &mut [[CachedKey; 2]; 8], +) -> Result<()> { + let header = packet.header(); + let (key, nonce) = create_key_nonce( + header.packet_type(), + header.client_id(), + header.packet_id(), + generation_id, + iv, + cache, + ); + encrypt_key_nonce(packet, &key, &nonce) +} + +pub fn decrypt_key_nonce( + packet: &InPacket, key: &GenericArray, nonce: &GenericArray, +) -> Result> { + let header = packet.header(); + let meta = header.get_meta(); + // TODO decrypt in-place in packet + let mut content = packet.content().to_vec(); + let cipher = Eax::::new(key); + cipher + .decrypt_in_place_detached(nonce, meta, &mut content, header.mac().into()) + .map(|()| content) + .map_err(|_| Error::WrongMac { + p_type: header.packet_type(), + generation_id: 0, + packet_id: header.packet_id(), + }) +} + +pub fn decrypt_fake(packet: &InPacket) -> Result> { + decrypt_key_nonce(packet, &crate::FAKE_KEY.into(), &crate::FAKE_NONCE.into()) +} + +pub fn decrypt( + packet: &InPacket, generation_id: u32, iv: &[u8; 64], cache: &mut [[CachedKey; 2]; 8], +) -> Result> { + let header = packet.header(); + let (key, nonce) = create_key_nonce( + header.packet_type(), + header.client_id(), + header.packet_id(), + generation_id, + iv, + cache, + ); + decrypt_key_nonce(packet, &key, &nonce).map_err(|e| { + if let Error::WrongMac { p_type, packet_id, .. } = e { + Error::WrongMac { p_type, generation_id, packet_id } + } else { + e + } + }) +} + +/// Compute shared iv and shared mac. +pub fn compute_iv_mac( + alpha: &[u8; 10], beta: &[u8; 54], our_key: &EccKeyPrivEd25519, other_key: &EdwardsPoint, +) -> ([u8; 64], [u8; 8]) { + let shared_secret = our_key.create_shared_secret(other_key); + let mut shared_iv = [0; 64]; + shared_iv.copy_from_slice(Sha512::digest(shared_secret).as_slice()); + for i in 0..10 { + shared_iv[i] ^= alpha[i]; + } + for i in 0..54 { + shared_iv[i + 10] ^= beta[i]; + } + let mut shared_mac = [0; 8]; + shared_mac.copy_from_slice(&Sha1::digest(shared_iv).as_slice()[..8]); + (shared_iv, shared_mac) +} + +pub fn hash_cash(key: &EccKeyPubP256, level: u8) -> u64 { + let omega = key.to_ts(); + let mut offset = 0; + while offset < u64::MAX && get_hash_cash_level(&omega, offset) < level { + offset += 1; + } + offset +} + +#[inline] +pub fn get_hash_cash_level(omega: &str, offset: u64) -> u8 { + let data = Sha1::digest(format!("{}{}", omega, offset).as_bytes()); + let mut res = 0; + for &d in data.as_slice() { + if d == 0 { + res += 8; + } else { + res += d.trailing_zeros() as u8; + break; + } + } + res +} + +pub fn biguint_to_array(i: &BigUint) -> [u8; 64] { + let mut v = i.to_bytes_le(); + + // Extend with zeroes until 64 bytes + let len = v.len(); + v.append(&mut vec![0; 64 - len]); + v.reverse(); + + let mut a = [0; 64]; + a.copy_from_slice(&v); + a +} + +pub fn array_to_biguint(i: &[u8; 64]) -> BigUint { BigUint::from_bytes_be(i) } + +#[cfg(test)] +mod tests { + use base64::prelude::*; + + use super::*; + use crate::license::Licenses; + use crate::packets::PacketType; + use crate::utils; + use tsproto_types::crypto::EccKeyPubEd25519; + + #[test] + fn test_fake_crypt() { + let data = (0..100).into_iter().collect::>(); + let mut packet = OutPacket::new_with_dir(Direction::C2S, Flags::empty(), PacketType::Ack); + packet.data_mut().extend_from_slice(&data); + encrypt_fake(&mut packet).unwrap(); + let packet = + InPacket::try_new(Direction::C2S, packet.data_mut().as_slice().into()).unwrap(); + let dec_data = decrypt_fake(&packet).unwrap(); + assert_eq!(&data, &dec_data); + } + + #[test] + fn test_fake_encrypt() { + let mut packet = OutAck::new(Direction::C2S, PacketType::Command, 0); + encrypt_fake(&mut packet).unwrap(); + + let real_res: &[u8] = + &[0xa4, 0x7b, 0x47, 0x94, 0xdb, 0xa9, 0x6a, 0xc5, 0, 0, 0, 0, 0x6, 0xfe, 0x18]; + assert_eq!(real_res, packet.data_mut().as_slice()); + } + + #[test] + fn shared_iv31() { + let licenses = Licenses::parse_ignore_expired(BASE64_STANDARD.decode("AQA1hUFJiiSs\ + 0wFXkYuPUJVcDa6XCrZTcsvkB0Ffzz4CmwIITRXgCqeTYAcAAAAgQW5vbnltb3VzAAC\ + 4R+5mos+UQ/KCbkpQLMI5WRp4wkQu8e5PZY4zU+/FlyAJwaE8CcJJ/A==") + .unwrap()).unwrap(); + let derived_key = + licenses.derive_public_key(EccKeyPubEd25519::from_bytes(crate::ROOT_KEY)).unwrap(); + + let client_ek = [ + 0xb0, 0x4e, 0xa1, 0xd9, 0x5c, 0x72, 0x64, 0xdf, 0x0d, 0xe8, 0xb3, 0x6b, 0xaa, 0x7c, + 0xa1, 0x5f, 0x75, 0x71, 0xf5, 0x1f, 0xa0, 0x54, 0xb5, 0x51, 0x27, 0x08, 0x8e, 0xdd, + 0x96, 0x3d, 0x6e, 0x79, + ]; + + let priv_key = EccKeyPrivEd25519::from_bytes(client_ek); + + let alpha_b64 = BASE64_STANDARD.decode("Jkxq1wIvvhzaCA==").unwrap(); + let mut alpha = [0; 10]; + alpha.copy_from_slice(&alpha_b64); + let beta_b64 = BASE64_STANDARD + .decode("wU5T/MM6toW6Wge9th7VlTlzVZ9JDWypw2P9migfc25pjGP2Tj7Hm6rJpmKeHRr08Ch7BEAR") + .unwrap(); + let mut beta = [0; 54]; + beta.copy_from_slice(&beta_b64); + + let expected_shared_shared_iv: [u8; 64] = [ + 0x58, 0x78, 0xae, 0x08, 0x08, 0x72, 0x05, 0xb0, 0x13, 0x27, 0x10, 0xe9, 0x81, 0xb4, + 0xaf, 0x14, 0x14, 0x71, 0xad, 0xcd, 0x82, 0x98, 0xf3, 0xd1, 0x1d, 0x07, 0x20, 0x72, + 0x7e, 0xb2, 0x1b, 0x89, 0x47, 0x82, 0x1e, 0xfb, 0x02, 0x53, 0x5a, 0x8a, 0x52, 0x4d, + 0x9a, 0x7a, 0x09, 0x2c, 0x1b, 0xe7, 0x1f, 0xd1, 0x9d, 0x2a, 0x9d, 0x4f, 0xbd, 0xe3, + 0x22, 0x09, 0xe4, 0x86, 0x7d, 0x63, 0x49, 0x07, + ]; + + let expected_xored_shared_shared_iv: [u8; 64] = [ + 0x7e, 0x34, 0xc4, 0xdf, 0x0a, 0x5d, 0xbb, 0xac, 0xc9, 0x2f, 0xd1, 0xa7, 0xd2, 0x48, + 0x6c, 0x2e, 0xa2, 0xf4, 0x17, 0x97, 0x85, 0x25, 0x45, 0xcf, 0xc8, 0x92, 0x19, 0x01, + 0x2b, 0x2d, 0x52, 0x84, 0x2b, 0x2b, 0xdd, 0x98, 0xff, 0xc9, 0x72, 0x95, 0x21, 0x23, + 0xf3, 0xf6, 0x6a, 0xda, 0x55, 0xd9, 0xd8, 0x4a, 0x37, 0xe3, 0x3b, 0x2d, 0x23, 0xfe, + 0x38, 0xfd, 0x14, 0xae, 0x06, 0x67, 0x09, 0x16, + ]; + + let (mut shared_iv, _shared_mac) = compute_iv_mac(&alpha, &beta, &priv_key, &derived_key); + + assert_eq!(&shared_iv as &[u8], &expected_xored_shared_shared_iv as &[u8]); + + for i in 0..10 { + shared_iv[i] ^= alpha[i]; + } + for i in 0..54 { + shared_iv[i + 10] ^= beta[i]; + } + + assert_eq!(&shared_iv as &[u8], &expected_shared_shared_iv as &[u8]); + + let mut temp = [0; 70]; + temp[0] = 0x31; + temp[1] = 0x2 & 0xf; + temp[6..].copy_from_slice(&expected_xored_shared_shared_iv); + + let temporary: [u8; 70] = [ + 0x31, 0x02, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x34, 0xc4, 0xdf, 0x0a, 0x5d, 0xbb, 0xac, + 0xc9, 0x2f, 0xd1, 0xa7, 0xd2, 0x48, 0x6c, 0x2e, 0xa2, 0xf4, 0x17, 0x97, 0x85, 0x25, + 0x45, 0xcf, 0xc8, 0x92, 0x19, 0x01, 0x2b, 0x2d, 0x52, 0x84, 0x2b, 0x2b, 0xdd, 0x98, + 0xff, 0xc9, 0x72, 0x95, 0x21, 0x23, 0xf3, 0xf6, 0x6a, 0xda, 0x55, 0xd9, 0xd8, 0x4a, + 0x37, 0xe3, 0x3b, 0x2d, 0x23, 0xfe, 0x38, 0xfd, 0x14, 0xae, 0x06, 0x67, 0x09, 0x16, + ]; + assert!(&temp as &[u8] == &temporary as &[u8]); + + let keynonce = Sha256::digest(&temp); + + let expected_keynonce: [u8; 32] = [ + 0xf3, 0x70, 0xd3, 0x43, 0xe7, 0x78, 0x15, 0x70, 0x7a, 0xff, 0x60, 0x48, 0xfb, 0xd9, + 0xac, 0x6b, 0xb6, 0x33, 0x35, 0x79, 0x31, 0x9b, 0x88, 0x0e, 0x2d, 0x25, 0xef, 0x9c, + 0xe9, 0x9e, 0x77, 0x5c, + ]; + + assert!(keynonce.as_slice() == &expected_keynonce as &[u8]); + } + + #[test] + fn test_new_decrypt() { + let shared_iv = utils::read_hex( + "C2 45 6F CB FC 22 08 AE 44 2B 7D E7 3A 67 1B DA 93 09 B2 00 F2 CD 10 49 08 CD 3A B0 \ + 7B DD 58 AD", + ) + .unwrap(); + let mut shared_iv = Sha512::digest(&shared_iv).as_slice().to_vec(); + assert_eq!( + utils::read_hex( + "4D 3F DA B7 D8 B0 2C 82 70 6A 39 3E 97 17 61 09 FA 03 AB 30 5C BB 78 7A 9A 82 D5 \ + 39 9A 60 FD A9 F6 7A D9 04 52 F2 AE 00 3E 35 E8 19 10 89 40 43 80 58 27 1F 0A E0 \ + E0 3D E0 9C F0 A3 4D 15 6B F0" + ) + .unwrap() + .as_slice(), + shared_iv.as_slice() + ); + + let alpha = [0; 10]; + let beta = BASE64_STANDARD + .decode("I4onb0zMyAD6bd24QANDls40eOES7qmjonBFtt5wRWzAfIIQWTSxjEas6TGTZIJ8QSJNX+Pl") + .unwrap(); + + for i in 0..10 { + shared_iv[i] ^= alpha[i]; + } + for i in 0..54 { + shared_iv[i + 10] ^= beta[i]; + } + + let mut temp = [0; 70]; + temp[0] = 0x31; + temp[1] = 0x2 & 0xf; + temp[6..].copy_from_slice(&shared_iv); + + let keynonce = Sha256::digest(&temp); + let keynonce = keynonce.as_slice(); + + let all = utils::read_hex("2b982443ab38be6b00020000329abf64d4572e1349897b5e1e96fbc4a763a4c4ce1f64f0c1e3febd0a5f04a82ab1f2bc2344bb374fd16181beb8233b5b06944280470e9b6893290a1da0776ffcd89f3beec2ce23b9694930c09efaaea0d88a6895a08ede4d5cbfea61291fc553ac651f1e2bc1d2bd277a8bd9ab5386415579a9e56fac46d8b6b119f454bebd99179cd317dec60af205341d11f274d02bbacdd7e9773f72a426358ca1d39016dd95bde2409cd81bf99b340887e997ea982370c6790cf4d23150460820224766838ea4ec4d71dd102ede701ea0001f392623aa410dd9ab0e45874da82e29e6e370515ec30a37dd73f5a364c233ff014384beab5f1708c9f48dfba33a520f8fcdcef055789c54693c3fe72c5bfaca7cb4ca1fed77b8624660b8abc882f4b95b1284cb6dc55019c6082dd6dd146fa50383662d7298bef04ababaf1af80e15cd4c1f81326f085788e2918e00324147dce39b23db71326abc3de4b94df10f1531e9cce202bba71fa3ebeefd77b21fa3260a62e92eeee2183421d384a8c48777e2f9efbc58d4f442c5f0529c7c0e27e81b2b6b1b05eb8fa19256886248d553582dfd24c7cfab3c3f7317a5cebc6504b53fa0e86fc8c1100fc1d506fcf96caa76a7c0b6a27e577f2efdecd4070e847a559bf37d75bfdbe9e814c702426ce696d8645bc300b5f28f9e7f1ce").unwrap(); + + let packet = InPacket::try_new(Direction::C2S, &all).unwrap(); + println!("Packet: {:?}", packet); + let mut key = [0; 16]; + let mut nonce = [0; 16]; + key.copy_from_slice(&keynonce[..16]); + nonce.copy_from_slice(&keynonce[16..]); + + let expected_key = + utils::read_hex("D2 42 75 71 9C EE 83 35 EF 8A CE E0 B7 28 40 B8").unwrap(); + let expected_nonce = + utils::read_hex("9C D9 30 B7 58 FE 50 23 64 66 11 C5 36 0E A2 5F").unwrap(); + + assert_eq!(&expected_nonce, &nonce); + assert_eq!(&expected_key, &key); + + key[1] ^= 2; // packet id + let dec = decrypt_key_nonce(&packet, &key.into(), &nonce.into()).unwrap(); + + println!("Decrypted: {:?}", String::from_utf8_lossy(&dec)); + } +} diff --git a/crates/proto/tsproto/src/client.rs b/crates/proto/tsproto/src/client.rs new file mode 100644 index 0000000..bd67ca3 --- /dev/null +++ b/crates/proto/tsproto/src/client.rs @@ -0,0 +1,1213 @@ +use std::net::SocketAddr; +use std::ops::{Deref, DerefMut}; +use std::pin::Pin; +use std::str; +use std::task::{Context, Poll}; + +use base64::prelude::*; +use futures::prelude::*; +#[cfg(not(feature = "rug"))] +use num_bigint::BigUint; +#[cfg(not(feature = "rug"))] +use num_traits::One; +use rand::RngExt; +#[cfg(feature = "rug")] +use rug::Integer; +#[cfg(feature = "rug")] +use rug::integer::Order; +use thiserror::Error; +use time::OffsetDateTime; +use tracing::{info, warn}; +use tsproto_packets::commands::{CommandItem, CommandParser}; +use tsproto_packets::packets::*; +use tsproto_types::crypto::{EccKeyPrivEd25519, EccKeyPrivP256, EccKeyPubEd25519, EccKeyPubP256}; + +use crate::algorithms as algs; +use crate::connection::{ConnectedParams, Connection, Socket, StreamItem}; +use crate::license::Licenses; +use crate::resend::{PacketId, ResenderState}; + +type Result = std::result::Result; + +#[derive(Error, Debug)] +#[non_exhaustive] +pub enum Error { + #[error("Connection ended unexpectedly")] + ConnectionEnd, + #[error("Got initserver, but we have not yet a full connection")] + EarlyInitserver, + #[error("Cannot parse base64 argument {0}: {1}")] + InvalidBase64Arg(&'static str, #[source] base64::DecodeError), + #[error("Invalid packet: Incorrect beta length in initivexpand2 {0} != 54")] + InvalidBetaLength(usize), + #[error("Got invalid client id {0:?}: {1}")] + InvalidClientId(Vec, #[source] tsproto_packets::Error), + #[error("Invalid packet: initivexpand2 command has wrong arguments")] + InvalidInitivexpand2, + #[error("Invalid packet: Cannot parse omega as key: {0}")] + InvalidOmegaKey(#[source] tsproto_types::crypto::Error), + #[error("Invalid packet: Cannot parse omega as string: {0}")] + InvalidOmegaString(#[source] tsproto_packets::Error), + #[error("Invalid packet: {0}")] + InvalidPacket(&'static str), + #[error("Invalid packet: Got root for initivexpand2, but length {0} != 32")] + InvalidRootKeyLength(usize), + #[error("The server license signature is invalid: {0}")] + InvalidSignature(#[source] tsproto_types::crypto::Error), + #[error("Invalid packet: Got multiple {0} in one packet")] + MultipleCommands(&'static str), + #[error("Got initserver without accepted client id")] + NoClientId, + #[error("Got no ot=1, the server is probably outdated")] + OutdatedServer, + #[error("Failed to parse license: {0}")] + ParseLicense(#[source] crate::license::Error), + #[error("Failed to solve RSA puzzle")] + RsaPuzzle, + #[error("Requested RSA puzzle level {0} is too high")] + RsaPuzzleTooHighLevel(u32), + #[error(transparent)] + TsProto(#[from] crate::Error), + #[error("Expected {0} but got {1}")] + UnexpectedPacket(&'static str, String), +} + +pub struct Client { + con: Connection, + pub private_key: EccKeyPrivP256, +} + +impl Client { + pub fn new( + address: SocketAddr, udp_socket: Box, private_key: EccKeyPrivP256, + ) -> Self { + Self { con: Connection::new(true, address, udp_socket), private_key } + } + + async fn get_init(&mut self, init_steps: &[u8]) -> Result { + self.filter_items(|con, i| { + Ok(match i { + StreamItem::S2CInit(packet) => { + if init_steps.contains(&packet.data().data().get_step()) { + Some(packet) + } else { + // Resent packet + warn!(parent: &con.span, "Got wrong init packet"); + con.hand_back_buffer(packet.into_buffer()); + None + } + } + StreamItem::C2SInit(packet) => { + warn!(parent: &con.span, "Got init packet from the wrong direction"); + con.hand_back_buffer(packet.into_buffer()); + None + } + StreamItem::Error(error) => { + warn!(parent: &con.span, %error, "Got connection error"); + None + } + StreamItem::AckPacket(_) => None, + StreamItem::NetworkStatsUpdated => None, + i => { + warn!(parent: &con.span, got = ?i, "Unexpected packet, wanted S2CInit"); + None + } + }) + }) + .await + } + + async fn get_command(&mut self) -> Result { + self.filter_items(|con, i| { + Ok(match i { + StreamItem::S2CInit(packet) => { + con.hand_back_buffer(packet.into_buffer()); + None + } + StreamItem::C2SInit(packet) => { + con.hand_back_buffer(packet.into_buffer()); + None + } + StreamItem::Command(packet) => Some(packet), + StreamItem::Error(error) => { + warn!(parent: &con.span, %error, "Got connection error"); + None + } + StreamItem::AckPacket(_) => None, + StreamItem::NetworkStatsUpdated => None, + i => { + warn!(parent: &con.span, got = ?i, "Unexpected packet, wanted Command"); + None + } + }) + }) + .await + } + + /// Drop all packets until the given packet is acknowledged. + pub async fn wait_for_ack(&mut self, id: PacketId) -> Result<()> { + self.filter_items(|con, i| { + Ok(match i { + StreamItem::S2CInit(packet) => { + con.hand_back_buffer(packet.into_buffer()); + None + } + StreamItem::C2SInit(packet) => { + con.hand_back_buffer(packet.into_buffer()); + None + } + StreamItem::Command(packet) => { + con.hand_back_buffer(packet.into_buffer()); + None + } + StreamItem::Error(error) => { + warn!(parent: &con.span, %error, "Got connection error"); + None + } + StreamItem::AckPacket(ack) => { + if id <= ack { + Some(()) + } else { + None + } + } + StreamItem::NetworkStatsUpdated => None, + i => { + warn!(parent: &con.span, got = ?i, "Unexpected packet, wanted Ack"); + None + } + }) + }) + .await + } + + /// Drop all packets until the send queue is not full anymore. + pub async fn wait_until_can_send(&mut self) -> Result<()> { + if !self.is_send_queue_full() { + return Ok(()); + } + self.filter_items(|con, i| { + Ok(match i { + StreamItem::S2CInit(packet) => { + con.hand_back_buffer(packet.into_buffer()); + None + } + StreamItem::C2SInit(packet) => { + con.hand_back_buffer(packet.into_buffer()); + None + } + StreamItem::Command(packet) => { + con.hand_back_buffer(packet.into_buffer()); + None + } + StreamItem::Error(error) => { + warn!(parent: &con.span, %error, "Got connection error"); + None + } + StreamItem::AckPacket(_) => { + if !con.is_send_queue_full() { + Some(()) + } else { + None + } + } + StreamItem::NetworkStatsUpdated => None, + i => { + warn!(parent: &con.span, got = ?i, "Unexpected packet, wanted Ack"); + None + } + }) + }) + .await + } + + /// Send a packet. The `send_packet` function will resolve to a future when + /// the packet has been sent. + /// + /// If the packet has an acknowledgement (ack or pong), the returned future + /// will resolve when it is received. Otherwise it will resolve instantly. + pub fn send_packet(&mut self, packet: OutPacket) -> Result { + let _span = self.con.span.clone().entered(); + if packet.header().packet_type() == PacketType::Command + && packet.content().starts_with(b"clientdisconnect") + { + let this = &mut **self; + this.resender.set_state(ResenderState::Disconnecting); + } + Ok(self.con.send_packet(packet)?) + } + + pub async fn connect(&mut self) -> Result<()> { + // Send the first init packet + // Get the current timestamp + let now = OffsetDateTime::now_utc(); + let timestamp = now.unix_timestamp() as u32; + // TeamSpeak offsets the timestamp for the version by some years + let version = timestamp - 1356998400; + + // Random bytes + let random0 = rand::rng().random::<[u8; 4]>(); + + let alpha; + loop { + // Wait for Init1 + { + self.send_packet(OutC2SInit0::new(version, timestamp, random0))?; + let init1 = self.get_init(&[1]).await?; + match init1.data().data() { + S2CInitData::Init1 { random1, random0_r } => { + // Check the response + // Most of the time, random0_r is the reversed random0, but + // sometimes it isn't so do not check it. + // random0.as_ref().iter().rev().eq(random0_r.as_ref()) + // The packet is correct. + + // Send next init packet + self.send_packet(OutC2SInit2::new(version, random1, **random0_r))?; + } + _ => { + return Err(Error::UnexpectedPacket( + "Init1", + format!("{:?}", init1.data().packet().header().packet_type()), + )); + } + } + } + + // Wait for Init3 + { + let init3 = self.get_init(&[3, 127]).await?; + if init3.data().data().get_step() == 127 { + continue; + } + match init3.data().data() { + S2CInitData::Init3 { x, n, level, random2 } => { + let level = *level; + // Solve RSA puzzle: y = x ^ (2 ^ level) % n + // Use Montgomery Reduction + if level > 10_000_000 { + // Reject too high exponents + return Err(Error::RsaPuzzleTooHighLevel(level)); + } + + // Create clientinitiv + alpha = rand::rng().random::<[u8; 10]>(); + // omega is an ASN.1-DER encoded public key from + // the ECDH parameters. + + let ip = self.con.address.ip(); + + let x = **x; + let n = **n; + let random2 = **random2; + + // Use gmp for faster computations if it is + // available. + #[cfg(feature = "rug")] + let y = { + let mut e = Integer::new(); + let n = Integer::from_digits(&n[..], Order::Msf); + let x = Integer::from_digits(&x[..], Order::Msf); + e.set_bit(level, true); + let y = x.pow_mod(&e, &n).map_err(|_| Error::RsaPuzzle)?; + let mut yi = [0; 64]; + y.write_digits(&mut yi, Order::Msf); + yi + }; + + #[cfg(not(feature = "rug"))] + let y = { + let xi = BigUint::from_bytes_be(&x); + let ni = BigUint::from_bytes_be(&n); + let e = BigUint::one() << level as usize; + let yi = xi.modpow(&e, &ni); + info!(parent: &self.con.span, level, x = %xi, n = %ni, y = %yi, + "Solve RSA puzzle"); + algs::biguint_to_array(&yi) + }; + + // Create the command string + // omega is an ASN.1-DER encoded public key from + // the ECDH parameters. + let omega = self.private_key.to_pub().to_tomcrypt(); + let ip = if crate::utils::is_global_ip(&ip) { + ip.to_string() + } else { + String::new() + }; + + // Send next init packet + self.send_packet(OutC2SInit4::new( + version, &x, &n, level, &random2, &y, &alpha, &omega, &ip, + ))?; + } + _ => { + return Err(Error::UnexpectedPacket( + "Init3", + format!("{:?}", init3.data().packet().header().packet_type()), + )); + } + } + } + break; + } + + let clientek_id; + { + let command = self.get_command().await?; + + let (name, args) = CommandParser::new(command.data().packet().content()); + if name != b"initivexpand2" { + return Err(Error::UnexpectedPacket( + "initivexpand2", + format!("{:?}", str::from_utf8(name)), + )); + } + + let mut l = None; + let mut beta_vec = None; + let mut server_key = None; + let mut proof = None; + let mut ot = false; + let mut root = None; + for item in args { + match item { + CommandItem::NextCommand => { + return Err(Error::MultipleCommands("initivexpand2")); + } + CommandItem::Argument(arg) => match arg.name() { + b"l" => { + l = Some( + BASE64_STANDARD + .decode(arg.value().get()) + .map_err(|e| Error::InvalidBase64Arg("proof", e))?, + ) + } + b"beta" => { + beta_vec = Some( + BASE64_STANDARD + .decode(arg.value().get()) + .map_err(|e| Error::InvalidBase64Arg("proof", e))?, + ) + } + b"omega" => { + server_key = Some( + EccKeyPubP256::from_ts( + &arg.value().get_str().map_err(Error::InvalidOmegaString)?, + ) + .map_err(Error::InvalidOmegaKey)?, + ) + } + b"proof" => { + proof = Some( + BASE64_STANDARD + .decode(arg.value().get()) + .map_err(|e| Error::InvalidBase64Arg("proof", e))?, + ) + } + b"ot" => ot = arg.value().get_raw() == b"1", + b"root" => { + let data = BASE64_STANDARD + .decode(arg.value().get()) + .map_err(|e| Error::InvalidBase64Arg("root", e))?; + let mut data2 = [0; 32]; + if data.len() != 32 { + return Err(Error::InvalidRootKeyLength(data.len())); + } + data2.copy_from_slice(&data); + root = Some(EccKeyPubEd25519::from_bytes(data2)); + } + _ => {} + }, + } + } + + if !ot { + return Err(Error::OutdatedServer); + } + if l.is_none() || beta_vec.is_none() || server_key.is_none() || proof.is_none() { + return Err(Error::InvalidInitivexpand2); + } + let l = l.unwrap(); + let beta_vec = beta_vec.unwrap(); + let server_key = server_key.unwrap(); + let proof = proof.unwrap(); + let root = root.unwrap_or_else(|| EccKeyPubEd25519::from_bytes(crate::ROOT_KEY)); + + // Check signature of l (proof) + server_key.verify(&l, &proof).map_err(Error::InvalidSignature)?; + + if beta_vec.len() != 54 { + return Err(Error::InvalidBetaLength(beta_vec.len())); + } + + let mut beta = [0; 54]; + beta.copy_from_slice(&beta_vec); + + // Parse license argument + let licenses = Licenses::parse(l).map_err(Error::ParseLicense)?; + // Ephemeral key of server + let server_ek = licenses.derive_public_key(root).map_err(Error::ParseLicense)?; + + // Create own ephemeral key + let ek = EccKeyPrivEd25519::create(); + + let (iv, mac) = algs::compute_iv_mac(&alpha, &beta, &ek, &server_ek); + self.con.params = Some(ConnectedParams::new(server_key, iv, mac)); + + // Send clientek + let ek_pub = ek.to_pub(); + let ek_s = BASE64_STANDARD.encode(ek_pub.0.as_bytes()); + + // Proof: ECDSA signature of ek || beta + let mut all = Vec::with_capacity(32 + 54); + all.extend_from_slice(ek_pub.0.as_bytes()); + all.extend_from_slice(&beta); + let proof = self.private_key.clone().sign(&all); + let proof_s = BASE64_STANDARD.encode(&proof); + + // Send clientek + let mut cmd = + OutCommand::new(Direction::C2S, Flags::empty(), PacketType::Command, "clientek"); + cmd.write_arg("ek", &ek_s); + cmd.write_arg("proof", &proof_s); + clientek_id = self.send_packet(cmd.into_packet())?; + } + self.wait_for_ack(clientek_id).await?; + + Ok(()) + } + + /// Filter the incoming items. + pub async fn filter_items Result>>( + &mut self, filter: F, + ) -> Result { + loop { + let item = self.next().await; + match item { + None => return Err(Error::ConnectionEnd), + Some(r) => { + if let Some(r) = filter(self, r?)? { + return Ok(r); + } + } + } + } + } + + /// Filter the incoming items. Drops audio packets. + pub async fn filter_commands Result>>( + &mut self, filter: F, + ) -> Result { + loop { + let item = self.next().await; + match item { + None => return Err(Error::ConnectionEnd), + Some(Err(e)) => return Err(e), + Some(Ok(StreamItem::Error(error))) => { + warn!(%error, "Got connection error"); + } + Some(Ok(StreamItem::AckPacket(_))) => {} + Some(Ok(StreamItem::S2CInit(packet))) => { + self.hand_back_buffer(packet.into_buffer()); + } + Some(Ok(StreamItem::C2SInit(packet))) => { + self.hand_back_buffer(packet.into_buffer()); + } + Some(Ok(StreamItem::Audio(packet))) => { + self.hand_back_buffer(packet.into_buffer()); + } + Some(Ok(StreamItem::Command(packet))) => { + if let Some(r) = filter(self, packet)? { + return Ok(r); + } + } + Some(Ok(StreamItem::NetworkStatsUpdated)) => {} + } + } + } + + pub async fn wait_disconnect(&mut self) -> Result<()> { + loop { + let item = self.next().await; + match item { + None => return Ok(()), + Some(Err(e)) => return Err(e), + Some(Ok(StreamItem::AckPacket(_))) => {} + Some(Ok(StreamItem::Error(error))) => { + warn!(%error, "Got connection error"); + } + Some(Ok(StreamItem::S2CInit(packet))) => { + self.hand_back_buffer(packet.into_buffer()); + } + Some(Ok(StreamItem::C2SInit(packet))) => { + self.hand_back_buffer(packet.into_buffer()); + } + Some(Ok(StreamItem::Audio(packet))) => { + self.hand_back_buffer(packet.into_buffer()); + } + Some(Ok(StreamItem::Command(packet))) => { + self.hand_back_buffer(packet.into_buffer()); + } + Some(Ok(StreamItem::NetworkStatsUpdated)) => {} + } + } + } + + fn handle_command(&mut self, command: InCommandBuf) -> Result> { + let _span = self.con.span.clone().entered(); + let (name, args) = CommandParser::new(command.data().packet().content()); + if name == b"initserver" { + // Handle an initserver + if let Some(params) = &mut self.params { + let mut c_id = None; + for item in args { + match item { + CommandItem::NextCommand => { + return Err(Error::MultipleCommands("initserver")); + } + CommandItem::Argument(arg) => { + if arg.name() == b"aclid" { + c_id = Some( + arg.value() + .get_parse::() + .map_err(|e| { + Error::InvalidClientId( + arg.value().get_raw().to_vec(), + e, + ) + })?, + ); + break; + } + } + } + } + + if let Some(c_id) = c_id { + params.c_id = c_id; + } else { + return Err(Error::NoClientId); + } + } else { + return Err(Error::EarlyInitserver); + } + + // Notify the resender that we are connected + let this = &mut **self; + this.resender.set_state(ResenderState::Connected); + } else if name == b"notifyclientleftview" { + // Handle disconnect + if let Some(params) = &mut self.params { + let mut own_client = false; + for item in args { + match item { + CommandItem::NextCommand => {} + CommandItem::Argument(arg) => { + if arg.name() == b"clid" { + let c_id = arg + .value() + .get_parse::() + .map_err(|e| { + Error::InvalidClientId(arg.value().get_raw().to_vec(), e) + })?; + own_client |= c_id == params.c_id; + } + } + } + } + + if own_client { + // We are disconnected + let this = &mut **self; + this.resender.set_state(ResenderState::Disconnected); + } + } + } else if name == b"notifyplugincmd" { + let mut is_getversion = false; + let mut is_getversion_request = false; + let mut sender: Option = None; + for item in args.chain(std::iter::once(CommandItem::NextCommand)) { + match item { + CommandItem::Argument(arg) => match arg.name() { + b"name" => is_getversion = arg.value().get_raw() == b"getversion", + b"data" => is_getversion_request = arg.value().get_raw() == b"request", + b"invokerid" => { + if let Ok(id) = arg.value().get_parse::() { + sender = Some(id); + } + } + _ => {} + }, + CommandItem::NextCommand => { + if let Some(sender) = sender { + if is_getversion && is_getversion_request { + let mut version = format!( + "{} {}", + env!("CARGO_PKG_NAME"), + git_testament::render_testament!(crate::TESTAMENT), + ); + #[cfg(debug_assertions)] + version.push_str(" (Debug)"); + #[cfg(not(debug_assertions))] + version.push_str(" (Release)"); + + let mut cmd = OutCommand::new( + Direction::C2S, + Flags::empty(), + PacketType::Command, + "plugincmd", + ); + cmd.write_arg("name", &"getversion"); + cmd.write_arg("data", &version); + cmd.write_arg("targetmode", &2); + cmd.write_arg("target", &sender); + self.send_packet(cmd.into_packet())?; + } + } + } + } + } + } + + Ok(Some(command)) + } +} + +impl Deref for Client { + type Target = Connection; + fn deref(&self) -> &Self::Target { &self.con } +} + +impl DerefMut for Client { + fn deref_mut(&mut self) -> &mut Self::Target { &mut self.con } +} + +/// Return queued errors and inspect packets. +impl Stream for Client { + type Item = Result; + fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll> { + loop { + match Pin::new(&mut self.con).poll_next(cx) { + Poll::Ready(Some(Ok(StreamItem::Command(command)))) => { + match self.handle_command(command) { + Err(e) => return Poll::Ready(Some(Err(e))), + Ok(Some(cmd)) => { + return Poll::Ready(Some(Ok(StreamItem::Command(cmd)))); + } + Ok(None) => {} + } + } + Poll::Ready(Some(Err(e))) => return Poll::Ready(Some(Err(e.into()))), + Poll::Ready(Some(Ok(r))) => return Poll::Ready(Some(Ok(r))), + Poll::Ready(None) => return Poll::Ready(None), + Poll::Pending => return Poll::Pending, + } + } + } +} + +#[cfg(test)] +mod tests { + use std::cell::Cell; + use std::collections::VecDeque; + use std::io; + use std::sync::{Arc, Mutex}; + use std::task::Waker; + + use anyhow::{Result, bail}; + use num_traits::ToPrimitive; + use once_cell::sync::Lazy; + use tokio::io::ReadBuf; + use tokio::sync::oneshot; + use tokio::time::{self, Duration}; + + use super::*; + use crate::connection::Event; + use crate::resend::PartialPacketId; + + static TRACING: Lazy<()> = Lazy::new(|| tracing_subscriber::fmt().with_test_writer().init()); + + #[derive(Clone, Debug)] + struct SimulatedSocketState { + buffer: [VecDeque>; 2], + wakers: [Option; 2], + } + + /// Simulate a connection + #[derive(Clone, Debug)] + struct SimulatedSocket { + state: Arc>, + /// Index into the wakers list. + i: usize, + addr: SocketAddr, + } + + #[derive(Clone, Debug)] + struct SimulatedMixSocketState { + /// The order in which packets are sent to the inner socket. + /// + /// The default (if the list is empty) is `0, 1, 2, 3, 4, ...`. + /// To send the third packet first use `2, 0, 1, 3, 4, ...`. + order: Vec, + /// Queued packets that are waiting to be sent to the inner socket + send_buffer: Vec>, + } + + /// Simulate a connection but mix the packet order + #[derive(Debug)] + struct SimulatedMixSocket { + inner: SimulatedSocket, + state: Mutex, + } + + impl SimulatedSocketState { + fn new() -> Self { Self { buffer: Default::default(), wakers: Default::default() } } + } + + impl SimulatedSocket { + fn new(state: Arc>, i: usize, addr: SocketAddr) -> Self { + Self { state, i, addr } + } + + /// Create a pair of simulated sockets which are connected with each + /// other. + fn pair(addr0: SocketAddr, addr1: SocketAddr) -> (SimulatedSocket, SimulatedSocket) { + let state = Arc::new(Mutex::new(SimulatedSocketState::new())); + // Switch addresses as we use them as address from receiving packets + (Self::new(state.clone(), 0, addr1), Self::new(state, 1, addr0)) + } + } + + impl Socket for SimulatedSocket { + fn poll_recv_from( + &self, cx: &mut Context, buf: &mut ReadBuf, + ) -> Poll> { + let mut state = self.state.lock().unwrap(); + if let Some(packet) = state.buffer[self.i].pop_front() { + let len = std::cmp::min(buf.remaining(), packet.len()); + buf.put_slice(&packet[..len]); + info!(packet = ?&packet[..len], "{} receives packet", self.i); + Poll::Ready(Ok(self.addr)) + } else { + state.wakers[self.i] = Some(cx.waker().clone()); + Poll::Pending + } + } + + fn poll_send_to( + &self, _: &mut Context, buf: &[u8], _: SocketAddr, + ) -> Poll> { + let mut state = self.state.lock().unwrap(); + info!(packet = ?buf, "{} sends packet", self.i); + state.buffer[1 - self.i].push_back(buf.to_vec()); + if let Some(waker) = state.wakers[1 - self.i].take() { + waker.wake(); + } + Poll::Ready(Ok(buf.len())) + } + + fn local_addr(&self) -> io::Result { Ok(self.addr) } + } + + impl SimulatedMixSocket { + fn new(inner: SimulatedSocket, order: Vec) -> Self { + let mut check_order = order.clone(); + check_order.sort(); + assert!(check_order.is_empty() || check_order.windows(2).all(|win| win[0] != win[1])); + Self { + inner, + state: Mutex::new(SimulatedMixSocketState { + order, + send_buffer: Default::default(), + }), + } + } + + fn pair( + addr0: SocketAddr, addr1: SocketAddr, order0: Vec, order1: Vec, + ) -> (SimulatedMixSocket, SimulatedMixSocket) { + let (inner0, inner1) = SimulatedSocket::pair(addr0, addr1); + (Self::new(inner0, order0), Self::new(inner1, order1)) + } + } + + impl Socket for SimulatedMixSocket { + fn poll_recv_from( + &self, cx: &mut Context, buf: &mut ReadBuf, + ) -> Poll> { + self.inner.poll_recv_from(cx, buf) + } + + fn poll_send_to( + &self, cx: &mut Context, buf: &[u8], target: SocketAddr, + ) -> Poll> { + let mut state = self.state.lock().unwrap(); + state.send_buffer.push(buf.to_vec()); + + // Send packets from send_buffer which are ready + while !state.order.is_empty() { + let next = state.order[0]; + if state.send_buffer.len() <= next { + break; + } + state.order.remove(0); + info!("Sending packet {}", next); + let packet = state.send_buffer.remove(next); + let send_res = self.inner.poll_send_to(cx, &packet, target); + let Poll::Ready(Ok(len)) = send_res else { + panic!("Unexpected send result {:?}", send_res) + }; + assert_eq!(len, packet.len()); + + // Shift all following packet ids + // After sending packet 2 + // 2, 0, 1, 3, 4 + // becomes + // 0, 1, 2, 3 + for order in &mut state.order { + if *order > next { + *order -= 1; + } + } + } + + if state.order.is_empty() { + for packet in std::mem::take(&mut state.send_buffer) { + // Send all packets in order + info!("Sending packet in order"); + let send_res = self.inner.poll_send_to(cx, &packet, target); + let Poll::Ready(Ok(len)) = send_res else { + panic!("Unexpected send result {:?}", send_res) + }; + assert_eq!(len, packet.len()); + } + } + + Poll::Ready(Ok(buf.len())) + } + + fn local_addr(&self) -> io::Result { self.inner.local_addr() } + } + + pub struct TestConnection { + pub client: Client, + pub server: Client, + } + + impl TestConnection { + pub fn new() -> Result { + let addr = "127.0.0.1:0".parse()?; + let (socket0, socket1) = SimulatedSocket::pair(addr, addr); + Self::new_with_sockets(Box::new(socket0), Box::new(socket1)) + } + + pub fn new_with_sockets( + socket0: Box, socket1: Box, + ) -> Result { + Lazy::force(&TRACING); + + let addr = "127.0.0.1:0".parse()?; + let client_key = EccKeyPrivP256::create(); + let server_key = EccKeyPrivP256::create(); + + let mut client = Client::new(addr, socket0, client_key); + let mut server = Client::new(addr, socket1, server_key); + server.is_client = false; + + // TODO Span is = "client" + crate::log::add_logger_with_verbosity(3, &mut client); + // TODO Span is = "server" + crate::log::add_logger_with_verbosity(3, &mut server); + + Ok(Self { client, server }) + } + + pub fn set_connected(&mut self) { + Self::set_con_connected(&mut self.client, self.server.private_key.to_pub()); + Self::set_con_connected(&mut self.server, self.client.private_key.to_pub()); + } + + /// Set the connection to connected. + fn set_con_connected(con: &mut Client, other_key: EccKeyPubP256) { + let con = &mut **con; + con.resender.set_state(ResenderState::Connected); + + con.codec.outgoing_p_ids[PacketType::Command.to_usize().unwrap()] = + PartialPacketId { generation_id: 0, packet_id: 1 }; + con.codec.incoming_p_ids[PacketType::Command.to_usize().unwrap()] = + PartialPacketId { generation_id: 0, packet_id: 1 }; + con.codec.outgoing_p_ids[PacketType::Ack.to_usize().unwrap()] = + PartialPacketId { generation_id: 0, packet_id: 1 }; + con.codec.incoming_p_ids[PacketType::Ack.to_usize().unwrap()] = + PartialPacketId { generation_id: 0, packet_id: 1 }; + + // Set params + let mut params = ConnectedParams::new(other_key, [0; 64], [0x42; 8]); + params.c_id = 1; + con.params = Some(params); + } + } + + /// Check if init packet is sent and connect timeout is working. + #[tokio::test] + async fn connect_timeout() -> Result<()> { + let mut state = TestConnection::new()?; + + let (send, recv) = oneshot::channel(); + let send = Cell::new(Some(send)); + let listener = move |event: &Event| { + if let Event::ReceivePacket(packet) = event { + if packet.header().packet_type() == PacketType::Init { + if let Some(s) = send.replace(None) { + s.send(()).unwrap(); + } + } + } + }; + + state.server.event_listeners.push(Box::new(listener)); + + tokio::select!( + (r, err) = future::join( + time::timeout(Duration::from_secs(10), recv), + state.client.connect(), + ) => { + r??; + assert!(err.is_err(), "Connect should timeout"); + } + _ = state.server.wait_disconnect() => { + bail!("Server should just run in the background"); + } + ); + Ok(()) + } + + #[tokio::test] + async fn disconnect_timeout() -> Result<()> { + let mut state = TestConnection::new()?; + state.set_connected(); + + let (send, recv) = oneshot::channel(); + let send = Cell::new(Some(send)); + let listener = move |event: &Event| { + if let Event::ReceivePacket(packet) = event { + if packet.header().packet_type() == PacketType::Command { + send.replace(None).unwrap().send(()).unwrap(); + } + } + }; + + state.server.event_listeners.push(Box::new(listener)); + + let mut cmd = OutCommand::new( + Direction::C2S, + Flags::empty(), + PacketType::Command, + "clientdisconnect", + ); + cmd.write_arg("reasonid", &8); + cmd.write_arg("reasonmsg", &"Bye"); + + state.client.send_packet(cmd.into_packet())?; + + tokio::select!( + (r, err) = future::join( + time::timeout(Duration::from_secs(10), recv), + state.client.wait_disconnect(), + ) => { + r??; + assert!(err.is_err(), "Disconnect should timeout"); + } + _ = state.server.wait_disconnect() => { + bail!("Server should just run in the background"); + } + ); + Ok(()) + } + + #[tokio::test] + async fn timeout() -> Result<()> { + let mut state = TestConnection::new()?; + state.set_connected(); + + let r = state.client.wait_disconnect().await; + assert!( + matches!(r, super::Result::<()>::Err(Error::TsProto(crate::Error::Timeout(_)))), + "Connection should timeout (result: {:?})", + r + ); + Ok(()) + } + + /// Send ping and check that a pong is received. + #[tokio::test] + async fn pong() -> Result<()> { + let mut state = TestConnection::new()?; + state.set_connected(); + + let packet = OutPacket::new_with_dir(Direction::S2C, Flags::UNENCRYPTED, PacketType::Ping); + state.server.send_packet(packet.clone())?; + state.server.send_packet(packet.clone())?; + + let (send, recv) = oneshot::channel(); + let send = Cell::new(Some(send)); + let counter = Cell::new(0u8); + let listener = move |event: &Event| { + if let Event::ReceivePacket(packet) = event { + if packet.header().packet_type() == PacketType::Pong { + counter.set(counter.get() + 1); + // Until 2 pongs are received + if counter.get() == 2 { + send.replace(None).unwrap().send(()).unwrap(); + } + } + } + }; + + state.server.event_listeners.push(Box::new(listener)); + + tokio::select!( + r = time::timeout(Duration::from_secs(5), recv) => { + r??; + return Ok(()); + } + _ = state.client.wait_disconnect() => {} + _ = state.server.wait_disconnect() => {} + ); + bail!("Unexpected disconnect") + } + + /// Check that the packet id wraps around. + #[tokio::test] + async fn generation_id() -> Result<()> { + let mut state = TestConnection::new()?; + state.set_connected(); + + // Sending 70 000 messages takes about 7 minutes in debug mode so we + // start at 65 500 and send only 100. + let count = 100; + + // Set current id + for c in [&mut state.client, &mut state.server] { + c.codec.outgoing_p_ids[PacketType::Command.to_usize().unwrap()] = + PartialPacketId { generation_id: 0, packet_id: 65_500 }; + c.codec.incoming_p_ids[PacketType::Command.to_usize().unwrap()] = + PartialPacketId { generation_id: 0, packet_id: 65_500 }; + c.codec.outgoing_p_ids[PacketType::Ack.to_usize().unwrap()] = + PartialPacketId { generation_id: 0, packet_id: 65_500 }; + c.codec.incoming_p_ids[PacketType::Ack.to_usize().unwrap()] = + PartialPacketId { generation_id: 0, packet_id: 65_500 }; + } + + let (send, recv) = oneshot::channel(); + let send = Cell::new(Some(send)); + let counter = Cell::new(0u8); + let listener = move |event: &Event| { + if let Event::ReceivePacket(packet) = event { + if packet.header().packet_type() == PacketType::Command { + counter.set(counter.get() + 1); + if counter.get() == count { + send.replace(None).unwrap().send(()).unwrap(); + } + } + } + }; + + state.client.event_listeners.push(Box::new(listener)); + + for i in 0..count { + let mut cmd = OutCommand::new( + Direction::S2C, + Flags::empty(), + PacketType::Command, + "notifytextmessage", + ); + cmd.write_arg("msg", &format!("message {}", i)); + state.server.send_packet(cmd.into_packet())?; + } + + tokio::select!( + r = recv => { + r?; + return Ok(()); + } + _ = state.client.wait_disconnect() => {} + _ = state.server.wait_disconnect() => {} + ); + bail!("Unexpected disconnect") + } + + /// Check that out of order packets are decoded in the correct order. + async fn out_of_order_test(order: Vec) -> Result<()> { + let addr = "127.0.0.1:0".parse()?; + let (socket0, socket1) = SimulatedMixSocket::pair(addr, addr, vec![], order); + let mut state = TestConnection::new_with_sockets(Box::new(socket0), Box::new(socket1))?; + state.set_connected(); + + let count = 10; + + let (send, recv) = oneshot::channel(); + let send = Cell::new(Some(send)); + let counter = Cell::new(0u8); + let listener = move |event: &Event| { + if let Event::ReceivePacket(packet) = event { + if packet.header().packet_type() == PacketType::Command { + let Some(content) = + packet.content().strip_prefix(b"notifytextmessage msg=message\\s") + else { + panic!("Expected text message but got '{:?}'", packet.content()) + }; + let i: u8 = std::str::from_utf8(content).unwrap().parse().unwrap(); + let cnt = counter.get(); + assert_eq!(cnt, i, "Messages are not in the correct order"); + counter.set(cnt + 1); + if counter.get() == count { + send.replace(None).unwrap().send(()).unwrap(); + } + } + } + }; + + state.client.event_listeners.push(Box::new(listener)); + + for i in 0..count { + let mut cmd = OutCommand::new( + Direction::S2C, + Flags::empty(), + PacketType::Command, + "notifytextmessage", + ); + cmd.write_arg("msg", &format!("message {}", i)); + state.server.send_packet(cmd.into_packet())?; + } + + tokio::select!( + r = recv => { + r?; + return Ok(()); + } + _ = state.client.wait_disconnect() => {} + _ = state.server.wait_disconnect() => {} + ); + bail!("Unexpected disconnect") + } + + // Check that out of order packets are decoded in the correct order. + + #[tokio::test] + async fn in_order() -> Result<()> { out_of_order_test(vec![]).await } + + #[tokio::test] + async fn single_out_of_order() -> Result<()> { out_of_order_test(vec![2]).await } + + #[tokio::test] + async fn reversed_order() -> Result<()> { + out_of_order_test(vec![9, 8, 7, 6, 5, 4, 3, 2, 1, 0]).await + } + + #[tokio::test] + async fn some_out_of_order() -> Result<()> { + out_of_order_test(vec![5, 3, 7, 8, 2, 0, 6, 1]).await + } +} diff --git a/crates/proto/tsproto/src/connection.rs b/crates/proto/tsproto/src/connection.rs new file mode 100644 index 0000000..dd4ee7a --- /dev/null +++ b/crates/proto/tsproto/src/connection.rs @@ -0,0 +1,449 @@ +use std::collections::VecDeque; +use std::io; +use std::mem; +use std::net::SocketAddr; +use std::pin::Pin; +use std::task::{Context, Poll}; + +use futures::prelude::*; +use generic_array::GenericArray; +use generic_array::typenum::consts::U16; +use num_traits::ToPrimitive; +use tokio::io::ReadBuf; +use tokio::net::UdpSocket; +use tracing::{Span, info_span}; +use tsproto_packets::packets::*; +use tsproto_types::crypto::EccKeyPubP256; + +use crate::packet_codec::PacketCodec; +use crate::resend::{PacketId, PartialPacketId, Resender, ResenderState}; +use crate::{Error, MAX_UDP_PACKET_LENGTH, Result, UDP_SINK_CAPACITY}; + +/// The needed functions, this can be used to abstract from the underlying +/// transport and allows simulation. +pub trait Socket { + fn poll_recv_from(&self, cx: &mut Context, buf: &mut ReadBuf) -> Poll>; + fn poll_send_to( + &self, cx: &mut Context, buf: &[u8], target: SocketAddr, + ) -> Poll>; + fn local_addr(&self) -> io::Result; +} + +/// A cache for the key and nonce for a generation id. +/// This has to be stored for each packet type. +#[derive(Debug)] +pub struct CachedKey { + pub generation_id: u32, + pub key: GenericArray, + pub nonce: GenericArray, +} + +/// Data that has to be stored for a connection when it is connected. +pub struct ConnectedParams { + /// The client id of this connection. + pub c_id: u16, + /// If voice packets should be encrypted + pub voice_encryption: bool, + + /// The public key of the other side. + pub public_key: EccKeyPubP256, + /// The iv used to encrypt and decrypt packets. + pub shared_iv: [u8; 64], + /// The mac used for unencrypted packets. + pub shared_mac: [u8; 8], + /// Cached key and nonce per packet type and for server to client (without + /// client id inside the packet) and client to server communication. + pub key_cache: [[CachedKey; 2]; 8], +} + +/// An event that originates from a tsproto raw connection. +#[derive(Debug)] +pub enum Event<'a> { + ReceiveUdpPacket(&'a InUdpPacket<'a>), + ReceivePacket(&'a InPacket<'a>), + SendUdpPacket(&'a OutUdpPacket), + SendPacket(&'a OutPacket), +} + +/// An item that originates from a tsproto raw event stream. +/// +/// The disconnected event is signaled by returning `None` from the stream. +#[derive(Debug)] +pub enum StreamItem { + Command(InCommandBuf), + Audio(InAudioBuf), + C2SInit(InC2SInitBuf), + S2CInit(InS2CInitBuf), + /// All packets with an id less or equal to this id were acknowledged. + AckPacket(PacketId), + /// The network statistics were updated. + NetworkStatsUpdated, + Error(Error), +} + +type EventListener = Box Fn(&'a Event<'a>) + Send>; + +/// Represents a currently alive connection. +pub struct Connection { + pub is_client: bool, + pub span: Span, + /// The parameters of this connection, if it is already established. + pub params: Option, + /// The address of the other side, where packets are coming from and going + /// to. + pub address: SocketAddr, + + pub resender: Resender, + pub codec: PacketCodec, + pub udp_socket: Box, + udp_buffer: Vec, + + /// A buffer of packets that should be returned from the stream. + /// + /// If a new udp packet is received and we already received the following + /// ids, we can get multiple packets back at once. As we can only return one + /// from the stream, the rest is stored here. + pub(crate) stream_items: VecDeque, + + /// The queue of non-command packets that should be sent. + /// + /// These packets are not influenced by congestion control. + /// If it gets too long, we don't poll from the `udp_socket` anymore. + acks_to_send: VecDeque, + + pub event_listeners: Vec, +} + +impl Socket for UdpSocket { + fn poll_recv_from(&self, cx: &mut Context, buf: &mut ReadBuf) -> Poll> { + self.poll_recv_from(cx, buf) + } + + fn poll_send_to( + &self, cx: &mut Context, buf: &[u8], target: SocketAddr, + ) -> Poll> { + self.poll_send_to(cx, buf, target) + } + + fn local_addr(&self) -> io::Result { self.local_addr() } +} + +impl Default for CachedKey { + fn default() -> Self { + CachedKey { generation_id: u32::MAX, key: [0; 16].into(), nonce: [0; 16].into() } + } +} + +impl ConnectedParams { + /// Fills the parameters for a connection with their default state. + pub fn new(public_key: EccKeyPubP256, shared_iv: [u8; 64], shared_mac: [u8; 8]) -> Self { + Self { + c_id: 0, + voice_encryption: true, + public_key, + shared_iv, + shared_mac, + key_cache: Default::default(), + } + } +} + +impl Connection { + pub fn new(is_client: bool, address: SocketAddr, udp_socket: Box) -> Self { + let span = info_span!("connection", local_addr = %udp_socket.local_addr().unwrap(), + remote_addr = %address); + + let mut res = Self { + is_client, + span, + params: None, + address, + resender: Default::default(), + codec: Default::default(), + udp_socket, + udp_buffer: Default::default(), + + stream_items: Default::default(), + acks_to_send: Default::default(), + event_listeners: Default::default(), + }; + if is_client { + // The first command is sent as part of the C2SInit::Init4 packet + // so it does not get registered automatically. + res.codec.outgoing_p_ids[PacketType::Command.to_usize().unwrap()] = + PartialPacketId { generation_id: 0, packet_id: 1 }; + } else { + res.codec.incoming_p_ids[PacketType::Command.to_usize().unwrap()] = + PartialPacketId { generation_id: 0, packet_id: 1 }; + } + res + } + + /// Check if a given id is in the receive window. + /// + /// Returns + /// 1. If the packet id is inside the receive window + /// 1. The generation of the packet + /// 1. The minimum accepted packet id + /// 1. The maximum accepted packet id + pub(crate) fn in_receive_window(&self, p_type: PacketType, p_id: u16) -> (bool, u32, u16, u16) { + if p_type == PacketType::Init { + return (true, 0, 0, 0); + } + let type_i = p_type.to_usize().unwrap(); + // Receive window is the next half of ids + let cur_next = self.codec.incoming_p_ids[type_i].packet_id; + let (limit, next_gen) = cur_next.overflowing_add(u16::MAX / 2); + let gen = self.codec.incoming_p_ids[type_i].generation_id; + let in_recv_win = (!next_gen && p_id >= cur_next && p_id < limit) + || (next_gen && (p_id >= cur_next || p_id < limit)); + let gen_id = if in_recv_win { + if next_gen && p_id < limit { gen + 1 } else { gen } + } else if p_id < cur_next { + gen + } else { + gen - 1 + }; + + (in_recv_win, gen_id, cur_next, limit) + } + + pub fn send_event(&self, event: &Event) { + for l in &self.event_listeners { + l(event) + } + } + + pub fn hand_back_buffer(&mut self, buffer: Vec) { + if self.udp_buffer.capacity() < MAX_UDP_PACKET_LENGTH + && buffer.capacity() >= MAX_UDP_PACKET_LENGTH + { + self.udp_buffer = buffer; + } + } + + fn poll_send_acks(&mut self, cx: &mut Context) -> Result<()> { + // Poll acks_to_send + while let Some(packet) = self.acks_to_send.front() { + match self.poll_send_udp_packet(cx, packet) { + Poll::Ready(Ok(())) => { + self.resender.handle_loss_outgoing(packet); + } + Poll::Ready(Err(e)) => return Err(e), + Poll::Pending => break, + } + self.acks_to_send.pop_front(); + } + Ok(()) + } + + fn poll_incoming_udp_packet(&mut self, cx: &mut Context) -> Poll> { + if self.acks_to_send.len() >= UDP_SINK_CAPACITY { + return Poll::Pending; + } + + loop { + // Poll udp_socket + if self.udp_buffer.len() != MAX_UDP_PACKET_LENGTH { + self.udp_buffer.resize(MAX_UDP_PACKET_LENGTH, 0); + } + + let mut read_buf = ReadBuf::new(&mut self.udp_buffer); + match self.udp_socket.poll_recv_from(cx, &mut read_buf) { + Poll::Ready(Ok(addr)) => { + let size = read_buf.filled().len(); + let mut udp_buffer = mem::take(&mut self.udp_buffer); + udp_buffer.truncate(size); + match self.handle_udp_packet(cx, udp_buffer, addr) { + Ok(()) => { + if let Some(item) = self.stream_items.pop_front() { + return Poll::Ready(Ok(item)); + } + } + Err(e) => { + return Poll::Ready(Err(e)); + } + } + } + // Udp socket closed + Poll::Ready(Err(e)) => return Poll::Ready(Err(Error::Network(e))), + Poll::Pending => return Poll::Pending, + } + } + } + + fn handle_udp_packet( + &mut self, cx: &mut Context, udp_buffer: Vec, addr: SocketAddr, + ) -> Result<()> { + let _span = self.span.clone().entered(); + if addr != self.address { + self.stream_items.push_back(StreamItem::Error(Error::WrongAddress)); + return Ok(()); + } + + let dir = if self.is_client { Direction::S2C } else { Direction::C2S }; + let packet = InUdpPacket(match InPacket::try_new(dir, &udp_buffer) { + Ok(r) => r, + Err(e) => { + self.stream_items.push_back(StreamItem::Error(Error::PacketParse("udp", e))); + return Ok(()); + } + }); + let event = Event::ReceiveUdpPacket(&packet); + self.send_event(&event); + + self.resender.received_packet(); + PacketCodec::handle_udp_packet(self, cx, udp_buffer)?; + + Ok(()) + } + + /// Try to send an ack packet. + /// + /// If it does not work, add it to the ack queue. + pub(crate) fn send_ack_packet(&mut self, cx: &mut Context, packet: OutPacket) -> Result<()> { + self.send_event(&Event::SendPacket(&packet)); + let mut udp_packets = PacketCodec::encode_packet(self, packet)?; + assert_eq!( + udp_packets.len(), + 1, + "Encoding an ack packet should only yield a single packet" + ); + let packet = udp_packets.pop().unwrap(); + + match self.poll_send_udp_packet(cx, &packet) { + Poll::Ready(r) => { + if r.is_ok() { + self.resender.handle_loss_outgoing(&packet); + } + r + } + Poll::Pending => { + self.acks_to_send.push_back(packet); + Ok(()) + } + } + } + + /// Add a packet to the send queue. + /// + /// This function buffers indefinitely, to prevent using a large amount of + /// memory, check `is_send_queue_full` first and only send a packet if this + /// function returns `false`. + /// + /// When the `PacketId` which is returned by this function is acknowledged, + /// the packet was successfully received by the other side of the + /// connection. + pub fn send_packet(&mut self, packet: OutPacket) -> Result { + self.send_event(&Event::SendPacket(&packet)); + let udp_packets = PacketCodec::encode_packet(self, packet)?; + + let id = udp_packets.last().unwrap().into(); + for p in udp_packets { + self.send_udp_packet(p); + } + Ok(id) + } + + /// Add an udp packet to the send queue. + pub fn send_udp_packet(&mut self, packet: OutUdpPacket) { + let _span = self.span.clone().entered(); + match packet.packet_type() { + PacketType::Init | PacketType::Command | PacketType::CommandLow => { + Resender::send_packet(self, packet); + } + _ => self.acks_to_send.push_back(packet), + } + } + + pub fn poll_send_udp_packet( + &self, cx: &mut Context, packet: &OutUdpPacket, + ) -> Poll> { + Self::static_poll_send_udp_packet( + &*self.udp_socket, + self.address, + &self.event_listeners, + cx, + packet, + ) + } + + /// Remember to add the size of the sent packet to the stats in the resender. + pub fn static_poll_send_udp_packet( + udp_socket: &dyn Socket, address: SocketAddr, event_listeners: &[EventListener], + cx: &mut Context, packet: &OutUdpPacket, + ) -> Poll> { + let data = packet.data().data(); + match udp_socket.poll_send_to(cx, data, address).map_err(Error::Network)? { + Poll::Pending => Poll::Pending, + Poll::Ready(size) => { + let event = Event::SendUdpPacket(packet); + for l in event_listeners { + l(&event) + } + + if size != data.len() { + Poll::Ready(Err(Error::Network(std::io::Error::new( + std::io::ErrorKind::Other, + "Failed to send whole udp packet", + )))) + } else { + Poll::Ready(Ok(())) + } + } + } + } + + pub fn is_send_queue_full(&self) -> bool { self.resender.is_full() } + pub fn is_send_queue_empty(&self) -> bool { self.resender.is_empty() } +} + +/// Pull for events. +/// +/// `Ok(StreamItem::Error)` is recoverable, `Err()` is not. +/// +/// Polling does a few things in round robin fashion: +/// 1. Check for new udp packets +/// 2. Use the resender to resend packets if necessary +/// 3. Use the resender to send ping packets if necessary +impl Stream for Connection { + type Item = Result; + fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll> { + let _span = self.span.clone().entered(); + if let Err(e) = self.poll_send_acks(cx) { + return Poll::Ready(Some(Err(e))); + } + + if self.resender.get_state() == ResenderState::Disconnected { + // Send all ack packets and return `None` afterwards + if self.acks_to_send.is_empty() { + return Poll::Ready(None); + } + } + + // Use the resender to resend packets + match Resender::poll_resend(&mut self, cx) { + Ok(()) => {} + Err(e) => return Poll::Ready(Some(Err(e))), + } + + // Use the resender to send pings + match Resender::poll_ping(&mut self, cx) { + Ok(()) => {} + Err(e) => return Poll::Ready(Some(Err(e))), + } + + // Return existing stream_items + if let Some(item) = self.stream_items.pop_front() { + return Poll::Ready(Some(Ok(item))); + } + + // Check for new udp packets + match self.poll_incoming_udp_packet(cx) { + Poll::Ready(r) => return Poll::Ready(Some(r)), + Poll::Pending => {} + } + + Poll::Pending + } +} diff --git a/crates/proto/tsproto/src/lib.rs b/crates/proto/tsproto/src/lib.rs new file mode 100644 index 0000000..972d9b9 --- /dev/null +++ b/crates/proto/tsproto/src/lib.rs @@ -0,0 +1,253 @@ +//! This library implements the TeamSpeak3 protocol. +//! +//! For a usable library to build clients and bots, you should take a look at +//! [`tsclientlib`](https://github.com/ReSpeak/tsclientlib), which provides a +//! convenient interface to this library. +//! +//! If you are searching for a usable client, [Qint](https://github.com/ReSpeak/Qint) +//! is a cross-platform TeamSpeak client, which is using this library (more +//! correctly, it is using `tsclientlib`). +//! +//! For more info on this project, take a look at the +//! [tsclientlib README](https://github.com/ReSpeak/tsclientlib). + +use std::fmt; +use std::num::ParseIntError; + +use base64::prelude::*; +use serde::de::{Unexpected, Visitor}; +use serde::{Deserialize, Deserializer, Serialize, Serializer}; +use thiserror::Error; +use tsproto_packets::packets; +use tsproto_types::crypto::EccKeyPrivP256; + +pub mod algorithms; +pub mod client; +pub mod connection; +pub mod license; +pub mod log; +pub mod packet_codec; +pub mod resend; +pub mod utils; + +use algorithms as algs; + +// The build environment of tsproto. +git_testament::git_testament!(TESTAMENT); +#[doc(hidden)] +pub fn get_testament() -> &'static git_testament::GitTestament<'static> { &TESTAMENT } + +type Result = std::result::Result; + +/// The maximum number of bytes for a fragmented packet. +/// +/// The maximum packet size is 500 bytes, as used by +/// `algorithms::compress_and_split`. +/// We pick the ethernet MTU for possible future compatibility, it is unlikely +/// that a packet will get bigger. +pub const MAX_UDP_PACKET_LENGTH: usize = 1500; + +/// The maximum number of bytes for a fragmented packet. +#[allow(clippy::unreadable_literal)] +const MAX_FRAGMENTS_LENGTH: usize = 40960; + +/// The maximum number of packets which are stored, if they are received +/// out-of-order. +const MAX_QUEUE_LEN: u16 = 200; + +/// The maximum decompressed size of a packet. +#[allow(clippy::unreadable_literal)] + +/// On large servers with more than 2000 channels, the notifychannelsubscribed packet can be +/// 50 kB large (uncompressed). A maximum size to 2 MiB should allow for even larger servers. +const MAX_DECOMPRESSED_SIZE: u32 = 2 * 1024 * 1024; +const FAKE_KEY: [u8; 16] = *b"c:\\windows\\syste"; +const FAKE_NONCE: [u8; 16] = *b"m\\firewall32.cpl"; + +/// The root key in the TeamSpeak license system. +pub const ROOT_KEY: [u8; 32] = [ + 0xcd, 0x0d, 0xe2, 0xae, 0xd4, 0x63, 0x45, 0x50, 0x9a, 0x7e, 0x3c, 0xfd, 0x8f, 0x68, 0xb3, 0xdc, + 0x75, 0x55, 0xb2, 0x9d, 0xcc, 0xec, 0x73, 0xcd, 0x18, 0x75, 0x0f, 0x99, 0x38, 0x12, 0x40, 0x8a, +]; + +/// The maximum amount of ack pachets that a connection intermediately stores. +/// +/// When this amount is stored, no new packets will be polled from the UDP +/// connection. +const UDP_SINK_CAPACITY: usize = 50; + +#[derive(Error, Debug)] +#[non_exhaustive] +pub enum Error { + #[error("Failed to create ack packet: {0}")] + CreateAck(#[source] tsproto_packets::Error), + #[error("Failed to decompress packet: {0}")] + DecompressPacket(#[source] quicklz::Error), + #[error(transparent)] + IdentityCrypto(tsproto_types::crypto::Error), + #[error("Failed to parse int: {0}")] + InvalidHex(#[source] ParseIntError), + #[error("Maximum length exceeded for {0}")] + MaxLengthExceeded(&'static str), + #[error("Network error: {0}")] + Network(#[source] std::io::Error), + #[error("Packet {id} not in receive window [{next};{limit}) for type {p_type:?}")] + NotInReceiveWindow { id: u16, next: u16, limit: u16, p_type: packets::PacketType }, + #[error("Failed to parse {0} packet: {1}")] + PacketParse(&'static str, #[source] tsproto_packets::Error), + #[error("Connection timed out: {0}")] + Timeout(&'static str), + #[error("Got unallowed unencrypted packet")] + UnallowedUnencryptedPacket, + #[error("Got unexpected init packet")] + UnexpectedInitPacket, + #[error("Packet has wrong client id {0}")] + WrongClientId(u16), + #[error("Received udp packet from wrong address")] + WrongAddress, + #[error("{p_type:?} Packet {generation_id}:{packet_id} has a wrong mac")] + WrongMac { p_type: packets::PacketType, generation_id: u32, packet_id: u16 }, +} + +#[derive(Clone, Debug, Deserialize, Serialize)] +pub struct Identity { + #[serde(serialize_with = "serialize_id_key", deserialize_with = "deserialize_id_key")] + key: EccKeyPrivP256, + /// The `client_key_offset`/counter for hash cash. + counter: u64, + /// The maximum counter that was tried, this is greater or equal to + /// `counter` but may yield a lower level. + max_counter: u64, +} + +struct IdKeyVisitor; +impl<'de> Visitor<'de> for IdKeyVisitor { + type Value = EccKeyPrivP256; + + fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "a P256 private ecc key") + } + + fn visit_str(self, s: &str) -> std::result::Result { + EccKeyPrivP256::import_str(s) + .map_err(|_| serde::de::Error::invalid_value(Unexpected::Str(s), &self)) + } +} + +fn serialize_id_key( + key: &EccKeyPrivP256, s: S, +) -> std::result::Result { + s.serialize_str(&BASE64_STANDARD.encode(key.to_short())) +} + +fn deserialize_id_key<'de, D: Deserializer<'de>>( + d: D, +) -> std::result::Result { + d.deserialize_str(IdKeyVisitor) +} + +impl Identity { + #[inline] + pub fn create() -> Self { + let mut res = Self::new(EccKeyPrivP256::create(), 0); + res.upgrade_level(8); + res + } + + #[inline] + pub fn new(key: EccKeyPrivP256, counter: u64) -> Self { + Self::new_with_max_counter(key, counter, counter) + } + + #[inline] + pub fn new_with_max_counter(key: EccKeyPrivP256, counter: u64, max_counter: u64) -> Self { + Self { key, counter, max_counter } + } + + #[inline] + pub fn new_from_str(key: &str) -> Result { + if let Ok(identity) = Identity::new_from_ts_str(key) { + return Ok(identity); + } + let mut res = Self::new(EccKeyPrivP256::import_str(key).map_err(Error::IdentityCrypto)?, 0); + res.upgrade_level(8); + Ok(res) + } + + pub fn new_from_ts_str(key: &str) -> Result { + let counter_separator = key + .find('V') + .ok_or(Error::IdentityCrypto(tsproto_types::crypto::Error::NoCounterBlock))?; + let counter = key[..counter_separator] + .parse::() + .map_err(|_| Error::IdentityCrypto(tsproto_types::crypto::Error::NoCounterBlock))?; + let ecc_key = EccKeyPrivP256::import_str(&key[(counter_separator + 1)..]) + .map_err(Error::IdentityCrypto)?; + Ok(Self::new(ecc_key, counter)) + } + + #[inline] + pub fn new_from_bytes(key: &[u8]) -> Result { + let mut res = Self::new(EccKeyPrivP256::import(key).map_err(Error::IdentityCrypto)?, 0); + res.upgrade_level(8); + Ok(res) + } + + #[inline] + pub fn key(&self) -> &EccKeyPrivP256 { &self.key } + #[inline] + pub fn counter(&self) -> u64 { self.counter } + #[inline] + pub fn max_counter(&self) -> u64 { self.max_counter } + + #[inline] + pub fn set_key(&mut self, key: EccKeyPrivP256) { self.key = key } + #[inline] + pub fn set_counter(&mut self, counter: u64) { self.counter = counter; } + #[inline] + pub fn set_max_counter(&mut self, max_counter: u64) { self.max_counter = max_counter; } + + /// Compute the current hash cash level. + #[inline] + pub fn level(&self) -> u8 { + let omega = self.key.to_pub().to_ts(); + algs::get_hash_cash_level(&omega, self.counter) + } + + /// Compute a better hash cash level. + pub fn upgrade_level(&mut self, target: u8) { + let omega = self.key.to_pub().to_ts(); + let mut offset = self.max_counter; + while offset < u64::MAX && algs::get_hash_cash_level(&omega, offset) < target { + offset += 1; + } + self.counter = offset; + self.max_counter = offset; + } +} + +#[cfg(test)] +mod identity_tests { + use super::*; + + const TEST_PRIV_KEY: &str = + "MG8DAgeAAgEgAiEA6rtKxDn/o/Bo50rNtAE5Ph3h2RKLHQ0gbFkvm2yA79kCIQCrfzAZts/\ + vHP+3MOetKLjNnpZXt4c6U3UB4gWLKR4H9AIgYTyJofmztcTBjq3KZcDdxu+G4RPVwE5vg8VaN2jbQao="; + const TEST_UID: &str = "test/9PZ9vww/Bpf5vJxtJhpz80="; + + #[test] + fn parse_ts_base64() { + let identity = Identity::new_from_str(TEST_PRIV_KEY).unwrap(); + let uid = identity.key().to_pub().get_uid(); + assert_eq!(TEST_UID, &uid); + } + + #[test] + fn parse_ts_base64_with_offset() { + let ident_str = String::from("2792354V") + TEST_PRIV_KEY; + let identity = Identity::new_from_str(&ident_str).unwrap(); + let uid = identity.key().to_pub().get_uid(); + assert_eq!(TEST_UID, &uid); + assert_eq!(identity.level(), 21u8); + } +} diff --git a/crates/proto/tsproto/src/license.rs b/crates/proto/tsproto/src/license.rs new file mode 100644 index 0000000..ad40c7e --- /dev/null +++ b/crates/proto/tsproto/src/license.rs @@ -0,0 +1,932 @@ +use std::convert::{TryFrom, TryInto}; +use std::fmt; +use std::io::Cursor; +use std::str; + +use curve25519_dalek_ng::edwards::EdwardsPoint; +use curve25519_dalek_ng::scalar::Scalar; +use num_derive::{FromPrimitive, ToPrimitive}; +use num_traits::{FromPrimitive as _, ToPrimitive as _}; +use omnom::{ReadExt, WriteExt}; +use sha2::{Digest, Sha512}; +use thiserror::Error; +use time::OffsetDateTime; +use time::format_description::well_known::Rfc3339; +use tracing::trace; +use tsproto_packets::HexSlice; +use tsproto_types::{ + LicenseType, + crypto::{EccKeyPrivEd25519, EccKeyPubEd25519}, +}; + +pub const TIMESTAMP_OFFSET: i64 = 0x50e2_2700; + +const BLOCK_MIN_LEN: usize = 42; +const BLOCK_TYPE_OFFSET: usize = 33; +const BLOCK_NOT_VALID_BEFORE_OFFSET: usize = 34; +const BLOCK_NOT_VALID_AFTER_OFFSET: usize = 38; + +type Result = std::result::Result; + +#[derive(Error, Debug)] +#[non_exhaustive] +pub enum Error { + #[error( + "License must not exceed bounds {outer_start} - {outer_end} but has {inner_start} - \ + {inner_end}" + )] + Bounds { + outer_start: OffsetDateTime, + outer_end: OffsetDateTime, + inner_start: OffsetDateTime, + inner_end: OffsetDateTime, + }, + #[error("Failed to deserialize license: {0}")] + Deserialize(#[source] std::io::Error), + #[error("Failed to deserialize license: {0}")] + DeserializeString(#[source] std::str::Utf8Error), + #[error("Failed to deserialize date: {0}")] + DeserializeDate(#[source] time::error::ComponentRange), + #[error("License is only valid between {start} and {end}")] + Expired { start: OffsetDateTime, end: OffsetDateTime }, + #[error("Cannot uncompress license public key")] + InvalidPublicKey, + #[error("Invalid data {0:#x} in intermediate license")] + IntermediateInvalidData(u32), + #[error("Invalid public root key for license")] + InvalidRootKey, + #[error("Non-null-terminated string")] + NonterminatedString, + #[error("License contains no private key")] + NoPrivateKey, + #[error("Too many license blocks: {0}")] + TooManyBlocks(usize), + #[error("License too short ({0}): {1}")] + TooShort(usize, &'static str), + #[error("Unknown license block type {0}")] + UnknownBlockType(u8), + #[error("Unknown license type {0}")] + UnknownLicenseType(u8), + #[error("Unsupported license version {0}")] + UnsupportedVersion(u8), + #[error("Wrong key kind {0} in license")] + WrongKeyKind(u8), + #[error("There is no {0} in this block")] + NoSuchProperty(&'static str), + #[error("Wrong property type for id {id}: Expected type {expected} but got type {actual}")] + WrongPropertyType { id: u8, expected: u8, actual: u8 }, + #[error( + "Property with id {id} and type {typ} has wrong length: Expected length {expected} but \ + got length {actual}" + )] + WrongPropertyLength { id: u8, typ: u8, expected: u8, actual: u8 }, +} + +/// A single block of a license +#[derive(Clone, Debug)] +pub struct License { + /// Length of the block + pub len: usize, + /// A private key for the block to derive a private key + pub private_key: Option, + pub inner: InnerLicense, +} + +/// Helper struct to debug print a license block. +pub struct DebugLicense<'a>(&'a License, &'a [u8]); + +#[derive(Debug, Clone, Copy, Eq, Hash, PartialEq, FromPrimitive, ToPrimitive)] +pub enum LicenseBlockType { + Intermediate, + Website, + /// Ts3_Server + Server, + Code, + // Not existing in the license parameter: + // 4: Token, 5: License_Sign, 6: MyTsId_Sign, 7: Updater + /// Ts_Server_License + Ts5Server = 8, + /// 32, Ephemeral_Key + Ephemeral = 32, +} + +#[derive(Debug, Clone)] +pub enum InnerLicense { + Ts5Server { + /// Properties from the license, offset from the start of properties for every field + properties: Vec, + }, + Other, +} + +/// A list of blocks, forming a complete license +#[derive(Clone)] +pub struct Licenses { + pub data: Vec, + pub blocks: Vec, +} + +#[derive(Clone, Debug)] +pub enum LicenseProperty<'a> { + /// Unknown property with id 1 and type 1 + Unknown1(u32), + Issuer(&'a str), + MaxClients(u32), + Unknown { + id: u8, + typ: u8, + data: &'a [u8], + }, +} + +#[derive(Debug)] +pub struct LicenseBuilder<'a> { + licenses: &'a mut Licenses, +} + +#[derive(Debug)] +pub struct LicenseBlockBuilder<'a, 'b> { + builder: &'b mut LicenseBuilder<'a>, + /// The start offset for the new block + offset: usize, + typ: LicenseBlockType, +} + +type LicenseTimeBounds = (OffsetDateTime, OffsetDateTime); + +impl Licenses { + pub fn new() -> Self { Self::default() } + + /// Parse a license but ignore expired licenses. + /// + /// This is useful for tests but should not be used otherwise. + pub fn parse_ignore_expired(data: Vec) -> Result { Self::parse_internal(data, false) } + + pub fn parse(data: Vec) -> Result { Self::parse_internal(data, true) } + + pub fn parse_internal(data: Vec, check_expired: bool) -> Result { + let version = data[0]; + if version != 0 && version != 1 { + return Err(Error::UnsupportedVersion(version)); + } + // Read licenses + let mut blocks = Vec::new(); + + let now = OffsetDateTime::now_utc(); + let mut offset = 1; + let mut bounds = None; + while data.len() > offset { + if blocks.len() >= 8 { + // Accept only 8 blocks + return Err(Error::TooManyBlocks(blocks.len())); + } + + // Read next license + let (license, b) = Self::parse_block(&data[offset..], check_expired, now, bounds)?; + offset += license.len; + bounds = Some(b); + + blocks.push(license); + } + + Ok(Licenses { data, blocks }) + } + + fn parse_block( + data: &[u8], check_expired: bool, now: OffsetDateTime, bounds: Option, + ) -> Result<(License, LicenseTimeBounds)> { + let license = License::parse(data)?; + let license_data = &data[..license.len]; + + // Check if the certificate is valid + let new_bounds = ( + license.get_not_valid_before(license_data)?, + license.get_not_valid_after(license_data)?, + ); + if new_bounds.0 > now && check_expired { + return Err(Error::Expired { start: new_bounds.0, end: new_bounds.1 }); + } + if new_bounds.1 < now && check_expired { + return Err(Error::Expired { start: new_bounds.0, end: new_bounds.1 }); + } + if let Some((start, end)) = bounds { + // The inner license must not have wider bounds + if new_bounds.0 < start || new_bounds.1 > end { + return Err(Error::Bounds { + outer_start: start, + outer_end: end, + inner_start: new_bounds.0, + inner_end: new_bounds.1, + }); + } + } + Ok((license, new_bounds)) + } + + pub fn derive_public_key(&self, root: EccKeyPubEd25519) -> Result { + let mut last_round = root.0.decompress().ok_or(Error::InvalidRootKey)?; + let mut offset = 1; + trace!("Deriving public key for license"); + for l in &self.blocks { + trace!(current_key = %HexSlice((&last_round.compress().0) as &[u8])); + last_round = l.derive_public_key(&self.data[offset..offset + l.len], &last_round)?; + offset += l.len; + } + trace!( + final_key = %HexSlice((&last_round.compress().0) as &[u8]), + "Finished deriving public key" + ); + Ok(last_round) + } + + /// Derive the private key of this license, starting with a specific block. + /// + /// The keys which are stored inside the licenses from the starting block on + /// have to be private keys. + /// + /// # Arguments + /// + /// `starting_block`: The index of the first block for the key computation. + /// `first_key`: The starting private key (the key of a parent block or the + /// root private key). + /// + /// # Panics + /// + /// Panics if `starting_block` is not a valid license block index. + pub fn derive_private_key( + &self, starting_block: usize, first_key: EccKeyPrivEd25519, + ) -> Result { + let mut res = first_key; + let mut offset = 1; + for (i, l) in self.blocks.iter().enumerate() { + if i >= starting_block { + res = l.derive_private_key(&self.data[offset..offset + l.len], &res)?; + } + offset += l.len; + } + Ok(res) + } + + pub fn build(mut self, f: F) -> Result { + let len = self.data.len(); + + f(LicenseBuilder { licenses: &mut self }); + + // Parse new blocks + let now = OffsetDateTime::now_utc(); + let mut offset = len; + let mut bounds = self + .blocks + .last() + .map(|b| { + let b_offset = len - b.len; + let b_data = &self.data[b_offset..len]; + Ok((b.get_not_valid_before(b_data)?, b.get_not_valid_after(b_data)?)) + }) + .transpose()?; + + while self.data.len() > offset { + if self.blocks.len() >= 8 { + // Accept only 8 blocks + return Err(Error::TooManyBlocks(self.blocks.len())); + } + + // Read next license + let (license, b) = Self::parse_block(&self.data[offset..], false, now, bounds)?; + offset += license.len; + bounds = Some(b); + + self.blocks.push(license); + } + + Ok(self) + } + + pub fn is_valid(&self) -> Result<()> { + let mut offset = 1; + for b in &self.blocks { + b.is_valid(&self.data[offset..offset + b.len])?; + offset += b.len; + } + Ok(()) + } +} + +impl Default for Licenses { + fn default() -> Self { Self { data: vec![1], blocks: Default::default() } } +} + +impl fmt::Debug for Licenses { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "Licenses ")?; + let mut offset = 1; + f.debug_list() + .entries(self.blocks.iter().map(|b| { + let o = offset; + offset += b.len; + DebugLicense(b, &self.data[o..o + b.len]) + })) + .finish()?; + Ok(()) + } +} + +impl License { + /// Parse license and return read length. + pub fn parse(data: &[u8]) -> Result { + let len = data.len(); + if data.len() < BLOCK_MIN_LEN { + return Err(Error::TooShort(len, "less than minimum block length")); + } + if data[0] != 0 { + return Err(Error::WrongKeyKind(data[0])); + } + + let typ_i = data[BLOCK_TYPE_OFFSET]; + let typ = LicenseBlockType::from_u8(typ_i).ok_or(Error::UnknownBlockType(typ_i))?; + let data = &data[BLOCK_MIN_LEN..]; + let (inner, extra_len) = match typ { + LicenseBlockType::Intermediate => { + if data.len() < 5 { + return Err(Error::TooShort( + len, + "less than minimum length of intermediate license", + )); + } + // 4 byte unknown + // Issuer string + + let len = if let Some(len) = data[4..].iter().position(|&b| b == 0) { + len + } else { + return Err(Error::NonterminatedString); + }; + (InnerLicense::Other, 5 + len) + } + LicenseBlockType::Server => { + if data.len() < 6 { + return Err(Error::TooShort( + len, + "less than minimum length of TS3 server license", + )); + } + // 1 byte server license type + // 4 byte max clients + // Issuer string + let len = if let Some(len) = data[5..].iter().position(|&b| b == 0) { + len + } else { + return Err(Error::NonterminatedString); + }; + + (InnerLicense::Other, 6 + len) + } + LicenseBlockType::Ts5Server => { + if data.len() < 2 { + return Err(Error::TooShort( + len, + "less than minimum length of TS5 server license", + )); + } + // 1 byte server license type + // Property count and properties + let property_count = data[1]; + let mut pos = 2; + + let properties = (0..property_count) + .map(|_| { + let p = pos - 2; + if pos >= data.len() { + return Err(Error::TooShort(len, "missing TS5 license property")); + } + let len = usize::from(data[pos]); + pos += 1; + if pos + len >= data.len() { + return Err(Error::TooShort(len, "cut off TS5 license property")); + } + pos += len; + Ok(p) + }) + .collect::>()?; + + (InnerLicense::Ts5Server { properties }, pos) + } + LicenseBlockType::Ephemeral => (InnerLicense::Other, 0), + _ => { + return Err(Error::UnknownBlockType(typ_i)); + } + }; + + Ok(License { len: BLOCK_MIN_LEN + extra_len, private_key: None, inner }) + } + + pub fn get_type(&self, data: &[u8]) -> Result { + let typ_i = data[BLOCK_TYPE_OFFSET]; + LicenseBlockType::from_u8(typ_i).ok_or(Error::UnknownBlockType(typ_i)) + } + + pub fn get_public_key(&self, data: &[u8]) -> Result { + let k = EccKeyPubEd25519::from_bytes(data[1..33].try_into().unwrap()); + k.0.decompress().ok_or(Error::InvalidPublicKey) + } + + fn get_timestamp(&self, data: &[u8], block_offset: usize) -> Result { + let num: u32 = (&data[block_offset..]).read_be().map_err(Error::Deserialize)?; + OffsetDateTime::from_unix_timestamp(i64::from(num) + TIMESTAMP_OFFSET) + .map_err(Error::DeserializeDate) + } + + pub fn get_not_valid_before(&self, data: &[u8]) -> Result { + self.get_timestamp(data, BLOCK_NOT_VALID_BEFORE_OFFSET) + } + + pub fn get_not_valid_after(&self, data: &[u8]) -> Result { + self.get_timestamp(data, BLOCK_NOT_VALID_AFTER_OFFSET) + } + + pub fn get_license_type(&self, data: &[u8]) -> Result { + if ![LicenseBlockType::Server, LicenseBlockType::Ts5Server].contains(&self.get_type(data)?) + { + return Err(Error::NoSuchProperty("license type")); + } + LicenseType::from_u8(data[BLOCK_MIN_LEN]) + .ok_or(Error::UnknownLicenseType(data[BLOCK_MIN_LEN])) + } + + pub fn get_issuer<'a>(&self, data: &'a [u8]) -> Result<&'a str> { + let typ = self.get_type(data)?; + + if typ == LicenseBlockType::Ts5Server { + // Search in properties + let res = self + .get_properties(data)? + .find_map(|p| if let Ok(LicenseProperty::Issuer(i)) = p { Some(i) } else { None }) + .ok_or(Error::NoSuchProperty("issuer")); + return res; + } + + let offset = BLOCK_MIN_LEN + + match typ { + LicenseBlockType::Intermediate => 4, + LicenseBlockType::Website | LicenseBlockType::Code => 0, + LicenseBlockType::Server => 5, + _ => return Err(Error::NoSuchProperty("issuer")), + }; + let len = match typ { + LicenseBlockType::Intermediate + | LicenseBlockType::Website + | LicenseBlockType::Code + | LicenseBlockType::Server => self.len - offset - 1, + _ => return Err(Error::NoSuchProperty("issuer")), + }; + str::from_utf8(&data[offset..offset + len]).map_err(Error::DeserializeString) + } + + pub fn get_max_clients(&self, data: &[u8]) -> Result { + let typ = self.get_type(data)?; + + if typ == LicenseBlockType::Ts5Server { + // Search in properties + let res = self + .get_properties(data)? + .find_map( + |p| if let Ok(LicenseProperty::MaxClients(i)) = p { Some(i) } else { None }, + ) + .ok_or(Error::NoSuchProperty("max clients")); + return res; + } + + let offset = BLOCK_MIN_LEN + + match typ { + LicenseBlockType::Intermediate => 0, + LicenseBlockType::Server => 1, + _ => return Err(Error::NoSuchProperty("max clients")), + }; + (&data[offset..offset + 4]).read_be().map_err(Error::Deserialize) + } + + pub fn get_properties<'a: 'b, 'b>( + &'b self, data: &'a [u8], + ) -> Result>> + 'b> { + if let InnerLicense::Ts5Server { properties } = &self.inner { + Ok(properties.iter().map(move |p| { + let o = BLOCK_MIN_LEN + 2 + p; + let len = data[o]; + let len_usize = len as usize; + let id = data[o + 1]; + let typ = data[o + 2]; + + // Check length + if let Some(expected) = match typ { + // String, check that it is null-terminated + 0 => { + if data[o + len_usize] != 0 { + return Err(Error::NonterminatedString); + } + None + } + 1 | 3 => Some(4), + 2 | 4 => Some(8), + _ => None, + } { + if len != expected { + return Err(Error::WrongPropertyLength { id, typ, expected, actual: len }); + } + } + + match id { + 1 => { + if typ != 1 { + return Err(Error::WrongPropertyType { id, expected: 1, actual: typ }); + } + Ok(LicenseProperty::Unknown1( + (&data[o + 3..o + 3 + 4]).read_be().map_err(Error::Deserialize)?, + )) + } + 2 => { + if typ != 0 { + return Err(Error::WrongPropertyType { id, expected: 0, actual: typ }); + } + let s = str::from_utf8(&data[o + 3..o + len_usize]) + .map_err(Error::DeserializeString)?; + Ok(LicenseProperty::Issuer(s)) + } + 3 => { + if typ != 1 { + return Err(Error::WrongPropertyType { id, expected: 1, actual: typ }); + } + Ok(LicenseProperty::MaxClients( + (&data[o + 3..o + 3 + 4]).read_be().map_err(Error::Deserialize)?, + )) + } + _ => { + Ok(LicenseProperty::Unknown { id, typ, data: &data[o + 3..o + len_usize] }) + } + } + })) + } else { + Err(Error::NoSuchProperty("properties")) + } + } + + /// Get the private key from the hash of this license block. + pub fn get_hash_key(&self, data: &[u8]) -> Scalar { + // Make a valid private key from the hash + let mut hash_key = Sha512::digest(&data[1..]); + hash_key[0] &= 248; + hash_key[31] &= 63; + hash_key[31] |= 64; + Scalar::from_bytes_mod_order(hash_key.as_slice()[..32].try_into().unwrap()) + } + + pub fn derive_public_key( + &self, data: &[u8], parent_key: &EdwardsPoint, + ) -> Result { + let pub_key = self.get_public_key(data)?; + let hash_key = self.get_hash_key(data); + Ok(pub_key * hash_key + parent_key) + } + + /// Derive the private key of this license block. + /// + /// The key which is stored inside this license has to be a private key. + /// + /// # Arguments + /// + /// `parent_key`: The resulting private key of the previous block. + pub fn derive_private_key( + &self, data: &[u8], parent_key: &EccKeyPrivEd25519, + ) -> Result { + let priv_key = if let Some(k) = &self.private_key { + &k.0 + } else { + return Err(Error::NoPrivateKey); + }; + let hash_key = self.get_hash_key(data); + Ok(EccKeyPrivEd25519(priv_key * hash_key + parent_key.0)) + } + + /// Check if this is a valid license. + /// + /// Does some sanity checking on fields. Does not need to be called for correctness. + pub fn is_valid(&self, data: &[u8]) -> Result<()> { + self.get_public_key(data)?; + self.get_not_valid_before(data)?; + self.get_not_valid_after(data)?; + + if let Err(e) = self.get_license_type(data) { + if !matches!(e, Error::NoSuchProperty(_)) { + return Err(e); + } + } + + if let Err(e) = self.get_issuer(data) { + if !matches!(e, Error::NoSuchProperty(_)) { + return Err(e); + } + } + + match self.get_properties(data) { + Ok(ps) => { + for p in ps { + p?; + } + } + Err(e) => { + if !matches!(e, Error::NoSuchProperty(_)) { + return Err(e); + } + } + } + + Ok(()) + } +} + +impl fmt::Debug for DebugLicense<'_> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let from = self + .0 + .get_not_valid_before(self.1) + .ok() + .and_then(|d| d.format(&Rfc3339).ok()) + .unwrap_or_else(|| "error".to_string()); + let to = self + .0 + .get_not_valid_after(self.1) + .ok() + .and_then(|d| d.format(&Rfc3339).ok()) + .unwrap_or_else(|| "error".to_string()); + + let mut d = f.debug_struct("License"); + let typ = self.0.get_type(self.1).unwrap(); + d.field("type", &typ); + if let Some(key) = &self.0.private_key { + d.field("private_key", key); + } + d.field("not_valid_before", &from).field("not_valid_after", &to); + + match typ { + LicenseBlockType::Intermediate => { + if let Ok(num) = self.0.get_max_clients(self.1) { + d.field("data", &num); + } else { + d.field("data", &"error"); + } + } + LicenseBlockType::Website | LicenseBlockType::Code => { + if let Ok(issuer) = self.0.get_issuer(self.1) { + d.field("issuer", &issuer); + } else { + d.field("issuer", &"error"); + } + } + LicenseBlockType::Server => { + if let Ok(license_type) = self.0.get_license_type(self.1) { + d.field("license_type", &license_type); + } else { + d.field("license_type", &"error"); + } + if let Ok(issuer) = self.0.get_issuer(self.1) { + d.field("issuer", &issuer); + } else { + d.field("issuer", &"error"); + } + if let Ok(max_clients) = self.0.get_max_clients(self.1) { + d.field("max_clients", &max_clients); + } else { + d.field("max_clients", &"error"); + } + } + LicenseBlockType::Ts5Server => { + if let Ok(props) = + self.0.get_properties(self.1).and_then(|ps| ps.collect::>>()) + { + d.field("properties", &props); + } else { + d.field("properties", &"error"); + } + } + LicenseBlockType::Ephemeral => {} + } + + d.finish()?; + + Ok(()) + } +} + +impl LicenseBlockType { + fn min_len(&self) -> usize { + BLOCK_MIN_LEN + + match self { + Self::Intermediate => 5, + Self::Website | Self::Code => 1, + Self::Server => 6, + Self::Ts5Server => 2, + Self::Ephemeral => 0, + } + } +} + +impl<'a> LicenseBuilder<'a> { + pub fn add_block<'b>(&'b mut self, typ: LicenseBlockType) -> LicenseBlockBuilder<'a, 'b> { + let len = self.licenses.data.len(); + self.licenses.data.resize(len + typ.min_len(), 0); + self.licenses.data[len + BLOCK_TYPE_OFFSET] = typ.to_u8().unwrap(); + LicenseBlockBuilder { builder: self, offset: len, typ } + } +} + +impl LicenseBlockBuilder<'_, '_> { + pub fn public_key(&mut self, key: &EccKeyPubEd25519) -> &mut Self { + let o = self.offset + 1; + self.builder.licenses.data[o..o + 32].copy_from_slice(&key.0.0); + self + } + + fn write_timestamp(&mut self, offset: usize, time: OffsetDateTime) -> &mut Self { + let o = self.offset + offset; + Cursor::new(&mut self.builder.licenses.data[o..o + 4]) + .write_be((time.unix_timestamp() - TIMESTAMP_OFFSET) as u32) + .unwrap(); + self + } + + pub fn not_valid_before(&mut self, time: OffsetDateTime) -> &mut Self { + self.write_timestamp(BLOCK_NOT_VALID_BEFORE_OFFSET, time) + } + + pub fn not_valid_after(&mut self, time: OffsetDateTime) -> &mut Self { + self.write_timestamp(BLOCK_NOT_VALID_AFTER_OFFSET, time) + } + + /// Only valid for Server and Ts5Server license types + pub fn server_license_type(&mut self, typ: LicenseType) -> &mut Self { + if ![LicenseBlockType::Server, LicenseBlockType::Ts5Server].contains(&self.typ) { + panic!( + "Setting the license type is only allowed for Server and Ts5Server license types, \ + but this is a {:?}", + self.typ + ); + } + self.builder.licenses.data[self.offset + BLOCK_MIN_LEN] = typ.to_u8().unwrap(); + self + } + + /// Add a property in a TS5 license block. + /// + /// `len` is the length of the content, excluding id, type and length field. + /// Return the byte offset to where the contents of the property starts. + fn ts5_add_property(&mut self, id: u8, typ: u8, len: usize) -> usize { + let o = self.builder.licenses.data.len(); + self.builder.licenses.data.resize(o + len + 3, 0); + // Increment property count + self.builder.licenses.data[self.offset + BLOCK_MIN_LEN + 1] += 1; + self.builder.licenses.data[o] = u8::try_from(len).unwrap() + 2; + self.builder.licenses.data[o + 1] = id; + self.builder.licenses.data[o + 2] = typ; + o + 3 + } + + /// Only valid for Intermediate, Server and Ts5Server license types + pub fn max_clients(&mut self, max_clients: u32) -> &mut Self { + let o = if self.typ == LicenseBlockType::Ts5Server { + self.ts5_add_property(3, 1, 4) + } else { + self.offset + + BLOCK_MIN_LEN + + match self.typ { + LicenseBlockType::Intermediate => 0, + LicenseBlockType::Server => 1, + _ => panic!( + "Setting max clients is only allowed for Intermediate, Server and \ + Ts5Server license types, but this is a {:?}", + self.typ + ), + } + }; + Cursor::new(&mut self.builder.licenses.data[o..o + 4]).write_be(max_clients).unwrap(); + self + } + + /// Only valid for Intermediate, Server and Ts5Server license types + pub fn issuer(&mut self, issuer: &str) -> &mut Self { + // Check that the issuer does not contain null bytes + assert!( + !issuer.contains('\0'), + "The issuer is written as a null-terminated string so it cannot contain null bytes" + ); + + let o = if self.typ == LicenseBlockType::Ts5Server { + self.ts5_add_property(2, 0, issuer.len() + 1) + } else { + if ![LicenseBlockType::Intermediate, LicenseBlockType::Server].contains(&self.typ) { + panic!( + "Setting the issuer is only allowed for Intermediate, Server and Ts5Server \ + license types, but this is a {:?}", + self.typ + ); + } + // Check that no issuer was written so far + assert!( + self.builder.licenses.data.len() - self.offset == self.typ.min_len(), + "Only a single issuer can be written into a license block" + ); + let o = self.builder.licenses.data.len(); + self.builder.licenses.data.resize(o + issuer.len(), 0); + o - 1 + }; + self.builder.licenses.data[o..o + issuer.len()].copy_from_slice(issuer.as_bytes()); + self + } +} + +#[cfg(test)] +mod tests { + use super::*; + use base64::prelude::*; + + #[test] + fn parse_standard_license() { + Licenses::parse_ignore_expired(BASE64_STANDARD.decode("AQA1hUFJiiSs0wFXkYuPUJVcDa6XCrZTcsvkB0\ + Ffzz4CmwIITRXgCqeTYAcAAAAgQW5vbnltb3VzAACiIBip9hQaK6P3QhwOJs/BkPn0i\ + oyIDPaNgzJ6M8x0kiAJf4hxCYAxMQ==").unwrap()).unwrap(); + } + + #[test] + fn parse_standard_license_expired() { + assert!(Licenses::parse(BASE64_STANDARD.decode("AQA1hUFJiiSs0wFXkYuPUJVcDa6XCrZTcsvkB0\ + Ffzz4CmwIITRXgCqeTYAcAAAAgQW5vbnltb3VzAACiIBip9hQaK6P3QhwOJs/BkPn0i\ + oyIDPaNgzJ6M8x0kiAJf4hxCYAxMQ==").unwrap()).is_err()); + } + + #[test] + fn parse_aal_license() { + Licenses::parse_ignore_expired(BASE64_STANDARD.decode("AQCvbHFTQDY/terPeilrp/ECU9xCH5U3xC92lY\ + TNaY/0KQAJFueAazbsgAAAACVUZWFtU3BlYWsgU3lzdGVtcyBHbWJIAABhl9gwla/UJ\ + p2Eszst9TRVXO/PeE6a6d+CTI6Pg7OEVgAJc5CrL4Nh8gAAACRUZWFtU3BlYWsgc3lz\ + dGVtcyBHbWJIAACvTQIgpv6zmLZq3znh7ygmOSokGFkFjz4bTigrOnetrgIJdIIACdS\ + /gAYAAAAAU29zc2VuU3lzdGVtcy5iaWQAADY7+uV1CQ1niOvYSdGzsu83kPTNWijovr\ + 3B78eHGeePIAm98vQJvpu0").unwrap()).unwrap(); + } + + #[test] + fn parse_ts5_server_license_long() { + // Slightly older format having a block with a Ts5 license block in it + Licenses::parse_ignore_expired(BASE64_STANDARD.decode("AQDVsMGbcrMmGif1vSXPWWXNW2CB5\ + Fe9oZ/2uxP29j1EXQAQSfiAazbsgAAAASVUZWFtU3BlYWsgU3lzdGVtcyBHbWJIAAALB6Qfbe\ + JyN+9foJhe+/KPFwyU+i++4MAA0q1/WCnizwARRuEPN1aeBQAAASBUZWFtU3BlYWsgc3lzdGV\ + tcyBHbWJIAADrhbI5gUR3thsS7FqKV5P5h7djnwMSJfF2vi58lm1VcwgRUFMAE0P7gAUCGQIA\ + VGVhbVNwZWFrIFN5c3RlbXMgR21iSAAGAwEAAAAFAAf2KhQ7WLjOvwwY0Bi7LxAcWmQeT+LQt\ + uaOzjhYoA+YIBGNq1kRjlQZ").unwrap()).unwrap(); + } + + #[test] + fn parse_ts5_server_license_long2() { + // Also slightly older, has 3 properties + Licenses::parse_ignore_expired(BASE64_STANDARD.decode("AQDVsMGbcrMmGif1vSXPWWXNW2CB5\ + Fe9oZ/2uxP29j1EXQAQSfiAazbsgAAAASVUZWFtU3BlYWsgU3lzdGVtcyBHbWJIAAAtXG5p2n\ + iXlDfpVAGuD88w8hetKYL4vqHRkB5xB8ASRwAR2t/MN+ttjAAAASBUZWFtU3BlYWsgc3lzdGV\ + tcyBHbWJIAAAdZYGtwkeZFhzqnoV1uk+Tcphe8GgcqiPVtELF9y4wOAgR4qmAF4jnAAkDGQIA\ + VGVhbVNwZWFrIFN5c3RlbXMgR21iSAAGAwEAAAAFBgEBAAGGoADzyFvD+9G6uhIxmh0jK+Uo8\ + z8fYGJVH81vWFULDS0l8yATKe4cEyqW3A==").unwrap()).unwrap(); + } + + #[test] + fn parse_ts5_server_license_single_block_with_issuer() { + Licenses::parse_ignore_expired( + BASE64_STANDARD + .decode( + "AQBgjAAqtcBUrw5futTtkl3+EM3OW4Lal6OTPlwuv4xV/\ + gIRFlEAG0NlAAcAAAAgQW5vbnltb3VzAACKNY+/\ + 9qCbonCSxG18vBb7y7zPIgDdjTmcZoAHHclnJSATPa69Ez5XfQ==", + ) + .unwrap(), + ) + .unwrap(); + } + + #[test] + fn parse_ts5_server_license_single_block() { + // Only a single server block and the ephemeral block + Licenses::parse_ignore_expired(BASE64_STANDARD.decode("AQAuio9ZxThXKE+hmzQyzBRedysp9\ + 79JBTv2xP3s2oCkiAgQI70AE+YkAAcBBgMBAAAABQBoazM313063zaipPTH06zrXc91ch3huB\ + YrUET9sEbz1CATKgK8EyqrfA==").unwrap()).unwrap(); + } + + #[test] + fn derive_public_key() { + let licenses = Licenses::parse_ignore_expired(BASE64_STANDARD.decode("AQA1hUFJiiSs0wFXkYuPUJVcDa6XCrZTcsvkB0Ffzz4CmwIITRXgCqeTYAcAAAAgQW5vbnltb3VzAAC4R+5mos+UQ/KCbkpQLMI5WRp4wkQu8e5PZY4zU+/FlyAJwaE8CcJJ/A==").unwrap()).unwrap(); + let derived_key = + licenses.derive_public_key(EccKeyPubEd25519::from_bytes(crate::ROOT_KEY)).unwrap(); + + let expected_key = [ + 0x40, 0xe9, 0x50, 0xc4, 0x61, 0xba, 0x18, 0x3a, 0x1e, 0xb7, 0xcb, 0xb1, 0x9a, 0xc3, + 0xd8, 0xd9, 0xc4, 0xd5, 0x24, 0xdb, 0x38, 0xf7, 0x2d, 0x3d, 0x66, 0x75, 0x77, 0x2a, + 0xc5, 0x9c, 0xc5, 0xc6, + ]; + let derived_key = derived_key.compress().0; + assert_eq!(derived_key, expected_key); + } +} diff --git a/crates/proto/tsproto/src/log.rs b/crates/proto/tsproto/src/log.rs new file mode 100644 index 0000000..18aadab --- /dev/null +++ b/crates/proto/tsproto/src/log.rs @@ -0,0 +1,111 @@ +use std::fmt::Debug; +use std::str; + +use tracing::{debug, debug_span, Span}; +use tsproto_packets::packets::{InUdpPacket, OutUdpPacket, PacketType}; +use tsproto_packets::HexSlice; + +use crate::connection::{Connection, Event}; + +fn prepare_span(is_client: bool, incoming: bool) -> Span { + let dir = if incoming { + if !cfg!(windows) { "\x1b[1;32mIN\x1b[0m" } else { "IN" } + } else if !cfg!(windows) { + "\x1b[1;31mOUT\x1b[0m" + } else { + "OUT" + }; + let to = if is_client { "S" } else { "C" }; + debug_span!("packet", to, %dir) +} + +pub fn log_udp_packet(is_client: bool, incoming: bool, packet: &InUdpPacket) { + let _span = prepare_span(is_client, incoming).entered(); + debug!(header = ?packet.0.header(), content = %HexSlice(packet.0.content()), "UdpPacket"); +} + +pub fn log_out_udp_packet(is_client: bool, incoming: bool, packet: &OutUdpPacket) { + let _span = prepare_span(is_client, incoming).entered(); + debug!( + generation = packet.generation_id(), + header = ?packet.data().header(), + content = %HexSlice(packet.data().content()), + "UdpPacket" + ); +} + +pub fn log_packet(is_client: bool, incoming: bool, packet: &P) { + // packet.header.c_id is not set for newly created packets so we cannot + // detect if a packet is incoming or not. + let _span = prepare_span(is_client, incoming).entered(); + debug!(content = ?packet, "Packet"); +} + +pub fn log_command(is_client: bool, incoming: bool, p_type: PacketType, cmd: &str) { + // packet.header.c_id is not set for newly created packets so we cannot + // detect if a packet is incoming or not. + let _span = prepare_span(is_client, incoming).entered(); + if p_type == PacketType::Command { + debug!(content = cmd, "Command"); + } else { + debug!(content = cmd, "CommandLow"); + } +} + +/// Print the content of all packets +/// +/// 0 - Print commands +/// 1 - Print packets +/// 2 - Print udp packets +pub fn add_logger_with_verbosity(verbosity: u8, con: &mut Connection) { + let log_commands = verbosity > 0; + let log_packets = verbosity > 1; + let log_udp_packets = verbosity > 2; + add_logger(log_commands, log_packets, log_udp_packets, con); +} + +pub fn add_logger( + log_commands: bool, log_packets: bool, log_udp_packets: bool, con: &mut Connection, +) { + if log_commands || log_packets || log_udp_packets { + let is_client = con.is_client; + let listener = Box::new(move |event: &Event| match event { + Event::ReceiveUdpPacket(packet) => { + if log_udp_packets { + log_udp_packet(is_client, true, packet); + } + } + Event::ReceivePacket(packet) => { + if log_packets { + log_packet(is_client, true, packet); + } else if log_commands { + let p_type = packet.header().packet_type(); + if p_type.is_command() { + if let Ok(s) = str::from_utf8(packet.content()) { + log_command(is_client, true, p_type, s); + } + } + } + } + Event::SendUdpPacket(packet) => { + if log_udp_packets { + log_out_udp_packet(is_client, false, packet); + } + } + Event::SendPacket(packet) => { + if log_packets { + log_packet(is_client, false, &packet.packet()); + } else if log_commands { + let p_type = packet.header().packet_type(); + if p_type.is_command() { + if let Ok(s) = str::from_utf8(packet.content()) { + log_command(is_client, false, p_type, s); + } + } + } + } + }); + + con.event_listeners.push(listener); + } +} diff --git a/crates/proto/tsproto/src/packet_codec.rs b/crates/proto/tsproto/src/packet_codec.rs new file mode 100644 index 0000000..f43a7a5 --- /dev/null +++ b/crates/proto/tsproto/src/packet_codec.rs @@ -0,0 +1,461 @@ +use std::io::Cursor; +use std::task::Context; + +use num_traits::ToPrimitive; +use omnom::WriteExt; +use tracing::warn; +use tsproto_packets::packets::*; + +use crate::algorithms as algs; +use crate::connection::{Connection, Event, StreamItem}; +use crate::resend::{PartialPacketId, Resender}; +use crate::{Error, Result, MAX_FRAGMENTS_LENGTH, MAX_QUEUE_LEN}; + +/// Encodes outgoing packets. +/// +/// This part does the compression, encryption and fragmentation. +#[derive(Clone, Debug, Default)] +pub struct PacketCodec { + /// The next packet id that should be sent. + /// + /// This list is indexed by the `PacketType`, `PacketType::Init` is an + /// invalid index. + pub outgoing_p_ids: [PartialPacketId; 8], + /// Used for incoming out-of-order packets. + /// + /// Only used for `Command` and `CommandLow` packets. + pub receive_queue: [Vec>; 2], + /// Used for incoming fragmented packets. + /// + /// Contains the accumulated data from fragmented packets, the header of the + /// first packet is at the beginning, all other headers are stripped away. + /// Only used for `Command` and `CommandLow` packets. + pub fragmented_queue: [Option>; 2], + /// The next packet id that is expected. + /// + /// Works like the `outgoing_p_ids`. + pub incoming_p_ids: [PartialPacketId; 8], +} + +impl PacketCodec { + /// Handle a packet for a specific connection. + /// + /// This part does the defragmentation, decryption and decompression. + pub fn handle_udp_packet( + con: &mut Connection, cx: &mut Context, mut packet_data: Vec, + ) -> Result<()> { + let mut ack = false; + + let dir = if con.is_client { Direction::S2C } else { Direction::C2S }; + let packet = InPacket::new(dir, &packet_data); + let p_type = packet.header().packet_type(); + let type_i = p_type.to_usize().unwrap(); + let id = packet.header().packet_id(); + let (in_recv_win, gen_id, cur_next, limit) = con.in_receive_window(p_type, id); + + con.resender.handle_loss_incoming(&packet, in_recv_win, cur_next); + + if let Some(params) = &con.params { + if p_type == PacketType::Init { + con.stream_items.push_back(StreamItem::Error(Error::UnexpectedInitPacket)); + return Ok(()); + } + if !con.is_client { + let c_id = packet.header().client_id().unwrap(); + // Accept any client id for the first few acks + let is_first_ack = gen_id == 0 && id <= 3 && p_type == PacketType::Ack; + if c_id != params.c_id && !is_first_ack { + con.stream_items.push_back(StreamItem::Error(Error::WrongClientId(c_id))); + return Ok(()); + } + } + } + + // Ignore range for acks and audio packets + if [PacketType::Ack, PacketType::AckLow, PacketType::Voice, PacketType::VoiceWhisper] + .contains(&p_type) + || in_recv_win + { + if !packet.header().flags().contains(Flags::UNENCRYPTED) { + if p_type == PacketType::Ack && id == 1 && con.is_client { + // This is the ack packet for the clientinit, we take the + // initserver as ack instead. + return Ok(()); + } + + // If it is the first ack packet of a client, try to fake + // decrypt it. + let new_content = if (p_type == PacketType::Ack && id <= 1 && con.is_client) + || con.params.is_none() + { + match algs::decrypt_fake(&packet).or_else(|_| { + if let Some(params) = &mut con.params { + // Decrypt the packet + algs::decrypt(&packet, gen_id, ¶ms.shared_iv, &mut params.key_cache) + } else { + // Failed to fake decrypt the packet + Err(Error::WrongMac { p_type, generation_id: gen_id, packet_id: id }) + } + }) { + Ok(r) => r, + Err(e) => { + con.stream_items.push_back(StreamItem::Error(e)); + return Ok(()); + } + } + } else if let Some(params) = &mut con.params { + // Decrypt the packet + match algs::decrypt(&packet, gen_id, ¶ms.shared_iv, &mut params.key_cache) { + Ok(r) => r, + Err(e) => { + con.stream_items.push_back(StreamItem::Error(e)); + return Ok(()); + } + } + } else { + // Failed to fake decrypt the packet + con.stream_items.push_back(StreamItem::Error(Error::WrongMac { + p_type, + generation_id: gen_id, + packet_id: id, + })); + return Ok(()); + }; + + let start = packet.header().data().len(); + packet_data[start..].copy_from_slice(&new_content); + } else if algs::must_encrypt(p_type) { + // Check if it is ok for the packet to be unencrypted + con.stream_items.push_back(StreamItem::Error(Error::UnallowedUnencryptedPacket)); + return Ok(()); + } + + let packet = InPacket::new(dir, &packet_data); + match p_type { + PacketType::Command | PacketType::CommandLow => { + ack = true; + + let commands = Self::handle_command_packet(con, packet_data)?; + + // Be careful with command packets, they are guaranteed to + // be in the right order now. + for c in commands { + // Send again + let packet = InPacket::new(dir, &c); + let event = Event::ReceivePacket(&packet); + con.send_event(&event); + + let item = match InCommandBuf::try_new(dir, c) { + Ok(c) => { + // initivexpand2 is the ack for the last init packet + if con.is_client + && c.data().packet().content().starts_with(b"initivexpand2 ") + { + Resender::ack_packet(con, cx, PacketType::Init, 4); + } else if con.is_client + && c.data().packet().content().starts_with(b"initserver ") + { + // initserver acks clientinit + Resender::ack_packet(con, cx, PacketType::Command, 2); + } else if !con.is_client + && c.data().packet().content().starts_with(b"clientek ") + { + // clientek acks initivexpand2 + Resender::ack_packet(con, cx, PacketType::Command, 0); + } + StreamItem::Command(c) + } + Err(e) => return Err(Error::PacketParse("command", e)), + }; + con.stream_items.push_back(item); + } + } + _ => { + if p_type == PacketType::Ping { + ack = true; + } + // Update packet ids + let in_ids = &mut con.codec.incoming_p_ids; + if p_type != PacketType::Init { + let (id, next_gen) = id.overflowing_add(1); + let generation_id = if next_gen { gen_id + 1 } else { gen_id }; + in_ids[type_i] = PartialPacketId { generation_id, packet_id: id }; + } + + match packet.ack_packet() { + Ok(Some(ack_id)) => { + // Remove command packet from send queue if the fitting ack is received. + let p_type = if p_type == PacketType::Ack { + PacketType::Command + } else if p_type == PacketType::AckLow { + PacketType::CommandLow + } else if p_type == PacketType::Pong { + PacketType::Ping + } else { + p_type + }; + Resender::ack_packet(con, cx, p_type, ack_id); + } + Ok(None) => {} + Err(e) => { + con.stream_items.push_back(StreamItem::Error(Error::CreateAck(e))); + return Ok(()); + } + } + + // Send event after handling acks + let event = Event::ReceivePacket(&packet); + con.send_event(&event); + + if p_type.is_voice() { + con.stream_items.push_back(match InAudioBuf::try_new(dir, packet_data) { + Ok(r) => StreamItem::Audio(r), + Err(e) => StreamItem::Error(Error::PacketParse("audio", e)), + }); + } else if p_type == PacketType::Init { + con.stream_items.push_back(if con.is_client { + match InS2CInitBuf::try_new(dir, packet_data) { + Ok(r) => StreamItem::S2CInit(r), + Err(e) => StreamItem::Error(Error::PacketParse("s2cinit", e)), + } + } else { + match InC2SInitBuf::try_new(dir, packet_data) { + Ok(r) => StreamItem::C2SInit(r), + Err(e) => StreamItem::Error(Error::PacketParse("c2sinit", e)), + } + }); + } + } + } + } else { + // Send an ack for the case when it was lost + if p_type == PacketType::Command || p_type == PacketType::CommandLow { + ack = true; + con.resender.handle_loss_resend_ack(); + } + con.stream_items.push_back(StreamItem::Error(Error::NotInReceiveWindow { + id, + next: cur_next, + limit, + p_type, + })); + } + + // Send ack + if ack { + con.send_ack_packet(cx, OutAck::new(dir.reverse(), p_type, id))?; + } + + Ok(()) + } + + /// Handle `Command` and `CommandLow` packets. + /// + /// They have to be handled in the right order. + fn handle_command_packet( + con: &mut Connection, mut packet_data: Vec, + ) -> Result>> { + let dir = if con.is_client { Direction::S2C } else { Direction::C2S }; + let mut packet = InPacket::new(dir, &packet_data); + let header = packet.header(); + let p_type = header.packet_type(); + let mut id = header.packet_id(); + let type_i = p_type.to_usize().unwrap(); + let cmd_i = if p_type == PacketType::Command { 0 } else { 1 }; + let r_queue = &mut con.codec.receive_queue[cmd_i]; + let frag_queue = &mut con.codec.fragmented_queue[cmd_i]; + let in_ids = &mut con.codec.incoming_p_ids[type_i]; + let cur_next = in_ids.packet_id; + if cur_next == id { + // In order + let mut packets = Vec::new(); + loop { + // Update next packet id + *in_ids = *in_ids + 1; + + let flags = packet.header().flags(); + let res_packet = if flags.contains(Flags::FRAGMENTED) { + if let Some(mut frag_queue) = frag_queue.take() { + // Last fragmented packet + frag_queue.extend_from_slice(packet.content()); + let header = InPacket::new(dir, &frag_queue); + // Decompress + if header.header().flags().contains(Flags::COMPRESSED) { + let decompressed = quicklz::decompress( + &mut Cursor::new(header.content()), + crate::MAX_DECOMPRESSED_SIZE, + ) + .map_err(Error::DecompressPacket)?; + let start = header.header().data().len(); + frag_queue.truncate(start); + frag_queue.extend_from_slice(&decompressed); + } + + Some(frag_queue) + } else { + // Enqueue + *frag_queue = Some(packet_data); + None + } + } else if let Some(frag_queue) = frag_queue { + // The packet is fragmented + if frag_queue.len() < MAX_FRAGMENTS_LENGTH { + frag_queue.extend_from_slice(packet.content()); + None + } else { + return Err(Error::MaxLengthExceeded("fragment queue")); + } + } else { + // Decompress + if flags.contains(Flags::COMPRESSED) { + let decompressed = quicklz::decompress( + &mut Cursor::new(packet.content()), + crate::MAX_DECOMPRESSED_SIZE, + ) + .map_err(Error::DecompressPacket)?; + let start = packet.header().data().len(); + packet_data.truncate(start); + packet_data.extend_from_slice(&decompressed); + }; + Some(packet_data) + }; + if let Some(p) = res_packet { + packets.push(p); + } + + // Check if there are following packets in the receive queue. + id = id.wrapping_add(1); + if let Some(pos) = + r_queue.iter().position(|p| InHeader::new(dir, p).packet_id() == id) + { + packet_data = r_queue.remove(pos); + packet = InPacket::new(dir, &packet_data); + } else { + break; + } + } + + Ok(packets) + } else { + // Out of order + warn!(got = id, expected = cur_next, "Out of order command packet"); + let (limit, next_gen) = cur_next.overflowing_add(MAX_QUEUE_LEN); + if (!next_gen && id >= cur_next && id < limit) + || (next_gen && (id >= cur_next || id < limit)) + { + r_queue.push(packet_data); + Ok(vec![]) + } else { + Err(Error::MaxLengthExceeded("command queue")) + } + } + } + + pub fn encode_packet(con: &mut Connection, mut packet: OutPacket) -> Result> { + let p_type = packet.header().packet_type(); + let type_i = p_type.to_usize().unwrap(); + + // TODO Needed, commands should set their own flag? + if (p_type == PacketType::Command || p_type == PacketType::CommandLow) && con.is_client { + // Set newprotocol flag + packet.flags(packet.header().flags() | Flags::NEWPROTOCOL); + } + + let p_id = if p_type == PacketType::Init { + PartialPacketId { generation_id: 0, packet_id: 0 } + } else { + con.codec.outgoing_p_ids[type_i] + }; + // We fake encrypt the first command packet of the server (id 0) and the + // first command packet of the client (id 1, clientek). + let mut fake_encrypt = p_type == PacketType::Command + && p_id.generation_id == 0 + && ((!con.is_client && p_id.packet_id == 0) + || (con.is_client && p_id.packet_id == 1 && { + // Test if it is a clientek packet + packet.content().starts_with(b"clientek") + })); + // Also fake encrypt the first ack of the client, which is the response + // for the initivexpand2 packet. + fake_encrypt |= con.is_client + && p_type == PacketType::Ack + && p_id.generation_id == 0 + && p_id.packet_id == 0; + + // Get values from parameters + let should_encrypt; + let c_id; + if let Some(params) = con.params.as_mut() { + should_encrypt = algs::should_encrypt(p_type, params.voice_encryption); + c_id = params.c_id; + } else { + should_encrypt = algs::should_encrypt(p_type, false); + if should_encrypt { + fake_encrypt = true; + } + c_id = 0; + } + + // Client id for clients + if con.is_client { + packet.client_id(c_id); + } + + if !should_encrypt && !fake_encrypt { + packet.flags(packet.header().flags() | Flags::UNENCRYPTED); + if let Some(params) = con.params.as_mut() { + packet.mac().copy_from_slice(¶ms.shared_mac); + } + } + + // Compress and split packet + let packets = if p_type == PacketType::Command || p_type == PacketType::CommandLow { + algs::compress_and_split(con.is_client, packet) + } else { + // Set the inner packet id for voice packets + if con.is_client && (p_type == PacketType::Voice || p_type == PacketType::VoiceWhisper) + { + (&mut packet.content_mut()[..2]) + .write_be(con.codec.outgoing_p_ids[type_i].packet_id) + .unwrap(); + } + + vec![packet] + }; + + let packets = packets + .into_iter() + .map(|mut packet| -> Result<_> { + // Get packet id + let p_id = if p_type == PacketType::Init { + PartialPacketId { generation_id: 0, packet_id: 0 } + } else { + packet.packet_id(con.codec.outgoing_p_ids[type_i].packet_id); + con.codec.outgoing_p_ids[type_i] + }; + + // Encrypt if necessary + if fake_encrypt { + algs::encrypt_fake(&mut packet)?; + } else if should_encrypt { + // The params are set + let params = con.params.as_mut().unwrap(); + algs::encrypt( + &mut packet, + p_id.generation_id, + ¶ms.shared_iv, + &mut params.key_cache, + )?; + } + + // Increment outgoing_p_ids + let p_id = p_id + 1; + if p_type != PacketType::Init { + con.codec.outgoing_p_ids[type_i] = p_id; + } + Ok(OutUdpPacket::new(p_id.generation_id, packet)) + }) + .collect::>>()?; + Ok(packets) + } +} diff --git a/crates/proto/tsproto/src/resend.rs b/crates/proto/tsproto/src/resend.rs new file mode 100644 index 0000000..ba86a33 --- /dev/null +++ b/crates/proto/tsproto/src/resend.rs @@ -0,0 +1,1067 @@ +use std::cmp::{min, Ord, Ordering}; +use std::collections::{BTreeMap, BinaryHeap}; +use std::convert::From; +use std::fmt; +use std::hash::{Hash, Hasher}; +use std::ops::{Add, Sub}; +use std::pin::Pin; +use std::task::{Context, Poll}; + +use futures::prelude::*; +use num_traits::ToPrimitive; +use pin_project_lite::pin_project; +use tokio::time::{Duration, Instant, Sleep}; +use tracing::{info, trace, warn}; +use tsproto_packets::packets::*; + +use crate::connection::{Connection, StreamItem}; +use crate::{Error, Result, UDP_SINK_CAPACITY}; + +// TODO implement fast retransmit: 2 Acks received but earlier packet not acked -> retransmit +// TODO implement slow start and redo slow start when send window reaches 1, also reset all tries then + +// Use cubic for congestion control: https://en.wikipedia.org/wiki/CUBIC_TCP +// But scaling with number of sent packets instead of time because we might not +// send packets that often. + +/// Congestion windows gets down to 0.3*w_max for BETA=0.7 +const BETA: f32 = 0.7; +/// Increase over w_max after roughly 5 packets (C=0.2 needs seven packets). +const C: f32 = 0.5; +/// Store that many pings, if all of them get lost, it is a timeout. +const PING_COUNT: usize = 30; +/// Duration in seconds between sending two ping packets. +const PING_SECONDS: u64 = 1; +/// Duration in seconds between resetting the statistic counters. +const STAT_SECONDS: u64 = 1; +/// Size of an UDP header in bytes. +const UDP_HEADER_SIZE: u32 = 8; +/// Size of an IPv4 header in bytes. +const IPV4_HEADER_SIZE: u32 = 20; +// TODO Use correct IPv6 header size to compute bandwidth +// Size of an IPv6 header in bytes. +//const IPV6_HEADER_SIZE: u32 = 40; + +/// Events to inform a resender of the current state of a connection. +#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)] +pub enum ResenderState { + /// The connection is starting, reduce the timeout time. + Connecting, + /// The handshake is completed, this is the normal operation mode. + Connected, + /// The connection is tearing down, reduce the timeout time. + Disconnecting, + /// The connection is gone, we only send ack packets. + Disconnected, +} + +#[derive(Clone, Copy, Default, Eq, Hash, PartialEq)] +pub struct PartialPacketId { + pub generation_id: u32, + pub packet_id: u16, +} + +#[derive(Clone, Copy, Eq, Hash, PartialEq)] +pub struct PacketId { + pub packet_type: PacketType, + pub part: PartialPacketId, +} + +#[derive(Clone, Debug)] +pub struct SendRecordId { + /// The last time when the packet was sent. + pub last: Instant, + /// How often the packet was already resent. + pub tries: usize, + id: PacketId, +} + +/// A record of a packet that can be resent. +#[derive(Debug)] +struct SendRecord { + /// When this packet was originally sent. + pub sent: Instant, + pub id: SendRecordId, + pub packet: OutUdpPacket, +} + +#[derive(Debug)] +struct Ping { + id: PartialPacketId, + /// When the ping packet was sent. + sent: Instant, +} + +/// Enum for different collected packet statistics. +#[derive(Clone, Copy, Debug)] +pub enum PacketStat { + /// Commands and acks + InControl, + /// Ping and Pong + InKeepalive, + /// Voice + InSpeech, + /// Commands and acks + OutControl, + /// Ping and Pong + OutKeepalive, + /// Voice + OutSpeech, +} + +/// Metrics collected to compute packet loss. +/// +/// The count of incoming packets includes packets that were lost. It is computed by the difference +/// of packet ids. +/// +/// Packet losses that are impossible to track: Outgoing voice, incoming commands, outgoing pongs. +#[derive(Clone, Copy, Debug)] +enum PacketLossStat { + /// Count of incoming voice packets. + VoiceInCount, + /// Count of packet ids that we should have received but did not get. + VoiceInLost, + /// Count of outgoing acks. + AckOutCount, + /// Count of already acked commands that were received. + AckOutLost, + /// Count of incoming ack packets. + AckInCount, + /// Count of packet ids that we should have received but did not get. + AckInLost, + /// Count of command packets that were resent. + /// + /// If a command packet needs to be resent, either the command or the ack was lost. + AckInOrCommandOutLost, + /// Count of outgoing command packets. + CommandOutCount, + /// Count of incoming pong packets. + PongInCount, + /// Count of packet ids that we should have received but did not get. + PongInLost, + // Count of ping packets for which we did not get an answer. + // + // If no pong is received for a ping, either the ping or the pong was lost. + // We do not handle many pings, so just use PingOutCount - PongInCount. + //PongInOrPingOutLost, + /// Count of outgoing pings. + PingOutCount, + /// Count of incoming pings. + PingInCount, + /// Count of packet ids that we should have received but did not get. + PingInLost, +} + +/// Network statistics of a connection. +#[derive(Clone)] +pub struct ConnectionStats { + /// Non-smoothed Round Trip Time. + pub rtt: Duration, + /// Deviation of the rtt. + pub rtt_dev: Duration, + /// Total count of packets since start of the connection. Indexed by `PacketStat`. + pub total_packets: [u64; 6], + /// Total count of bytes since start of the connection. Indexed by `PacketStat`. + pub total_bytes: [u64; 6], + /// Stats collected to compute packet loss. Indexed by `PacketLossStat`. + packet_loss: [u32; 13], + /// Bytes in the last second. Indexed by `PacketStat`. + /// + /// For the last 60 seconds, so the per minute stats can be computed. + pub last_second_bytes: [[u32; 6]; 60], + /// The index in `last_second_bytes` that will be written next. + next_second_index: u8, +} + +/// An intermediate struct to collect network statistics. +/// +/// Collected for one second and reset after moving them to `ConnectionStats`. +#[derive(Clone, Debug, Default)] +struct ConnectionStatsCounter { + bytes: [u32; 6], + /// Stats collected to compute packet loss. Indexed by `PacketLossStat`. + packet_loss: [u32; 13], +} + +pin_project! { + /// Timers are extra because they need to be pinned. + #[derive(Debug)] + struct Timers { + // The future to wake us up when the next packet should be resent. + #[pin] + timeout: Sleep, + // The timer used for sending ping packets. + #[pin] + ping_timeout: Sleep, + // The timer used for disconnecting the connection. + #[pin] + state_timeout: Sleep, + // The timer used to update network statistics. + #[pin] + stats_timeout: Sleep, + } +} + +/// Resend command and init packets until the other side acknowledges them. +#[derive(Debug)] +pub struct Resender { + /// Send queue ordered by when a packet has to be sent. + /// + /// The maximum in this queue is the next packet that should be resent. + /// This is a part of `full_send_queue`. + send_queue: BinaryHeap, + /// Send queue ordered by packet id. + /// + /// There is one queue per packet type: `Init`, `Command` and `CommandLow`. + full_send_queue: [BTreeMap; 3], + /// All packets with an id less than this index id are currently in the + /// `send_queue`. Packets with an id greater or equal to this index are not + /// in the send queue. + send_queue_indices: [PartialPacketId; 3], + config: ResendConfig, + state: ResenderState, + /// A list of the last sent pings that were not yet acknowledged. + last_pings: Vec, + /// In progress counters. + stats_counter: ConnectionStatsCounter, + /// Current up to date statistics. + pub stats: ConnectionStats, + + // Congestion control + /// The maximum send window before the last reduction. + w_max: u16, + /// The time when the last packet loss occurred. + /// + /// This is not necessarily the accurate time, but the duration until + /// now/no_congestion_since is accurate. + last_loss: Instant, + /// The send queue was never full since this time. We use this to not + /// increase the send window in this case. + no_congestion_since: Option, + + /// When the last packet was added to the send queue or received. + /// + /// This is used to decide when to send ping packets. + last_receive: Instant, + /// When the last packet was added to the send queue. + /// + /// This is used to handle timeouts when disconnecting. + last_send: Instant, + /// When the statistics were last reset. + last_stat: Instant, + + timers: Pin>, +} + +#[derive(Clone, Debug)] +pub struct ResendConfig { + // Close the connection after no packet is received for this duration. + pub connecting_timeout: Duration, + pub normal_timeout: Duration, + pub disconnect_timeout: Duration, + + /// Smoothed Round Trip Time. + pub srtt: Duration, + /// Deviation of the srtt. + pub srtt_dev: Duration, +} + +impl Ord for PartialPacketId { + fn cmp(&self, other: &Self) -> Ordering { + self.generation_id + .cmp(&other.generation_id) + .then_with(|| self.packet_id.cmp(&other.packet_id)) + } +} + +impl PartialOrd for PartialPacketId { + fn partial_cmp(&self, other: &Self) -> Option { Some(self.cmp(other)) } +} + +impl Add for PartialPacketId { + type Output = Self; + fn add(self, rhs: u16) -> Self::Output { + let (packet_id, next_gen) = self.packet_id.overflowing_add(rhs); + Self { + generation_id: if next_gen { + self.generation_id.wrapping_add(1) + } else { + self.generation_id + }, + packet_id, + } + } +} + +impl Sub for PartialPacketId { + type Output = Self; + fn sub(self, rhs: u16) -> Self::Output { + let (packet_id, last_gen) = self.packet_id.overflowing_sub(rhs); + Self { + generation_id: if last_gen { + self.generation_id.wrapping_sub(1) + } else { + self.generation_id + }, + packet_id, + } + } +} + +impl Sub for PartialPacketId { + type Output = i64; + fn sub(self, rhs: Self) -> Self::Output { + let gen_diff = i64::from(self.generation_id) - i64::from(rhs.generation_id); + let id_diff = i64::from(self.packet_id) - i64::from(rhs.packet_id); + + gen_diff * i64::from(u16::MAX) + id_diff + } +} + +impl PartialOrd for PacketId { + fn partial_cmp(&self, other: &Self) -> Option { + if self.packet_type == other.packet_type { Some(self.part.cmp(&other.part)) } else { None } + } +} + +impl From<&OutUdpPacket> for PacketId { + fn from(packet: &OutUdpPacket) -> Self { + Self { + packet_type: packet.packet_type(), + part: PartialPacketId { + generation_id: packet.generation_id(), + packet_id: packet.packet_id(), + }, + } + } +} + +impl fmt::Debug for PacketId { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{:?}{:?}", self.packet_type, self.part)?; + Ok(()) + } +} + +impl fmt::Debug for PartialPacketId { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "({:x}:{:x})", self.generation_id, self.packet_id)?; + Ok(()) + } +} + +impl Ord for SendRecordId { + fn cmp(&self, other: &Self) -> Ordering { + // If the packet was not already sent, it is more important + if self.tries == 0 { + if other.tries != 0 { + return Ordering::Greater; + } + } else if other.tries == 0 { + return Ordering::Less; + } + // The smallest time is the most important time + self.last.cmp(&other.last).reverse().then_with(|| + // Else, the lower packet id is more important + self.id.part.cmp(&other.id.part).reverse()) + } +} + +impl PartialOrd for SendRecordId { + fn partial_cmp(&self, other: &Self) -> Option { Some(self.cmp(other)) } +} + +impl PartialEq for SendRecordId { + fn eq(&self, other: &Self) -> bool { self.id.eq(&other.id) } +} +impl Eq for SendRecordId {} + +impl Hash for SendRecordId { + fn hash(&self, state: &mut H) { self.id.hash(state); } +} + +impl Default for Resender { + fn default() -> Self { + let now = Instant::now(); + Self { + send_queue: Default::default(), + full_send_queue: Default::default(), + send_queue_indices: Default::default(), + config: Default::default(), + state: ResenderState::Connecting, + last_pings: Default::default(), + stats: Default::default(), + stats_counter: Default::default(), + + w_max: UDP_SINK_CAPACITY as u16, + last_loss: now, + no_congestion_since: Some(now), + + last_receive: now, + last_send: now, + last_stat: now, + + timers: Box::pin(Timers { + timeout: tokio::time::sleep(std::time::Duration::from_secs(1)), + ping_timeout: tokio::time::sleep(std::time::Duration::from_secs(PING_SECONDS)), + state_timeout: tokio::time::sleep(std::time::Duration::from_secs(1)), + stats_timeout: tokio::time::sleep(std::time::Duration::from_secs(STAT_SECONDS)), + }), + } + } +} + +impl Resender { + fn packet_type_to_index(t: PacketType) -> usize { + match t { + PacketType::Init => 0, + PacketType::Command => 1, + PacketType::CommandLow => 2, + _ => panic!("Resender cannot handle packet type {:?}", t), + } + } + + pub fn ack_packet(con: &mut Connection, cx: &mut Context, p_type: PacketType, p_id: u16) { + if p_type == PacketType::Ping { + Self::ack_ping(con, p_id); + return; + } + + // Remove from ordered queue + let queue = &mut con.resender.full_send_queue[Self::packet_type_to_index(p_type)]; + let mut queue_iter = queue.iter(); + if let Some((first, _)) = queue_iter.next() { + let id = if first.packet_id == p_id { + let p_id = if let Some((_, rec2)) = queue_iter.next() { + // Ack all until the next packet + rec2.id.id.part + } else if p_type == PacketType::Init { + // Ack the current packet + PartialPacketId { generation_id: 0, packet_id: p_id + 1 } + } else { + // Ack all until the next packet to send + con.codec.outgoing_p_ids[p_type.to_usize().unwrap()] + }; + + let id = PacketId { packet_type: p_type, part: p_id - 1 }; + con.stream_items.push_back(StreamItem::AckPacket(id)); + + *first + } else { + PartialPacketId { + generation_id: if p_id < first.packet_id { + first.generation_id.wrapping_add(1) + } else { + first.generation_id + }, + packet_id: p_id, + } + }; + + if let Some(rec) = queue.remove(&id) { + // Update srtt if the packet was not resent + if rec.id.tries == 1 { + let now = Instant::now(); + con.resender.update_srtt(now - rec.sent); + } + + // Notify the waker that we can send another packet from the + // send queue. + cx.waker().wake_by_ref(); + } + } + } + + pub fn ack_ping(con: &mut Connection, p_id: u16) { + if let Ok(i) = con.resender.last_pings.binary_search_by_key(&p_id, |p| p.id.packet_id) { + let ping = con.resender.last_pings.remove(i); + let now = Instant::now(); + con.resender.update_srtt(now - ping.sent); + } + } + + pub fn received_packet(&mut self) { self.last_receive = Instant::now(); } + + pub fn handle_loss_incoming(&mut self, packet: &InPacket, in_recv_win: bool, cur_next: u16) { + let p_type = packet.header().packet_type(); + let id = packet.header().packet_id(); + let id_diff = u32::from(id.wrapping_sub(cur_next)); + let p_stat = PacketStat::from(p_type, true); + let len = (packet.header().data().len() + packet.content().len()) as u32 + + UDP_HEADER_SIZE + + IPV4_HEADER_SIZE; + + self.stats_counter.bytes[p_stat as usize] += len; + self.stats.total_packets[p_stat as usize] += 1; + self.stats.total_bytes[p_stat as usize] += u64::from(len); + + let stats; + if p_type.is_voice() { + stats = Some((PacketLossStat::VoiceInCount, PacketLossStat::VoiceInLost)); + } else if p_type.is_ack() { + stats = Some((PacketLossStat::AckInCount, PacketLossStat::AckInLost)); + } else if p_type == PacketType::Pong { + stats = Some((PacketLossStat::PongInCount, PacketLossStat::PongInLost)); + } else if p_type == PacketType::Ping { + stats = Some((PacketLossStat::PingInCount, PacketLossStat::PingInLost)); + } else { + stats = None; + } + + if let Some((count, lost)) = stats { + if in_recv_win { + self.stats_counter.packet_loss[count as usize] += id_diff + 1; + self.stats_counter.packet_loss[lost as usize] += id_diff; + } else { + self.stats_counter.packet_loss[lost as usize] = + self.stats_counter.packet_loss[lost as usize].saturating_sub(1); + } + } + } + + pub fn handle_loss_outgoing(&mut self, packet: &OutUdpPacket) { + let p_type = packet.data().header().packet_type(); + let p_stat = PacketStat::from(p_type, false); + // 8 byte UDP header + let len = packet.data().data().len() as u32 + UDP_HEADER_SIZE + IPV4_HEADER_SIZE; + self.stats_counter.handle_loss_outgoing(packet, p_stat, len); + self.stats.handle_loss_outgoing(p_stat, u64::from(len)); + } + + pub fn handle_loss_resend_ack(&mut self) { + self.stats_counter.packet_loss[PacketLossStat::AckOutLost as usize] += 1; + } + + fn get_timeout(&self) -> Duration { + match self.state { + ResenderState::Connecting => self.config.connecting_timeout, + ResenderState::Disconnecting | ResenderState::Disconnected => { + self.config.disconnect_timeout + } + ResenderState::Connected => self.config.normal_timeout, + } + } + + /// Inform the resender of state changes of the connection. + pub fn set_state(&mut self, state: ResenderState) { + info!(from = ?self.state, to = ?state, "Resender: Changed state"); + self.state = state; + + self.last_send = Instant::now(); + let new_timeout = self.last_send + self.get_timeout(); + let timers = self.timers.as_mut().project(); + timers.state_timeout.reset(new_timeout); + } + + pub fn get_state(&self) -> ResenderState { self.state } + + /// If the send queue is full if it reached the congestion window size or + /// it contains packets that were not yet sent once. + pub fn is_full(&self) -> bool { self.full_send_queue.len() >= self.get_window() as usize } + + /// If the send queue is empty. + pub fn is_empty(&self) -> bool { self.full_send_queue.iter().all(|q| q.is_empty()) } + + /// Take the first packets from `to_send_ordered` and put them into + /// `to_send`. + /// + /// This is done on packet loss, when the send queue is rebuilt. + fn rebuild_send_queue(&mut self) { + self.send_queue.clear(); + self.send_queue_indices = Default::default(); + self.fill_up_send_queue(); + } + + /// Fill up to the send window size. + fn fill_up_send_queue(&mut self) { + let get_skip_closure = |i: usize| { + let start = self.send_queue_indices[i]; + move |r: &&SendRecord| r.id.id.part < start + }; + let mut iters = [ + self.full_send_queue[0].values().skip_while(get_skip_closure(0)).peekable(), + self.full_send_queue[1].values().skip_while(get_skip_closure(1)).peekable(), + self.full_send_queue[2].values().skip_while(get_skip_closure(2)).peekable(), + ]; + + for _ in self.send_queue.len()..(self.get_window() as usize) { + let mut max_i = None; + let mut min_time = None; + + for (i, iter) in iters.iter_mut().enumerate() { + if let Some(rec) = iter.peek() { + if min_time.map(|t| t < rec.sent).unwrap_or(true) { + max_i = Some(i); + min_time = Some(rec.sent); + } + } + } + + if let Some(max_i) = max_i { + let max = iters[max_i].next().unwrap().id.clone(); + self.send_queue_indices[max_i] = max.id.part + 1; + self.send_queue.push(max); + } else { + if self.no_congestion_since.is_none() { + self.no_congestion_since = Some(Instant::now()); + } + return; + } + } + + if let Some(until) = self.no_congestion_since.take() { + self.last_loss = Instant::now() - (until - self.last_loss); + } + } + + /// The amount of packets that can be in-flight concurrently. + /// + /// The CUBIC congestion control window. + fn get_window(&self) -> u16 { + let time = self.no_congestion_since.unwrap_or_else(Instant::now) - self.last_loss; + let res = C + * (time.as_secs_f32() - (self.w_max as f32 * BETA / C).powf(1.0 / 3.0)).powf(3.0) + + self.w_max as f32; + let max = u16::MAX / 2; + if res > max as f32 { + max + } else if res < 1.0 { + 1 + } else { + res as u16 + } + } + + /// Add another duration to the stored smoothed rtt. + fn update_srtt(&mut self, rtt: Duration) { + let diff = + if rtt > self.config.srtt { rtt - self.config.srtt } else { self.config.srtt - rtt }; + self.config.srtt_dev = self.config.srtt_dev * 3 / 4 + diff / 4; + self.config.srtt = self.config.srtt * 7 / 8 + rtt / 8; + + // Rtt (non-smoothed) + let diff = if rtt > self.stats.rtt { rtt - self.stats.rtt } else { self.stats.rtt - rtt }; + self.stats.rtt_dev = self.stats.rtt_dev * 3 / 4 + diff / 4; + self.stats.rtt = self.stats.rtt / 2 + rtt / 2; + } + + pub fn send_packet(con: &mut Connection, packet: OutUdpPacket) { + con.resender.last_send = Instant::now(); + let rec = SendRecord { + sent: Instant::now(), + id: SendRecordId { last: Instant::now(), tries: 0, id: (&packet).into() }, + packet, + }; + + trace!(record = ?rec, window = con.resender.get_window(), "Adding send record"); + let i = Self::packet_type_to_index(rec.id.id.packet_type); + // Reduce index if necessary (needed e.g. for resending lower init packets) + if con.resender.send_queue_indices[i] > rec.id.id.part { + con.resender.send_queue_indices[i] = rec.id.id.part; + } + + con.resender.full_send_queue[i].insert(rec.id.id.part, rec); + con.resender.fill_up_send_queue(); + trace!(state = ?con.resender.send_queue, indices = ?con.resender.send_queue_indices, "After adding send record"); + } + + /// Returns an error if the timeout is exceeded and the connection is + /// considered dead or another unrecoverable error occurs. + pub fn poll_resend(con: &mut Connection, cx: &mut Context) -> Result<()> { + trace!(state = ?con.resender.send_queue, "Poll resend"); + let timeout = con.resender.get_timeout(); + // Send a packet at least every second + let max_send_rto = Duration::from_secs(1); + + // Check if there are packets to send. + loop { + let now = Instant::now(); + let window = con.resender.get_window(); + + // Retransmission timeout + let mut rto: Duration = con.resender.config.srtt + con.resender.config.srtt_dev * 4; + if rto > max_send_rto { + rto = max_send_rto; + } + let last_threshold = now - rto; + + let mut rec = if let Some(rec) = con.resender.send_queue.peek_mut() { + rec + } else { + break; + }; + trace!("Polling send record"); + + // Skip if not contained in full_send_queue. This happens when the + // packet was acknowledged. + let full_queue = + &mut con.resender.full_send_queue[Self::packet_type_to_index(rec.id.packet_type)]; + let full_rec = if let Some(r) = full_queue.get_mut(&rec.id.part) { + r + } else { + drop(rec); + con.resender.send_queue.pop(); + con.resender.fill_up_send_queue(); + continue; + }; + + // Check if we should resend this packet or not + if rec.tries != 0 && rec.last > last_threshold { + // Schedule next send + let dur = rec.last - last_threshold; + let timers = con.resender.timers.as_mut().project(); + timers.timeout.reset(now + dur); + let timers = con.resender.timers.as_mut().project(); + if let Poll::Ready(()) = timers.timeout.poll(cx) { + continue; + } + break; + } + + if now - full_rec.sent > timeout { + return Err(Error::Timeout("Packet was not acked")); + } + + // Try to send this packet + trace!("Try sending packet"); + match Connection::static_poll_send_udp_packet( + &*con.udp_socket, + con.address, + &con.event_listeners, + cx, + &full_rec.packet, + ) { + Poll::Pending => break, + Poll::Ready(r) => { + r?; + if rec.tries != 0 { + let to_s = if con.is_client { "S" } else { "C" }; + warn!(id = ?rec.id, + tries = rec.tries, + last = %format!("{:?} ago", now - rec.last), + to = to_s, + srtt = ?con.resender.config.srtt, + srtt_dev = ?con.resender.config.srtt_dev, + ?rto, + send_window = window, + "Resend" + ); + con.resender.stats_counter.handle_loss_resend_command(); + } + + // Successfully started sending the packet, update record + rec.last = now; + rec.tries += 1; + full_rec.id = rec.clone(); + + let p_type = full_rec.packet.data().header().packet_type(); + let p_stat = PacketStat::from(p_type, false); + let len = full_rec.packet.data().data().len() as u32 + + UDP_HEADER_SIZE + IPV4_HEADER_SIZE; + con.resender.stats_counter.handle_loss_outgoing(&full_rec.packet, p_stat, len); + con.resender.stats.handle_loss_outgoing(p_stat, u64::from(len)); + + if rec.tries != 1 { + drop(rec); + // Double srtt on packet loss + con.resender.config.srtt *= 2; + if con.resender.config.srtt > timeout { + con.resender.config.srtt = timeout; + } + + // Handle congestion window + con.resender.w_max = con.resender.get_window(); + con.resender.last_loss = Instant::now(); + con.resender.no_congestion_since = None; + con.resender.rebuild_send_queue(); + } else { + drop(rec); + } + } + } + } + + Ok(()) + } + + /// Returns an error if the timeout is exceeded and the connection is + /// considered dead or another unrecoverable error occurs. + pub fn poll_ping(con: &mut Connection, cx: &mut Context) -> Result<()> { + let now = Instant::now(); + let timeout = con.resender.get_timeout(); + + if con.resender.state == ResenderState::Disconnecting { + if now - con.resender.last_send >= timeout { + return Err(Error::Timeout("No disconnect ack received")); + } + + let timers = con.resender.timers.as_mut().project(); + timers.state_timeout.reset(con.resender.last_send + timeout); + let timers = con.resender.timers.as_mut().project(); + if let Poll::Ready(()) = timers.state_timeout.poll(cx) { + return Err(Error::Timeout("No disconnect ack received")); + } + } + + // Update stats + loop { + let next_reset = con.resender.last_stat + Duration::from_secs(STAT_SECONDS); + let timers = con.resender.timers.as_mut().project(); + timers.stats_timeout.reset(next_reset); + + let timers = con.resender.timers.as_mut().project(); + if let Poll::Ready(()) = timers.stats_timeout.poll(cx) { + // Reset stats + con.resender.last_stat = Instant::now(); + let stats = &mut con.resender.stats; + let counter = &mut con.resender.stats_counter; + let second_index = stats.next_second_index; + stats.last_second_bytes[second_index as usize] = counter.bytes; + stats.next_second_index = (second_index + 1) % stats.last_second_bytes.len() as u8; + stats.packet_loss = counter.packet_loss; + counter.reset(); + + con.stream_items.push_back(StreamItem::NetworkStatsUpdated); + } else { + break; + } + } + + if con.resender.get_state() == ResenderState::Connected + && !con.resender.full_send_queue.iter().any(|q| !q.is_empty()) + { + // Send pings if we are connected and there are no packets in the queue + loop { + let now = Instant::now(); + let mut next_ping = con.resender.last_receive + Duration::from_secs(PING_SECONDS); + if let Some(p) = con.resender.last_pings.last() { + if p.sent > con.resender.last_receive { + next_ping = p.sent + Duration::from_secs(PING_SECONDS); + } else { + // We received a packet, clear the ping queue + con.resender.last_pings.clear(); + } + } + let timers = con.resender.timers.as_mut().project(); + timers.ping_timeout.reset(next_ping); + + let timers = con.resender.timers.as_mut().project(); + if let Poll::Ready(()) = timers.ping_timeout.poll(cx) { + // Check for timeouts + if con.resender.last_pings.len() >= PING_COUNT { + let diff = con.resender.last_pings.last().unwrap().id + - con.resender.last_pings.first().unwrap().id; + // We did not receive a pong in between the last pings + if diff as usize == con.resender.last_pings.len() - 1 { + return Err(Error::Timeout("Server did not respond to pings")); + } + } + + // Send ping + let dir = if con.is_client { Direction::C2S } else { Direction::S2C }; + let packet = OutPacket::new_with_dir(dir, Flags::empty(), PacketType::Ping); + let p_id = con.send_packet(packet)?; + con.resender.last_pings.push(Ping { id: p_id.part, sent: now }); + if con.resender.last_pings.len() > PING_COUNT { + con.resender.last_pings.remove(0); + } + } else { + break; + } + } + } + + Ok(()) + } +} + +impl ConnectionStatsCounter { + fn handle_loss_outgoing(&mut self, packet: &OutUdpPacket, p_stat: PacketStat, len: u32) { + let p_type = packet.data().header().packet_type(); + + self.bytes[p_stat as usize] += len; + + if p_type.is_ack() { + self.packet_loss[PacketLossStat::AckOutCount as usize] += 1; + } else if p_type == PacketType::Ping { + self.packet_loss[PacketLossStat::PingOutCount as usize] += 1; + } else if p_type.is_command() { + self.packet_loss[PacketLossStat::CommandOutCount as usize] += 1; + } + } + + pub(crate) fn handle_loss_resend_command(&mut self) { + self.packet_loss[PacketLossStat::AckInOrCommandOutLost as usize] += 1; + } + + fn reset(&mut self) { *self = Default::default(); } +} + +impl ConnectionStats { + fn handle_loss_outgoing(&mut self, p_stat: PacketStat, len: u64) { + self.total_packets[p_stat as usize] += 1; + self.total_bytes[p_stat as usize] += len; + } + + pub fn get_last_second_bytes(&self) -> &[u32; 6] { + &self.last_second_bytes[((self.next_second_index + 60 - 1) % 60) as usize] + } + + pub fn get_last_minute_bytes(&self) -> [u64; 6] { + let mut bytes = [0; 6]; + for bs in &self.last_second_bytes[..] { + for (i, b) in bs.iter().enumerate() { + bytes[i] += u64::from(*b); + } + } + bytes + } + + // Packetloss stats for TeamSpeak + pub fn get_packetloss_s2c_speech(&self) -> f32 { + let count = self.packet_loss[PacketLossStat::VoiceInCount as usize]; + if count == 0 { + 0.0 + } else { + self.packet_loss[PacketLossStat::VoiceInLost as usize] as f32 / count as f32 + } + } + + pub fn get_packetloss_s2c_keepalive(&self) -> f32 { + let count = self.packet_loss[PacketLossStat::PingInCount as usize] + + self.packet_loss[PacketLossStat::PongInCount as usize]; + if count == 0 { + 0.0 + } else { + (self.packet_loss[PacketLossStat::PingInLost as usize] as f32 + + self.packet_loss[PacketLossStat::PongInLost as usize] as f32) + / count as f32 + } + } + + pub fn get_packetloss_s2c_control(&self) -> f32 { + let count = self.packet_loss[PacketLossStat::AckInCount as usize]; + if count == 0 { + 0.0 + } else { + self.packet_loss[PacketLossStat::AckInLost as usize] as f32 / count as f32 + } + } + + pub fn get_packetloss_s2c_total(&self) -> f32 { + let count = self.packet_loss[PacketLossStat::VoiceInCount as usize] + + self.packet_loss[PacketLossStat::PingInCount as usize] + + self.packet_loss[PacketLossStat::PongInCount as usize] + + self.packet_loss[PacketLossStat::AckInCount as usize]; + if count == 0 { + 0.0 + } else { + (self.packet_loss[PacketLossStat::VoiceInLost as usize] as f32 + + self.packet_loss[PacketLossStat::PingInLost as usize] as f32 + + self.packet_loss[PacketLossStat::PongInLost as usize] as f32 + + self.packet_loss[PacketLossStat::AckInLost as usize] as f32) + / count as f32 + } + } + + /// Compute the average incoming and outgoing packet loss. + pub fn get_packetloss(&self) -> f32 { + let count = self.packet_loss[PacketLossStat::VoiceInCount as usize] + + self.packet_loss[PacketLossStat::PingInCount as usize] + + self.packet_loss[PacketLossStat::PongInCount as usize] + + self.packet_loss[PacketLossStat::AckInCount as usize] + + self.packet_loss[PacketLossStat::AckOutCount as usize] + + self.packet_loss[PacketLossStat::CommandOutCount as usize]; + // Do not use ping count, it is unreliable + if count == 0 { + 0.0 + } else { + let command_out_lost = min( + self.packet_loss[PacketLossStat::AckInOrCommandOutLost as usize] + .saturating_sub(self.packet_loss[PacketLossStat::AckInLost as usize]), + self.packet_loss[PacketLossStat::CommandOutCount as usize], + ); + + (self.packet_loss[PacketLossStat::VoiceInLost as usize] as f32 + + self.packet_loss[PacketLossStat::PingInLost as usize] as f32 + + self.packet_loss[PacketLossStat::PongInLost as usize] as f32 + + self.packet_loss[PacketLossStat::AckInLost as usize] as f32 + + self.packet_loss[PacketLossStat::AckOutLost as usize] as f32 + + command_out_lost as f32) + / count as f32 + } + } +} + +impl Default for ResendConfig { + fn default() -> Self { + Self { + connecting_timeout: Duration::from_secs(5), + normal_timeout: Duration::from_secs(30), + disconnect_timeout: Duration::from_secs(5), + + srtt: Duration::from_millis(500), + srtt_dev: Duration::from_millis(0), + } + } +} + +impl Default for ConnectionStats { + fn default() -> Self { + Self { + rtt: Duration::from_millis(0), + rtt_dev: Duration::from_millis(0), + total_packets: Default::default(), + total_bytes: Default::default(), + packet_loss: Default::default(), + last_second_bytes: [Default::default(); 60], + next_second_index: Default::default(), + } + } +} + +impl fmt::Debug for ConnectionStats { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("ConnectionStats") + .field("rtt", &self.rtt) + .field("rtt_dev", &self.rtt_dev) + .field("total_packets", &self.total_packets) + .field("total_bytes", &self.total_bytes) + .field("packet_loss", &self.packet_loss) + .field("last_second_bytes", self.get_last_second_bytes()) + .field("next_second_index", &self.next_second_index) + .finish() + } +} + +impl PacketStat { + fn from(t: PacketType, incoming: bool) -> Self { + match t { + PacketType::Voice | PacketType::VoiceWhisper => { + if incoming { + PacketStat::InSpeech + } else { + PacketStat::OutSpeech + } + } + PacketType::Command + | PacketType::CommandLow + | PacketType::Ack + | PacketType::AckLow + | PacketType::Init => { + if incoming { + PacketStat::InControl + } else { + PacketStat::OutControl + } + } + PacketType::Ping | PacketType::Pong => { + if incoming { + PacketStat::InKeepalive + } else { + PacketStat::OutKeepalive + } + } + } + } +} diff --git a/crates/proto/tsproto/src/utils.rs b/crates/proto/tsproto/src/utils.rs new file mode 100644 index 0000000..b7c86d7 --- /dev/null +++ b/crates/proto/tsproto/src/utils.rs @@ -0,0 +1,47 @@ +use std::net::IpAddr; + +use crate::{Error, Result}; + +/// Try to approximate the not stabilized ip.is_global(). +pub fn is_global_ip(ip: &IpAddr) -> bool { + if !ip.is_unspecified() && !ip.is_loopback() && !ip.is_multicast() { + match *ip { + IpAddr::V4(ref ip) => !ip.is_broadcast() && !ip.is_link_local() && !ip.is_private(), + IpAddr::V6(_) => true, + } + } else { + false + } +} + +pub fn read_hex(s: &str) -> Result> { + // Detect hex format + if s.chars().nth(2) == Some(':') { + // Wireshark + Ok(s.split(':') + .map(|s| u8::from_str_radix(s, 16)) + .collect::<::std::result::Result, _>>() + .map_err(Error::InvalidHex)?) + } else if s.chars().nth(2) == Some(' ') { + // Wireshark + Ok(s.split(' ') + .map(|s| u8::from_str_radix(s, 16)) + .collect::<::std::result::Result, _>>() + .map_err(Error::InvalidHex)?) + } else if s.starts_with("0x") { + let s: String = s.chars().filter(|c| !c.is_whitespace()).collect(); + // Own dumps + Ok(s[2..] + .split(',') + .map(|s| u8::from_str_radix(s.trim_start_matches("0x"), 16)) + .collect::<::std::result::Result, _>>() + .map_err(Error::InvalidHex)?) + } else { + let s: String = s.chars().filter(|c| !c.is_whitespace()).collect(); + Ok(s.as_bytes() + .chunks(2) + .map(|s| u8::from_str_radix(::std::str::from_utf8(s).unwrap(), 16)) + .collect::<::std::result::Result, _>>() + .map_err(Error::InvalidHex)?) + } +}