From 38f480566085f01d9776dc69b44db6778a0d47f4 Mon Sep 17 00:00:00 2001 From: Auzan Date: Thu, 12 Apr 2018 08:33:44 +0700 Subject: [PATCH] Update mumble proto to latest version. --- Mumble.proto | 35 +++++++++++++++++++++++++++-------- include/mumlib.hpp | 2 -- include/mumlib/Transport.hpp | 2 -- src/Transport.cpp | 11 ----------- src/mumlib.cpp | 32 +++++++++++++++++++++----------- 5 files changed, 48 insertions(+), 34 deletions(-) diff --git a/Mumble.proto b/Mumble.proto index 92b8737..a74f247 100644 --- a/Mumble.proto +++ b/Mumble.proto @@ -1,3 +1,10 @@ +// Copyright 2005-2018 The Mumble Developers. All rights reserved. +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file at the root of the +// Mumble source tree or at . + +syntax = "proto2"; + package MumbleProto; option optimize_for = SPEED; @@ -63,7 +70,8 @@ message Ping { // Sent by the server when it rejects the user connection. message Reject { enum RejectType { - // TODO ?? + // The rejection reason is unknown (details should be available + // in Reject.reason). None = 0; // The client attempted to connect with an incompatible version. WrongVersion = 1; @@ -98,7 +106,7 @@ message ServerSync { optional uint32 max_bandwidth = 2; // Server welcome text. optional string welcome_text = 3; - // Current user permissions TODO: Confirm?? + // Current user permissions in the root channel. optional uint64 permissions = 4; } @@ -134,6 +142,10 @@ message ChannelState { optional int32 position = 9 [default = 0]; // SHA1 hash of the description if the description is 128 bytes or more. optional bytes description_hash = 10; + // Maximum number of users allowed in the channel. If this value is zero, + // the maximum number of users allowed in the channel is given by the + // server's "usersperchannel" setting. + optional uint32 max_users = 11; } // Used to communicate user leaving or being kicked. May be sent by the client @@ -180,9 +192,14 @@ message UserState { optional bool self_deaf = 10; // User image if it is less than 128 bytes. optional bytes texture = 11; - // TODO ?? + // The positional audio plugin identifier. + // Positional audio information is only sent to users who share + // identical plugin contexts. + // + // This value is not trasmitted to clients. optional bytes plugin_context = 12; - // TODO ?? + // The user's plugin-specific identity. + // This value is not transmitted to clients. optional string plugin_identity = 13; // User comment if it is less than 128 bytes. optional string comment = 14; @@ -209,7 +226,7 @@ message BanList { required uint32 mask = 2; // User name for identification purposes (does not affect the ban). optional string name = 3; - // TODO ?? + // The certificate hash of the banned user. optional string hash = 4; // Reason for the ban (does not affect the ban). optional string reason = 5; @@ -403,9 +420,9 @@ message VoiceTarget { message Target { // Users that are included as targets. repeated uint32 session = 1; - // Channels that are included as targets. + // Channel that is included as a target. optional uint32 channel_id = 2; - // TODO ?? + // ACL group that is included as a target. optional string group = 3; // True if the voice should follow links from the specified channel. optional bool links = 4 [default = false]; @@ -529,6 +546,8 @@ message ServerConfig { optional uint32 message_length = 4; // Maximum image message length. optional uint32 image_message_length = 5; + // The maximum number of users allowed on the server. + optional uint32 max_users = 6; } // Sent by the server to inform the clients of suggested client configuration @@ -541,4 +560,4 @@ message SuggestConfig { optional bool positional = 2; // True if the administrator suggests push to talk to be used on this server. optional bool push_to_talk = 3; -} +} \ No newline at end of file diff --git a/include/mumlib.hpp b/include/mumlib.hpp index da0baf0..ee18567 100644 --- a/include/mumlib.hpp +++ b/include/mumlib.hpp @@ -48,8 +48,6 @@ namespace mumlib { void disconnect(); - void reconnect(); - void run(); ConnectionState getConnectionState(); diff --git a/include/mumlib/Transport.hpp b/include/mumlib/Transport.hpp index f200dca..346728b 100644 --- a/include/mumlib/Transport.hpp +++ b/include/mumlib/Transport.hpp @@ -50,8 +50,6 @@ namespace mumlib { void disconnect(); - void reconnect(); - ConnectionState getConnectionState() { return state; } diff --git a/src/Transport.cpp b/src/Transport.cpp index 2c14e4d..b3803f6 100644 --- a/src/Transport.cpp +++ b/src/Transport.cpp @@ -95,7 +95,6 @@ void mumlib::Transport::connect( void mumlib::Transport::disconnect() { - pingTimer.cancel(); if (state != ConnectionState::NOT_CONNECTED) { boost::system::error_code errorCode; @@ -120,16 +119,6 @@ void mumlib::Transport::disconnect() { } } -void mumlib::Transport::reconnect() { - boost::system::error_code errorCode; - - udpSocket.close(errorCode); - if (errorCode) { - logger.warn("SSL socket close return an error: %s.", errorCode.message().c_str()); - } -} - - void mumlib::Transport::sendVersion() { MumbleProto::Version version; diff --git a/src/mumlib.cpp b/src/mumlib.cpp index f289992..e21d1e1 100644 --- a/src/mumlib.cpp +++ b/src/mumlib.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -201,6 +202,9 @@ namespace mumlib { int32_t priority_speaker = userState.has_priority_speaker() ? userState.priority_speaker() : -1; int32_t recording = userState.has_recording() ? userState.recording() : -1; + if(session == this->sessionId) { + this->channelId = channel_id; + } callback.userState(session, actor, userState.name(), @@ -381,15 +385,6 @@ namespace mumlib { } } - void Mumlib::reconnect() { - if (not impl->externalIoService) { - impl->ioService.reset(); - } - if (impl->transport.getConnectionState() != ConnectionState::NOT_CONNECTED) { - impl->transport.disconnect(); - } - } - void Mumlib::run() { if (impl->externalIoService) { throw MumlibException("can't call run() when using external io_service"); @@ -473,8 +468,23 @@ namespace mumlib { switch (field) { case UserState::COMMENT: - // TODO: if comment longer than 128 bytes, we need to set the SHA1 hash - userState.set_comment(val); + + if(val.size() < 128) { + userState.set_comment(val); + } else { + // if comment longer than 128 bytes, we need to set the SHA1 hash + boost::uuids::detail::sha1 sha1; + uint hash[5]; + sha1.process_bytes(val.c_str(), val.size()); + sha1.get_digest(hash); + + std::stringstream valStream; + for(std::size_t i=0; i