X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=src%2Fmessagehandler.c;h=4111d4980d0ba9b3dedccffab90d224cc77208c7;hb=a76733ea91c6a1d42dfbb50631fa214cc284c3bf;hp=b2f5670e90d6c0c1f08fdd67b531a465bde7fefb;hpb=0f60078dfd1f7a770311c3dffa011788e5b7dcc2;p=umurmur.git diff --git a/src/messagehandler.c b/src/messagehandler.c index b2f5670..4111d49 100644 --- a/src/messagehandler.c +++ b/src/messagehandler.c @@ -29,7 +29,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include -#include +#include #include "log.h" #include "list.h" @@ -79,9 +79,15 @@ void Mh_handle_message(client_t *client, message_t *msg) } switch (msg->messageType) { case Authenticate: - Log_debug("Authenticate message received"); - Log_debug("Username: %s", msg->payload.authenticate->username); + + if (IS_AUTH(client) || !msg->payload.authenticate->username) { + /* Authenticate message might be sent when a token is set by the user.*/ + if (msg->payload.authenticate->n_tokens > 0) { + Log_debug("Tokens in auth message from %s", client->username); + } + break; + } client->authenticated = true; @@ -98,11 +104,14 @@ void Mh_handle_message(client_t *client, message_t *msg) } } if (strlen(getStrConf(PASSPHRASE)) > 0) { - if (!msg->payload.authenticate->password || strncmp(getStrConf(PASSPHRASE), msg->payload.authenticate->password, MAX_TEXT) != 0) { + if (!msg->payload.authenticate->password || + (msg->payload.authenticate->password && + strncmp(getStrConf(PASSPHRASE), msg->payload.authenticate->password, MAX_TEXT) != 0)) { char buf[64]; sprintf(buf, "Wrong server password"); sendServerReject(client, buf, MUMBLE_PROTO__REJECT__REJECT_TYPE__WrongServerPW); - Log_debug("Wrong server password: %s", msg->payload.authenticate->password); + Log_debug("Wrong server password: '%s'", msg->payload.authenticate->password != NULL ? + msg->payload.authenticate->password : "(null)"); goto disconnect; } } @@ -215,8 +224,6 @@ void Mh_handle_message(client_t *client, message_t *msg) sendmsg = Msg_create(UserState); sendmsg->payload.userState->has_session = true; sendmsg->payload.userState->session = client->sessionId; - sendmsg->payload.userState->has_user_id = true; - sendmsg->payload.userState->user_id = client->sessionId; sendmsg->payload.userState->name = strdup(client->username); sendmsg->payload.userState->has_channel_id = true; sendmsg->payload.userState->channel_id = ((channel_t *)client->channel)->id; @@ -323,11 +330,22 @@ void Mh_handle_message(client_t *client, message_t *msg) sendPermissionDenied(client, "Not supported by uMurmur"); break; } + + msg->payload.userState->has_session = true; + msg->payload.userState->session = client->sessionId; + msg->payload.userState->has_actor = true; + msg->payload.userState->actor = client->sessionId; + if (msg->payload.userState->has_self_deaf) { client->deaf = msg->payload.userState->self_deaf; } if (msg->payload.userState->has_self_mute) { - client->mute = msg->payload.userState->self_mute; + client->mute = msg->payload.userState->self_mute; + if (!client->mute) { + msg->payload.userState->has_self_deaf = true; + msg->payload.userState->self_deaf = false; + client->deaf = false; + } } if (msg->payload.userState->has_channel_id) { int leave_id; @@ -352,8 +370,7 @@ void Mh_handle_message(client_t *client, message_t *msg) /* Re-use message */ Msg_inc_ref(msg); - msg->payload.userState->has_actor = true; - msg->payload.userState->actor = client->sessionId; + Client_send_message_except(NULL, msg); /* Need to send remove channel message _after_ UserState message */