mirror of
https://github.com/mumble-voip/grumble.git
synced 2025-12-20 06:10:00 -08:00
Add message numbers to mumbleproto package.
This commit is contained in:
parent
4d5b897d66
commit
7482d5cb19
6 changed files with 112 additions and 108 deletions
32
client.go
32
client.go
|
|
@ -5,16 +5,16 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
|
||||||
"bufio"
|
"bufio"
|
||||||
"log"
|
|
||||||
"os"
|
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"goprotobuf.googlecode.com/hg/proto"
|
"goprotobuf.googlecode.com/hg/proto"
|
||||||
"mumbleproto"
|
|
||||||
"grumble/blobstore"
|
"grumble/blobstore"
|
||||||
"grumble/cryptstate"
|
"grumble/cryptstate"
|
||||||
|
"grumble/mumbleproto"
|
||||||
"io"
|
"io"
|
||||||
|
"log"
|
||||||
|
"net"
|
||||||
|
"os"
|
||||||
"packetdatastream"
|
"packetdatastream"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
@ -187,7 +187,7 @@ func (client *Client) RejectAuth(kind, reason string) {
|
||||||
reasonString = proto.String(reason)
|
reasonString = proto.String(reason)
|
||||||
}
|
}
|
||||||
|
|
||||||
client.sendProtoMessage(MessageReject, &mumbleproto.Reject{
|
client.sendProtoMessage(mumbleproto.MessageReject, &mumbleproto.Reject{
|
||||||
Type: mumbleproto.NewReject_RejectType(mumbleproto.Reject_RejectType_value[kind]),
|
Type: mumbleproto.NewReject_RejectType(mumbleproto.Reject_RejectType_value[kind]),
|
||||||
Reason: reasonString,
|
Reason: reasonString,
|
||||||
})
|
})
|
||||||
|
|
@ -265,7 +265,7 @@ func (c *Client) sendPermissionDeniedTypeUser(kind string, user *Client) {
|
||||||
}
|
}
|
||||||
c.msgchan <- &Message{
|
c.msgchan <- &Message{
|
||||||
buf: d,
|
buf: d,
|
||||||
kind: MessagePermissionDenied,
|
kind: mumbleproto.MessagePermissionDenied,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
c.Panicf("Unknown permission denied type.")
|
c.Panicf("Unknown permission denied type.")
|
||||||
|
|
@ -285,7 +285,7 @@ func (c *Client) sendPermissionDenied(who *Client, where *Channel, what Permissi
|
||||||
}
|
}
|
||||||
c.msgchan <- &Message{
|
c.msgchan <- &Message{
|
||||||
buf: d,
|
buf: d,
|
||||||
kind: MessagePermissionDenied,
|
kind: mumbleproto.MessagePermissionDenied,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -307,11 +307,11 @@ func (client *Client) udpreceiver() {
|
||||||
kind := (buf[0] >> 5) & 0x07
|
kind := (buf[0] >> 5) & 0x07
|
||||||
|
|
||||||
switch kind {
|
switch kind {
|
||||||
case UDPMessageVoiceSpeex:
|
case mumbleproto.UDPMessageVoiceSpeex:
|
||||||
fallthrough
|
fallthrough
|
||||||
case UDPMessageVoiceCELTAlpha:
|
case mumbleproto.UDPMessageVoiceCELTAlpha:
|
||||||
fallthrough
|
fallthrough
|
||||||
case UDPMessageVoiceCELTBeta:
|
case mumbleproto.UDPMessageVoiceCELTBeta:
|
||||||
kind := buf[0] & 0xe0
|
kind := buf[0] & 0xe0
|
||||||
target := buf[0] & 0x1f
|
target := buf[0] & 0x1f
|
||||||
var counter uint8
|
var counter uint8
|
||||||
|
|
@ -348,7 +348,7 @@ func (client *Client) udpreceiver() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
case UDPMessagePing:
|
case mumbleproto.UDPMessagePing:
|
||||||
client.server.udpsend <- &Message{
|
client.server.udpsend <- &Message{
|
||||||
buf: buf,
|
buf: buf,
|
||||||
client: client,
|
client: client,
|
||||||
|
|
@ -363,7 +363,7 @@ func (client *Client) sendUdp(msg *Message) {
|
||||||
client.server.udpsend <- msg
|
client.server.udpsend <- msg
|
||||||
} else {
|
} else {
|
||||||
client.Printf("Sent TCP!")
|
client.Printf("Sent TCP!")
|
||||||
msg.kind = MessageUDPTunnel
|
msg.kind = mumbleproto.MessageUDPTunnel
|
||||||
client.msgchan <- msg
|
client.msgchan <- msg
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -445,7 +445,7 @@ func (client *Client) receiver() {
|
||||||
}
|
}
|
||||||
// Special case UDPTunnel messages. They're high priority and shouldn't
|
// Special case UDPTunnel messages. They're high priority and shouldn't
|
||||||
// go through our synchronous path.
|
// go through our synchronous path.
|
||||||
if msg.kind == MessageUDPTunnel {
|
if msg.kind == mumbleproto.MessageUDPTunnel {
|
||||||
client.udp = false
|
client.udp = false
|
||||||
client.udprecv <- msg.buf
|
client.udprecv <- msg.buf
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -485,7 +485,7 @@ func (client *Client) receiver() {
|
||||||
// information we must send it our version information so it knows
|
// information we must send it our version information so it knows
|
||||||
// what version of the protocol it should speak.
|
// what version of the protocol it should speak.
|
||||||
if client.state == StateClientConnected {
|
if client.state == StateClientConnected {
|
||||||
client.sendProtoMessage(MessageVersion, &mumbleproto.Version{
|
client.sendProtoMessage(mumbleproto.MessageVersion, &mumbleproto.Version{
|
||||||
Version: proto.Uint32(0x10203),
|
Version: proto.Uint32(0x10203),
|
||||||
Release: proto.String("Grumble"),
|
Release: proto.String("Grumble"),
|
||||||
})
|
})
|
||||||
|
|
@ -575,7 +575,7 @@ func (client *Client) sendChannelTree(channel *Channel) {
|
||||||
}
|
}
|
||||||
chanstate.Links = links
|
chanstate.Links = links
|
||||||
|
|
||||||
err := client.sendProtoMessage(MessageChannelState, chanstate)
|
err := client.sendProtoMessage(mumbleproto.MessageChannelState, chanstate)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
client.Panicf("%v", err)
|
client.Panicf("%v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -593,7 +593,7 @@ func (client *Client) cryptResync() {
|
||||||
if requestElapsed > 5 {
|
if requestElapsed > 5 {
|
||||||
client.lastResync = time.Seconds()
|
client.lastResync = time.Seconds()
|
||||||
cryptsetup := &mumbleproto.CryptSetup{}
|
cryptsetup := &mumbleproto.CryptSetup{}
|
||||||
err := client.sendProtoMessage(MessageCryptSetup, cryptsetup)
|
err := client.sendProtoMessage(mumbleproto.MessageCryptSetup, cryptsetup)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
client.Panicf("%v", err)
|
client.Panicf("%v", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,10 @@ import (
|
||||||
"goprotobuf.googlecode.com/hg/proto"
|
"goprotobuf.googlecode.com/hg/proto"
|
||||||
"grumble/ban"
|
"grumble/ban"
|
||||||
"grumble/freezer"
|
"grumble/freezer"
|
||||||
|
"grumble/mumbleproto"
|
||||||
"grumble/serverconf"
|
"grumble/serverconf"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"mumbleproto"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
|
||||||
83
message.go
83
message.go
|
|
@ -12,48 +12,11 @@ import (
|
||||||
"grumble/ban"
|
"grumble/ban"
|
||||||
"grumble/blobstore"
|
"grumble/blobstore"
|
||||||
"grumble/freezer"
|
"grumble/freezer"
|
||||||
"mumbleproto"
|
"grumble/mumbleproto"
|
||||||
"net"
|
"net"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// These are the different kinds of messages
|
|
||||||
// that are defined for the Mumble protocol
|
|
||||||
const (
|
|
||||||
MessageVersion = iota
|
|
||||||
MessageUDPTunnel
|
|
||||||
MessageAuthenticate
|
|
||||||
MessagePing
|
|
||||||
MessageReject
|
|
||||||
MessageServerSync
|
|
||||||
MessageChannelRemove
|
|
||||||
MessageChannelState
|
|
||||||
MessageUserRemove
|
|
||||||
MessageUserState
|
|
||||||
MessageBanList
|
|
||||||
MessageTextMessage
|
|
||||||
MessagePermissionDenied
|
|
||||||
MessageACL
|
|
||||||
MessageQueryUsers
|
|
||||||
MessageCryptSetup
|
|
||||||
MessageContextActionAdd
|
|
||||||
MessageContextAction
|
|
||||||
MessageUserList
|
|
||||||
MessageVoiceTarget
|
|
||||||
MessagePermissionQuery
|
|
||||||
MessageCodecVersion
|
|
||||||
MessageUserStats
|
|
||||||
MessageRequestBlob
|
|
||||||
MessageServerConfig
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
UDPMessageVoiceCELTAlpha = iota
|
|
||||||
UDPMessagePing
|
|
||||||
UDPMessageVoiceSpeex
|
|
||||||
UDPMessageVoiceCELTBeta
|
|
||||||
)
|
|
||||||
|
|
||||||
type Message struct {
|
type Message struct {
|
||||||
buf []byte
|
buf []byte
|
||||||
|
|
||||||
|
|
@ -94,7 +57,7 @@ func (server *Server) handleCryptSetup(client *Client, msg *Message) {
|
||||||
if copy(cs.ClientNonce, client.crypt.EncryptIV[0:]) != aes.BlockSize {
|
if copy(cs.ClientNonce, client.crypt.EncryptIV[0:]) != aes.BlockSize {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
client.sendProtoMessage(MessageCryptSetup, cs)
|
client.sendProtoMessage(mumbleproto.MessageCryptSetup, cs)
|
||||||
} else {
|
} else {
|
||||||
client.Printf("Received client nonce")
|
client.Printf("Received client nonce")
|
||||||
if len(cs.ClientNonce) != aes.BlockSize {
|
if len(cs.ClientNonce) != aes.BlockSize {
|
||||||
|
|
@ -150,7 +113,7 @@ func (server *Server) handlePingMessage(client *Client, msg *Message) {
|
||||||
client.TcpPackets = *ping.TcpPackets
|
client.TcpPackets = *ping.TcpPackets
|
||||||
}
|
}
|
||||||
|
|
||||||
client.sendProtoMessage(MessagePing, &mumbleproto.Ping{
|
client.sendProtoMessage(mumbleproto.MessagePing, &mumbleproto.Ping{
|
||||||
Timestamp: ping.Timestamp,
|
Timestamp: ping.Timestamp,
|
||||||
Good: proto.Uint32(uint32(client.crypt.Good)),
|
Good: proto.Uint32(uint32(client.crypt.Good)),
|
||||||
Late: proto.Uint32(uint32(client.crypt.Late)),
|
Late: proto.Uint32(uint32(client.crypt.Late)),
|
||||||
|
|
@ -339,7 +302,7 @@ func (server *Server) handleChannelStateMessage(client *Client, msg *Message) {
|
||||||
chanstate.ChannelId = proto.Uint32(uint32(channel.Id))
|
chanstate.ChannelId = proto.Uint32(uint32(channel.Id))
|
||||||
|
|
||||||
// Broadcast channel add
|
// Broadcast channel add
|
||||||
server.broadcastProtoMessageWithPredicate(MessageChannelState, chanstate, func(client *Client) bool {
|
server.broadcastProtoMessageWithPredicate(mumbleproto.MessageChannelState, chanstate, func(client *Client) bool {
|
||||||
return client.Version < 0x10202
|
return client.Version < 0x10202
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -348,7 +311,7 @@ func (server *Server) handleChannelStateMessage(client *Client, msg *Message) {
|
||||||
chanstate.Description = nil
|
chanstate.Description = nil
|
||||||
chanstate.DescriptionHash = channel.DescriptionBlobHashBytes()
|
chanstate.DescriptionHash = channel.DescriptionBlobHashBytes()
|
||||||
}
|
}
|
||||||
server.broadcastProtoMessageWithPredicate(MessageChannelState, chanstate, func(client *Client) bool {
|
server.broadcastProtoMessageWithPredicate(mumbleproto.MessageChannelState, chanstate, func(client *Client) bool {
|
||||||
return client.Version >= 0x10202
|
return client.Version >= 0x10202
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -358,7 +321,7 @@ func (server *Server) handleChannelStateMessage(client *Client, msg *Message) {
|
||||||
userstate.Session = proto.Uint32(client.Session)
|
userstate.Session = proto.Uint32(client.Session)
|
||||||
userstate.ChannelId = proto.Uint32(uint32(channel.Id))
|
userstate.ChannelId = proto.Uint32(uint32(channel.Id))
|
||||||
server.userEnterChannel(client, channel, userstate)
|
server.userEnterChannel(client, channel, userstate)
|
||||||
server.broadcastProtoMessage(MessageUserState, userstate)
|
server.broadcastProtoMessage(mumbleproto.MessageUserState, userstate)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Edit existing channel.
|
// Edit existing channel.
|
||||||
|
|
@ -503,7 +466,7 @@ func (server *Server) handleChannelStateMessage(client *Client, msg *Message) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Broadcast the update
|
// Broadcast the update
|
||||||
server.broadcastProtoMessageWithPredicate(MessageChannelState, chanstate, func(client *Client) bool {
|
server.broadcastProtoMessageWithPredicate(mumbleproto.MessageChannelState, chanstate, func(client *Client) bool {
|
||||||
return client.Version < 0x10202
|
return client.Version < 0x10202
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -513,7 +476,7 @@ func (server *Server) handleChannelStateMessage(client *Client, msg *Message) {
|
||||||
chanstate.DescriptionHash = channel.DescriptionBlobHashBytes()
|
chanstate.DescriptionHash = channel.DescriptionBlobHashBytes()
|
||||||
}
|
}
|
||||||
chanstate.DescriptionHash = channel.DescriptionBlobHashBytes()
|
chanstate.DescriptionHash = channel.DescriptionBlobHashBytes()
|
||||||
server.broadcastProtoMessageWithPredicate(MessageChannelState, chanstate, func(client *Client) bool {
|
server.broadcastProtoMessageWithPredicate(mumbleproto.MessageChannelState, chanstate, func(client *Client) bool {
|
||||||
return client.Version >= 0x10202
|
return client.Version >= 0x10202
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -574,7 +537,7 @@ func (server *Server) handleUserRemoveMessage(client *Client, msg *Message) {
|
||||||
}
|
}
|
||||||
|
|
||||||
userremove.Actor = proto.Uint32(uint32(client.Session))
|
userremove.Actor = proto.Uint32(uint32(client.Session))
|
||||||
if err = server.broadcastProtoMessage(MessageUserRemove, userremove); err != nil {
|
if err = server.broadcastProtoMessage(mumbleproto.MessageUserRemove, userremove); err != nil {
|
||||||
server.Panicf("Unable to broadcast UserRemove message")
|
server.Panicf("Unable to broadcast UserRemove message")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -823,7 +786,7 @@ func (server *Server) handleUserStateMessage(client *Client, msg *Message) {
|
||||||
txtmsg.Message = proto.String(fmt.Sprintf("User '%s' stopped recording", target.ShownName()))
|
txtmsg.Message = proto.String(fmt.Sprintf("User '%s' stopped recording", target.ShownName()))
|
||||||
}
|
}
|
||||||
|
|
||||||
server.broadcastProtoMessageWithPredicate(MessageTextMessage, txtmsg, func(client *Client) bool {
|
server.broadcastProtoMessageWithPredicate(mumbleproto.MessageTextMessage, txtmsg, func(client *Client) bool {
|
||||||
return client.Version < 0x10203
|
return client.Version < 0x10203
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -866,7 +829,7 @@ func (server *Server) handleUserStateMessage(client *Client, msg *Message) {
|
||||||
// The sent texture is a new-style texture. Strip it from the message
|
// The sent texture is a new-style texture. Strip it from the message
|
||||||
// we send to pre-1.2.2 clients.
|
// we send to pre-1.2.2 clients.
|
||||||
userstate.Texture = nil
|
userstate.Texture = nil
|
||||||
err := server.broadcastProtoMessageWithPredicate(MessageUserState, userstate, func(client *Client) bool {
|
err := server.broadcastProtoMessageWithPredicate(mumbleproto.MessageUserState, userstate, func(client *Client) bool {
|
||||||
return client.Version < 0x10202
|
return client.Version < 0x10202
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -876,7 +839,7 @@ func (server *Server) handleUserStateMessage(client *Client, msg *Message) {
|
||||||
userstate.Texture = texture
|
userstate.Texture = texture
|
||||||
} else {
|
} else {
|
||||||
// Old style texture. We can send the message as-is.
|
// Old style texture. We can send the message as-is.
|
||||||
err := server.broadcastProtoMessageWithPredicate(MessageUserState, userstate, func(client *Client) bool {
|
err := server.broadcastProtoMessageWithPredicate(mumbleproto.MessageUserState, userstate, func(client *Client) bool {
|
||||||
return client.Version < 0x10202
|
return client.Version < 0x10202
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -908,7 +871,7 @@ func (server *Server) handleUserStateMessage(client *Client, msg *Message) {
|
||||||
server.ClearACLCache()
|
server.ClearACLCache()
|
||||||
}
|
}
|
||||||
|
|
||||||
err := server.broadcastProtoMessageWithPredicate(MessageUserState, userstate, func(client *Client) bool {
|
err := server.broadcastProtoMessageWithPredicate(mumbleproto.MessageUserState, userstate, func(client *Client) bool {
|
||||||
return client.Version >= 0x10203
|
return client.Version >= 0x10203
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -951,7 +914,7 @@ func (server *Server) handleBanListMessage(client *Client, msg *Message) {
|
||||||
entry.Duration = proto.Uint32(ban.Duration)
|
entry.Duration = proto.Uint32(ban.Duration)
|
||||||
banlist.Bans = append(banlist.Bans, entry)
|
banlist.Bans = append(banlist.Bans, entry)
|
||||||
}
|
}
|
||||||
if err := client.sendProtoMessage(MessageBanList, banlist); err != nil {
|
if err := client.sendProtoMessage(mumbleproto.MessageBanList, banlist); err != nil {
|
||||||
client.Panic("Unable to send BanList")
|
client.Panic("Unable to send BanList")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1051,7 +1014,7 @@ func (server *Server) handleTextMessage(client *Client, msg *Message) {
|
||||||
clients[client.Session] = nil, false
|
clients[client.Session] = nil, false
|
||||||
|
|
||||||
for _, target := range clients {
|
for _, target := range clients {
|
||||||
target.sendProtoMessage(MessageTextMessage, &mumbleproto.TextMessage{
|
target.sendProtoMessage(mumbleproto.MessageTextMessage, &mumbleproto.TextMessage{
|
||||||
Actor: proto.Uint32(client.Session),
|
Actor: proto.Uint32(client.Session),
|
||||||
Message: txtmsg.Message,
|
Message: txtmsg.Message,
|
||||||
})
|
})
|
||||||
|
|
@ -1180,7 +1143,7 @@ func (server *Server) handleAclMessage(client *Client, msg *Message) {
|
||||||
reply.Groups = append(reply.Groups, mpgroup)
|
reply.Groups = append(reply.Groups, mpgroup)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := client.sendProtoMessage(MessageACL, reply); err != nil {
|
if err := client.sendProtoMessage(mumbleproto.MessageACL, reply); err != nil {
|
||||||
client.Panic(err.String())
|
client.Panic(err.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1196,7 +1159,7 @@ func (server *Server) handleAclMessage(client *Client, msg *Message) {
|
||||||
queryusers.Names = append(queryusers.Names, user.Name)
|
queryusers.Names = append(queryusers.Names, user.Name)
|
||||||
}
|
}
|
||||||
if len(queryusers.Ids) > 0 {
|
if len(queryusers.Ids) > 0 {
|
||||||
client.sendProtoMessage(MessageQueryUsers, queryusers)
|
client.sendProtoMessage(mumbleproto.MessageQueryUsers, queryusers)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set new groups and ACLs
|
// Set new groups and ACLs
|
||||||
|
|
@ -1303,7 +1266,7 @@ func (server *Server) handleQueryUsers(client *Client, msg *Message) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := client.sendProtoMessage(MessageQueryUsers, reply); err != nil {
|
if err := client.sendProtoMessage(mumbleproto.MessageQueryUsers, reply); err != nil {
|
||||||
client.Panic(err.String())
|
client.Panic(err.String())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -1407,7 +1370,7 @@ func (server *Server) handleUserStatsMessage(client *Client, msg *Message) {
|
||||||
|
|
||||||
// fixme(mkrautz): we don't do bandwidth tracking yet
|
// fixme(mkrautz): we don't do bandwidth tracking yet
|
||||||
|
|
||||||
if err := client.sendProtoMessage(MessageUserStats, stats); err != nil {
|
if err := client.sendProtoMessage(mumbleproto.MessageUserStats, stats); err != nil {
|
||||||
client.Panic(err.String())
|
client.Panic(err.String())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -1455,7 +1418,7 @@ func (server *Server) handleRequestBlob(client *Client, msg *Message) {
|
||||||
userstate.Reset()
|
userstate.Reset()
|
||||||
userstate.Session = proto.Uint32(uint32(target.Session))
|
userstate.Session = proto.Uint32(uint32(target.Session))
|
||||||
userstate.Texture = buf
|
userstate.Texture = buf
|
||||||
if err := client.sendProtoMessage(MessageUserState, userstate); err != nil {
|
if err := client.sendProtoMessage(mumbleproto.MessageUserState, userstate); err != nil {
|
||||||
client.Panic(err.String())
|
client.Panic(err.String())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -1479,7 +1442,7 @@ func (server *Server) handleRequestBlob(client *Client, msg *Message) {
|
||||||
userstate.Reset()
|
userstate.Reset()
|
||||||
userstate.Session = proto.Uint32(uint32(target.Session))
|
userstate.Session = proto.Uint32(uint32(target.Session))
|
||||||
userstate.Comment = proto.String(string(buf))
|
userstate.Comment = proto.String(string(buf))
|
||||||
if err := client.sendProtoMessage(MessageUserState, userstate); err != nil {
|
if err := client.sendProtoMessage(mumbleproto.MessageUserState, userstate); err != nil {
|
||||||
client.Panic(err.String())
|
client.Panic(err.String())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -1502,7 +1465,7 @@ func (server *Server) handleRequestBlob(client *Client, msg *Message) {
|
||||||
}
|
}
|
||||||
chanstate.ChannelId = proto.Uint32(uint32(channel.Id))
|
chanstate.ChannelId = proto.Uint32(uint32(channel.Id))
|
||||||
chanstate.Description = proto.String(string(buf))
|
chanstate.Description = proto.String(string(buf))
|
||||||
if err := client.sendProtoMessage(MessageChannelState, chanstate); err != nil {
|
if err := client.sendProtoMessage(mumbleproto.MessageChannelState, chanstate); err != nil {
|
||||||
client.Panic(err.String())
|
client.Panic(err.String())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -1538,7 +1501,7 @@ func (server *Server) handleUserList(client *Client, msg *Message) {
|
||||||
Name: proto.String(user.Name),
|
Name: proto.String(user.Name),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if err := client.sendProtoMessage(MessageUserList, userlist); err != nil {
|
if err := client.sendProtoMessage(mumbleproto.MessageUserList, userlist); err != nil {
|
||||||
client.Panic(err.String())
|
client.Panic(err.String())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
include $(GOROOT)/src/Make.inc
|
include $(GOROOT)/src/Make.inc
|
||||||
|
|
||||||
TARG = mumbleproto
|
TARG = grumble/mumbleproto
|
||||||
GOFILES=\
|
GOFILES=\
|
||||||
Mumble.pb.go
|
Mumble.pb.go \
|
||||||
|
types.go
|
||||||
|
|
||||||
include $(GOROOT)/src/Make.pkg
|
include $(GOROOT)/src/Make.pkg
|
||||||
include $(GOROOT)/src/pkg/goprotobuf.googlecode.com/hg/Make.protobuf
|
include $(GOROOT)/src/pkg/goprotobuf.googlecode.com/hg/Make.protobuf
|
||||||
|
|
|
||||||
40
pkg/mumbleproto/types.go
Normal file
40
pkg/mumbleproto/types.go
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
// Copyright (c) 2011 The Grumble Authors
|
||||||
|
// The use of this source code is goverened by a BSD-style
|
||||||
|
// license that can be found in the LICENSE-file.
|
||||||
|
|
||||||
|
package mumbleproto
|
||||||
|
|
||||||
|
const (
|
||||||
|
MessageVersion = iota
|
||||||
|
MessageUDPTunnel
|
||||||
|
MessageAuthenticate
|
||||||
|
MessagePing
|
||||||
|
MessageReject
|
||||||
|
MessageServerSync
|
||||||
|
MessageChannelRemove
|
||||||
|
MessageChannelState
|
||||||
|
MessageUserRemove
|
||||||
|
MessageUserState
|
||||||
|
MessageBanList
|
||||||
|
MessageTextMessage
|
||||||
|
MessagePermissionDenied
|
||||||
|
MessageACL
|
||||||
|
MessageQueryUsers
|
||||||
|
MessageCryptSetup
|
||||||
|
MessageContextActionAdd
|
||||||
|
MessageContextAction
|
||||||
|
MessageUserList
|
||||||
|
MessageVoiceTarget
|
||||||
|
MessagePermissionQuery
|
||||||
|
MessageCodecVersion
|
||||||
|
MessageUserStats
|
||||||
|
MessageRequestBlob
|
||||||
|
MessageServerConfig
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
UDPMessageVoiceCELTAlpha = iota
|
||||||
|
UDPMessagePing
|
||||||
|
UDPMessageVoiceSpeex
|
||||||
|
UDPMessageVoiceCELTBeta
|
||||||
|
)
|
||||||
58
server.go
58
server.go
|
|
@ -19,11 +19,11 @@ import (
|
||||||
"grumble/cryptstate"
|
"grumble/cryptstate"
|
||||||
"grumble/freezer"
|
"grumble/freezer"
|
||||||
"grumble/htmlfilter"
|
"grumble/htmlfilter"
|
||||||
|
"grumble/mumbleproto"
|
||||||
"grumble/serverconf"
|
"grumble/serverconf"
|
||||||
"grumble/sessionpool"
|
"grumble/sessionpool"
|
||||||
"hash"
|
"hash"
|
||||||
"log"
|
"log"
|
||||||
"mumbleproto"
|
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -302,7 +302,7 @@ func (server *Server) RemoveClient(client *Client, kicked bool) {
|
||||||
// If the user is disconnect via a kick, the UserRemove message has already been sent
|
// If the user is disconnect via a kick, the UserRemove message has already been sent
|
||||||
// at this point.
|
// at this point.
|
||||||
if !kicked && client.state > StateClientAuthenticated {
|
if !kicked && client.state > StateClientAuthenticated {
|
||||||
err := server.broadcastProtoMessage(MessageUserRemove, &mumbleproto.UserRemove{
|
err := server.broadcastProtoMessage(mumbleproto.MessageUserRemove, &mumbleproto.UserRemove{
|
||||||
Session: proto.Uint32(client.Session),
|
Session: proto.Uint32(client.Session),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -403,7 +403,7 @@ func (server *Server) handler() {
|
||||||
// will send the channel tree, user list, etc. to the client.
|
// will send the channel tree, user list, etc. to the client.
|
||||||
func (server *Server) handleAuthenticate(client *Client, msg *Message) {
|
func (server *Server) handleAuthenticate(client *Client, msg *Message) {
|
||||||
// Is this message not an authenticate message? If not, discard it...
|
// Is this message not an authenticate message? If not, discard it...
|
||||||
if msg.kind != MessageAuthenticate {
|
if msg.kind != mumbleproto.MessageAuthenticate {
|
||||||
client.Panic("Unexpected message. Expected Authenticate.")
|
client.Panic("Unexpected message. Expected Authenticate.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -499,7 +499,7 @@ func (server *Server) handleAuthenticate(client *Client, msg *Message) {
|
||||||
// Send CryptState information to the client so it can establish an UDP connection,
|
// Send CryptState information to the client so it can establish an UDP connection,
|
||||||
// if it wishes.
|
// if it wishes.
|
||||||
client.lastResync = time.Seconds()
|
client.lastResync = time.Seconds()
|
||||||
err = client.sendProtoMessage(MessageCryptSetup, &mumbleproto.CryptSetup{
|
err = client.sendProtoMessage(mumbleproto.MessageCryptSetup, &mumbleproto.CryptSetup{
|
||||||
Key: client.crypt.RawKey[0:],
|
Key: client.crypt.RawKey[0:],
|
||||||
ClientNonce: client.crypt.DecryptIV[0:],
|
ClientNonce: client.crypt.DecryptIV[0:],
|
||||||
ServerNonce: client.crypt.EncryptIV[0:],
|
ServerNonce: client.crypt.EncryptIV[0:],
|
||||||
|
|
@ -601,7 +601,7 @@ func (server *Server) finishAuthenticate(client *Client) {
|
||||||
}
|
}
|
||||||
|
|
||||||
server.userEnterChannel(client, server.RootChannel(), userstate)
|
server.userEnterChannel(client, server.RootChannel(), userstate)
|
||||||
if err := server.broadcastProtoMessage(MessageUserState, userstate); err != nil {
|
if err := server.broadcastProtoMessage(mumbleproto.MessageUserState, userstate); err != nil {
|
||||||
// Server panic?
|
// Server panic?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -623,12 +623,12 @@ func (server *Server) finishAuthenticate(client *Client) {
|
||||||
perm.ClearCacheBit()
|
perm.ClearCacheBit()
|
||||||
sync.Permissions = proto.Uint64(uint64(perm))
|
sync.Permissions = proto.Uint64(uint64(perm))
|
||||||
}
|
}
|
||||||
if err := client.sendProtoMessage(MessageServerSync, sync); err != nil {
|
if err := client.sendProtoMessage(mumbleproto.MessageServerSync, sync); err != nil {
|
||||||
client.Panicf("%v", err)
|
client.Panicf("%v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err := client.sendProtoMessage(MessageServerConfig, &mumbleproto.ServerConfig{
|
err := client.sendProtoMessage(mumbleproto.MessageServerConfig, &mumbleproto.ServerConfig{
|
||||||
AllowHtml: proto.Bool(server.cfg.BoolValue("AllowHTML")),
|
AllowHtml: proto.Bool(server.cfg.BoolValue("AllowHTML")),
|
||||||
MessageLength: proto.Uint32(server.cfg.Uint32Value("MaxTextMessageLength")),
|
MessageLength: proto.Uint32(server.cfg.Uint32Value("MaxTextMessageLength")),
|
||||||
ImageMessageLength: proto.Uint32(server.cfg.Uint32Value("MaxImageMessageLength")),
|
ImageMessageLength: proto.Uint32(server.cfg.Uint32Value("MaxImageMessageLength")),
|
||||||
|
|
@ -686,7 +686,7 @@ func (server *Server) updateCodecVersions() {
|
||||||
server.BetaCodec = winner
|
server.BetaCodec = winner
|
||||||
}
|
}
|
||||||
|
|
||||||
err := server.broadcastProtoMessage(MessageCodecVersion, &mumbleproto.CodecVersion{
|
err := server.broadcastProtoMessage(mumbleproto.MessageCodecVersion, &mumbleproto.CodecVersion{
|
||||||
Alpha: proto.Int32(server.AlphaCodec),
|
Alpha: proto.Int32(server.AlphaCodec),
|
||||||
Beta: proto.Int32(server.BetaCodec),
|
Beta: proto.Int32(server.BetaCodec),
|
||||||
PreferAlpha: proto.Bool(server.PreferAlphaCodec),
|
PreferAlpha: proto.Bool(server.PreferAlphaCodec),
|
||||||
|
|
@ -774,7 +774,7 @@ func (server *Server) sendUserList(client *Client) {
|
||||||
userstate.PluginIdentity = proto.String(connectedClient.PluginIdentity)
|
userstate.PluginIdentity = proto.String(connectedClient.PluginIdentity)
|
||||||
}
|
}
|
||||||
|
|
||||||
err := client.sendProtoMessage(MessageUserState, userstate)
|
err := client.sendProtoMessage(mumbleproto.MessageUserState, userstate)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Server panic?
|
// Server panic?
|
||||||
continue
|
continue
|
||||||
|
|
@ -794,7 +794,7 @@ func (server *Server) sendClientPermissions(client *Client, channel *Channel) {
|
||||||
perm := server.aclcache.GetPermission(client, channel)
|
perm := server.aclcache.GetPermission(client, channel)
|
||||||
|
|
||||||
// fixme(mkrautz): Cache which permissions we've already sent.
|
// fixme(mkrautz): Cache which permissions we've already sent.
|
||||||
client.sendProtoMessage(MessagePermissionQuery, &mumbleproto.PermissionQuery{
|
client.sendProtoMessage(mumbleproto.MessagePermissionQuery, &mumbleproto.PermissionQuery{
|
||||||
ChannelId: proto.Uint32(uint32(channel.Id)),
|
ChannelId: proto.Uint32(uint32(channel.Id)),
|
||||||
Permissions: proto.Uint32(uint32(perm)),
|
Permissions: proto.Uint32(uint32(perm)),
|
||||||
})
|
})
|
||||||
|
|
@ -826,39 +826,39 @@ func (server *Server) broadcastProtoMessage(kind uint16, msg interface{}) (err o
|
||||||
|
|
||||||
func (server *Server) handleIncomingMessage(client *Client, msg *Message) {
|
func (server *Server) handleIncomingMessage(client *Client, msg *Message) {
|
||||||
switch msg.kind {
|
switch msg.kind {
|
||||||
case MessageAuthenticate:
|
case mumbleproto.MessageAuthenticate:
|
||||||
server.handleAuthenticate(msg.client, msg)
|
server.handleAuthenticate(msg.client, msg)
|
||||||
case MessagePing:
|
case mumbleproto.MessagePing:
|
||||||
server.handlePingMessage(msg.client, msg)
|
server.handlePingMessage(msg.client, msg)
|
||||||
case MessageChannelRemove:
|
case mumbleproto.MessageChannelRemove:
|
||||||
server.handleChannelRemoveMessage(msg.client, msg)
|
server.handleChannelRemoveMessage(msg.client, msg)
|
||||||
case MessageChannelState:
|
case mumbleproto.MessageChannelState:
|
||||||
server.handleChannelStateMessage(msg.client, msg)
|
server.handleChannelStateMessage(msg.client, msg)
|
||||||
case MessageUserState:
|
case mumbleproto.MessageUserState:
|
||||||
server.handleUserStateMessage(msg.client, msg)
|
server.handleUserStateMessage(msg.client, msg)
|
||||||
case MessageUserRemove:
|
case mumbleproto.MessageUserRemove:
|
||||||
server.handleUserRemoveMessage(msg.client, msg)
|
server.handleUserRemoveMessage(msg.client, msg)
|
||||||
case MessageBanList:
|
case mumbleproto.MessageBanList:
|
||||||
server.handleBanListMessage(msg.client, msg)
|
server.handleBanListMessage(msg.client, msg)
|
||||||
case MessageTextMessage:
|
case mumbleproto.MessageTextMessage:
|
||||||
server.handleTextMessage(msg.client, msg)
|
server.handleTextMessage(msg.client, msg)
|
||||||
case MessageACL:
|
case mumbleproto.MessageACL:
|
||||||
server.handleAclMessage(msg.client, msg)
|
server.handleAclMessage(msg.client, msg)
|
||||||
case MessageQueryUsers:
|
case mumbleproto.MessageQueryUsers:
|
||||||
server.handleQueryUsers(msg.client, msg)
|
server.handleQueryUsers(msg.client, msg)
|
||||||
case MessageCryptSetup:
|
case mumbleproto.MessageCryptSetup:
|
||||||
server.handleCryptSetup(msg.client, msg)
|
server.handleCryptSetup(msg.client, msg)
|
||||||
case MessageContextAction:
|
case mumbleproto.MessageContextAction:
|
||||||
server.Printf("MessageContextAction from client")
|
server.Printf("MessageContextAction from client")
|
||||||
case MessageUserList:
|
case mumbleproto.MessageUserList:
|
||||||
server.handleUserList(msg.client, msg)
|
server.handleUserList(msg.client, msg)
|
||||||
case MessageVoiceTarget:
|
case mumbleproto.MessageVoiceTarget:
|
||||||
server.Printf("MessageVoiceTarget from client")
|
server.Printf("MessageVoiceTarget from client")
|
||||||
case MessagePermissionQuery:
|
case mumbleproto.MessagePermissionQuery:
|
||||||
server.handlePermissionQuery(msg.client, msg)
|
server.handlePermissionQuery(msg.client, msg)
|
||||||
case MessageUserStats:
|
case mumbleproto.MessageUserStats:
|
||||||
server.handleUserStatsMessage(msg.client, msg)
|
server.handleUserStatsMessage(msg.client, msg)
|
||||||
case MessageRequestBlob:
|
case mumbleproto.MessageRequestBlob:
|
||||||
server.handleRequestBlob(msg.client, msg)
|
server.handleRequestBlob(msg.client, msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1120,7 +1120,7 @@ func (server *Server) RemoveChannel(channel *Channel) {
|
||||||
userstate.Session = proto.Uint32(client.Session)
|
userstate.Session = proto.Uint32(client.Session)
|
||||||
userstate.ChannelId = proto.Uint32(uint32(target.Id))
|
userstate.ChannelId = proto.Uint32(uint32(target.Id))
|
||||||
server.userEnterChannel(client, target, userstate)
|
server.userEnterChannel(client, target, userstate)
|
||||||
if err := server.broadcastProtoMessage(MessageUserState, userstate); err != nil {
|
if err := server.broadcastProtoMessage(mumbleproto.MessageUserState, userstate); err != nil {
|
||||||
server.Panicf("%v", err)
|
server.Panicf("%v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1132,7 +1132,7 @@ func (server *Server) RemoveChannel(channel *Channel) {
|
||||||
chanremove := &mumbleproto.ChannelRemove{
|
chanremove := &mumbleproto.ChannelRemove{
|
||||||
ChannelId: proto.Uint32(uint32(channel.Id)),
|
ChannelId: proto.Uint32(uint32(channel.Id)),
|
||||||
}
|
}
|
||||||
if err := server.broadcastProtoMessage(MessageChannelRemove, chanremove); err != nil {
|
if err := server.broadcastProtoMessage(mumbleproto.MessageChannelRemove, chanremove); err != nil {
|
||||||
server.Panicf("%v", err)
|
server.Panicf("%v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue