From 214a6a13861b9fd495797386f36507373728e577 Mon Sep 17 00:00:00 2001 From: Sebastian P <5564491+s3lph@users.noreply.github.com> Date: Thu, 1 Oct 2020 22:50:56 +0200 Subject: [PATCH] Add Mumble support (#1245) --- README.md | 2 + bridge/config/config.go | 1 + bridge/mumble/handlers.go | 90 + bridge/mumble/helpers.go | 143 + bridge/mumble/mumble.go | 259 ++ gateway/bridgemap/bmumble.go | 11 + go.mod | 2 + go.sum | 6 + matterbridge.toml.sample | 48 + .../vincent-petithory/dataurl/LICENSE | 20 + .../vincent-petithory/dataurl/README.md | 81 + .../vincent-petithory/dataurl/dataurl.go | 291 ++ .../vincent-petithory/dataurl/doc.go | 28 + .../vincent-petithory/dataurl/lex.go | 521 +++ .../vincent-petithory/dataurl/rfc2396.go | 130 + .../vincent-petithory/dataurl/wercker.yml | 1 + vendor/layeh.com/gumble/LICENSE | 373 ++ .../gumble/gumble/MumbleProto/LICENSE | 37 + .../gumble/gumble/MumbleProto/Mumble.pb.go | 3085 +++++++++++++++++ .../gumble/gumble/MumbleProto/generate.go | 2 + .../layeh.com/gumble/gumble/accesstokens.go | 16 + vendor/layeh.com/gumble/gumble/acl.go | 116 + vendor/layeh.com/gumble/gumble/audio.go | 85 + vendor/layeh.com/gumble/gumble/audiocodec.go | 55 + .../layeh.com/gumble/gumble/audiolisteners.go | 46 + vendor/layeh.com/gumble/gumble/bans.go | 101 + vendor/layeh.com/gumble/gumble/channel.go | 207 ++ vendor/layeh.com/gumble/gumble/channels.go | 28 + vendor/layeh.com/gumble/gumble/client.go | 289 ++ vendor/layeh.com/gumble/gumble/config.go | 53 + vendor/layeh.com/gumble/gumble/conn.go | 200 ++ .../layeh.com/gumble/gumble/contextaction.go | 57 + .../layeh.com/gumble/gumble/contextactions.go | 12 + vendor/layeh.com/gumble/gumble/detacher.go | 7 + vendor/layeh.com/gumble/gumble/doc.go | 45 + vendor/layeh.com/gumble/gumble/event.go | 223 ++ vendor/layeh.com/gumble/gumble/handlers.go | 1261 +++++++ vendor/layeh.com/gumble/gumble/listeners.go | 153 + vendor/layeh.com/gumble/gumble/message.go | 13 + vendor/layeh.com/gumble/gumble/permission.go | 33 + vendor/layeh.com/gumble/gumble/ping.go | 108 + vendor/layeh.com/gumble/gumble/reject.go | 61 + vendor/layeh.com/gumble/gumble/rpwmutex.go | 36 + vendor/layeh.com/gumble/gumble/textmessage.go | 45 + vendor/layeh.com/gumble/gumble/user.go | 233 ++ vendor/layeh.com/gumble/gumble/userlist.go | 74 + vendor/layeh.com/gumble/gumble/users.go | 30 + vendor/layeh.com/gumble/gumble/userstats.go | 62 + vendor/layeh.com/gumble/gumble/varint/read.go | 52 + .../layeh.com/gumble/gumble/varint/write.go | 64 + vendor/layeh.com/gumble/gumble/version.go | 24 + vendor/layeh.com/gumble/gumble/voicetarget.go | 76 + vendor/layeh.com/gumble/gumbleutil/acl.go | 55 + vendor/layeh.com/gumble/gumbleutil/bitrate.go | 27 + vendor/layeh.com/gumble/gumbleutil/channel.go | 18 + vendor/layeh.com/gumble/gumbleutil/doc.go | 2 + .../layeh.com/gumble/gumbleutil/listener.go | 100 + .../gumble/gumbleutil/listenerfunc.go | 80 + vendor/layeh.com/gumble/gumbleutil/main.go | 79 + .../gumble/gumbleutil/textmessage.go | 45 + vendor/modules.txt | 7 + 61 files changed, 9409 insertions(+) create mode 100644 bridge/mumble/handlers.go create mode 100644 bridge/mumble/helpers.go create mode 100644 bridge/mumble/mumble.go create mode 100644 gateway/bridgemap/bmumble.go create mode 100644 vendor/github.com/vincent-petithory/dataurl/LICENSE create mode 100644 vendor/github.com/vincent-petithory/dataurl/README.md create mode 100644 vendor/github.com/vincent-petithory/dataurl/dataurl.go create mode 100644 vendor/github.com/vincent-petithory/dataurl/doc.go create mode 100644 vendor/github.com/vincent-petithory/dataurl/lex.go create mode 100644 vendor/github.com/vincent-petithory/dataurl/rfc2396.go create mode 100644 vendor/github.com/vincent-petithory/dataurl/wercker.yml create mode 100644 vendor/layeh.com/gumble/LICENSE create mode 100644 vendor/layeh.com/gumble/gumble/MumbleProto/LICENSE create mode 100644 vendor/layeh.com/gumble/gumble/MumbleProto/Mumble.pb.go create mode 100644 vendor/layeh.com/gumble/gumble/MumbleProto/generate.go create mode 100644 vendor/layeh.com/gumble/gumble/accesstokens.go create mode 100644 vendor/layeh.com/gumble/gumble/acl.go create mode 100644 vendor/layeh.com/gumble/gumble/audio.go create mode 100644 vendor/layeh.com/gumble/gumble/audiocodec.go create mode 100644 vendor/layeh.com/gumble/gumble/audiolisteners.go create mode 100644 vendor/layeh.com/gumble/gumble/bans.go create mode 100644 vendor/layeh.com/gumble/gumble/channel.go create mode 100644 vendor/layeh.com/gumble/gumble/channels.go create mode 100644 vendor/layeh.com/gumble/gumble/client.go create mode 100644 vendor/layeh.com/gumble/gumble/config.go create mode 100644 vendor/layeh.com/gumble/gumble/conn.go create mode 100644 vendor/layeh.com/gumble/gumble/contextaction.go create mode 100644 vendor/layeh.com/gumble/gumble/contextactions.go create mode 100644 vendor/layeh.com/gumble/gumble/detacher.go create mode 100644 vendor/layeh.com/gumble/gumble/doc.go create mode 100644 vendor/layeh.com/gumble/gumble/event.go create mode 100644 vendor/layeh.com/gumble/gumble/handlers.go create mode 100644 vendor/layeh.com/gumble/gumble/listeners.go create mode 100644 vendor/layeh.com/gumble/gumble/message.go create mode 100644 vendor/layeh.com/gumble/gumble/permission.go create mode 100644 vendor/layeh.com/gumble/gumble/ping.go create mode 100644 vendor/layeh.com/gumble/gumble/reject.go create mode 100644 vendor/layeh.com/gumble/gumble/rpwmutex.go create mode 100644 vendor/layeh.com/gumble/gumble/textmessage.go create mode 100644 vendor/layeh.com/gumble/gumble/user.go create mode 100644 vendor/layeh.com/gumble/gumble/userlist.go create mode 100644 vendor/layeh.com/gumble/gumble/users.go create mode 100644 vendor/layeh.com/gumble/gumble/userstats.go create mode 100644 vendor/layeh.com/gumble/gumble/varint/read.go create mode 100644 vendor/layeh.com/gumble/gumble/varint/write.go create mode 100644 vendor/layeh.com/gumble/gumble/version.go create mode 100644 vendor/layeh.com/gumble/gumble/voicetarget.go create mode 100644 vendor/layeh.com/gumble/gumbleutil/acl.go create mode 100644 vendor/layeh.com/gumble/gumbleutil/bitrate.go create mode 100644 vendor/layeh.com/gumble/gumbleutil/channel.go create mode 100644 vendor/layeh.com/gumble/gumbleutil/doc.go create mode 100644 vendor/layeh.com/gumble/gumbleutil/listener.go create mode 100644 vendor/layeh.com/gumble/gumbleutil/listenerfunc.go create mode 100644 vendor/layeh.com/gumble/gumbleutil/main.go create mode 100644 vendor/layeh.com/gumble/gumbleutil/textmessage.go diff --git a/README.md b/README.md index 66ce3b65..c38e2058 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,7 @@ And more... - [Matrix](https://matrix.org) - [Mattermost](https://github.com/mattermost/mattermost-server/) 4.x, 5.x - [Microsoft Teams](https://teams.microsoft.com) +- [Mumble](https://www.mumble.info/) - [Nextcloud Talk](https://nextcloud.com/talk/) - [Rocket.chat](https://rocket.chat) - [Slack](https://slack.com) @@ -324,6 +325,7 @@ Matterbridge wouldn't exist without these libraries: - gitter - - gops - - gozulipbot - +- gumble - - irc - - keybase - - matrix - diff --git a/bridge/config/config.go b/bridge/config/config.go index f34da511..a1bce8dc 100644 --- a/bridge/config/config.go +++ b/bridge/config/config.go @@ -213,6 +213,7 @@ type BridgeValues struct { WhatsApp map[string]Protocol // TODO is this struct used? Search for "SlackLegacy" for example didn't return any results Zulip map[string]Protocol Keybase map[string]Protocol + Mumble map[string]Protocol General Protocol Tengo Tengo Gateway []Gateway diff --git a/bridge/mumble/handlers.go b/bridge/mumble/handlers.go new file mode 100644 index 00000000..a6845955 --- /dev/null +++ b/bridge/mumble/handlers.go @@ -0,0 +1,90 @@ +package bmumble + +import ( + "strconv" + "time" + + "layeh.com/gumble/gumble" + + "github.com/42wim/matterbridge/bridge/config" + "github.com/42wim/matterbridge/bridge/helper" +) + +func (b *Bmumble) handleServerConfig(event *gumble.ServerConfigEvent) { + b.serverConfigUpdate <- *event +} + +func (b *Bmumble) handleTextMessage(event *gumble.TextMessageEvent) { + sender := "unknown" + if event.TextMessage.Sender != nil { + sender = event.TextMessage.Sender.Name + } + // Convert Mumble HTML messages to markdown + parts, err := b.convertHTMLtoMarkdown(event.TextMessage.Message) + if err != nil { + b.Log.Error(err) + } + now := time.Now().UTC() + for i, part := range parts { + // Construct matterbridge message and pass on to the gateway + rmsg := config.Message{ + Channel: strconv.FormatUint(uint64(event.Client.Self.Channel.ID), 10), + Username: sender, + UserID: sender + "@" + b.Host, + Account: b.Account, + } + if part.Image == nil { + rmsg.Text = part.Text + } else { + fname := b.Account + "_" + strconv.FormatInt(now.UnixNano(), 10) + "_" + strconv.Itoa(i) + part.FileExtension + rmsg.Extra = make(map[string][]interface{}) + if err = helper.HandleDownloadSize(b.Log, &rmsg, fname, int64(len(part.Image)), b.General); err != nil { + b.Log.WithError(err).Warn("not including image in message") + continue + } + helper.HandleDownloadData(b.Log, &rmsg, fname, "", "", &part.Image, b.General) + } + b.Log.Debugf("Sending message to gateway: %+v", rmsg) + b.Remote <- rmsg + } +} + +func (b *Bmumble) handleConnect(event *gumble.ConnectEvent) { + // Set the user's "bio"/comment + if comment := b.GetString("UserComment"); comment != "" && event.Client.Self != nil { + event.Client.Self.SetComment(comment) + } + // No need to talk or listen + event.Client.Self.SetSelfDeafened(true) + event.Client.Self.SetSelfMuted(true) + // if the Channel variable is set, this is a reconnect -> rejoin channel + if b.Channel != nil { + if err := b.doJoin(event.Client, *b.Channel); err != nil { + b.Log.Error(err) + } + b.Remote <- config.Message{ + Username: "system", + Text: "rejoin", + Channel: "", + Account: b.Account, + Event: config.EventRejoinChannels, + } + } +} + +func (b *Bmumble) handleUserChange(event *gumble.UserChangeEvent) { + // Only care about changes to self + if event.User != event.Client.Self { + return + } + // Someone attempted to move the user out of the configured channel; attempt to join back + if b.Channel != nil { + if err := b.doJoin(event.Client, *b.Channel); err != nil { + b.Log.Error(err) + } + } +} + +func (b *Bmumble) handleDisconnect(event *gumble.DisconnectEvent) { + b.connected <- *event +} diff --git a/bridge/mumble/helpers.go b/bridge/mumble/helpers.go new file mode 100644 index 00000000..c828df2c --- /dev/null +++ b/bridge/mumble/helpers.go @@ -0,0 +1,143 @@ +package bmumble + +import ( + "fmt" + "mime" + "net/http" + "regexp" + "strings" + + "github.com/42wim/matterbridge/bridge/config" + "github.com/mattn/godown" + "github.com/vincent-petithory/dataurl" +) + +type MessagePart struct { + Text string + FileExtension string + Image []byte +} + +func (b *Bmumble) decodeImage(uri string, parts *[]MessagePart) error { + // Decode the data:image/... URI + image, err := dataurl.DecodeString(uri) + if err != nil { + b.Log.WithError(err).Info("No image extracted") + return err + } + // Determine the file extensions for that image + ext, err := mime.ExtensionsByType(image.MediaType.ContentType()) + if err != nil || len(ext) == 0 { + b.Log.WithError(err).Infof("No file extension registered for MIME type '%s'", image.MediaType.ContentType()) + return err + } + // Add the image to the MessagePart slice + *parts = append(*parts, MessagePart{"", ext[0], image.Data}) + return nil +} + +func (b *Bmumble) tokenize(t *string) ([]MessagePart, error) { + // `^(.*?)` matches everything before the image + // `!\[[^\]]*\]\(` matches the `![alt](` part of markdown images + // `(data:image\/[^)]+)` matches the data: URI used by Mumble + // `\)` matches the closing parenthesis after the URI + // `(.*)$` matches the remaining text to be examined in the next iteration + p := regexp.MustCompile(`^(?ms)(.*?)!\[[^\]]*\]\((data:image\/[^)]+)\)(.*)$`) + remaining := *t + var parts []MessagePart + for { + tokens := p.FindStringSubmatch(remaining) + if tokens == nil { + // no match -> remaining string is non-image text + pre := strings.TrimSpace(remaining) + if len(pre) > 0 { + parts = append(parts, MessagePart{pre, "", nil}) + } + return parts, nil + } + + // tokens[1] is the text before the image + if len(tokens[1]) > 0 { + pre := strings.TrimSpace(tokens[1]) + parts = append(parts, MessagePart{pre, "", nil}) + } + // tokens[2] is the image URL + uri, err := dataurl.UnescapeToString(strings.TrimSpace(strings.ReplaceAll(tokens[2], " ", ""))) + if err != nil { + b.Log.WithError(err).Info("URL unescaping failed") + remaining = strings.TrimSpace(tokens[3]) + continue + } + err = b.decodeImage(uri, &parts) + if err != nil { + b.Log.WithError(err).Info("Decoding the image failed") + } + // tokens[3] is the text after the image, processed in the next iteration + remaining = strings.TrimSpace(tokens[3]) + } +} + +func (b *Bmumble) convertHTMLtoMarkdown(html string) ([]MessagePart, error) { + var sb strings.Builder + err := godown.Convert(&sb, strings.NewReader(html), nil) + if err != nil { + return nil, err + } + markdown := sb.String() + b.Log.Debugf("### to markdown: %s", markdown) + return b.tokenize(&markdown) +} + +func (b *Bmumble) extractFiles(msg *config.Message) []config.Message { + var messages []config.Message + if msg.Extra == nil || len(msg.Extra["file"]) == 0 { + return messages + } + // Create a separate message for each file + for _, f := range msg.Extra["file"] { + fi := f.(config.FileInfo) + imsg := config.Message{ + Channel: msg.Channel, + Username: msg.Username, + UserID: msg.UserID, + Account: msg.Account, + Protocol: msg.Protocol, + Timestamp: msg.Timestamp, + Event: "mumble_image", + } + // If no data is present for the file, send a link instead + if fi.Data == nil || len(*fi.Data) == 0 { + if len(fi.URL) > 0 { + imsg.Text = fmt.Sprintf(`%s`, fi.URL, fi.URL) + messages = append(messages, imsg) + } else { + b.Log.Infof("Not forwarding file without local data") + } + continue + } + mimeType := http.DetectContentType(*fi.Data) + // Mumble only supports images natively, send a link instead + if !strings.HasPrefix(mimeType, "image/") { + if len(fi.URL) > 0 { + imsg.Text = fmt.Sprintf(`%s`, fi.URL, fi.URL) + messages = append(messages, imsg) + } else { + b.Log.Infof("Not forwarding file of type %s", mimeType) + } + continue + } + mimeType = strings.TrimSpace(strings.Split(mimeType, ";")[0]) + // Build data:image/...;base64,... style image URL and embed image directly into the message + du := dataurl.New(*fi.Data, mimeType) + dataURL, err := du.MarshalText() + if err != nil { + b.Log.WithError(err).Infof("Image Serialization into data URL failed (type: %s, length: %d)", mimeType, len(*fi.Data)) + continue + } + imsg.Text = fmt.Sprintf(``, dataURL) + messages = append(messages, imsg) + } + // Remove files from original message + msg.Extra["file"] = nil + return messages +} diff --git a/bridge/mumble/mumble.go b/bridge/mumble/mumble.go new file mode 100644 index 00000000..2281d1c2 --- /dev/null +++ b/bridge/mumble/mumble.go @@ -0,0 +1,259 @@ +package bmumble + +import ( + "crypto/tls" + "crypto/x509" + "errors" + "fmt" + "io/ioutil" + "net" + "strconv" + "time" + + "layeh.com/gumble/gumble" + "layeh.com/gumble/gumbleutil" + + "github.com/42wim/matterbridge/bridge" + "github.com/42wim/matterbridge/bridge/config" + "github.com/42wim/matterbridge/bridge/helper" + stripmd "github.com/writeas/go-strip-markdown" + + // We need to import the 'data' package as an implicit dependency. + // See: https://godoc.org/github.com/paulrosania/go-charset/charset + _ "github.com/paulrosania/go-charset/data" +) + +type Bmumble struct { + client *gumble.Client + Nick string + Host string + Channel *uint32 + local chan config.Message + running chan error + connected chan gumble.DisconnectEvent + serverConfigUpdate chan gumble.ServerConfigEvent + serverConfig gumble.ServerConfigEvent + tlsConfig tls.Config + + *bridge.Config +} + +func New(cfg *bridge.Config) bridge.Bridger { + b := &Bmumble{} + b.Config = cfg + b.Nick = b.GetString("Nick") + b.local = make(chan config.Message) + b.running = make(chan error) + b.connected = make(chan gumble.DisconnectEvent) + b.serverConfigUpdate = make(chan gumble.ServerConfigEvent) + return b +} + +func (b *Bmumble) Connect() error { + b.Log.Infof("Connecting %s", b.GetString("Server")) + host, portstr, err := net.SplitHostPort(b.GetString("Server")) + if err != nil { + return err + } + b.Host = host + _, err = strconv.Atoi(portstr) + if err != nil { + return err + } + + if err = b.buildTLSConfig(); err != nil { + return err + } + + go b.doSend() + go b.connectLoop() + err = <-b.running + return err +} + +func (b *Bmumble) Disconnect() error { + return b.client.Disconnect() +} + +func (b *Bmumble) JoinChannel(channel config.ChannelInfo) error { + cid, err := strconv.ParseUint(channel.Name, 10, 32) + if err != nil { + return err + } + channelID := uint32(cid) + if b.Channel != nil && *b.Channel != channelID { + b.Log.Fatalf("Cannot join channel ID '%d', already joined to channel ID %d", channelID, *b.Channel) + return errors.New("the Mumble bridge can only join a single channel") + } + b.Channel = &channelID + return b.doJoin(b.client, channelID) +} + +func (b *Bmumble) Send(msg config.Message) (string, error) { + // Only process text messages + b.Log.Debugf("=> Received local message %#v", msg) + if msg.Event != "" && msg.Event != config.EventUserAction { + return "", nil + } + + attachments := b.extractFiles(&msg) + b.local <- msg + for _, a := range attachments { + b.local <- a + } + return "", nil +} + +func (b *Bmumble) buildTLSConfig() error { + b.tlsConfig = tls.Config{} + // Load TLS client certificate keypair required for registered user authentication + if cpath := b.GetString("TLSClientCertificate"); cpath != "" { + if ckey := b.GetString("TLSClientKey"); ckey != "" { + cert, err := tls.LoadX509KeyPair(cpath, ckey) + if err != nil { + return err + } + b.tlsConfig.Certificates = []tls.Certificate{cert} + } + } + // Load TLS CA used for server verification. If not provided, the Go system trust anchor is used + if capath := b.GetString("TLSCACertificate"); capath != "" { + ca, err := ioutil.ReadFile(capath) + if err != nil { + return err + } + b.tlsConfig.RootCAs = x509.NewCertPool() + b.tlsConfig.RootCAs.AppendCertsFromPEM(ca) + } + b.tlsConfig.InsecureSkipVerify = b.GetBool("SkipTLSVerify") + return nil +} + +func (b *Bmumble) connectLoop() { + firstConnect := true + for { + err := b.doConnect() + if firstConnect { + b.running <- err + } + if err != nil { + b.Log.Errorf("Connection to server failed: %#v", err) + if firstConnect { + break + } else { + b.Log.Info("Retrying in 10s") + time.Sleep(10 * time.Second) + continue + } + } + firstConnect = false + d := <-b.connected + switch d.Type { + case gumble.DisconnectError: + b.Log.Errorf("Lost connection to the server (%s), attempting reconnect", d.String) + continue + case gumble.DisconnectKicked: + b.Log.Errorf("Kicked from the server (%s), attempting reconnect", d.String) + continue + case gumble.DisconnectBanned: + b.Log.Errorf("Banned from the server (%s), not attempting reconnect", d.String) + close(b.connected) + close(b.running) + return + case gumble.DisconnectUser: + b.Log.Infof("Disconnect successful") + close(b.connected) + close(b.running) + return + } + } +} + +func (b *Bmumble) doConnect() error { + // Create new gumble config and attach event handlers + gumbleConfig := gumble.NewConfig() + gumbleConfig.Attach(gumbleutil.Listener{ + ServerConfig: b.handleServerConfig, + TextMessage: b.handleTextMessage, + Connect: b.handleConnect, + Disconnect: b.handleDisconnect, + UserChange: b.handleUserChange, + }) + gumbleConfig.Username = b.GetString("Nick") + if password := b.GetString("Password"); password != "" { + gumbleConfig.Password = password + } + + client, err := gumble.DialWithDialer(new(net.Dialer), b.GetString("Server"), gumbleConfig, &b.tlsConfig) + if err != nil { + return err + } + b.client = client + return nil +} + +func (b *Bmumble) doJoin(client *gumble.Client, channelID uint32) error { + channel, ok := client.Channels[channelID] + if !ok { + return fmt.Errorf("no channel with ID %d", channelID) + } + client.Self.Move(channel) + return nil +} + +func (b *Bmumble) doSend() { + // Message sending loop that makes sure server-side + // restrictions and client-side message traits don't conflict + // with each other. + for { + select { + case serverConfig := <-b.serverConfigUpdate: + b.Log.Debugf("Received server config update: AllowHTML=%#v, MaximumMessageLength=%#v", serverConfig.AllowHTML, serverConfig.MaximumMessageLength) + b.serverConfig = serverConfig + case msg := <-b.local: + b.processMessage(&msg) + } + } +} + +func (b *Bmumble) processMessage(msg *config.Message) { + b.Log.Debugf("Processing message %s", msg.Text) + + allowHTML := true + if b.serverConfig.AllowHTML != nil { + allowHTML = *b.serverConfig.AllowHTML + } + + // If this is a specially generated image message, send it unmodified + if msg.Event == "mumble_image" { + if allowHTML { + b.client.Self.Channel.Send(msg.Username+msg.Text, false) + } else { + b.Log.Info("Can't send image, server does not allow HTML messages") + } + return + } + + // Don't process empty messages + if len(msg.Text) == 0 { + return + } + // If HTML is allowed, convert markdown into HTML, otherwise strip markdown + if allowHTML { + msg.Text = helper.ParseMarkdown(msg.Text) + } else { + msg.Text = stripmd.Strip(msg.Text) + } + + // If there is a maximum message length, split and truncate the lines + var msgLines []string + if maxLength := b.serverConfig.MaximumMessageLength; maxLength != nil { + msgLines = helper.GetSubLines(msg.Text, *maxLength-len(msg.Username)) + } else { + msgLines = helper.GetSubLines(msg.Text, 0) + } + // Send the individual lindes + for i := range msgLines { + b.client.Self.Channel.Send(msg.Username+msgLines[i], false) + } +} diff --git a/gateway/bridgemap/bmumble.go b/gateway/bridgemap/bmumble.go new file mode 100644 index 00000000..7b9241fe --- /dev/null +++ b/gateway/bridgemap/bmumble.go @@ -0,0 +1,11 @@ +// +build !nomumble + +package bridgemap + +import ( + bmumble "github.com/42wim/matterbridge/bridge/mumble" +) + +func init() { + FullMap["mumble"] = bmumble.New +} diff --git a/go.mod b/go.mod index f0c244d2..bf5513ad 100644 --- a/go.mod +++ b/go.mod @@ -43,6 +43,7 @@ require ( github.com/slack-go/slack v0.6.6 github.com/spf13/viper v1.7.1 github.com/stretchr/testify v1.6.1 + github.com/vincent-petithory/dataurl v0.0.0-20191104211930-d1553a71de50 github.com/writeas/go-strip-markdown v2.0.1+incompatible github.com/x-cray/logrus-prefixed-formatter v0.5.2 // indirect github.com/yaegashi/msgraph.go v0.1.4 @@ -51,6 +52,7 @@ require ( golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43 gomod.garykim.dev/nc-talk v0.1.3 gopkg.in/olahol/melody.v1 v1.0.0-20170518105555-d52139073376 + layeh.com/gumble v0.0.0-20200818122324-146f9205029b ) go 1.13 diff --git a/go.sum b/go.sum index 97cb5b85..bda19a2b 100644 --- a/go.sum +++ b/go.sum @@ -145,6 +145,7 @@ github.com/d5/tengo/v2 v2.6.0/go.mod h1:XRGjEs5I9jYIKTxly6HCF8oiiilk5E/RYXOZ5b0D github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dchote/go-openal v0.0.0-20171116030048-f4a9a141d372/go.mod h1:74z+CYu2/mx4N+mcIS/rsvfAxBPBV9uv8zRAnwyFkdI= github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/dgoogauth v0.0.0-20190221195224-5a805980a5f3/go.mod h1:hEfFauPHz7+NnjR/yHJGhrKo1Za+zStgwUETx3yzqgY= @@ -691,6 +692,8 @@ github.com/valyala/fasttemplate v1.2.1 h1:TVEnxayobAdVkhQfrfes2IzOB6o+z4roRkPF52 github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= github.com/viant/assertly v0.4.8/go.mod h1:aGifi++jvCrUaklKEKT0BU95igDNaqkvz+49uaYMPRU= github.com/viant/toolbox v0.24.0/go.mod h1:OxMCG57V0PXuIP2HNQrtJf2CjqdmbrOx5EkMILuUhzM= +github.com/vincent-petithory/dataurl v0.0.0-20191104211930-d1553a71de50 h1:uxE3GYdXIOfhMv3unJKETJEhw78gvzuQqRX/rVirc2A= +github.com/vincent-petithory/dataurl v0.0.0-20191104211930-d1553a71de50/go.mod h1:FHafX5vmDzyP+1CQATJn7WFKc9CvnvxyvZy6I1MrG/U= github.com/wiggin77/cfg v1.0.2/go.mod h1:b3gotba2e5bXTqTW48DwIFoLc+4lWKP7WPi/CdvZ4aE= github.com/wiggin77/logr v1.0.4/go.mod h1:h98FF6GPfThhDrHCg063hZA1sIyOEzQ/P85wgqI0IqE= github.com/wiggin77/merror v1.0.2/go.mod h1:uQTcIU0Z6jRK4OwqganPYerzQxSFJ4GSHM3aurxxQpg= @@ -1134,6 +1137,9 @@ honnef.co/go/tools v0.0.1-2020.1.3 h1:sXmLre5bzIR6ypkjXCDI3jHPssRhc8KD/Ome589sc3 honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4 h1:UoveltGrhghAA7ePc+e+QYDHXrBps2PqFZiHkGR/xK8= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +layeh.com/gopus v0.0.0-20161224163843-0ebf989153aa/go.mod h1:AOef7vHz0+v4sWwJnr0jSyHiX/1NgsMoaxl+rEPz/I0= +layeh.com/gumble v0.0.0-20200818122324-146f9205029b h1:Kne6wkHqbqrygRsqs5XUNhSs84DFG5TYMeCkCbM56sY= +layeh.com/gumble v0.0.0-20200818122324-146f9205029b/go.mod h1:tWPVA9ZAfImNwabjcd9uDE+Mtz0Hfs7a7G3vxrnrwyc= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/goversion v1.2.0 h1:SPn+NLTiAG7w30IRK/DKp1BjvpWabYgxlLp/+kx5J8w= rsc.io/goversion v1.2.0/go.mod h1:Eih9y/uIBS3ulggl7KNJ09xGSLcuNaLgmvvqa07sgfo= diff --git a/matterbridge.toml.sample b/matterbridge.toml.sample index b1574f3d..c9263e7b 100644 --- a/matterbridge.toml.sample +++ b/matterbridge.toml.sample @@ -1405,6 +1405,52 @@ Login = "talkuser" # Password of the bot Password = "talkuserpass" +################################################################### +# +# Mumble +# +################################################################### + +[mumble.bridge] + +# Host and port of your Mumble server +Server = "mumble.yourdomain.me:64738" + +# Nickname to log in as +Nick = "matterbridge" + +# Some servers require a password +# OPTIONAL (default empty) +Password = "serverpasswordhere" + +# User comment to set on the Mumble user, visible to other users. +# OPTIONAL (default empty) +UserComment="I am bridging text messages between this channel and #general on irc.yourdomain.me" + +# Self-signed TLS client certificate + private key used to connect to +# Mumble. This is required if you want to register the matterbridge +# user on your Mumble server, so its nick becomes reserved. +# You can generate a keypair using e.g. +# +# openssl req -x509 -newkey rsa:2048 -nodes -days 10000 \ +# -keyout mumble.key -out mumble.crt +# +# To actually register the matterbridege user, connect to Mumble as an +# admin, right click on the user and click "Register". +# +# OPTIONAL (default empty) +TLSClientCertificate="mumble.crt" +TLSClientKey="mumble.key" + +# TLS CA certificate used to validate the Mumble server. +# OPTIONAL (defaults to Go system CA) +TLSCACertificate=mumble-ca.crt + +# Enable to not verify the certificate on your Mumble server. +# e.g. when using selfsigned certificates +# OPTIONAL (default false) +SkipTLSVerify=false + ################################################################### # # WhatsApp @@ -1745,6 +1791,8 @@ enable=true # ------------------------------------------------------------------------------------------------------------------------------------- # msteams | threadId | 19:82abcxx@thread.skype | You'll find the threadId in the URL # ------------------------------------------------------------------------------------------------------------------------------------- + # mumble | channel id | 42 | The channel ID, as shown in the channel's "Edit" window + # ------------------------------------------------------------------------------------------------------------------------------------- # rocketchat | channel | #channel | # is required for private channels too # ------------------------------------------------------------------------------------------------------------------------------------- # slack | channel name | general | Do not include the # symbol diff --git a/vendor/github.com/vincent-petithory/dataurl/LICENSE b/vendor/github.com/vincent-petithory/dataurl/LICENSE new file mode 100644 index 00000000..ae6cb62b --- /dev/null +++ b/vendor/github.com/vincent-petithory/dataurl/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2014 Vincent Petithory + +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/vendor/github.com/vincent-petithory/dataurl/README.md b/vendor/github.com/vincent-petithory/dataurl/README.md new file mode 100644 index 00000000..1ac59ad2 --- /dev/null +++ b/vendor/github.com/vincent-petithory/dataurl/README.md @@ -0,0 +1,81 @@ +# Data URL Schemes for Go [![wercker status](https://app.wercker.com/status/6f9a2e144dfcc59e862c52459b452928/s "wercker status")](https://app.wercker.com/project/bykey/6f9a2e144dfcc59e862c52459b452928) [![GoDoc](https://godoc.org/github.com/vincent-petithory/dataurl?status.png)](https://godoc.org/github.com/vincent-petithory/dataurl) + +This package parses and generates Data URL Schemes for the Go language, according to [RFC 2397](http://tools.ietf.org/html/rfc2397). + +Data URLs are small chunks of data commonly used in browsers to display inline data, +typically like small images, or when you use the FileReader API of the browser. + +Common use-cases: + + * generate a data URL out of a `string`, `[]byte`, `io.Reader` for inclusion in HTML templates, + * parse a data URL sent by a browser in a http.Handler, and do something with the data (save to disk, etc.) + * ... + +Install the package with: +~~~ +go get github.com/vincent-petithory/dataurl +~~~ + +## Usage + +~~~ go +package main + +import ( + "github.com/vincent-petithory/dataurl" + "fmt" +) + +func main() { + dataURL, err := dataurl.DecodeString(`data:text/plain;charset=utf-8;base64,aGV5YQ==`) + if err != nil { + fmt.Println(err) + return + } + fmt.Printf("content type: %s, data: %s\n", dataURL.MediaType.ContentType(), string(dataURL.Data)) + // Output: content type: text/plain, data: heya +} +~~~ + +From a `http.Handler`: + +~~~ go +func handleDataURLUpload(w http.ResponseWriter, r *http.Request) { + dataURL, err := dataurl.Decode(r.Body) + defer r.Body.Close() + if err != nil { + http.Error(w, err.Error(), http.StatusBadRequest) + return + } + if dataURL.ContentType() == "image/png" { + ioutil.WriteFile("image.png", dataURL.Data, 0644) + } else { + http.Error(w, "not a png", http.StatusBadRequest) + } +} +~~~ + +## Command + +For convenience, a `dataurl` command is provided to encode/decode dataurl streams. + +~~~ +dataurl - Encode or decode dataurl data and print to standard output + +Usage: dataurl [OPTION]... [FILE] + + dataurl encodes or decodes FILE or standard input if FILE is - or omitted, and prints to standard output. + Unless -mimetype is used, when FILE is specified, dataurl will attempt to detect its mimetype using Go's mime.TypeByExtension (http://golang.org/pkg/mime/#TypeByExtension). If this fails or data is read from STDIN, the mimetype will default to application/octet-stream. + +Options: + -a=false: encode data using ascii instead of base64 + -ascii=false: encode data using ascii instead of base64 + -d=false: decode data instead of encoding + -decode=false: decode data instead of encoding + -m="": force the mimetype of the data to encode to this value + -mimetype="": force the mimetype of the data to encode to this value +~~~ + +## Contributing + +Feel free to file an issue/make a pull request if you find any bug, or want to suggest enhancements. diff --git a/vendor/github.com/vincent-petithory/dataurl/dataurl.go b/vendor/github.com/vincent-petithory/dataurl/dataurl.go new file mode 100644 index 00000000..7a9fe67e --- /dev/null +++ b/vendor/github.com/vincent-petithory/dataurl/dataurl.go @@ -0,0 +1,291 @@ +package dataurl + +import ( + "bytes" + "encoding/base64" + "errors" + "fmt" + "io" + "io/ioutil" + "net/http" + "sort" + "strconv" + "strings" +) + +const ( + // EncodingBase64 is base64 encoding for the data url + EncodingBase64 = "base64" + // EncodingASCII is ascii encoding for the data url + EncodingASCII = "ascii" +) + +func defaultMediaType() MediaType { + return MediaType{ + "text", + "plain", + map[string]string{"charset": "US-ASCII"}, + } +} + +// MediaType is the combination of a media type, a media subtype +// and optional parameters. +type MediaType struct { + Type string + Subtype string + Params map[string]string +} + +// ContentType returns the content type of the dataurl's data, in the form type/subtype. +func (mt *MediaType) ContentType() string { + return fmt.Sprintf("%s/%s", mt.Type, mt.Subtype) +} + +// String implements the Stringer interface. +// +// Params values are escaped with the Escape function, rather than in a quoted string. +func (mt *MediaType) String() string { + var ( + buf bytes.Buffer + keys = make([]string, len(mt.Params)) + i int + ) + for k := range mt.Params { + keys[i] = k + i++ + } + sort.Strings(keys) + for _, k := range keys { + v := mt.Params[k] + fmt.Fprintf(&buf, ";%s=%s", k, EscapeString(v)) + } + return mt.ContentType() + (&buf).String() +} + +// DataURL is the combination of a MediaType describing the type of its Data. +type DataURL struct { + MediaType + Encoding string + Data []byte +} + +// New returns a new DataURL initialized with data and +// a MediaType parsed from mediatype and paramPairs. +// mediatype must be of the form "type/subtype" or it will panic. +// paramPairs must have an even number of elements or it will panic. +// For more complex DataURL, initialize a DataURL struct. +// The DataURL is initialized with base64 encoding. +func New(data []byte, mediatype string, paramPairs ...string) *DataURL { + parts := strings.Split(mediatype, "/") + if len(parts) != 2 { + panic("dataurl: invalid mediatype") + } + + nParams := len(paramPairs) + if nParams%2 != 0 { + panic("dataurl: requires an even number of param pairs") + } + params := make(map[string]string) + for i := 0; i < nParams; i += 2 { + params[paramPairs[i]] = paramPairs[i+1] + } + + mt := MediaType{ + parts[0], + parts[1], + params, + } + return &DataURL{ + MediaType: mt, + Encoding: EncodingBase64, + Data: data, + } +} + +// String implements the Stringer interface. +// +// Note: it doesn't guarantee the returned string is equal to +// the initial source string that was used to create this DataURL. +// The reasons for that are: +// * Insertion of default values for MediaType that were maybe not in the initial string, +// * Various ways to encode the MediaType parameters (quoted string or url encoded string, the latter is used), +func (du *DataURL) String() string { + var buf bytes.Buffer + du.WriteTo(&buf) + return (&buf).String() +} + +// WriteTo implements the WriterTo interface. +// See the note about String(). +func (du *DataURL) WriteTo(w io.Writer) (n int64, err error) { + var ni int + ni, _ = fmt.Fprint(w, "data:") + n += int64(ni) + + ni, _ = fmt.Fprint(w, du.MediaType.String()) + n += int64(ni) + + if du.Encoding == EncodingBase64 { + ni, _ = fmt.Fprint(w, ";base64") + n += int64(ni) + } + + ni, _ = fmt.Fprint(w, ",") + n += int64(ni) + + if du.Encoding == EncodingBase64 { + encoder := base64.NewEncoder(base64.StdEncoding, w) + ni, err = encoder.Write(du.Data) + if err != nil { + return + } + encoder.Close() + } else if du.Encoding == EncodingASCII { + ni, _ = fmt.Fprint(w, Escape(du.Data)) + n += int64(ni) + } else { + err = fmt.Errorf("dataurl: invalid encoding %s", du.Encoding) + return + } + + return +} + +// UnmarshalText decodes a Data URL string and sets it to *du +func (du *DataURL) UnmarshalText(text []byte) error { + decoded, err := DecodeString(string(text)) + if err != nil { + return err + } + *du = *decoded + return nil +} + +// MarshalText writes du as a Data URL +func (du *DataURL) MarshalText() ([]byte, error) { + buf := bytes.NewBuffer(nil) + if _, err := du.WriteTo(buf); err != nil { + return nil, err + } + return buf.Bytes(), nil +} + +type encodedDataReader func(string) ([]byte, error) + +var asciiDataReader encodedDataReader = func(s string) ([]byte, error) { + us, err := Unescape(s) + if err != nil { + return nil, err + } + return []byte(us), nil +} + +var base64DataReader encodedDataReader = func(s string) ([]byte, error) { + data, err := base64.StdEncoding.DecodeString(s) + if err != nil { + return nil, err + } + return []byte(data), nil +} + +type parser struct { + du *DataURL + l *lexer + currentAttr string + unquoteParamVal bool + encodedDataReaderFn encodedDataReader +} + +func (p *parser) parse() error { + for item := range p.l.items { + switch item.t { + case itemError: + return errors.New(item.String()) + case itemMediaType: + p.du.MediaType.Type = item.val + // Should we clear the default + // "charset" parameter at this point? + delete(p.du.MediaType.Params, "charset") + case itemMediaSubType: + p.du.MediaType.Subtype = item.val + case itemParamAttr: + p.currentAttr = item.val + case itemLeftStringQuote: + p.unquoteParamVal = true + case itemParamVal: + val := item.val + if p.unquoteParamVal { + p.unquoteParamVal = false + us, err := strconv.Unquote("\"" + val + "\"") + if err != nil { + return err + } + val = us + } else { + us, err := UnescapeToString(val) + if err != nil { + return err + } + val = us + } + p.du.MediaType.Params[p.currentAttr] = val + case itemBase64Enc: + p.du.Encoding = EncodingBase64 + p.encodedDataReaderFn = base64DataReader + case itemDataComma: + if p.encodedDataReaderFn == nil { + p.encodedDataReaderFn = asciiDataReader + } + case itemData: + reader, err := p.encodedDataReaderFn(item.val) + if err != nil { + return err + } + p.du.Data = reader + case itemEOF: + if p.du.Data == nil { + p.du.Data = []byte("") + } + return nil + } + } + panic("EOF not found") +} + +// DecodeString decodes a Data URL scheme string. +func DecodeString(s string) (*DataURL, error) { + du := &DataURL{ + MediaType: defaultMediaType(), + Encoding: EncodingASCII, + } + + parser := &parser{ + du: du, + l: lex(s), + } + if err := parser.parse(); err != nil { + return nil, err + } + return du, nil +} + +// Decode decodes a Data URL scheme from a io.Reader. +func Decode(r io.Reader) (*DataURL, error) { + data, err := ioutil.ReadAll(r) + if err != nil { + return nil, err + } + return DecodeString(string(data)) +} + +// EncodeBytes encodes the data bytes into a Data URL string, using base 64 encoding. +// +// The media type of data is detected using http.DetectContentType. +func EncodeBytes(data []byte) string { + mt := http.DetectContentType(data) + // http.DetectContentType may add spurious spaces between ; and a parameter. + // The canonical way is to not have them. + cleanedMt := strings.Replace(mt, "; ", ";", -1) + + return New(data, cleanedMt).String() +} diff --git a/vendor/github.com/vincent-petithory/dataurl/doc.go b/vendor/github.com/vincent-petithory/dataurl/doc.go new file mode 100644 index 00000000..56461d04 --- /dev/null +++ b/vendor/github.com/vincent-petithory/dataurl/doc.go @@ -0,0 +1,28 @@ +/* +Package dataurl parses Data URL Schemes +according to RFC 2397 +(http://tools.ietf.org/html/rfc2397). + +Data URLs are small chunks of data commonly used in browsers to display inline data, +typically like small images, or when you use the FileReader API of the browser. + +A dataurl looks like: + + data:text/plain;charset=utf-8,A%20brief%20note + +Or, with base64 encoding: + + data:image/vnd.microsoft.icon;name=golang%20favicon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAD///8AVE44//7hdv/+4Xb//uF2//7hdv/+4Xb//uF2//7hdv/+4Xb//uF2//7hdv/+4Xb/ + /uF2/1ROOP////8A////AFROOP/+4Xb//uF2//7hdv/+4Xb//uF2//7hdv/+4Xb//uF2//7hdv/+ + ... + /6CcjP97c07/e3NO/1dOMf9BOiX/TkUn/2VXLf97c07/e3NO/6CcjP/h4uX/////AP///wD///8A + ////AP///wD///8A////AP///wDq6/H/3N/j/9fZ3f/q6/H/////AP///wD///8A////AP///wD/ + //8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAA== + +Common functions are Decode and DecodeString to obtain a DataURL, +and DataURL.String() and DataURL.WriteTo to generate a Data URL string. + +*/ +package dataurl diff --git a/vendor/github.com/vincent-petithory/dataurl/lex.go b/vendor/github.com/vincent-petithory/dataurl/lex.go new file mode 100644 index 00000000..1a8717f5 --- /dev/null +++ b/vendor/github.com/vincent-petithory/dataurl/lex.go @@ -0,0 +1,521 @@ +package dataurl + +import ( + "fmt" + "strings" + "unicode" + "unicode/utf8" +) + +type item struct { + t itemType + val string +} + +func (i item) String() string { + switch i.t { + case itemEOF: + return "EOF" + case itemError: + return i.val + } + if len(i.val) > 10 { + return fmt.Sprintf("%.10q...", i.val) + } + return fmt.Sprintf("%q", i.val) +} + +type itemType int + +const ( + itemError itemType = iota + itemEOF + + itemDataPrefix + + itemMediaType + itemMediaSep + itemMediaSubType + itemParamSemicolon + itemParamAttr + itemParamEqual + itemLeftStringQuote + itemRightStringQuote + itemParamVal + + itemBase64Enc + + itemDataComma + itemData +) + +const eof rune = -1 + +func isTokenRune(r rune) bool { + return r <= unicode.MaxASCII && + !unicode.IsControl(r) && + !unicode.IsSpace(r) && + !isTSpecialRune(r) +} + +func isTSpecialRune(r rune) bool { + return r == '(' || + r == ')' || + r == '<' || + r == '>' || + r == '@' || + r == ',' || + r == ';' || + r == ':' || + r == '\\' || + r == '"' || + r == '/' || + r == '[' || + r == ']' || + r == '?' || + r == '=' +} + +// See http://tools.ietf.org/html/rfc2045 +// This doesn't include extension-token case +// as it's handled separatly +func isDiscreteType(s string) bool { + if strings.HasPrefix(s, "text") || + strings.HasPrefix(s, "image") || + strings.HasPrefix(s, "audio") || + strings.HasPrefix(s, "video") || + strings.HasPrefix(s, "application") { + return true + } + return false +} + +// See http://tools.ietf.org/html/rfc2045 +// This doesn't include extension-token case +// as it's handled separatly +func isCompositeType(s string) bool { + if strings.HasPrefix(s, "message") || + strings.HasPrefix(s, "multipart") { + return true + } + return false +} + +func isURLCharRune(r rune) bool { + // We're a bit permissive here, + // by not including '%' in delims + // This is okay, since url unescaping will validate + // that later in the parser. + return r <= unicode.MaxASCII && + !(r >= 0x00 && r <= 0x1F) && r != 0x7F && /* control */ + // delims + r != ' ' && + r != '<' && + r != '>' && + r != '#' && + r != '"' && + // unwise + r != '{' && + r != '}' && + r != '|' && + r != '\\' && + r != '^' && + r != '[' && + r != ']' && + r != '`' +} + +func isBase64Rune(r rune) bool { + return (r >= 'a' && r <= 'z') || + (r >= 'A' && r <= 'Z') || + (r >= '0' && r <= '9') || + r == '+' || + r == '/' || + r == '=' || + r == '\n' +} + +type stateFn func(*lexer) stateFn + +// lexer lexes the data URL scheme input string. +// The implementation is from the text/template/parser package. +type lexer struct { + input string + start int + pos int + width int + seenBase64Item bool + items chan item +} + +func (l *lexer) run() { + for state := lexBeforeDataPrefix; state != nil; { + state = state(l) + } + close(l.items) +} + +func (l *lexer) emit(t itemType) { + l.items <- item{t, l.input[l.start:l.pos]} + l.start = l.pos +} + +func (l *lexer) next() (r rune) { + if l.pos >= len(l.input) { + l.width = 0 + return eof + } + r, l.width = utf8.DecodeRuneInString(l.input[l.pos:]) + l.pos += l.width + return r +} + +func (l *lexer) backup() { + l.pos -= l.width +} + +func (l *lexer) ignore() { + l.start = l.pos +} + +func (l *lexer) errorf(format string, args ...interface{}) stateFn { + l.items <- item{itemError, fmt.Sprintf(format, args...)} + return nil +} + +func lex(input string) *lexer { + l := &lexer{ + input: input, + items: make(chan item), + } + go l.run() // Concurrently run state machine. + return l +} + +const ( + dataPrefix = "data:" + mediaSep = '/' + paramSemicolon = ';' + paramEqual = '=' + dataComma = ',' +) + +// start lexing by detecting data prefix +func lexBeforeDataPrefix(l *lexer) stateFn { + if strings.HasPrefix(l.input[l.pos:], dataPrefix) { + return lexDataPrefix + } + return l.errorf("missing data prefix") +} + +// lex data prefix +func lexDataPrefix(l *lexer) stateFn { + l.pos += len(dataPrefix) + l.emit(itemDataPrefix) + return lexAfterDataPrefix +} + +// lex what's after data prefix. +// it can be the media type/subtype separator, +// the base64 encoding, or the comma preceding the data +func lexAfterDataPrefix(l *lexer) stateFn { + switch r := l.next(); { + case r == paramSemicolon: + l.backup() + return lexParamSemicolon + case r == dataComma: + l.backup() + return lexDataComma + case r == eof: + return l.errorf("missing comma before data") + case r == 'x' || r == 'X': + if l.next() == '-' { + return lexXTokenMediaType + } + return lexInDiscreteMediaType + case isTokenRune(r): + return lexInDiscreteMediaType + default: + return l.errorf("invalid character after data prefix") + } +} + +func lexXTokenMediaType(l *lexer) stateFn { + for { + switch r := l.next(); { + case r == mediaSep: + l.backup() + return lexMediaType + case r == eof: + return l.errorf("missing media type slash") + case isTokenRune(r): + default: + return l.errorf("invalid character for media type") + } + } +} + +func lexInDiscreteMediaType(l *lexer) stateFn { + for { + switch r := l.next(); { + case r == mediaSep: + l.backup() + // check it's valid discrete type + if !isDiscreteType(l.input[l.start:l.pos]) && + !isCompositeType(l.input[l.start:l.pos]) { + return l.errorf("invalid media type") + } + return lexMediaType + case r == eof: + return l.errorf("missing media type slash") + case isTokenRune(r): + default: + return l.errorf("invalid character for media type") + } + } +} + +func lexMediaType(l *lexer) stateFn { + if l.pos > l.start { + l.emit(itemMediaType) + } + return lexMediaSep +} + +func lexMediaSep(l *lexer) stateFn { + l.next() + l.emit(itemMediaSep) + return lexAfterMediaSep +} + +func lexAfterMediaSep(l *lexer) stateFn { + for { + switch r := l.next(); { + case r == paramSemicolon || r == dataComma: + l.backup() + return lexMediaSubType + case r == eof: + return l.errorf("incomplete media type") + case isTokenRune(r): + default: + return l.errorf("invalid character for media subtype") + } + } +} + +func lexMediaSubType(l *lexer) stateFn { + if l.pos > l.start { + l.emit(itemMediaSubType) + } + return lexAfterMediaSubType +} + +func lexAfterMediaSubType(l *lexer) stateFn { + switch r := l.next(); { + case r == paramSemicolon: + l.backup() + return lexParamSemicolon + case r == dataComma: + l.backup() + return lexDataComma + case r == eof: + return l.errorf("missing comma before data") + default: + return l.errorf("expected semicolon or comma") + } +} + +func lexParamSemicolon(l *lexer) stateFn { + l.next() + l.emit(itemParamSemicolon) + return lexAfterParamSemicolon +} + +func lexAfterParamSemicolon(l *lexer) stateFn { + switch r := l.next(); { + case r == eof: + return l.errorf("unterminated parameter sequence") + case r == paramEqual || r == dataComma: + return l.errorf("unterminated parameter sequence") + case isTokenRune(r): + l.backup() + return lexInParamAttr + default: + return l.errorf("invalid character for parameter attribute") + } +} + +func lexBase64Enc(l *lexer) stateFn { + if l.pos > l.start { + if v := l.input[l.start:l.pos]; v != "base64" { + return l.errorf("expected base64, got %s", v) + } + l.seenBase64Item = true + l.emit(itemBase64Enc) + } + return lexDataComma +} + +func lexInParamAttr(l *lexer) stateFn { + for { + switch r := l.next(); { + case r == paramEqual: + l.backup() + return lexParamAttr + case r == dataComma: + l.backup() + return lexBase64Enc + case r == eof: + return l.errorf("unterminated parameter sequence") + case isTokenRune(r): + default: + return l.errorf("invalid character for parameter attribute") + } + } +} + +func lexParamAttr(l *lexer) stateFn { + if l.pos > l.start { + l.emit(itemParamAttr) + } + return lexParamEqual +} + +func lexParamEqual(l *lexer) stateFn { + l.next() + l.emit(itemParamEqual) + return lexAfterParamEqual +} + +func lexAfterParamEqual(l *lexer) stateFn { + switch r := l.next(); { + case r == '"': + l.emit(itemLeftStringQuote) + return lexInQuotedStringParamVal + case r == eof: + return l.errorf("missing comma before data") + case isTokenRune(r): + return lexInParamVal + default: + return l.errorf("invalid character for parameter value") + } +} + +func lexInQuotedStringParamVal(l *lexer) stateFn { + for { + switch r := l.next(); { + case r == eof: + return l.errorf("unclosed quoted string") + case r == '\\': + return lexEscapedChar + case r == '"': + l.backup() + return lexQuotedStringParamVal + case r <= unicode.MaxASCII: + default: + return l.errorf("invalid character for parameter value") + } + } +} + +func lexEscapedChar(l *lexer) stateFn { + switch r := l.next(); { + case r <= unicode.MaxASCII: + return lexInQuotedStringParamVal + case r == eof: + return l.errorf("unexpected eof") + default: + return l.errorf("invalid escaped character") + } +} + +func lexInParamVal(l *lexer) stateFn { + for { + switch r := l.next(); { + case r == paramSemicolon || r == dataComma: + l.backup() + return lexParamVal + case r == eof: + return l.errorf("missing comma before data") + case isTokenRune(r): + default: + return l.errorf("invalid character for parameter value") + } + } +} + +func lexQuotedStringParamVal(l *lexer) stateFn { + if l.pos > l.start { + l.emit(itemParamVal) + } + l.next() + l.emit(itemRightStringQuote) + return lexAfterParamVal +} + +func lexParamVal(l *lexer) stateFn { + if l.pos > l.start { + l.emit(itemParamVal) + } + return lexAfterParamVal +} + +func lexAfterParamVal(l *lexer) stateFn { + switch r := l.next(); { + case r == paramSemicolon: + l.backup() + return lexParamSemicolon + case r == dataComma: + l.backup() + return lexDataComma + case r == eof: + return l.errorf("missing comma before data") + default: + return l.errorf("expected semicolon or comma") + } +} + +func lexDataComma(l *lexer) stateFn { + l.next() + l.emit(itemDataComma) + if l.seenBase64Item { + return lexBase64Data + } + return lexData +} + +func lexData(l *lexer) stateFn { +Loop: + for { + switch r := l.next(); { + case r == eof: + break Loop + case isURLCharRune(r): + default: + return l.errorf("invalid data character") + } + } + if l.pos > l.start { + l.emit(itemData) + } + l.emit(itemEOF) + return nil +} + +func lexBase64Data(l *lexer) stateFn { +Loop: + for { + switch r := l.next(); { + case r == eof: + break Loop + case isBase64Rune(r): + default: + return l.errorf("invalid data character") + } + } + if l.pos > l.start { + l.emit(itemData) + } + l.emit(itemEOF) + return nil +} diff --git a/vendor/github.com/vincent-petithory/dataurl/rfc2396.go b/vendor/github.com/vincent-petithory/dataurl/rfc2396.go new file mode 100644 index 00000000..e2ea0cac --- /dev/null +++ b/vendor/github.com/vincent-petithory/dataurl/rfc2396.go @@ -0,0 +1,130 @@ +package dataurl + +import ( + "bytes" + "fmt" + "io" + "strings" +) + +// Escape implements URL escaping, as defined in RFC 2397 (http://tools.ietf.org/html/rfc2397). +// It differs a bit from net/url's QueryEscape and QueryUnescape, e.g how spaces are treated (+ instead of %20): +// +// Only ASCII chars are allowed. Reserved chars are escaped to their %xx form. +// Unreserved chars are [a-z], [A-Z], [0-9], and -_.!~*\(). +func Escape(data []byte) string { + var buf = new(bytes.Buffer) + for _, b := range data { + switch { + case isUnreserved(b): + buf.WriteByte(b) + default: + fmt.Fprintf(buf, "%%%02X", b) + } + } + return buf.String() +} + +// EscapeString is like Escape, but taking +// a string as argument. +func EscapeString(s string) string { + return Escape([]byte(s)) +} + +// isUnreserved return true +// if the byte c is an unreserved char, +// as defined in RFC 2396. +func isUnreserved(c byte) bool { + return (c >= 'a' && c <= 'z') || + (c >= 'A' && c <= 'Z') || + (c >= '0' && c <= '9') || + c == '-' || + c == '_' || + c == '.' || + c == '!' || + c == '~' || + c == '*' || + c == '\'' || + c == '(' || + c == ')' +} + +func isHex(c byte) bool { + switch { + case c >= 'a' && c <= 'f': + return true + case c >= 'A' && c <= 'F': + return true + case c >= '0' && c <= '9': + return true + } + return false +} + +// borrowed from net/url/url.go +func unhex(c byte) byte { + switch { + case '0' <= c && c <= '9': + return c - '0' + case 'a' <= c && c <= 'f': + return c - 'a' + 10 + case 'A' <= c && c <= 'F': + return c - 'A' + 10 + } + return 0 +} + +// Unescape unescapes a character sequence +// escaped with Escape(String?). +func Unescape(s string) ([]byte, error) { + var buf = new(bytes.Buffer) + reader := strings.NewReader(s) + + for { + r, size, err := reader.ReadRune() + if err == io.EOF { + break + } + if err != nil { + return nil, err + } + if size > 1 { + return nil, fmt.Errorf("rfc2396: non-ASCII char detected") + } + + switch r { + case '%': + eb1, err := reader.ReadByte() + if err == io.EOF { + return nil, fmt.Errorf("rfc2396: unexpected end of unescape sequence") + } + if err != nil { + return nil, err + } + if !isHex(eb1) { + return nil, fmt.Errorf("rfc2396: invalid char 0x%x in unescape sequence", r) + } + eb0, err := reader.ReadByte() + if err == io.EOF { + return nil, fmt.Errorf("rfc2396: unexpected end of unescape sequence") + } + if err != nil { + return nil, err + } + if !isHex(eb0) { + return nil, fmt.Errorf("rfc2396: invalid char 0x%x in unescape sequence", r) + } + buf.WriteByte(unhex(eb0) + unhex(eb1)*16) + default: + buf.WriteByte(byte(r)) + } + } + return buf.Bytes(), nil +} + +// UnescapeToString is like Unescape, but returning +// a string. +func UnescapeToString(s string) (string, error) { + b, err := Unescape(s) + return string(b), err +} diff --git a/vendor/github.com/vincent-petithory/dataurl/wercker.yml b/vendor/github.com/vincent-petithory/dataurl/wercker.yml new file mode 100644 index 00000000..3ab8084c --- /dev/null +++ b/vendor/github.com/vincent-petithory/dataurl/wercker.yml @@ -0,0 +1 @@ +box: wercker/default \ No newline at end of file diff --git a/vendor/layeh.com/gumble/LICENSE b/vendor/layeh.com/gumble/LICENSE new file mode 100644 index 00000000..14e2f777 --- /dev/null +++ b/vendor/layeh.com/gumble/LICENSE @@ -0,0 +1,373 @@ +Mozilla Public License Version 2.0 +================================== + +1. Definitions +-------------- + +1.1. "Contributor" + means each individual or legal entity that creates, contributes to + the creation of, or owns Covered Software. + +1.2. "Contributor Version" + means the combination of the Contributions of others (if any) used + by a Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" + means Covered Software of a particular Contributor. + +1.4. "Covered Software" + means Source Code Form to which the initial Contributor has attached + the notice in Exhibit A, the Executable Form of such Source Code + Form, and Modifications of such Source Code Form, in each case + including portions thereof. + +1.5. "Incompatible With Secondary Licenses" + means + + (a) that the initial Contributor has attached the notice described + in Exhibit B to the Covered Software; or + + (b) that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the + terms of a Secondary License. + +1.6. "Executable Form" + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + means a work that combines Covered Software with other material, in + a separate file or files, that is not Covered Software. + +1.8. "License" + means this document. + +1.9. "Licensable" + means having the right to grant, to the maximum extent possible, + whether at the time of the initial grant or subsequently, any and + all of the rights conveyed by this License. + +1.10. "Modifications" + means any of the following: + + (a) any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered + Software; or + + (b) any new file in Source Code Form that contains any Covered + Software. + +1.11. "Patent Claims" of a Contributor + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the + License, by the making, using, selling, offering for sale, having + made, import, or transfer of either its Contributions or its + Contributor Version. + +1.12. "Secondary License" + means either the GNU General Public License, Version 2.0, the GNU + Lesser General Public License, Version 2.1, the GNU Affero General + Public License, Version 3.0, or any later versions of those + licenses. + +1.13. "Source Code Form" + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that + controls, is controlled by, or is under common control with You. For + purposes of this definition, "control" means (a) the power, direct + or indirect, to cause the direction or management of such entity, + whether by contract or otherwise, or (b) ownership of more than + fifty percent (50%) of the outstanding shares or beneficial + ownership of such entity. + +2. License Grants and Conditions +-------------------------------- + +2.1. Grants + +Each Contributor hereby grants You a world-wide, royalty-free, +non-exclusive license: + +(a) under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + +(b) under Patent Claims of such Contributor to make, use, sell, offer + for sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + +The licenses granted in Section 2.1 with respect to any Contribution +become effective for each Contribution on the date the Contributor first +distributes such Contribution. + +2.3. Limitations on Grant Scope + +The licenses granted in this Section 2 are the only rights granted under +this License. No additional rights or licenses will be implied from the +distribution or licensing of Covered Software under this License. +Notwithstanding Section 2.1(b) above, no patent license is granted by a +Contributor: + +(a) for any code that a Contributor has removed from Covered Software; + or + +(b) for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + +(c) under Patent Claims infringed by Covered Software in the absence of + its Contributions. + +This License does not grant any rights in the trademarks, service marks, +or logos of any Contributor (except as may be necessary to comply with +the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + +No Contributor makes additional grants as a result of Your choice to +distribute the Covered Software under a subsequent version of this +License (see Section 10.2) or under the terms of a Secondary License (if +permitted under the terms of Section 3.3). + +2.5. Representation + +Each Contributor represents that the Contributor believes its +Contributions are its original creation(s) or it has sufficient rights +to grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + +This License is not intended to limit any rights You have under +applicable copyright doctrines of fair use, fair dealing, or other +equivalents. + +2.7. Conditions + +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted +in Section 2.1. + +3. Responsibilities +------------------- + +3.1. Distribution of Source Form + +All distribution of Covered Software in Source Code Form, including any +Modifications that You create or to which You contribute, must be under +the terms of this License. You must inform recipients that the Source +Code Form of the Covered Software is governed by the terms of this +License, and how they can obtain a copy of this License. You may not +attempt to alter or restrict the recipients' rights in the Source Code +Form. + +3.2. Distribution of Executable Form + +If You distribute Covered Software in Executable Form then: + +(a) such Covered Software must also be made available in Source Code + Form, as described in Section 3.1, and You must inform recipients of + the Executable Form how they can obtain a copy of such Source Code + Form by reasonable means in a timely manner, at a charge no more + than the cost of distribution to the recipient; and + +(b) You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter + the recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + +You may create and distribute a Larger Work under terms of Your choice, +provided that You also comply with the requirements of this License for +the Covered Software. If the Larger Work is a combination of Covered +Software with a work governed by one or more Secondary Licenses, and the +Covered Software is not Incompatible With Secondary Licenses, this +License permits You to additionally distribute such Covered Software +under the terms of such Secondary License(s), so that the recipient of +the Larger Work may, at their option, further distribute the Covered +Software under the terms of either this License or such Secondary +License(s). + +3.4. Notices + +You may not remove or alter the substance of any license notices +(including copyright notices, patent notices, disclaimers of warranty, +or limitations of liability) contained within the Source Code Form of +the Covered Software, except that You may alter any license notices to +the extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + +You may choose to offer, and to charge a fee for, warranty, support, +indemnity or liability obligations to one or more recipients of Covered +Software. However, You may do so only on Your own behalf, and not on +behalf of any Contributor. You must make it absolutely clear that any +such warranty, support, indemnity, or liability obligation is offered by +You alone, and You hereby agree to indemnify every Contributor for any +liability incurred by such Contributor as a result of warranty, support, +indemnity or liability terms You offer. You may include additional +disclaimers of warranty and limitations of liability specific to any +jurisdiction. + +4. Inability to Comply Due to Statute or Regulation +--------------------------------------------------- + +If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Software due to +statute, judicial order, or regulation then You must: (a) comply with +the terms of this License to the maximum extent possible; and (b) +describe the limitations and the code they affect. Such description must +be placed in a text file included with all distributions of the Covered +Software under this License. Except to the extent prohibited by statute +or regulation, such description must be sufficiently detailed for a +recipient of ordinary skill to be able to understand it. + +5. Termination +-------------- + +5.1. The rights granted under this License will terminate automatically +if You fail to comply with any of its terms. However, if You become +compliant, then the rights granted under this License from a particular +Contributor are reinstated (a) provisionally, unless and until such +Contributor explicitly and finally terminates Your grants, and (b) on an +ongoing basis, if such Contributor fails to notify You of the +non-compliance by some reasonable means prior to 60 days after You have +come back into compliance. Moreover, Your grants from a particular +Contributor are reinstated on an ongoing basis if such Contributor +notifies You of the non-compliance by some reasonable means, this is the +first time You have received notice of non-compliance with this License +from such Contributor, and You become compliant prior to 30 days after +Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent +infringement claim (excluding declaratory judgment actions, +counter-claims, and cross-claims) alleging that a Contributor Version +directly or indirectly infringes any patent, then the rights granted to +You by any and all Contributors for the Covered Software under Section +2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all +end user license agreements (excluding distributors and resellers) which +have been validly granted by You or Your distributors under this License +prior to termination shall survive termination. + +************************************************************************ +* * +* 6. Disclaimer of Warranty * +* ------------------------- * +* * +* Covered Software is provided under this License on an "as is" * +* basis, without warranty of any kind, either expressed, implied, or * +* statutory, including, without limitation, warranties that the * +* Covered Software is free of defects, merchantable, fit for a * +* particular purpose or non-infringing. The entire risk as to the * +* quality and performance of the Covered Software is with You. * +* Should any Covered Software prove defective in any respect, You * +* (not any Contributor) assume the cost of any necessary servicing, * +* repair, or correction. This disclaimer of warranty constitutes an * +* essential part of this License. No use of any Covered Software is * +* authorized under this License except under this disclaimer. * +* * +************************************************************************ + +************************************************************************ +* * +* 7. Limitation of Liability * +* -------------------------- * +* * +* Under no circumstances and under no legal theory, whether tort * +* (including negligence), contract, or otherwise, shall any * +* Contributor, or anyone who distributes Covered Software as * +* permitted above, be liable to You for any direct, indirect, * +* special, incidental, or consequential damages of any character * +* including, without limitation, damages for lost profits, loss of * +* goodwill, work stoppage, computer failure or malfunction, or any * +* and all other commercial damages or losses, even if such party * +* shall have been informed of the possibility of such damages. This * +* limitation of liability shall not apply to liability for death or * +* personal injury resulting from such party's negligence to the * +* extent applicable law prohibits such limitation. Some * +* jurisdictions do not allow the exclusion or limitation of * +* incidental or consequential damages, so this exclusion and * +* limitation may not apply to You. * +* * +************************************************************************ + +8. Litigation +------------- + +Any litigation relating to this License may be brought only in the +courts of a jurisdiction where the defendant maintains its principal +place of business and such litigation shall be governed by laws of that +jurisdiction, without reference to its conflict-of-law provisions. +Nothing in this Section shall prevent a party's ability to bring +cross-claims or counter-claims. + +9. Miscellaneous +---------------- + +This License represents the complete agreement concerning the subject +matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent +necessary to make it enforceable. Any law or regulation which provides +that the language of a contract shall be construed against the drafter +shall not be used to construe this License against a Contributor. + +10. Versions of the License +--------------------------- + +10.1. New Versions + +Mozilla Foundation is the license steward. Except as provided in Section +10.3, no one other than the license steward has the right to modify or +publish new versions of this License. Each version will be given a +distinguishing version number. + +10.2. Effect of New Versions + +You may distribute the Covered Software under the terms of the version +of the License under which You originally received the Covered Software, +or under the terms of any subsequent version published by the license +steward. + +10.3. Modified Versions + +If you create software not governed by this License, and you want to +create a new license for such software, you may create and use a +modified version of this License if you rename the license and remove +any references to the name of the license steward (except to note that +such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary +Licenses + +If You choose to distribute Source Code Form that is Incompatible With +Secondary Licenses under the terms of this version of the License, the +notice described in Exhibit B of this License must be attached. + +Exhibit A - Source Code Form License Notice +------------------------------------------- + + This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular +file, then You may include the notice in a location (such as a LICENSE +file in a relevant directory) where a recipient would be likely to look +for such a notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice +--------------------------------------------------------- + + This Source Code Form is "Incompatible With Secondary Licenses", as + defined by the Mozilla Public License, v. 2.0. diff --git a/vendor/layeh.com/gumble/gumble/MumbleProto/LICENSE b/vendor/layeh.com/gumble/gumble/MumbleProto/LICENSE new file mode 100644 index 00000000..c3ffe8f9 --- /dev/null +++ b/vendor/layeh.com/gumble/gumble/MumbleProto/LICENSE @@ -0,0 +1,37 @@ +Copyright (C) 2005-2013, Thorvald Natvig +Copyright (C) 2007, Stefan Gehn +Copyright (C) 2007, Sebastian Schlingmann +Copyright (C) 2008-2013, Mikkel Krautz +Copyright (C) 2008, Andreas Messer +Copyright (C) 2007, Trenton Schulz +Copyright (C) 2008-2013, Stefan Hacker +Copyright (C) 2008-2011, Snares +Copyright (C) 2009-2013, Benjamin Jemlich +Copyright (C) 2009-2013, Kissaki + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +- Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. +- Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. +- Neither the name of the Mumble Developers nor the names of its + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +`AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/layeh.com/gumble/gumble/MumbleProto/Mumble.pb.go b/vendor/layeh.com/gumble/gumble/MumbleProto/Mumble.pb.go new file mode 100644 index 00000000..25380122 --- /dev/null +++ b/vendor/layeh.com/gumble/gumble/MumbleProto/Mumble.pb.go @@ -0,0 +1,3085 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: Mumble.proto + +package MumbleProto + +import ( + fmt "fmt" + proto "github.com/golang/protobuf/proto" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package + +type Reject_RejectType int32 + +const ( + // The rejection reason is unknown (details should be available + // in Reject.reason). + Reject_None Reject_RejectType = 0 + // The client attempted to connect with an incompatible version. + Reject_WrongVersion Reject_RejectType = 1 + // The user name supplied by the client was invalid. + Reject_InvalidUsername Reject_RejectType = 2 + // The client attempted to authenticate as a user with a password but it + // was wrong. + Reject_WrongUserPW Reject_RejectType = 3 + // The client attempted to connect to a passworded server but the password + // was wrong. + Reject_WrongServerPW Reject_RejectType = 4 + // Supplied username is already in use. + Reject_UsernameInUse Reject_RejectType = 5 + // Server is currently full and cannot accept more users. + Reject_ServerFull Reject_RejectType = 6 + // The user did not provide a certificate but one is required. + Reject_NoCertificate Reject_RejectType = 7 + Reject_AuthenticatorFail Reject_RejectType = 8 +) + +var Reject_RejectType_name = map[int32]string{ + 0: "None", + 1: "WrongVersion", + 2: "InvalidUsername", + 3: "WrongUserPW", + 4: "WrongServerPW", + 5: "UsernameInUse", + 6: "ServerFull", + 7: "NoCertificate", + 8: "AuthenticatorFail", +} + +var Reject_RejectType_value = map[string]int32{ + "None": 0, + "WrongVersion": 1, + "InvalidUsername": 2, + "WrongUserPW": 3, + "WrongServerPW": 4, + "UsernameInUse": 5, + "ServerFull": 6, + "NoCertificate": 7, + "AuthenticatorFail": 8, +} + +func (x Reject_RejectType) Enum() *Reject_RejectType { + p := new(Reject_RejectType) + *p = x + return p +} + +func (x Reject_RejectType) String() string { + return proto.EnumName(Reject_RejectType_name, int32(x)) +} + +func (x *Reject_RejectType) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(Reject_RejectType_value, data, "Reject_RejectType") + if err != nil { + return err + } + *x = Reject_RejectType(value) + return nil +} + +func (Reject_RejectType) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_56c09c2dce0fb003, []int{4, 0} +} + +type PermissionDenied_DenyType int32 + +const ( + // Operation denied for other reason, see reason field. + PermissionDenied_Text PermissionDenied_DenyType = 0 + // Permissions were denied. + PermissionDenied_Permission PermissionDenied_DenyType = 1 + // Cannot modify SuperUser. + PermissionDenied_SuperUser PermissionDenied_DenyType = 2 + // Invalid channel name. + PermissionDenied_ChannelName PermissionDenied_DenyType = 3 + // Text message too long. + PermissionDenied_TextTooLong PermissionDenied_DenyType = 4 + // The flux capacitor was spelled wrong. + PermissionDenied_H9K PermissionDenied_DenyType = 5 + // Operation not permitted in temporary channel. + PermissionDenied_TemporaryChannel PermissionDenied_DenyType = 6 + // Operation requires certificate. + PermissionDenied_MissingCertificate PermissionDenied_DenyType = 7 + // Invalid username. + PermissionDenied_UserName PermissionDenied_DenyType = 8 + // Channel is full. + PermissionDenied_ChannelFull PermissionDenied_DenyType = 9 + // Channels are nested too deply. + PermissionDenied_NestingLimit PermissionDenied_DenyType = 10 + // Maximum channel count reached. + PermissionDenied_ChannelCountLimit PermissionDenied_DenyType = 11 +) + +var PermissionDenied_DenyType_name = map[int32]string{ + 0: "Text", + 1: "Permission", + 2: "SuperUser", + 3: "ChannelName", + 4: "TextTooLong", + 5: "H9K", + 6: "TemporaryChannel", + 7: "MissingCertificate", + 8: "UserName", + 9: "ChannelFull", + 10: "NestingLimit", + 11: "ChannelCountLimit", +} + +var PermissionDenied_DenyType_value = map[string]int32{ + "Text": 0, + "Permission": 1, + "SuperUser": 2, + "ChannelName": 3, + "TextTooLong": 4, + "H9K": 5, + "TemporaryChannel": 6, + "MissingCertificate": 7, + "UserName": 8, + "ChannelFull": 9, + "NestingLimit": 10, + "ChannelCountLimit": 11, +} + +func (x PermissionDenied_DenyType) Enum() *PermissionDenied_DenyType { + p := new(PermissionDenied_DenyType) + *p = x + return p +} + +func (x PermissionDenied_DenyType) String() string { + return proto.EnumName(PermissionDenied_DenyType_name, int32(x)) +} + +func (x *PermissionDenied_DenyType) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(PermissionDenied_DenyType_value, data, "PermissionDenied_DenyType") + if err != nil { + return err + } + *x = PermissionDenied_DenyType(value) + return nil +} + +func (PermissionDenied_DenyType) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_56c09c2dce0fb003, []int{12, 0} +} + +type ContextActionModify_Context int32 + +const ( + // Action is applicable to the server. + ContextActionModify_Server ContextActionModify_Context = 1 + // Action can target a Channel. + ContextActionModify_Channel ContextActionModify_Context = 2 + // Action can target a User. + ContextActionModify_User ContextActionModify_Context = 4 +) + +var ContextActionModify_Context_name = map[int32]string{ + 1: "Server", + 2: "Channel", + 4: "User", +} + +var ContextActionModify_Context_value = map[string]int32{ + "Server": 1, + "Channel": 2, + "User": 4, +} + +func (x ContextActionModify_Context) Enum() *ContextActionModify_Context { + p := new(ContextActionModify_Context) + *p = x + return p +} + +func (x ContextActionModify_Context) String() string { + return proto.EnumName(ContextActionModify_Context_name, int32(x)) +} + +func (x *ContextActionModify_Context) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(ContextActionModify_Context_value, data, "ContextActionModify_Context") + if err != nil { + return err + } + *x = ContextActionModify_Context(value) + return nil +} + +func (ContextActionModify_Context) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_56c09c2dce0fb003, []int{16, 0} +} + +type ContextActionModify_Operation int32 + +const ( + ContextActionModify_Add ContextActionModify_Operation = 0 + ContextActionModify_Remove ContextActionModify_Operation = 1 +) + +var ContextActionModify_Operation_name = map[int32]string{ + 0: "Add", + 1: "Remove", +} + +var ContextActionModify_Operation_value = map[string]int32{ + "Add": 0, + "Remove": 1, +} + +func (x ContextActionModify_Operation) Enum() *ContextActionModify_Operation { + p := new(ContextActionModify_Operation) + *p = x + return p +} + +func (x ContextActionModify_Operation) String() string { + return proto.EnumName(ContextActionModify_Operation_name, int32(x)) +} + +func (x *ContextActionModify_Operation) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(ContextActionModify_Operation_value, data, "ContextActionModify_Operation") + if err != nil { + return err + } + *x = ContextActionModify_Operation(value) + return nil +} + +func (ContextActionModify_Operation) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_56c09c2dce0fb003, []int{16, 1} +} + +type Version struct { + // 2-byte Major, 1-byte Minor and 1-byte Patch version number. + Version *uint32 `protobuf:"varint,1,opt,name=version" json:"version,omitempty"` + // Client release name. + Release *string `protobuf:"bytes,2,opt,name=release" json:"release,omitempty"` + // Client OS name. + Os *string `protobuf:"bytes,3,opt,name=os" json:"os,omitempty"` + // Client OS version. + OsVersion *string `protobuf:"bytes,4,opt,name=os_version,json=osVersion" json:"os_version,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Version) Reset() { *m = Version{} } +func (m *Version) String() string { return proto.CompactTextString(m) } +func (*Version) ProtoMessage() {} +func (*Version) Descriptor() ([]byte, []int) { + return fileDescriptor_56c09c2dce0fb003, []int{0} +} + +func (m *Version) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Version.Unmarshal(m, b) +} +func (m *Version) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Version.Marshal(b, m, deterministic) +} +func (m *Version) XXX_Merge(src proto.Message) { + xxx_messageInfo_Version.Merge(m, src) +} +func (m *Version) XXX_Size() int { + return xxx_messageInfo_Version.Size(m) +} +func (m *Version) XXX_DiscardUnknown() { + xxx_messageInfo_Version.DiscardUnknown(m) +} + +var xxx_messageInfo_Version proto.InternalMessageInfo + +func (m *Version) GetVersion() uint32 { + if m != nil && m.Version != nil { + return *m.Version + } + return 0 +} + +func (m *Version) GetRelease() string { + if m != nil && m.Release != nil { + return *m.Release + } + return "" +} + +func (m *Version) GetOs() string { + if m != nil && m.Os != nil { + return *m.Os + } + return "" +} + +func (m *Version) GetOsVersion() string { + if m != nil && m.OsVersion != nil { + return *m.OsVersion + } + return "" +} + +// Not used. Not even for tunneling UDP through TCP. +type UDPTunnel struct { + // Not used. + Packet []byte `protobuf:"bytes,1,req,name=packet" json:"packet,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *UDPTunnel) Reset() { *m = UDPTunnel{} } +func (m *UDPTunnel) String() string { return proto.CompactTextString(m) } +func (*UDPTunnel) ProtoMessage() {} +func (*UDPTunnel) Descriptor() ([]byte, []int) { + return fileDescriptor_56c09c2dce0fb003, []int{1} +} + +func (m *UDPTunnel) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_UDPTunnel.Unmarshal(m, b) +} +func (m *UDPTunnel) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_UDPTunnel.Marshal(b, m, deterministic) +} +func (m *UDPTunnel) XXX_Merge(src proto.Message) { + xxx_messageInfo_UDPTunnel.Merge(m, src) +} +func (m *UDPTunnel) XXX_Size() int { + return xxx_messageInfo_UDPTunnel.Size(m) +} +func (m *UDPTunnel) XXX_DiscardUnknown() { + xxx_messageInfo_UDPTunnel.DiscardUnknown(m) +} + +var xxx_messageInfo_UDPTunnel proto.InternalMessageInfo + +func (m *UDPTunnel) GetPacket() []byte { + if m != nil { + return m.Packet + } + return nil +} + +// Used by the client to send the authentication credentials to the server. +type Authenticate struct { + // UTF-8 encoded username. + Username *string `protobuf:"bytes,1,opt,name=username" json:"username,omitempty"` + // Server or user password. + Password *string `protobuf:"bytes,2,opt,name=password" json:"password,omitempty"` + // Additional access tokens for server ACL groups. + Tokens []string `protobuf:"bytes,3,rep,name=tokens" json:"tokens,omitempty"` + // A list of CELT bitstream version constants supported by the client. + CeltVersions []int32 `protobuf:"varint,4,rep,name=celt_versions,json=celtVersions" json:"celt_versions,omitempty"` + Opus *bool `protobuf:"varint,5,opt,name=opus,def=0" json:"opus,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Authenticate) Reset() { *m = Authenticate{} } +func (m *Authenticate) String() string { return proto.CompactTextString(m) } +func (*Authenticate) ProtoMessage() {} +func (*Authenticate) Descriptor() ([]byte, []int) { + return fileDescriptor_56c09c2dce0fb003, []int{2} +} + +func (m *Authenticate) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Authenticate.Unmarshal(m, b) +} +func (m *Authenticate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Authenticate.Marshal(b, m, deterministic) +} +func (m *Authenticate) XXX_Merge(src proto.Message) { + xxx_messageInfo_Authenticate.Merge(m, src) +} +func (m *Authenticate) XXX_Size() int { + return xxx_messageInfo_Authenticate.Size(m) +} +func (m *Authenticate) XXX_DiscardUnknown() { + xxx_messageInfo_Authenticate.DiscardUnknown(m) +} + +var xxx_messageInfo_Authenticate proto.InternalMessageInfo + +const Default_Authenticate_Opus bool = false + +func (m *Authenticate) GetUsername() string { + if m != nil && m.Username != nil { + return *m.Username + } + return "" +} + +func (m *Authenticate) GetPassword() string { + if m != nil && m.Password != nil { + return *m.Password + } + return "" +} + +func (m *Authenticate) GetTokens() []string { + if m != nil { + return m.Tokens + } + return nil +} + +func (m *Authenticate) GetCeltVersions() []int32 { + if m != nil { + return m.CeltVersions + } + return nil +} + +func (m *Authenticate) GetOpus() bool { + if m != nil && m.Opus != nil { + return *m.Opus + } + return Default_Authenticate_Opus +} + +// Sent by the client to notify the server that the client is still alive. +// Server must reply to the packet with the same timestamp and its own +// good/late/lost/resync numbers. None of the fields is strictly required. +type Ping struct { + // Client timestamp. Server should not attempt to decode. + Timestamp *uint64 `protobuf:"varint,1,opt,name=timestamp" json:"timestamp,omitempty"` + // The amount of good packets received. + Good *uint32 `protobuf:"varint,2,opt,name=good" json:"good,omitempty"` + // The amount of late packets received. + Late *uint32 `protobuf:"varint,3,opt,name=late" json:"late,omitempty"` + // The amount of packets never received. + Lost *uint32 `protobuf:"varint,4,opt,name=lost" json:"lost,omitempty"` + // The amount of nonce resyncs. + Resync *uint32 `protobuf:"varint,5,opt,name=resync" json:"resync,omitempty"` + // The total amount of UDP packets received. + UdpPackets *uint32 `protobuf:"varint,6,opt,name=udp_packets,json=udpPackets" json:"udp_packets,omitempty"` + // The total amount of TCP packets received. + TcpPackets *uint32 `protobuf:"varint,7,opt,name=tcp_packets,json=tcpPackets" json:"tcp_packets,omitempty"` + // UDP ping average. + UdpPingAvg *float32 `protobuf:"fixed32,8,opt,name=udp_ping_avg,json=udpPingAvg" json:"udp_ping_avg,omitempty"` + // UDP ping variance. + UdpPingVar *float32 `protobuf:"fixed32,9,opt,name=udp_ping_var,json=udpPingVar" json:"udp_ping_var,omitempty"` + // TCP ping average. + TcpPingAvg *float32 `protobuf:"fixed32,10,opt,name=tcp_ping_avg,json=tcpPingAvg" json:"tcp_ping_avg,omitempty"` + // TCP ping variance. + TcpPingVar *float32 `protobuf:"fixed32,11,opt,name=tcp_ping_var,json=tcpPingVar" json:"tcp_ping_var,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Ping) Reset() { *m = Ping{} } +func (m *Ping) String() string { return proto.CompactTextString(m) } +func (*Ping) ProtoMessage() {} +func (*Ping) Descriptor() ([]byte, []int) { + return fileDescriptor_56c09c2dce0fb003, []int{3} +} + +func (m *Ping) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Ping.Unmarshal(m, b) +} +func (m *Ping) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Ping.Marshal(b, m, deterministic) +} +func (m *Ping) XXX_Merge(src proto.Message) { + xxx_messageInfo_Ping.Merge(m, src) +} +func (m *Ping) XXX_Size() int { + return xxx_messageInfo_Ping.Size(m) +} +func (m *Ping) XXX_DiscardUnknown() { + xxx_messageInfo_Ping.DiscardUnknown(m) +} + +var xxx_messageInfo_Ping proto.InternalMessageInfo + +func (m *Ping) GetTimestamp() uint64 { + if m != nil && m.Timestamp != nil { + return *m.Timestamp + } + return 0 +} + +func (m *Ping) GetGood() uint32 { + if m != nil && m.Good != nil { + return *m.Good + } + return 0 +} + +func (m *Ping) GetLate() uint32 { + if m != nil && m.Late != nil { + return *m.Late + } + return 0 +} + +func (m *Ping) GetLost() uint32 { + if m != nil && m.Lost != nil { + return *m.Lost + } + return 0 +} + +func (m *Ping) GetResync() uint32 { + if m != nil && m.Resync != nil { + return *m.Resync + } + return 0 +} + +func (m *Ping) GetUdpPackets() uint32 { + if m != nil && m.UdpPackets != nil { + return *m.UdpPackets + } + return 0 +} + +func (m *Ping) GetTcpPackets() uint32 { + if m != nil && m.TcpPackets != nil { + return *m.TcpPackets + } + return 0 +} + +func (m *Ping) GetUdpPingAvg() float32 { + if m != nil && m.UdpPingAvg != nil { + return *m.UdpPingAvg + } + return 0 +} + +func (m *Ping) GetUdpPingVar() float32 { + if m != nil && m.UdpPingVar != nil { + return *m.UdpPingVar + } + return 0 +} + +func (m *Ping) GetTcpPingAvg() float32 { + if m != nil && m.TcpPingAvg != nil { + return *m.TcpPingAvg + } + return 0 +} + +func (m *Ping) GetTcpPingVar() float32 { + if m != nil && m.TcpPingVar != nil { + return *m.TcpPingVar + } + return 0 +} + +// Sent by the server when it rejects the user connection. +type Reject struct { + // Rejection type. + Type *Reject_RejectType `protobuf:"varint,1,opt,name=type,enum=MumbleProto.Reject_RejectType" json:"type,omitempty"` + // Human readable rejection reason. + Reason *string `protobuf:"bytes,2,opt,name=reason" json:"reason,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Reject) Reset() { *m = Reject{} } +func (m *Reject) String() string { return proto.CompactTextString(m) } +func (*Reject) ProtoMessage() {} +func (*Reject) Descriptor() ([]byte, []int) { + return fileDescriptor_56c09c2dce0fb003, []int{4} +} + +func (m *Reject) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Reject.Unmarshal(m, b) +} +func (m *Reject) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Reject.Marshal(b, m, deterministic) +} +func (m *Reject) XXX_Merge(src proto.Message) { + xxx_messageInfo_Reject.Merge(m, src) +} +func (m *Reject) XXX_Size() int { + return xxx_messageInfo_Reject.Size(m) +} +func (m *Reject) XXX_DiscardUnknown() { + xxx_messageInfo_Reject.DiscardUnknown(m) +} + +var xxx_messageInfo_Reject proto.InternalMessageInfo + +func (m *Reject) GetType() Reject_RejectType { + if m != nil && m.Type != nil { + return *m.Type + } + return Reject_None +} + +func (m *Reject) GetReason() string { + if m != nil && m.Reason != nil { + return *m.Reason + } + return "" +} + +// ServerSync message is sent by the server when it has authenticated the user +// and finished synchronizing the server state. +type ServerSync struct { + // The session of the current user. + Session *uint32 `protobuf:"varint,1,opt,name=session" json:"session,omitempty"` + // Maximum bandwidth that the user should use. + MaxBandwidth *uint32 `protobuf:"varint,2,opt,name=max_bandwidth,json=maxBandwidth" json:"max_bandwidth,omitempty"` + // Server welcome text. + WelcomeText *string `protobuf:"bytes,3,opt,name=welcome_text,json=welcomeText" json:"welcome_text,omitempty"` + // Current user permissions in the root channel. + Permissions *uint64 `protobuf:"varint,4,opt,name=permissions" json:"permissions,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ServerSync) Reset() { *m = ServerSync{} } +func (m *ServerSync) String() string { return proto.CompactTextString(m) } +func (*ServerSync) ProtoMessage() {} +func (*ServerSync) Descriptor() ([]byte, []int) { + return fileDescriptor_56c09c2dce0fb003, []int{5} +} + +func (m *ServerSync) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ServerSync.Unmarshal(m, b) +} +func (m *ServerSync) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ServerSync.Marshal(b, m, deterministic) +} +func (m *ServerSync) XXX_Merge(src proto.Message) { + xxx_messageInfo_ServerSync.Merge(m, src) +} +func (m *ServerSync) XXX_Size() int { + return xxx_messageInfo_ServerSync.Size(m) +} +func (m *ServerSync) XXX_DiscardUnknown() { + xxx_messageInfo_ServerSync.DiscardUnknown(m) +} + +var xxx_messageInfo_ServerSync proto.InternalMessageInfo + +func (m *ServerSync) GetSession() uint32 { + if m != nil && m.Session != nil { + return *m.Session + } + return 0 +} + +func (m *ServerSync) GetMaxBandwidth() uint32 { + if m != nil && m.MaxBandwidth != nil { + return *m.MaxBandwidth + } + return 0 +} + +func (m *ServerSync) GetWelcomeText() string { + if m != nil && m.WelcomeText != nil { + return *m.WelcomeText + } + return "" +} + +func (m *ServerSync) GetPermissions() uint64 { + if m != nil && m.Permissions != nil { + return *m.Permissions + } + return 0 +} + +// Sent by the client when it wants a channel removed. Sent by the server when +// a channel has been removed and clients should be notified. +type ChannelRemove struct { + ChannelId *uint32 `protobuf:"varint,1,req,name=channel_id,json=channelId" json:"channel_id,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ChannelRemove) Reset() { *m = ChannelRemove{} } +func (m *ChannelRemove) String() string { return proto.CompactTextString(m) } +func (*ChannelRemove) ProtoMessage() {} +func (*ChannelRemove) Descriptor() ([]byte, []int) { + return fileDescriptor_56c09c2dce0fb003, []int{6} +} + +func (m *ChannelRemove) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ChannelRemove.Unmarshal(m, b) +} +func (m *ChannelRemove) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ChannelRemove.Marshal(b, m, deterministic) +} +func (m *ChannelRemove) XXX_Merge(src proto.Message) { + xxx_messageInfo_ChannelRemove.Merge(m, src) +} +func (m *ChannelRemove) XXX_Size() int { + return xxx_messageInfo_ChannelRemove.Size(m) +} +func (m *ChannelRemove) XXX_DiscardUnknown() { + xxx_messageInfo_ChannelRemove.DiscardUnknown(m) +} + +var xxx_messageInfo_ChannelRemove proto.InternalMessageInfo + +func (m *ChannelRemove) GetChannelId() uint32 { + if m != nil && m.ChannelId != nil { + return *m.ChannelId + } + return 0 +} + +// Used to communicate channel properties between the client and the server. +// Sent by the server during the login process or when channel properties are +// updated. Client may use this message to update said channel properties. +type ChannelState struct { + // Unique ID for the channel within the server. + ChannelId *uint32 `protobuf:"varint,1,opt,name=channel_id,json=channelId" json:"channel_id,omitempty"` + // channel_id of the parent channel. + Parent *uint32 `protobuf:"varint,2,opt,name=parent" json:"parent,omitempty"` + // UTF-8 encoded channel name. + Name *string `protobuf:"bytes,3,opt,name=name" json:"name,omitempty"` + // A collection of channel id values of the linked channels. Absent during + // the first channel listing. + Links []uint32 `protobuf:"varint,4,rep,name=links" json:"links,omitempty"` + // UTF-8 encoded channel description. Only if the description is less than + // 128 bytes + Description *string `protobuf:"bytes,5,opt,name=description" json:"description,omitempty"` + // A collection of channel_id values that should be added to links. + LinksAdd []uint32 `protobuf:"varint,6,rep,name=links_add,json=linksAdd" json:"links_add,omitempty"` + // A collection of channel_id values that should be removed from links. + LinksRemove []uint32 `protobuf:"varint,7,rep,name=links_remove,json=linksRemove" json:"links_remove,omitempty"` + // True if the channel is temporary. + Temporary *bool `protobuf:"varint,8,opt,name=temporary,def=0" json:"temporary,omitempty"` + // Position weight to tweak the channel position in the channel list. + Position *int32 `protobuf:"varint,9,opt,name=position,def=0" json:"position,omitempty"` + // SHA1 hash of the description if the description is 128 bytes or more. + DescriptionHash []byte `protobuf:"bytes,10,opt,name=description_hash,json=descriptionHash" json:"description_hash,omitempty"` + // 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. + MaxUsers *uint32 `protobuf:"varint,11,opt,name=max_users,json=maxUsers" json:"max_users,omitempty"` + // Whether this channel has enter restrictions (ACL denying ENTER) set + IsEnterRestricted *bool `protobuf:"varint,12,opt,name=is_enter_restricted,json=isEnterRestricted" json:"is_enter_restricted,omitempty"` + // Whether the receiver of this msg is considered to be able to enter this channel + CanEnter *bool `protobuf:"varint,13,opt,name=can_enter,json=canEnter" json:"can_enter,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ChannelState) Reset() { *m = ChannelState{} } +func (m *ChannelState) String() string { return proto.CompactTextString(m) } +func (*ChannelState) ProtoMessage() {} +func (*ChannelState) Descriptor() ([]byte, []int) { + return fileDescriptor_56c09c2dce0fb003, []int{7} +} + +func (m *ChannelState) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ChannelState.Unmarshal(m, b) +} +func (m *ChannelState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ChannelState.Marshal(b, m, deterministic) +} +func (m *ChannelState) XXX_Merge(src proto.Message) { + xxx_messageInfo_ChannelState.Merge(m, src) +} +func (m *ChannelState) XXX_Size() int { + return xxx_messageInfo_ChannelState.Size(m) +} +func (m *ChannelState) XXX_DiscardUnknown() { + xxx_messageInfo_ChannelState.DiscardUnknown(m) +} + +var xxx_messageInfo_ChannelState proto.InternalMessageInfo + +const Default_ChannelState_Temporary bool = false +const Default_ChannelState_Position int32 = 0 + +func (m *ChannelState) GetChannelId() uint32 { + if m != nil && m.ChannelId != nil { + return *m.ChannelId + } + return 0 +} + +func (m *ChannelState) GetParent() uint32 { + if m != nil && m.Parent != nil { + return *m.Parent + } + return 0 +} + +func (m *ChannelState) GetName() string { + if m != nil && m.Name != nil { + return *m.Name + } + return "" +} + +func (m *ChannelState) GetLinks() []uint32 { + if m != nil { + return m.Links + } + return nil +} + +func (m *ChannelState) GetDescription() string { + if m != nil && m.Description != nil { + return *m.Description + } + return "" +} + +func (m *ChannelState) GetLinksAdd() []uint32 { + if m != nil { + return m.LinksAdd + } + return nil +} + +func (m *ChannelState) GetLinksRemove() []uint32 { + if m != nil { + return m.LinksRemove + } + return nil +} + +func (m *ChannelState) GetTemporary() bool { + if m != nil && m.Temporary != nil { + return *m.Temporary + } + return Default_ChannelState_Temporary +} + +func (m *ChannelState) GetPosition() int32 { + if m != nil && m.Position != nil { + return *m.Position + } + return Default_ChannelState_Position +} + +func (m *ChannelState) GetDescriptionHash() []byte { + if m != nil { + return m.DescriptionHash + } + return nil +} + +func (m *ChannelState) GetMaxUsers() uint32 { + if m != nil && m.MaxUsers != nil { + return *m.MaxUsers + } + return 0 +} + +func (m *ChannelState) GetIsEnterRestricted() bool { + if m != nil && m.IsEnterRestricted != nil { + return *m.IsEnterRestricted + } + return false +} + +func (m *ChannelState) GetCanEnter() bool { + if m != nil && m.CanEnter != nil { + return *m.CanEnter + } + return false +} + +// Used to communicate user leaving or being kicked. May be sent by the client +// when it attempts to kick a user. Sent by the server when it informs the +// clients that a user is not present anymore. +type UserRemove struct { + // The user who is being kicked, identified by their session, not present + // when no one is being kicked. + Session *uint32 `protobuf:"varint,1,req,name=session" json:"session,omitempty"` + // The user who initiated the removal. Either the user who performs the kick + // or the user who is currently leaving. + Actor *uint32 `protobuf:"varint,2,opt,name=actor" json:"actor,omitempty"` + // Reason for the kick, stored as the ban reason if the user is banned. + Reason *string `protobuf:"bytes,3,opt,name=reason" json:"reason,omitempty"` + // True if the kick should result in a ban. + Ban *bool `protobuf:"varint,4,opt,name=ban" json:"ban,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *UserRemove) Reset() { *m = UserRemove{} } +func (m *UserRemove) String() string { return proto.CompactTextString(m) } +func (*UserRemove) ProtoMessage() {} +func (*UserRemove) Descriptor() ([]byte, []int) { + return fileDescriptor_56c09c2dce0fb003, []int{8} +} + +func (m *UserRemove) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_UserRemove.Unmarshal(m, b) +} +func (m *UserRemove) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_UserRemove.Marshal(b, m, deterministic) +} +func (m *UserRemove) XXX_Merge(src proto.Message) { + xxx_messageInfo_UserRemove.Merge(m, src) +} +func (m *UserRemove) XXX_Size() int { + return xxx_messageInfo_UserRemove.Size(m) +} +func (m *UserRemove) XXX_DiscardUnknown() { + xxx_messageInfo_UserRemove.DiscardUnknown(m) +} + +var xxx_messageInfo_UserRemove proto.InternalMessageInfo + +func (m *UserRemove) GetSession() uint32 { + if m != nil && m.Session != nil { + return *m.Session + } + return 0 +} + +func (m *UserRemove) GetActor() uint32 { + if m != nil && m.Actor != nil { + return *m.Actor + } + return 0 +} + +func (m *UserRemove) GetReason() string { + if m != nil && m.Reason != nil { + return *m.Reason + } + return "" +} + +func (m *UserRemove) GetBan() bool { + if m != nil && m.Ban != nil { + return *m.Ban + } + return false +} + +// Sent by the server when it communicates new and changed users to client. +// First seen during login procedure. May be sent by the client when it wishes +// to alter its state. +type UserState struct { + // Unique user session ID of the user whose state this is, may change on + // reconnect. + Session *uint32 `protobuf:"varint,1,opt,name=session" json:"session,omitempty"` + // The session of the user who is updating this user. + Actor *uint32 `protobuf:"varint,2,opt,name=actor" json:"actor,omitempty"` + // User name, UTF-8 encoded. + Name *string `protobuf:"bytes,3,opt,name=name" json:"name,omitempty"` + // Registered user ID if the user is registered. + UserId *uint32 `protobuf:"varint,4,opt,name=user_id,json=userId" json:"user_id,omitempty"` + // Channel on which the user is. + ChannelId *uint32 `protobuf:"varint,5,opt,name=channel_id,json=channelId" json:"channel_id,omitempty"` + // True if the user is muted by admin. + Mute *bool `protobuf:"varint,6,opt,name=mute" json:"mute,omitempty"` + // True if the user is deafened by admin. + Deaf *bool `protobuf:"varint,7,opt,name=deaf" json:"deaf,omitempty"` + // True if the user has been suppressed from talking by a reason other than + // being muted. + Suppress *bool `protobuf:"varint,8,opt,name=suppress" json:"suppress,omitempty"` + // True if the user has muted self. + SelfMute *bool `protobuf:"varint,9,opt,name=self_mute,json=selfMute" json:"self_mute,omitempty"` + // True if the user has deafened self. + SelfDeaf *bool `protobuf:"varint,10,opt,name=self_deaf,json=selfDeaf" json:"self_deaf,omitempty"` + // User image if it is less than 128 bytes. + Texture []byte `protobuf:"bytes,11,opt,name=texture" json:"texture,omitempty"` + // 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. + PluginContext []byte `protobuf:"bytes,12,opt,name=plugin_context,json=pluginContext" json:"plugin_context,omitempty"` + // The user's plugin-specific identity. + // This value is not transmitted to clients. + PluginIdentity *string `protobuf:"bytes,13,opt,name=plugin_identity,json=pluginIdentity" json:"plugin_identity,omitempty"` + // User comment if it is less than 128 bytes. + Comment *string `protobuf:"bytes,14,opt,name=comment" json:"comment,omitempty"` + // The hash of the user certificate. + Hash *string `protobuf:"bytes,15,opt,name=hash" json:"hash,omitempty"` + // SHA1 hash of the user comment if it 128 bytes or more. + CommentHash []byte `protobuf:"bytes,16,opt,name=comment_hash,json=commentHash" json:"comment_hash,omitempty"` + // SHA1 hash of the user picture if it 128 bytes or more. + TextureHash []byte `protobuf:"bytes,17,opt,name=texture_hash,json=textureHash" json:"texture_hash,omitempty"` + // True if the user is a priority speaker. + PrioritySpeaker *bool `protobuf:"varint,18,opt,name=priority_speaker,json=prioritySpeaker" json:"priority_speaker,omitempty"` + // True if the user is currently recording. + Recording *bool `protobuf:"varint,19,opt,name=recording" json:"recording,omitempty"` + // A list of temporary acces tokens to be respected when processing this request. + TemporaryAccessTokens []string `protobuf:"bytes,20,rep,name=temporary_access_tokens,json=temporaryAccessTokens" json:"temporary_access_tokens,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *UserState) Reset() { *m = UserState{} } +func (m *UserState) String() string { return proto.CompactTextString(m) } +func (*UserState) ProtoMessage() {} +func (*UserState) Descriptor() ([]byte, []int) { + return fileDescriptor_56c09c2dce0fb003, []int{9} +} + +func (m *UserState) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_UserState.Unmarshal(m, b) +} +func (m *UserState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_UserState.Marshal(b, m, deterministic) +} +func (m *UserState) XXX_Merge(src proto.Message) { + xxx_messageInfo_UserState.Merge(m, src) +} +func (m *UserState) XXX_Size() int { + return xxx_messageInfo_UserState.Size(m) +} +func (m *UserState) XXX_DiscardUnknown() { + xxx_messageInfo_UserState.DiscardUnknown(m) +} + +var xxx_messageInfo_UserState proto.InternalMessageInfo + +func (m *UserState) GetSession() uint32 { + if m != nil && m.Session != nil { + return *m.Session + } + return 0 +} + +func (m *UserState) GetActor() uint32 { + if m != nil && m.Actor != nil { + return *m.Actor + } + return 0 +} + +func (m *UserState) GetName() string { + if m != nil && m.Name != nil { + return *m.Name + } + return "" +} + +func (m *UserState) GetUserId() uint32 { + if m != nil && m.UserId != nil { + return *m.UserId + } + return 0 +} + +func (m *UserState) GetChannelId() uint32 { + if m != nil && m.ChannelId != nil { + return *m.ChannelId + } + return 0 +} + +func (m *UserState) GetMute() bool { + if m != nil && m.Mute != nil { + return *m.Mute + } + return false +} + +func (m *UserState) GetDeaf() bool { + if m != nil && m.Deaf != nil { + return *m.Deaf + } + return false +} + +func (m *UserState) GetSuppress() bool { + if m != nil && m.Suppress != nil { + return *m.Suppress + } + return false +} + +func (m *UserState) GetSelfMute() bool { + if m != nil && m.SelfMute != nil { + return *m.SelfMute + } + return false +} + +func (m *UserState) GetSelfDeaf() bool { + if m != nil && m.SelfDeaf != nil { + return *m.SelfDeaf + } + return false +} + +func (m *UserState) GetTexture() []byte { + if m != nil { + return m.Texture + } + return nil +} + +func (m *UserState) GetPluginContext() []byte { + if m != nil { + return m.PluginContext + } + return nil +} + +func (m *UserState) GetPluginIdentity() string { + if m != nil && m.PluginIdentity != nil { + return *m.PluginIdentity + } + return "" +} + +func (m *UserState) GetComment() string { + if m != nil && m.Comment != nil { + return *m.Comment + } + return "" +} + +func (m *UserState) GetHash() string { + if m != nil && m.Hash != nil { + return *m.Hash + } + return "" +} + +func (m *UserState) GetCommentHash() []byte { + if m != nil { + return m.CommentHash + } + return nil +} + +func (m *UserState) GetTextureHash() []byte { + if m != nil { + return m.TextureHash + } + return nil +} + +func (m *UserState) GetPrioritySpeaker() bool { + if m != nil && m.PrioritySpeaker != nil { + return *m.PrioritySpeaker + } + return false +} + +func (m *UserState) GetRecording() bool { + if m != nil && m.Recording != nil { + return *m.Recording + } + return false +} + +func (m *UserState) GetTemporaryAccessTokens() []string { + if m != nil { + return m.TemporaryAccessTokens + } + return nil +} + +// Relays information on the bans. The client may send the BanList message to +// either modify the list of bans or query them from the server. The server +// sends this list only after a client queries for it. +type BanList struct { + // List of ban entries currently in place. + Bans []*BanList_BanEntry `protobuf:"bytes,1,rep,name=bans" json:"bans,omitempty"` + // True if the server should return the list, false if it should replace old + // ban list with the one provided. + Query *bool `protobuf:"varint,2,opt,name=query,def=0" json:"query,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *BanList) Reset() { *m = BanList{} } +func (m *BanList) String() string { return proto.CompactTextString(m) } +func (*BanList) ProtoMessage() {} +func (*BanList) Descriptor() ([]byte, []int) { + return fileDescriptor_56c09c2dce0fb003, []int{10} +} + +func (m *BanList) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_BanList.Unmarshal(m, b) +} +func (m *BanList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_BanList.Marshal(b, m, deterministic) +} +func (m *BanList) XXX_Merge(src proto.Message) { + xxx_messageInfo_BanList.Merge(m, src) +} +func (m *BanList) XXX_Size() int { + return xxx_messageInfo_BanList.Size(m) +} +func (m *BanList) XXX_DiscardUnknown() { + xxx_messageInfo_BanList.DiscardUnknown(m) +} + +var xxx_messageInfo_BanList proto.InternalMessageInfo + +const Default_BanList_Query bool = false + +func (m *BanList) GetBans() []*BanList_BanEntry { + if m != nil { + return m.Bans + } + return nil +} + +func (m *BanList) GetQuery() bool { + if m != nil && m.Query != nil { + return *m.Query + } + return Default_BanList_Query +} + +type BanList_BanEntry struct { + // Banned IP address. + Address []byte `protobuf:"bytes,1,req,name=address" json:"address,omitempty"` + // The length of the subnet mask for the ban. + Mask *uint32 `protobuf:"varint,2,req,name=mask" json:"mask,omitempty"` + // User name for identification purposes (does not affect the ban). + Name *string `protobuf:"bytes,3,opt,name=name" json:"name,omitempty"` + // The certificate hash of the banned user. + Hash *string `protobuf:"bytes,4,opt,name=hash" json:"hash,omitempty"` + // Reason for the ban (does not affect the ban). + Reason *string `protobuf:"bytes,5,opt,name=reason" json:"reason,omitempty"` + // Ban start time. + Start *string `protobuf:"bytes,6,opt,name=start" json:"start,omitempty"` + // Ban duration in seconds. + Duration *uint32 `protobuf:"varint,7,opt,name=duration" json:"duration,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *BanList_BanEntry) Reset() { *m = BanList_BanEntry{} } +func (m *BanList_BanEntry) String() string { return proto.CompactTextString(m) } +func (*BanList_BanEntry) ProtoMessage() {} +func (*BanList_BanEntry) Descriptor() ([]byte, []int) { + return fileDescriptor_56c09c2dce0fb003, []int{10, 0} +} + +func (m *BanList_BanEntry) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_BanList_BanEntry.Unmarshal(m, b) +} +func (m *BanList_BanEntry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_BanList_BanEntry.Marshal(b, m, deterministic) +} +func (m *BanList_BanEntry) XXX_Merge(src proto.Message) { + xxx_messageInfo_BanList_BanEntry.Merge(m, src) +} +func (m *BanList_BanEntry) XXX_Size() int { + return xxx_messageInfo_BanList_BanEntry.Size(m) +} +func (m *BanList_BanEntry) XXX_DiscardUnknown() { + xxx_messageInfo_BanList_BanEntry.DiscardUnknown(m) +} + +var xxx_messageInfo_BanList_BanEntry proto.InternalMessageInfo + +func (m *BanList_BanEntry) GetAddress() []byte { + if m != nil { + return m.Address + } + return nil +} + +func (m *BanList_BanEntry) GetMask() uint32 { + if m != nil && m.Mask != nil { + return *m.Mask + } + return 0 +} + +func (m *BanList_BanEntry) GetName() string { + if m != nil && m.Name != nil { + return *m.Name + } + return "" +} + +func (m *BanList_BanEntry) GetHash() string { + if m != nil && m.Hash != nil { + return *m.Hash + } + return "" +} + +func (m *BanList_BanEntry) GetReason() string { + if m != nil && m.Reason != nil { + return *m.Reason + } + return "" +} + +func (m *BanList_BanEntry) GetStart() string { + if m != nil && m.Start != nil { + return *m.Start + } + return "" +} + +func (m *BanList_BanEntry) GetDuration() uint32 { + if m != nil && m.Duration != nil { + return *m.Duration + } + return 0 +} + +// Used to send and broadcast text messages. +type TextMessage struct { + // The message sender, identified by its session. + Actor *uint32 `protobuf:"varint,1,opt,name=actor" json:"actor,omitempty"` + // Target users for the message, identified by their session. + Session []uint32 `protobuf:"varint,2,rep,name=session" json:"session,omitempty"` + // The channels to which the message is sent, identified by their + // channel_ids. + ChannelId []uint32 `protobuf:"varint,3,rep,name=channel_id,json=channelId" json:"channel_id,omitempty"` + // The root channels when sending message recursively to several channels, + // identified by their channel_ids. + TreeId []uint32 `protobuf:"varint,4,rep,name=tree_id,json=treeId" json:"tree_id,omitempty"` + // The UTF-8 encoded message. May be HTML if the server allows. + Message *string `protobuf:"bytes,5,req,name=message" json:"message,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *TextMessage) Reset() { *m = TextMessage{} } +func (m *TextMessage) String() string { return proto.CompactTextString(m) } +func (*TextMessage) ProtoMessage() {} +func (*TextMessage) Descriptor() ([]byte, []int) { + return fileDescriptor_56c09c2dce0fb003, []int{11} +} + +func (m *TextMessage) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_TextMessage.Unmarshal(m, b) +} +func (m *TextMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_TextMessage.Marshal(b, m, deterministic) +} +func (m *TextMessage) XXX_Merge(src proto.Message) { + xxx_messageInfo_TextMessage.Merge(m, src) +} +func (m *TextMessage) XXX_Size() int { + return xxx_messageInfo_TextMessage.Size(m) +} +func (m *TextMessage) XXX_DiscardUnknown() { + xxx_messageInfo_TextMessage.DiscardUnknown(m) +} + +var xxx_messageInfo_TextMessage proto.InternalMessageInfo + +func (m *TextMessage) GetActor() uint32 { + if m != nil && m.Actor != nil { + return *m.Actor + } + return 0 +} + +func (m *TextMessage) GetSession() []uint32 { + if m != nil { + return m.Session + } + return nil +} + +func (m *TextMessage) GetChannelId() []uint32 { + if m != nil { + return m.ChannelId + } + return nil +} + +func (m *TextMessage) GetTreeId() []uint32 { + if m != nil { + return m.TreeId + } + return nil +} + +func (m *TextMessage) GetMessage() string { + if m != nil && m.Message != nil { + return *m.Message + } + return "" +} + +type PermissionDenied struct { + // The denied permission when type is Permission. + Permission *uint32 `protobuf:"varint,1,opt,name=permission" json:"permission,omitempty"` + // channel_id for the channel where the permission was denied when type is + // Permission. + ChannelId *uint32 `protobuf:"varint,2,opt,name=channel_id,json=channelId" json:"channel_id,omitempty"` + // The user who was denied permissions, identified by session. + Session *uint32 `protobuf:"varint,3,opt,name=session" json:"session,omitempty"` + // Textual reason for the denial. + Reason *string `protobuf:"bytes,4,opt,name=reason" json:"reason,omitempty"` + // Type of the denial. + Type *PermissionDenied_DenyType `protobuf:"varint,5,opt,name=type,enum=MumbleProto.PermissionDenied_DenyType" json:"type,omitempty"` + // The name that is invalid when type is UserName. + Name *string `protobuf:"bytes,6,opt,name=name" json:"name,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *PermissionDenied) Reset() { *m = PermissionDenied{} } +func (m *PermissionDenied) String() string { return proto.CompactTextString(m) } +func (*PermissionDenied) ProtoMessage() {} +func (*PermissionDenied) Descriptor() ([]byte, []int) { + return fileDescriptor_56c09c2dce0fb003, []int{12} +} + +func (m *PermissionDenied) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_PermissionDenied.Unmarshal(m, b) +} +func (m *PermissionDenied) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_PermissionDenied.Marshal(b, m, deterministic) +} +func (m *PermissionDenied) XXX_Merge(src proto.Message) { + xxx_messageInfo_PermissionDenied.Merge(m, src) +} +func (m *PermissionDenied) XXX_Size() int { + return xxx_messageInfo_PermissionDenied.Size(m) +} +func (m *PermissionDenied) XXX_DiscardUnknown() { + xxx_messageInfo_PermissionDenied.DiscardUnknown(m) +} + +var xxx_messageInfo_PermissionDenied proto.InternalMessageInfo + +func (m *PermissionDenied) GetPermission() uint32 { + if m != nil && m.Permission != nil { + return *m.Permission + } + return 0 +} + +func (m *PermissionDenied) GetChannelId() uint32 { + if m != nil && m.ChannelId != nil { + return *m.ChannelId + } + return 0 +} + +func (m *PermissionDenied) GetSession() uint32 { + if m != nil && m.Session != nil { + return *m.Session + } + return 0 +} + +func (m *PermissionDenied) GetReason() string { + if m != nil && m.Reason != nil { + return *m.Reason + } + return "" +} + +func (m *PermissionDenied) GetType() PermissionDenied_DenyType { + if m != nil && m.Type != nil { + return *m.Type + } + return PermissionDenied_Text +} + +func (m *PermissionDenied) GetName() string { + if m != nil && m.Name != nil { + return *m.Name + } + return "" +} + +type ACL struct { + // Channel ID of the channel this message affects. + ChannelId *uint32 `protobuf:"varint,1,req,name=channel_id,json=channelId" json:"channel_id,omitempty"` + // True if the channel inherits its parent's ACLs. + InheritAcls *bool `protobuf:"varint,2,opt,name=inherit_acls,json=inheritAcls,def=1" json:"inherit_acls,omitempty"` + // User group specifications. + Groups []*ACL_ChanGroup `protobuf:"bytes,3,rep,name=groups" json:"groups,omitempty"` + // ACL specifications. + Acls []*ACL_ChanACL `protobuf:"bytes,4,rep,name=acls" json:"acls,omitempty"` + // True if the message is a query for ACLs instead of setting them. + Query *bool `protobuf:"varint,5,opt,name=query,def=0" json:"query,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ACL) Reset() { *m = ACL{} } +func (m *ACL) String() string { return proto.CompactTextString(m) } +func (*ACL) ProtoMessage() {} +func (*ACL) Descriptor() ([]byte, []int) { + return fileDescriptor_56c09c2dce0fb003, []int{13} +} + +func (m *ACL) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ACL.Unmarshal(m, b) +} +func (m *ACL) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ACL.Marshal(b, m, deterministic) +} +func (m *ACL) XXX_Merge(src proto.Message) { + xxx_messageInfo_ACL.Merge(m, src) +} +func (m *ACL) XXX_Size() int { + return xxx_messageInfo_ACL.Size(m) +} +func (m *ACL) XXX_DiscardUnknown() { + xxx_messageInfo_ACL.DiscardUnknown(m) +} + +var xxx_messageInfo_ACL proto.InternalMessageInfo + +const Default_ACL_InheritAcls bool = true +const Default_ACL_Query bool = false + +func (m *ACL) GetChannelId() uint32 { + if m != nil && m.ChannelId != nil { + return *m.ChannelId + } + return 0 +} + +func (m *ACL) GetInheritAcls() bool { + if m != nil && m.InheritAcls != nil { + return *m.InheritAcls + } + return Default_ACL_InheritAcls +} + +func (m *ACL) GetGroups() []*ACL_ChanGroup { + if m != nil { + return m.Groups + } + return nil +} + +func (m *ACL) GetAcls() []*ACL_ChanACL { + if m != nil { + return m.Acls + } + return nil +} + +func (m *ACL) GetQuery() bool { + if m != nil && m.Query != nil { + return *m.Query + } + return Default_ACL_Query +} + +type ACL_ChanGroup struct { + // Name of the channel group, UTF-8 encoded. + Name *string `protobuf:"bytes,1,req,name=name" json:"name,omitempty"` + // True if the group has been inherited from the parent (Read only). + Inherited *bool `protobuf:"varint,2,opt,name=inherited,def=1" json:"inherited,omitempty"` + // True if the group members are inherited. + Inherit *bool `protobuf:"varint,3,opt,name=inherit,def=1" json:"inherit,omitempty"` + // True if the group can be inherited by sub channels. + Inheritable *bool `protobuf:"varint,4,opt,name=inheritable,def=1" json:"inheritable,omitempty"` + // Users explicitly included in this group, identified by user_id. + Add []uint32 `protobuf:"varint,5,rep,name=add" json:"add,omitempty"` + // Users explicitly removed from this group in this channel if the group + // has been inherited, identified by user_id. + Remove []uint32 `protobuf:"varint,6,rep,name=remove" json:"remove,omitempty"` + // Users inherited, identified by user_id. + InheritedMembers []uint32 `protobuf:"varint,7,rep,name=inherited_members,json=inheritedMembers" json:"inherited_members,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ACL_ChanGroup) Reset() { *m = ACL_ChanGroup{} } +func (m *ACL_ChanGroup) String() string { return proto.CompactTextString(m) } +func (*ACL_ChanGroup) ProtoMessage() {} +func (*ACL_ChanGroup) Descriptor() ([]byte, []int) { + return fileDescriptor_56c09c2dce0fb003, []int{13, 0} +} + +func (m *ACL_ChanGroup) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ACL_ChanGroup.Unmarshal(m, b) +} +func (m *ACL_ChanGroup) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ACL_ChanGroup.Marshal(b, m, deterministic) +} +func (m *ACL_ChanGroup) XXX_Merge(src proto.Message) { + xxx_messageInfo_ACL_ChanGroup.Merge(m, src) +} +func (m *ACL_ChanGroup) XXX_Size() int { + return xxx_messageInfo_ACL_ChanGroup.Size(m) +} +func (m *ACL_ChanGroup) XXX_DiscardUnknown() { + xxx_messageInfo_ACL_ChanGroup.DiscardUnknown(m) +} + +var xxx_messageInfo_ACL_ChanGroup proto.InternalMessageInfo + +const Default_ACL_ChanGroup_Inherited bool = true +const Default_ACL_ChanGroup_Inherit bool = true +const Default_ACL_ChanGroup_Inheritable bool = true + +func (m *ACL_ChanGroup) GetName() string { + if m != nil && m.Name != nil { + return *m.Name + } + return "" +} + +func (m *ACL_ChanGroup) GetInherited() bool { + if m != nil && m.Inherited != nil { + return *m.Inherited + } + return Default_ACL_ChanGroup_Inherited +} + +func (m *ACL_ChanGroup) GetInherit() bool { + if m != nil && m.Inherit != nil { + return *m.Inherit + } + return Default_ACL_ChanGroup_Inherit +} + +func (m *ACL_ChanGroup) GetInheritable() bool { + if m != nil && m.Inheritable != nil { + return *m.Inheritable + } + return Default_ACL_ChanGroup_Inheritable +} + +func (m *ACL_ChanGroup) GetAdd() []uint32 { + if m != nil { + return m.Add + } + return nil +} + +func (m *ACL_ChanGroup) GetRemove() []uint32 { + if m != nil { + return m.Remove + } + return nil +} + +func (m *ACL_ChanGroup) GetInheritedMembers() []uint32 { + if m != nil { + return m.InheritedMembers + } + return nil +} + +type ACL_ChanACL struct { + // True if this ACL applies to the current channel. + ApplyHere *bool `protobuf:"varint,1,opt,name=apply_here,json=applyHere,def=1" json:"apply_here,omitempty"` + // True if this ACL applies to the sub channels. + ApplySubs *bool `protobuf:"varint,2,opt,name=apply_subs,json=applySubs,def=1" json:"apply_subs,omitempty"` + // True if the ACL has been inherited from the parent. + Inherited *bool `protobuf:"varint,3,opt,name=inherited,def=1" json:"inherited,omitempty"` + // ID of the user that is affected by this ACL. + UserId *uint32 `protobuf:"varint,4,opt,name=user_id,json=userId" json:"user_id,omitempty"` + // ID of the group that is affected by this ACL. + Group *string `protobuf:"bytes,5,opt,name=group" json:"group,omitempty"` + // Bit flag field of the permissions granted by this ACL. + Grant *uint32 `protobuf:"varint,6,opt,name=grant" json:"grant,omitempty"` + // Bit flag field of the permissions denied by this ACL. + Deny *uint32 `protobuf:"varint,7,opt,name=deny" json:"deny,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ACL_ChanACL) Reset() { *m = ACL_ChanACL{} } +func (m *ACL_ChanACL) String() string { return proto.CompactTextString(m) } +func (*ACL_ChanACL) ProtoMessage() {} +func (*ACL_ChanACL) Descriptor() ([]byte, []int) { + return fileDescriptor_56c09c2dce0fb003, []int{13, 1} +} + +func (m *ACL_ChanACL) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ACL_ChanACL.Unmarshal(m, b) +} +func (m *ACL_ChanACL) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ACL_ChanACL.Marshal(b, m, deterministic) +} +func (m *ACL_ChanACL) XXX_Merge(src proto.Message) { + xxx_messageInfo_ACL_ChanACL.Merge(m, src) +} +func (m *ACL_ChanACL) XXX_Size() int { + return xxx_messageInfo_ACL_ChanACL.Size(m) +} +func (m *ACL_ChanACL) XXX_DiscardUnknown() { + xxx_messageInfo_ACL_ChanACL.DiscardUnknown(m) +} + +var xxx_messageInfo_ACL_ChanACL proto.InternalMessageInfo + +const Default_ACL_ChanACL_ApplyHere bool = true +const Default_ACL_ChanACL_ApplySubs bool = true +const Default_ACL_ChanACL_Inherited bool = true + +func (m *ACL_ChanACL) GetApplyHere() bool { + if m != nil && m.ApplyHere != nil { + return *m.ApplyHere + } + return Default_ACL_ChanACL_ApplyHere +} + +func (m *ACL_ChanACL) GetApplySubs() bool { + if m != nil && m.ApplySubs != nil { + return *m.ApplySubs + } + return Default_ACL_ChanACL_ApplySubs +} + +func (m *ACL_ChanACL) GetInherited() bool { + if m != nil && m.Inherited != nil { + return *m.Inherited + } + return Default_ACL_ChanACL_Inherited +} + +func (m *ACL_ChanACL) GetUserId() uint32 { + if m != nil && m.UserId != nil { + return *m.UserId + } + return 0 +} + +func (m *ACL_ChanACL) GetGroup() string { + if m != nil && m.Group != nil { + return *m.Group + } + return "" +} + +func (m *ACL_ChanACL) GetGrant() uint32 { + if m != nil && m.Grant != nil { + return *m.Grant + } + return 0 +} + +func (m *ACL_ChanACL) GetDeny() uint32 { + if m != nil && m.Deny != nil { + return *m.Deny + } + return 0 +} + +// Client may use this message to refresh its registered user information. The +// client should fill the IDs or Names of the users it wants to refresh. The +// server fills the missing parts and sends the message back. +type QueryUsers struct { + // user_ids. + Ids []uint32 `protobuf:"varint,1,rep,name=ids" json:"ids,omitempty"` + // User names in the same order as ids. + Names []string `protobuf:"bytes,2,rep,name=names" json:"names,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *QueryUsers) Reset() { *m = QueryUsers{} } +func (m *QueryUsers) String() string { return proto.CompactTextString(m) } +func (*QueryUsers) ProtoMessage() {} +func (*QueryUsers) Descriptor() ([]byte, []int) { + return fileDescriptor_56c09c2dce0fb003, []int{14} +} + +func (m *QueryUsers) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_QueryUsers.Unmarshal(m, b) +} +func (m *QueryUsers) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_QueryUsers.Marshal(b, m, deterministic) +} +func (m *QueryUsers) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryUsers.Merge(m, src) +} +func (m *QueryUsers) XXX_Size() int { + return xxx_messageInfo_QueryUsers.Size(m) +} +func (m *QueryUsers) XXX_DiscardUnknown() { + xxx_messageInfo_QueryUsers.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryUsers proto.InternalMessageInfo + +func (m *QueryUsers) GetIds() []uint32 { + if m != nil { + return m.Ids + } + return nil +} + +func (m *QueryUsers) GetNames() []string { + if m != nil { + return m.Names + } + return nil +} + +// Used to initialize and resync the UDP encryption. Either side may request a +// resync by sending the message without any values filled. The resync is +// performed by sending the message with only the client or server nonce +// filled. +type CryptSetup struct { + // Encryption key. + Key []byte `protobuf:"bytes,1,opt,name=key" json:"key,omitempty"` + // Client nonce. + ClientNonce []byte `protobuf:"bytes,2,opt,name=client_nonce,json=clientNonce" json:"client_nonce,omitempty"` + // Server nonce. + ServerNonce []byte `protobuf:"bytes,3,opt,name=server_nonce,json=serverNonce" json:"server_nonce,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *CryptSetup) Reset() { *m = CryptSetup{} } +func (m *CryptSetup) String() string { return proto.CompactTextString(m) } +func (*CryptSetup) ProtoMessage() {} +func (*CryptSetup) Descriptor() ([]byte, []int) { + return fileDescriptor_56c09c2dce0fb003, []int{15} +} + +func (m *CryptSetup) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_CryptSetup.Unmarshal(m, b) +} +func (m *CryptSetup) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_CryptSetup.Marshal(b, m, deterministic) +} +func (m *CryptSetup) XXX_Merge(src proto.Message) { + xxx_messageInfo_CryptSetup.Merge(m, src) +} +func (m *CryptSetup) XXX_Size() int { + return xxx_messageInfo_CryptSetup.Size(m) +} +func (m *CryptSetup) XXX_DiscardUnknown() { + xxx_messageInfo_CryptSetup.DiscardUnknown(m) +} + +var xxx_messageInfo_CryptSetup proto.InternalMessageInfo + +func (m *CryptSetup) GetKey() []byte { + if m != nil { + return m.Key + } + return nil +} + +func (m *CryptSetup) GetClientNonce() []byte { + if m != nil { + return m.ClientNonce + } + return nil +} + +func (m *CryptSetup) GetServerNonce() []byte { + if m != nil { + return m.ServerNonce + } + return nil +} + +type ContextActionModify struct { + // The action name. + Action *string `protobuf:"bytes,1,req,name=action" json:"action,omitempty"` + // The display name of the action. + Text *string `protobuf:"bytes,2,opt,name=text" json:"text,omitempty"` + // Context bit flags defining where the action should be displayed. + Context *uint32 `protobuf:"varint,3,opt,name=context" json:"context,omitempty"` + Operation *ContextActionModify_Operation `protobuf:"varint,4,opt,name=operation,enum=MumbleProto.ContextActionModify_Operation" json:"operation,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ContextActionModify) Reset() { *m = ContextActionModify{} } +func (m *ContextActionModify) String() string { return proto.CompactTextString(m) } +func (*ContextActionModify) ProtoMessage() {} +func (*ContextActionModify) Descriptor() ([]byte, []int) { + return fileDescriptor_56c09c2dce0fb003, []int{16} +} + +func (m *ContextActionModify) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ContextActionModify.Unmarshal(m, b) +} +func (m *ContextActionModify) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ContextActionModify.Marshal(b, m, deterministic) +} +func (m *ContextActionModify) XXX_Merge(src proto.Message) { + xxx_messageInfo_ContextActionModify.Merge(m, src) +} +func (m *ContextActionModify) XXX_Size() int { + return xxx_messageInfo_ContextActionModify.Size(m) +} +func (m *ContextActionModify) XXX_DiscardUnknown() { + xxx_messageInfo_ContextActionModify.DiscardUnknown(m) +} + +var xxx_messageInfo_ContextActionModify proto.InternalMessageInfo + +func (m *ContextActionModify) GetAction() string { + if m != nil && m.Action != nil { + return *m.Action + } + return "" +} + +func (m *ContextActionModify) GetText() string { + if m != nil && m.Text != nil { + return *m.Text + } + return "" +} + +func (m *ContextActionModify) GetContext() uint32 { + if m != nil && m.Context != nil { + return *m.Context + } + return 0 +} + +func (m *ContextActionModify) GetOperation() ContextActionModify_Operation { + if m != nil && m.Operation != nil { + return *m.Operation + } + return ContextActionModify_Add +} + +// Sent by the client when it wants to initiate a Context action. +type ContextAction struct { + // The target User for the action, identified by session. + Session *uint32 `protobuf:"varint,1,opt,name=session" json:"session,omitempty"` + // The target Channel for the action, identified by channel_id. + ChannelId *uint32 `protobuf:"varint,2,opt,name=channel_id,json=channelId" json:"channel_id,omitempty"` + // The action that should be executed. + Action *string `protobuf:"bytes,3,req,name=action" json:"action,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ContextAction) Reset() { *m = ContextAction{} } +func (m *ContextAction) String() string { return proto.CompactTextString(m) } +func (*ContextAction) ProtoMessage() {} +func (*ContextAction) Descriptor() ([]byte, []int) { + return fileDescriptor_56c09c2dce0fb003, []int{17} +} + +func (m *ContextAction) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ContextAction.Unmarshal(m, b) +} +func (m *ContextAction) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ContextAction.Marshal(b, m, deterministic) +} +func (m *ContextAction) XXX_Merge(src proto.Message) { + xxx_messageInfo_ContextAction.Merge(m, src) +} +func (m *ContextAction) XXX_Size() int { + return xxx_messageInfo_ContextAction.Size(m) +} +func (m *ContextAction) XXX_DiscardUnknown() { + xxx_messageInfo_ContextAction.DiscardUnknown(m) +} + +var xxx_messageInfo_ContextAction proto.InternalMessageInfo + +func (m *ContextAction) GetSession() uint32 { + if m != nil && m.Session != nil { + return *m.Session + } + return 0 +} + +func (m *ContextAction) GetChannelId() uint32 { + if m != nil && m.ChannelId != nil { + return *m.ChannelId + } + return 0 +} + +func (m *ContextAction) GetAction() string { + if m != nil && m.Action != nil { + return *m.Action + } + return "" +} + +// Lists the registered users. +type UserList struct { + // A list of registered users. + Users []*UserList_User `protobuf:"bytes,1,rep,name=users" json:"users,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *UserList) Reset() { *m = UserList{} } +func (m *UserList) String() string { return proto.CompactTextString(m) } +func (*UserList) ProtoMessage() {} +func (*UserList) Descriptor() ([]byte, []int) { + return fileDescriptor_56c09c2dce0fb003, []int{18} +} + +func (m *UserList) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_UserList.Unmarshal(m, b) +} +func (m *UserList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_UserList.Marshal(b, m, deterministic) +} +func (m *UserList) XXX_Merge(src proto.Message) { + xxx_messageInfo_UserList.Merge(m, src) +} +func (m *UserList) XXX_Size() int { + return xxx_messageInfo_UserList.Size(m) +} +func (m *UserList) XXX_DiscardUnknown() { + xxx_messageInfo_UserList.DiscardUnknown(m) +} + +var xxx_messageInfo_UserList proto.InternalMessageInfo + +func (m *UserList) GetUsers() []*UserList_User { + if m != nil { + return m.Users + } + return nil +} + +type UserList_User struct { + // Registered user ID. + UserId *uint32 `protobuf:"varint,1,req,name=user_id,json=userId" json:"user_id,omitempty"` + // Registered user name. + Name *string `protobuf:"bytes,2,opt,name=name" json:"name,omitempty"` + LastSeen *string `protobuf:"bytes,3,opt,name=last_seen,json=lastSeen" json:"last_seen,omitempty"` + LastChannel *uint32 `protobuf:"varint,4,opt,name=last_channel,json=lastChannel" json:"last_channel,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *UserList_User) Reset() { *m = UserList_User{} } +func (m *UserList_User) String() string { return proto.CompactTextString(m) } +func (*UserList_User) ProtoMessage() {} +func (*UserList_User) Descriptor() ([]byte, []int) { + return fileDescriptor_56c09c2dce0fb003, []int{18, 0} +} + +func (m *UserList_User) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_UserList_User.Unmarshal(m, b) +} +func (m *UserList_User) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_UserList_User.Marshal(b, m, deterministic) +} +func (m *UserList_User) XXX_Merge(src proto.Message) { + xxx_messageInfo_UserList_User.Merge(m, src) +} +func (m *UserList_User) XXX_Size() int { + return xxx_messageInfo_UserList_User.Size(m) +} +func (m *UserList_User) XXX_DiscardUnknown() { + xxx_messageInfo_UserList_User.DiscardUnknown(m) +} + +var xxx_messageInfo_UserList_User proto.InternalMessageInfo + +func (m *UserList_User) GetUserId() uint32 { + if m != nil && m.UserId != nil { + return *m.UserId + } + return 0 +} + +func (m *UserList_User) GetName() string { + if m != nil && m.Name != nil { + return *m.Name + } + return "" +} + +func (m *UserList_User) GetLastSeen() string { + if m != nil && m.LastSeen != nil { + return *m.LastSeen + } + return "" +} + +func (m *UserList_User) GetLastChannel() uint32 { + if m != nil && m.LastChannel != nil { + return *m.LastChannel + } + return 0 +} + +// Sent by the client when it wants to register or clear whisper targets. +// +// Note: The first available target ID is 1 as 0 is reserved for normal +// talking. Maximum target ID is 30. +type VoiceTarget struct { + // Voice target ID. + Id *uint32 `protobuf:"varint,1,opt,name=id" json:"id,omitempty"` + // The receivers that this voice target includes. + Targets []*VoiceTarget_Target `protobuf:"bytes,2,rep,name=targets" json:"targets,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *VoiceTarget) Reset() { *m = VoiceTarget{} } +func (m *VoiceTarget) String() string { return proto.CompactTextString(m) } +func (*VoiceTarget) ProtoMessage() {} +func (*VoiceTarget) Descriptor() ([]byte, []int) { + return fileDescriptor_56c09c2dce0fb003, []int{19} +} + +func (m *VoiceTarget) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_VoiceTarget.Unmarshal(m, b) +} +func (m *VoiceTarget) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_VoiceTarget.Marshal(b, m, deterministic) +} +func (m *VoiceTarget) XXX_Merge(src proto.Message) { + xxx_messageInfo_VoiceTarget.Merge(m, src) +} +func (m *VoiceTarget) XXX_Size() int { + return xxx_messageInfo_VoiceTarget.Size(m) +} +func (m *VoiceTarget) XXX_DiscardUnknown() { + xxx_messageInfo_VoiceTarget.DiscardUnknown(m) +} + +var xxx_messageInfo_VoiceTarget proto.InternalMessageInfo + +func (m *VoiceTarget) GetId() uint32 { + if m != nil && m.Id != nil { + return *m.Id + } + return 0 +} + +func (m *VoiceTarget) GetTargets() []*VoiceTarget_Target { + if m != nil { + return m.Targets + } + return nil +} + +type VoiceTarget_Target struct { + // Users that are included as targets. + Session []uint32 `protobuf:"varint,1,rep,name=session" json:"session,omitempty"` + // Channel that is included as a target. + ChannelId *uint32 `protobuf:"varint,2,opt,name=channel_id,json=channelId" json:"channel_id,omitempty"` + // ACL group that is included as a target. + Group *string `protobuf:"bytes,3,opt,name=group" json:"group,omitempty"` + // True if the voice should follow links from the specified channel. + Links *bool `protobuf:"varint,4,opt,name=links,def=0" json:"links,omitempty"` + // True if the voice should also be sent to children of the specific + // channel. + Children *bool `protobuf:"varint,5,opt,name=children,def=0" json:"children,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *VoiceTarget_Target) Reset() { *m = VoiceTarget_Target{} } +func (m *VoiceTarget_Target) String() string { return proto.CompactTextString(m) } +func (*VoiceTarget_Target) ProtoMessage() {} +func (*VoiceTarget_Target) Descriptor() ([]byte, []int) { + return fileDescriptor_56c09c2dce0fb003, []int{19, 0} +} + +func (m *VoiceTarget_Target) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_VoiceTarget_Target.Unmarshal(m, b) +} +func (m *VoiceTarget_Target) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_VoiceTarget_Target.Marshal(b, m, deterministic) +} +func (m *VoiceTarget_Target) XXX_Merge(src proto.Message) { + xxx_messageInfo_VoiceTarget_Target.Merge(m, src) +} +func (m *VoiceTarget_Target) XXX_Size() int { + return xxx_messageInfo_VoiceTarget_Target.Size(m) +} +func (m *VoiceTarget_Target) XXX_DiscardUnknown() { + xxx_messageInfo_VoiceTarget_Target.DiscardUnknown(m) +} + +var xxx_messageInfo_VoiceTarget_Target proto.InternalMessageInfo + +const Default_VoiceTarget_Target_Links bool = false +const Default_VoiceTarget_Target_Children bool = false + +func (m *VoiceTarget_Target) GetSession() []uint32 { + if m != nil { + return m.Session + } + return nil +} + +func (m *VoiceTarget_Target) GetChannelId() uint32 { + if m != nil && m.ChannelId != nil { + return *m.ChannelId + } + return 0 +} + +func (m *VoiceTarget_Target) GetGroup() string { + if m != nil && m.Group != nil { + return *m.Group + } + return "" +} + +func (m *VoiceTarget_Target) GetLinks() bool { + if m != nil && m.Links != nil { + return *m.Links + } + return Default_VoiceTarget_Target_Links +} + +func (m *VoiceTarget_Target) GetChildren() bool { + if m != nil && m.Children != nil { + return *m.Children + } + return Default_VoiceTarget_Target_Children +} + +// Sent by the client when it wants permissions for a certain channel. Sent by +// the server when it replies to the query or wants the user to resync all +// channel permissions. +type PermissionQuery struct { + // channel_id of the channel for which the permissions are queried. + ChannelId *uint32 `protobuf:"varint,1,opt,name=channel_id,json=channelId" json:"channel_id,omitempty"` + // Channel permissions. + Permissions *uint32 `protobuf:"varint,2,opt,name=permissions" json:"permissions,omitempty"` + // True if the client should drop its current permission information for all + // channels. + Flush *bool `protobuf:"varint,3,opt,name=flush,def=0" json:"flush,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *PermissionQuery) Reset() { *m = PermissionQuery{} } +func (m *PermissionQuery) String() string { return proto.CompactTextString(m) } +func (*PermissionQuery) ProtoMessage() {} +func (*PermissionQuery) Descriptor() ([]byte, []int) { + return fileDescriptor_56c09c2dce0fb003, []int{20} +} + +func (m *PermissionQuery) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_PermissionQuery.Unmarshal(m, b) +} +func (m *PermissionQuery) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_PermissionQuery.Marshal(b, m, deterministic) +} +func (m *PermissionQuery) XXX_Merge(src proto.Message) { + xxx_messageInfo_PermissionQuery.Merge(m, src) +} +func (m *PermissionQuery) XXX_Size() int { + return xxx_messageInfo_PermissionQuery.Size(m) +} +func (m *PermissionQuery) XXX_DiscardUnknown() { + xxx_messageInfo_PermissionQuery.DiscardUnknown(m) +} + +var xxx_messageInfo_PermissionQuery proto.InternalMessageInfo + +const Default_PermissionQuery_Flush bool = false + +func (m *PermissionQuery) GetChannelId() uint32 { + if m != nil && m.ChannelId != nil { + return *m.ChannelId + } + return 0 +} + +func (m *PermissionQuery) GetPermissions() uint32 { + if m != nil && m.Permissions != nil { + return *m.Permissions + } + return 0 +} + +func (m *PermissionQuery) GetFlush() bool { + if m != nil && m.Flush != nil { + return *m.Flush + } + return Default_PermissionQuery_Flush +} + +// Sent by the server to notify the users of the version of the CELT codec they +// should use. This may change during the connection when new users join. +type CodecVersion struct { + // The version of the CELT Alpha codec. + Alpha *int32 `protobuf:"varint,1,req,name=alpha" json:"alpha,omitempty"` + // The version of the CELT Beta codec. + Beta *int32 `protobuf:"varint,2,req,name=beta" json:"beta,omitempty"` + // True if the user should prefer Alpha over Beta. + PreferAlpha *bool `protobuf:"varint,3,req,name=prefer_alpha,json=preferAlpha,def=1" json:"prefer_alpha,omitempty"` + Opus *bool `protobuf:"varint,4,opt,name=opus,def=0" json:"opus,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *CodecVersion) Reset() { *m = CodecVersion{} } +func (m *CodecVersion) String() string { return proto.CompactTextString(m) } +func (*CodecVersion) ProtoMessage() {} +func (*CodecVersion) Descriptor() ([]byte, []int) { + return fileDescriptor_56c09c2dce0fb003, []int{21} +} + +func (m *CodecVersion) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_CodecVersion.Unmarshal(m, b) +} +func (m *CodecVersion) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_CodecVersion.Marshal(b, m, deterministic) +} +func (m *CodecVersion) XXX_Merge(src proto.Message) { + xxx_messageInfo_CodecVersion.Merge(m, src) +} +func (m *CodecVersion) XXX_Size() int { + return xxx_messageInfo_CodecVersion.Size(m) +} +func (m *CodecVersion) XXX_DiscardUnknown() { + xxx_messageInfo_CodecVersion.DiscardUnknown(m) +} + +var xxx_messageInfo_CodecVersion proto.InternalMessageInfo + +const Default_CodecVersion_PreferAlpha bool = true +const Default_CodecVersion_Opus bool = false + +func (m *CodecVersion) GetAlpha() int32 { + if m != nil && m.Alpha != nil { + return *m.Alpha + } + return 0 +} + +func (m *CodecVersion) GetBeta() int32 { + if m != nil && m.Beta != nil { + return *m.Beta + } + return 0 +} + +func (m *CodecVersion) GetPreferAlpha() bool { + if m != nil && m.PreferAlpha != nil { + return *m.PreferAlpha + } + return Default_CodecVersion_PreferAlpha +} + +func (m *CodecVersion) GetOpus() bool { + if m != nil && m.Opus != nil { + return *m.Opus + } + return Default_CodecVersion_Opus +} + +// Used to communicate user stats between the server and clients. +type UserStats struct { + // User whose stats these are. + Session *uint32 `protobuf:"varint,1,opt,name=session" json:"session,omitempty"` + // True if the message contains only mutable stats (packets, ping). + StatsOnly *bool `protobuf:"varint,2,opt,name=stats_only,json=statsOnly,def=0" json:"stats_only,omitempty"` + // Full user certificate chain of the user certificate in DER format. + Certificates [][]byte `protobuf:"bytes,3,rep,name=certificates" json:"certificates,omitempty"` + // Packet statistics for packets received from the client. + FromClient *UserStats_Stats `protobuf:"bytes,4,opt,name=from_client,json=fromClient" json:"from_client,omitempty"` + // Packet statistics for packets sent by the server. + FromServer *UserStats_Stats `protobuf:"bytes,5,opt,name=from_server,json=fromServer" json:"from_server,omitempty"` + // Amount of UDP packets sent. + UdpPackets *uint32 `protobuf:"varint,6,opt,name=udp_packets,json=udpPackets" json:"udp_packets,omitempty"` + // Amount of TCP packets sent. + TcpPackets *uint32 `protobuf:"varint,7,opt,name=tcp_packets,json=tcpPackets" json:"tcp_packets,omitempty"` + // UDP ping average. + UdpPingAvg *float32 `protobuf:"fixed32,8,opt,name=udp_ping_avg,json=udpPingAvg" json:"udp_ping_avg,omitempty"` + // UDP ping variance. + UdpPingVar *float32 `protobuf:"fixed32,9,opt,name=udp_ping_var,json=udpPingVar" json:"udp_ping_var,omitempty"` + // TCP ping average. + TcpPingAvg *float32 `protobuf:"fixed32,10,opt,name=tcp_ping_avg,json=tcpPingAvg" json:"tcp_ping_avg,omitempty"` + // TCP ping variance. + TcpPingVar *float32 `protobuf:"fixed32,11,opt,name=tcp_ping_var,json=tcpPingVar" json:"tcp_ping_var,omitempty"` + // Client version. + Version *Version `protobuf:"bytes,12,opt,name=version" json:"version,omitempty"` + // A list of CELT bitstream version constants supported by the client of this + // user. + CeltVersions []int32 `protobuf:"varint,13,rep,name=celt_versions,json=celtVersions" json:"celt_versions,omitempty"` + // Client IP address. + Address []byte `protobuf:"bytes,14,opt,name=address" json:"address,omitempty"` + // Bandwith used by this client. + Bandwidth *uint32 `protobuf:"varint,15,opt,name=bandwidth" json:"bandwidth,omitempty"` + // Connection duration. + Onlinesecs *uint32 `protobuf:"varint,16,opt,name=onlinesecs" json:"onlinesecs,omitempty"` + // Duration since last activity. + Idlesecs *uint32 `protobuf:"varint,17,opt,name=idlesecs" json:"idlesecs,omitempty"` + // True if the user has a strong certificate. + StrongCertificate *bool `protobuf:"varint,18,opt,name=strong_certificate,json=strongCertificate,def=0" json:"strong_certificate,omitempty"` + Opus *bool `protobuf:"varint,19,opt,name=opus,def=0" json:"opus,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *UserStats) Reset() { *m = UserStats{} } +func (m *UserStats) String() string { return proto.CompactTextString(m) } +func (*UserStats) ProtoMessage() {} +func (*UserStats) Descriptor() ([]byte, []int) { + return fileDescriptor_56c09c2dce0fb003, []int{22} +} + +func (m *UserStats) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_UserStats.Unmarshal(m, b) +} +func (m *UserStats) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_UserStats.Marshal(b, m, deterministic) +} +func (m *UserStats) XXX_Merge(src proto.Message) { + xxx_messageInfo_UserStats.Merge(m, src) +} +func (m *UserStats) XXX_Size() int { + return xxx_messageInfo_UserStats.Size(m) +} +func (m *UserStats) XXX_DiscardUnknown() { + xxx_messageInfo_UserStats.DiscardUnknown(m) +} + +var xxx_messageInfo_UserStats proto.InternalMessageInfo + +const Default_UserStats_StatsOnly bool = false +const Default_UserStats_StrongCertificate bool = false +const Default_UserStats_Opus bool = false + +func (m *UserStats) GetSession() uint32 { + if m != nil && m.Session != nil { + return *m.Session + } + return 0 +} + +func (m *UserStats) GetStatsOnly() bool { + if m != nil && m.StatsOnly != nil { + return *m.StatsOnly + } + return Default_UserStats_StatsOnly +} + +func (m *UserStats) GetCertificates() [][]byte { + if m != nil { + return m.Certificates + } + return nil +} + +func (m *UserStats) GetFromClient() *UserStats_Stats { + if m != nil { + return m.FromClient + } + return nil +} + +func (m *UserStats) GetFromServer() *UserStats_Stats { + if m != nil { + return m.FromServer + } + return nil +} + +func (m *UserStats) GetUdpPackets() uint32 { + if m != nil && m.UdpPackets != nil { + return *m.UdpPackets + } + return 0 +} + +func (m *UserStats) GetTcpPackets() uint32 { + if m != nil && m.TcpPackets != nil { + return *m.TcpPackets + } + return 0 +} + +func (m *UserStats) GetUdpPingAvg() float32 { + if m != nil && m.UdpPingAvg != nil { + return *m.UdpPingAvg + } + return 0 +} + +func (m *UserStats) GetUdpPingVar() float32 { + if m != nil && m.UdpPingVar != nil { + return *m.UdpPingVar + } + return 0 +} + +func (m *UserStats) GetTcpPingAvg() float32 { + if m != nil && m.TcpPingAvg != nil { + return *m.TcpPingAvg + } + return 0 +} + +func (m *UserStats) GetTcpPingVar() float32 { + if m != nil && m.TcpPingVar != nil { + return *m.TcpPingVar + } + return 0 +} + +func (m *UserStats) GetVersion() *Version { + if m != nil { + return m.Version + } + return nil +} + +func (m *UserStats) GetCeltVersions() []int32 { + if m != nil { + return m.CeltVersions + } + return nil +} + +func (m *UserStats) GetAddress() []byte { + if m != nil { + return m.Address + } + return nil +} + +func (m *UserStats) GetBandwidth() uint32 { + if m != nil && m.Bandwidth != nil { + return *m.Bandwidth + } + return 0 +} + +func (m *UserStats) GetOnlinesecs() uint32 { + if m != nil && m.Onlinesecs != nil { + return *m.Onlinesecs + } + return 0 +} + +func (m *UserStats) GetIdlesecs() uint32 { + if m != nil && m.Idlesecs != nil { + return *m.Idlesecs + } + return 0 +} + +func (m *UserStats) GetStrongCertificate() bool { + if m != nil && m.StrongCertificate != nil { + return *m.StrongCertificate + } + return Default_UserStats_StrongCertificate +} + +func (m *UserStats) GetOpus() bool { + if m != nil && m.Opus != nil { + return *m.Opus + } + return Default_UserStats_Opus +} + +type UserStats_Stats struct { + // The amount of good packets received. + Good *uint32 `protobuf:"varint,1,opt,name=good" json:"good,omitempty"` + // The amount of late packets received. + Late *uint32 `protobuf:"varint,2,opt,name=late" json:"late,omitempty"` + // The amount of packets never received. + Lost *uint32 `protobuf:"varint,3,opt,name=lost" json:"lost,omitempty"` + // The amount of nonce resyncs. + Resync *uint32 `protobuf:"varint,4,opt,name=resync" json:"resync,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *UserStats_Stats) Reset() { *m = UserStats_Stats{} } +func (m *UserStats_Stats) String() string { return proto.CompactTextString(m) } +func (*UserStats_Stats) ProtoMessage() {} +func (*UserStats_Stats) Descriptor() ([]byte, []int) { + return fileDescriptor_56c09c2dce0fb003, []int{22, 0} +} + +func (m *UserStats_Stats) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_UserStats_Stats.Unmarshal(m, b) +} +func (m *UserStats_Stats) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_UserStats_Stats.Marshal(b, m, deterministic) +} +func (m *UserStats_Stats) XXX_Merge(src proto.Message) { + xxx_messageInfo_UserStats_Stats.Merge(m, src) +} +func (m *UserStats_Stats) XXX_Size() int { + return xxx_messageInfo_UserStats_Stats.Size(m) +} +func (m *UserStats_Stats) XXX_DiscardUnknown() { + xxx_messageInfo_UserStats_Stats.DiscardUnknown(m) +} + +var xxx_messageInfo_UserStats_Stats proto.InternalMessageInfo + +func (m *UserStats_Stats) GetGood() uint32 { + if m != nil && m.Good != nil { + return *m.Good + } + return 0 +} + +func (m *UserStats_Stats) GetLate() uint32 { + if m != nil && m.Late != nil { + return *m.Late + } + return 0 +} + +func (m *UserStats_Stats) GetLost() uint32 { + if m != nil && m.Lost != nil { + return *m.Lost + } + return 0 +} + +func (m *UserStats_Stats) GetResync() uint32 { + if m != nil && m.Resync != nil { + return *m.Resync + } + return 0 +} + +// Used by the client to request binary data from the server. By default large +// comments or textures are not sent within standard messages but instead the +// hash is. If the client does not recognize the hash it may request the +// resource when it needs it. The client does so by sending a RequestBlob +// message with the correct fields filled with the user sessions or channel_ids +// it wants to receive. The server replies to this by sending a new +// UserState/ChannelState message with the resources filled even if they would +// normally be transmitted as hashes. +type RequestBlob struct { + // sessions of the requested UserState textures. + SessionTexture []uint32 `protobuf:"varint,1,rep,name=session_texture,json=sessionTexture" json:"session_texture,omitempty"` + // sessions of the requested UserState comments. + SessionComment []uint32 `protobuf:"varint,2,rep,name=session_comment,json=sessionComment" json:"session_comment,omitempty"` + // channel_ids of the requested ChannelState descriptions. + ChannelDescription []uint32 `protobuf:"varint,3,rep,name=channel_description,json=channelDescription" json:"channel_description,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *RequestBlob) Reset() { *m = RequestBlob{} } +func (m *RequestBlob) String() string { return proto.CompactTextString(m) } +func (*RequestBlob) ProtoMessage() {} +func (*RequestBlob) Descriptor() ([]byte, []int) { + return fileDescriptor_56c09c2dce0fb003, []int{23} +} + +func (m *RequestBlob) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_RequestBlob.Unmarshal(m, b) +} +func (m *RequestBlob) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_RequestBlob.Marshal(b, m, deterministic) +} +func (m *RequestBlob) XXX_Merge(src proto.Message) { + xxx_messageInfo_RequestBlob.Merge(m, src) +} +func (m *RequestBlob) XXX_Size() int { + return xxx_messageInfo_RequestBlob.Size(m) +} +func (m *RequestBlob) XXX_DiscardUnknown() { + xxx_messageInfo_RequestBlob.DiscardUnknown(m) +} + +var xxx_messageInfo_RequestBlob proto.InternalMessageInfo + +func (m *RequestBlob) GetSessionTexture() []uint32 { + if m != nil { + return m.SessionTexture + } + return nil +} + +func (m *RequestBlob) GetSessionComment() []uint32 { + if m != nil { + return m.SessionComment + } + return nil +} + +func (m *RequestBlob) GetChannelDescription() []uint32 { + if m != nil { + return m.ChannelDescription + } + return nil +} + +// Sent by the server when it informs the clients on server configuration +// details. +type ServerConfig struct { + // The maximum bandwidth the clients should use. + MaxBandwidth *uint32 `protobuf:"varint,1,opt,name=max_bandwidth,json=maxBandwidth" json:"max_bandwidth,omitempty"` + // Server welcome text. + WelcomeText *string `protobuf:"bytes,2,opt,name=welcome_text,json=welcomeText" json:"welcome_text,omitempty"` + // True if the server allows HTML. + AllowHtml *bool `protobuf:"varint,3,opt,name=allow_html,json=allowHtml" json:"allow_html,omitempty"` + // Maximum text message length. + MessageLength *uint32 `protobuf:"varint,4,opt,name=message_length,json=messageLength" json:"message_length,omitempty"` + // Maximum image message length. + ImageMessageLength *uint32 `protobuf:"varint,5,opt,name=image_message_length,json=imageMessageLength" json:"image_message_length,omitempty"` + // The maximum number of users allowed on the server. + MaxUsers *uint32 `protobuf:"varint,6,opt,name=max_users,json=maxUsers" json:"max_users,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ServerConfig) Reset() { *m = ServerConfig{} } +func (m *ServerConfig) String() string { return proto.CompactTextString(m) } +func (*ServerConfig) ProtoMessage() {} +func (*ServerConfig) Descriptor() ([]byte, []int) { + return fileDescriptor_56c09c2dce0fb003, []int{24} +} + +func (m *ServerConfig) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ServerConfig.Unmarshal(m, b) +} +func (m *ServerConfig) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ServerConfig.Marshal(b, m, deterministic) +} +func (m *ServerConfig) XXX_Merge(src proto.Message) { + xxx_messageInfo_ServerConfig.Merge(m, src) +} +func (m *ServerConfig) XXX_Size() int { + return xxx_messageInfo_ServerConfig.Size(m) +} +func (m *ServerConfig) XXX_DiscardUnknown() { + xxx_messageInfo_ServerConfig.DiscardUnknown(m) +} + +var xxx_messageInfo_ServerConfig proto.InternalMessageInfo + +func (m *ServerConfig) GetMaxBandwidth() uint32 { + if m != nil && m.MaxBandwidth != nil { + return *m.MaxBandwidth + } + return 0 +} + +func (m *ServerConfig) GetWelcomeText() string { + if m != nil && m.WelcomeText != nil { + return *m.WelcomeText + } + return "" +} + +func (m *ServerConfig) GetAllowHtml() bool { + if m != nil && m.AllowHtml != nil { + return *m.AllowHtml + } + return false +} + +func (m *ServerConfig) GetMessageLength() uint32 { + if m != nil && m.MessageLength != nil { + return *m.MessageLength + } + return 0 +} + +func (m *ServerConfig) GetImageMessageLength() uint32 { + if m != nil && m.ImageMessageLength != nil { + return *m.ImageMessageLength + } + return 0 +} + +func (m *ServerConfig) GetMaxUsers() uint32 { + if m != nil && m.MaxUsers != nil { + return *m.MaxUsers + } + return 0 +} + +// Sent by the server to inform the clients of suggested client configuration +// specified by the server administrator. +type SuggestConfig struct { + // Suggested client version. + Version *uint32 `protobuf:"varint,1,opt,name=version" json:"version,omitempty"` + // True if the administrator suggests positional audio to be used on this + // server. + Positional *bool `protobuf:"varint,2,opt,name=positional" json:"positional,omitempty"` + // True if the administrator suggests push to talk to be used on this server. + PushToTalk *bool `protobuf:"varint,3,opt,name=push_to_talk,json=pushToTalk" json:"push_to_talk,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *SuggestConfig) Reset() { *m = SuggestConfig{} } +func (m *SuggestConfig) String() string { return proto.CompactTextString(m) } +func (*SuggestConfig) ProtoMessage() {} +func (*SuggestConfig) Descriptor() ([]byte, []int) { + return fileDescriptor_56c09c2dce0fb003, []int{25} +} + +func (m *SuggestConfig) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SuggestConfig.Unmarshal(m, b) +} +func (m *SuggestConfig) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SuggestConfig.Marshal(b, m, deterministic) +} +func (m *SuggestConfig) XXX_Merge(src proto.Message) { + xxx_messageInfo_SuggestConfig.Merge(m, src) +} +func (m *SuggestConfig) XXX_Size() int { + return xxx_messageInfo_SuggestConfig.Size(m) +} +func (m *SuggestConfig) XXX_DiscardUnknown() { + xxx_messageInfo_SuggestConfig.DiscardUnknown(m) +} + +var xxx_messageInfo_SuggestConfig proto.InternalMessageInfo + +func (m *SuggestConfig) GetVersion() uint32 { + if m != nil && m.Version != nil { + return *m.Version + } + return 0 +} + +func (m *SuggestConfig) GetPositional() bool { + if m != nil && m.Positional != nil { + return *m.Positional + } + return false +} + +func (m *SuggestConfig) GetPushToTalk() bool { + if m != nil && m.PushToTalk != nil { + return *m.PushToTalk + } + return false +} + +func init() { + proto.RegisterEnum("MumbleProto.Reject_RejectType", Reject_RejectType_name, Reject_RejectType_value) + proto.RegisterEnum("MumbleProto.PermissionDenied_DenyType", PermissionDenied_DenyType_name, PermissionDenied_DenyType_value) + proto.RegisterEnum("MumbleProto.ContextActionModify_Context", ContextActionModify_Context_name, ContextActionModify_Context_value) + proto.RegisterEnum("MumbleProto.ContextActionModify_Operation", ContextActionModify_Operation_name, ContextActionModify_Operation_value) + proto.RegisterType((*Version)(nil), "MumbleProto.Version") + proto.RegisterType((*UDPTunnel)(nil), "MumbleProto.UDPTunnel") + proto.RegisterType((*Authenticate)(nil), "MumbleProto.Authenticate") + proto.RegisterType((*Ping)(nil), "MumbleProto.Ping") + proto.RegisterType((*Reject)(nil), "MumbleProto.Reject") + proto.RegisterType((*ServerSync)(nil), "MumbleProto.ServerSync") + proto.RegisterType((*ChannelRemove)(nil), "MumbleProto.ChannelRemove") + proto.RegisterType((*ChannelState)(nil), "MumbleProto.ChannelState") + proto.RegisterType((*UserRemove)(nil), "MumbleProto.UserRemove") + proto.RegisterType((*UserState)(nil), "MumbleProto.UserState") + proto.RegisterType((*BanList)(nil), "MumbleProto.BanList") + proto.RegisterType((*BanList_BanEntry)(nil), "MumbleProto.BanList.BanEntry") + proto.RegisterType((*TextMessage)(nil), "MumbleProto.TextMessage") + proto.RegisterType((*PermissionDenied)(nil), "MumbleProto.PermissionDenied") + proto.RegisterType((*ACL)(nil), "MumbleProto.ACL") + proto.RegisterType((*ACL_ChanGroup)(nil), "MumbleProto.ACL.ChanGroup") + proto.RegisterType((*ACL_ChanACL)(nil), "MumbleProto.ACL.ChanACL") + proto.RegisterType((*QueryUsers)(nil), "MumbleProto.QueryUsers") + proto.RegisterType((*CryptSetup)(nil), "MumbleProto.CryptSetup") + proto.RegisterType((*ContextActionModify)(nil), "MumbleProto.ContextActionModify") + proto.RegisterType((*ContextAction)(nil), "MumbleProto.ContextAction") + proto.RegisterType((*UserList)(nil), "MumbleProto.UserList") + proto.RegisterType((*UserList_User)(nil), "MumbleProto.UserList.User") + proto.RegisterType((*VoiceTarget)(nil), "MumbleProto.VoiceTarget") + proto.RegisterType((*VoiceTarget_Target)(nil), "MumbleProto.VoiceTarget.Target") + proto.RegisterType((*PermissionQuery)(nil), "MumbleProto.PermissionQuery") + proto.RegisterType((*CodecVersion)(nil), "MumbleProto.CodecVersion") + proto.RegisterType((*UserStats)(nil), "MumbleProto.UserStats") + proto.RegisterType((*UserStats_Stats)(nil), "MumbleProto.UserStats.Stats") + proto.RegisterType((*RequestBlob)(nil), "MumbleProto.RequestBlob") + proto.RegisterType((*ServerConfig)(nil), "MumbleProto.ServerConfig") + proto.RegisterType((*SuggestConfig)(nil), "MumbleProto.SuggestConfig") +} + +func init() { proto.RegisterFile("Mumble.proto", fileDescriptor_56c09c2dce0fb003) } + +var fileDescriptor_56c09c2dce0fb003 = []byte{ + // 2523 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x58, 0x4f, 0x6f, 0x24, 0x47, + 0x15, 0x4f, 0xcf, 0xff, 0x79, 0x33, 0x63, 0xb7, 0x6b, 0x9d, 0x64, 0x70, 0xb2, 0x89, 0xd3, 0x0b, + 0x89, 0x03, 0x91, 0x09, 0x56, 0x84, 0x94, 0x48, 0x1c, 0xbc, 0xde, 0x04, 0xaf, 0xb0, 0x37, 0x4b, + 0xdb, 0xd9, 0x1c, 0x38, 0x34, 0xe5, 0xee, 0xf2, 0x4c, 0xe3, 0x9e, 0xee, 0x4e, 0x55, 0xb5, 0x77, + 0x47, 0xe2, 0x08, 0x5c, 0xc9, 0x8d, 0x1b, 0x1f, 0x20, 0x87, 0x48, 0x7c, 0x05, 0x3e, 0x01, 0x07, + 0x3e, 0x01, 0xe2, 0xc6, 0x0d, 0x89, 0x3b, 0x7a, 0xaf, 0xaa, 0xff, 0x79, 0x9d, 0x6c, 0xb8, 0x72, + 0x99, 0xa9, 0xf7, 0x7b, 0xbf, 0xfa, 0xd3, 0x55, 0xef, 0x5f, 0x15, 0x4c, 0x4f, 0x8b, 0xd5, 0x45, + 0x22, 0xf6, 0x73, 0x99, 0xe9, 0x8c, 0x4d, 0x8c, 0xf4, 0x18, 0x05, 0x2f, 0x81, 0xe1, 0x13, 0x21, + 0x55, 0x9c, 0xa5, 0x6c, 0x0e, 0xc3, 0x6b, 0xd3, 0x9c, 0x3b, 0xbb, 0xce, 0xde, 0xcc, 0x2f, 0x45, + 0xd4, 0x48, 0x91, 0x08, 0xae, 0xc4, 0xbc, 0xb3, 0xeb, 0xec, 0x8d, 0xfd, 0x52, 0x64, 0x1b, 0xd0, + 0xc9, 0xd4, 0xbc, 0x4b, 0x60, 0x27, 0x53, 0xec, 0x2e, 0x40, 0xa6, 0x82, 0x72, 0x98, 0x1e, 0xe1, + 0xe3, 0x4c, 0xd9, 0x29, 0xbc, 0x7b, 0x30, 0xfe, 0xec, 0xc1, 0xe3, 0xf3, 0x22, 0x4d, 0x45, 0xc2, + 0x5e, 0x81, 0x41, 0xce, 0xc3, 0x2b, 0xa1, 0xe7, 0xce, 0x6e, 0x67, 0x6f, 0xea, 0x5b, 0xc9, 0xfb, + 0xb3, 0x03, 0xd3, 0xc3, 0x42, 0x2f, 0x45, 0xaa, 0xe3, 0x90, 0x6b, 0xc1, 0x76, 0x60, 0x54, 0x28, + 0x21, 0x53, 0xbe, 0x12, 0xb4, 0xb2, 0xb1, 0x5f, 0xc9, 0xa8, 0xcb, 0xb9, 0x52, 0x4f, 0x33, 0x19, + 0xd9, 0xb5, 0x55, 0x32, 0x4e, 0xa0, 0xb3, 0x2b, 0x91, 0xe2, 0x02, 0xbb, 0x7b, 0x63, 0xdf, 0x4a, + 0xec, 0x1e, 0xcc, 0x42, 0x91, 0xe8, 0x72, 0x99, 0x6a, 0xde, 0xdb, 0xed, 0xee, 0xf5, 0xfd, 0x29, + 0x82, 0x76, 0xa5, 0x8a, 0x7d, 0x0f, 0x7a, 0x59, 0x5e, 0xa8, 0x79, 0x7f, 0xd7, 0xd9, 0x1b, 0x7d, + 0xd4, 0xbf, 0xe4, 0x89, 0x12, 0x3e, 0x41, 0xde, 0x5f, 0x3b, 0xd0, 0x7b, 0x1c, 0xa7, 0x0b, 0xf6, + 0x3a, 0x8c, 0x75, 0xbc, 0x12, 0x4a, 0xf3, 0x55, 0x4e, 0x2b, 0xeb, 0xf9, 0x35, 0xc0, 0x18, 0xf4, + 0x16, 0x59, 0x66, 0x96, 0x35, 0xf3, 0xa9, 0x8d, 0x58, 0xc2, 0xb5, 0xa0, 0x1d, 0x9b, 0xf9, 0xd4, + 0x26, 0x2c, 0x53, 0x9a, 0x76, 0x0b, 0xb1, 0x4c, 0x69, 0x5c, 0xba, 0x14, 0x6a, 0x9d, 0x86, 0x34, + 0xff, 0xcc, 0xb7, 0x12, 0x7b, 0x13, 0x26, 0x45, 0x94, 0x07, 0x66, 0xa7, 0xd4, 0x7c, 0x40, 0x4a, + 0x28, 0xa2, 0xfc, 0xb1, 0x41, 0x90, 0xa0, 0xc3, 0x9a, 0x30, 0x34, 0x04, 0x1d, 0x56, 0x84, 0x5d, + 0x98, 0xd2, 0x08, 0x71, 0xba, 0x08, 0xf8, 0xf5, 0x62, 0x3e, 0xda, 0x75, 0xf6, 0x3a, 0x66, 0x88, + 0x38, 0x5d, 0x1c, 0x5e, 0x2f, 0x5a, 0x8c, 0x6b, 0x2e, 0xe7, 0xe3, 0x16, 0xe3, 0x09, 0x97, 0xc8, + 0xa0, 0x49, 0xca, 0x31, 0xc0, 0x30, 0x70, 0x96, 0x7a, 0x8c, 0x8a, 0x81, 0x63, 0x4c, 0x5a, 0x8c, + 0x27, 0x5c, 0x7a, 0xbf, 0xef, 0xc0, 0xc0, 0x17, 0xbf, 0x11, 0xa1, 0x66, 0x07, 0xd0, 0xd3, 0xeb, + 0xdc, 0x9c, 0xed, 0xc6, 0xc1, 0x1b, 0xfb, 0x0d, 0xfb, 0xdc, 0x37, 0x14, 0xfb, 0x77, 0xbe, 0xce, + 0x85, 0x4f, 0x5c, 0xb3, 0x41, 0x5c, 0x65, 0xa9, 0x3d, 0x75, 0x2b, 0x79, 0x5f, 0x3b, 0x00, 0x35, + 0x99, 0x8d, 0xa0, 0xf7, 0x28, 0x4b, 0x85, 0xfb, 0x12, 0x73, 0x61, 0xfa, 0xb9, 0xcc, 0xd2, 0x85, + 0x3d, 0x60, 0xd7, 0x61, 0x77, 0x60, 0xf3, 0x61, 0x7a, 0xcd, 0x93, 0x38, 0xfa, 0xcc, 0x5a, 0x93, + 0xdb, 0x61, 0x9b, 0x30, 0x21, 0x1a, 0x42, 0x8f, 0x3f, 0x77, 0xbb, 0x6c, 0x0b, 0x66, 0x04, 0x9c, + 0x09, 0x79, 0x4d, 0x50, 0x0f, 0xa1, 0xb2, 0xc7, 0xc3, 0xf4, 0x33, 0x25, 0xdc, 0x3e, 0xdb, 0x00, + 0x30, 0x84, 0x4f, 0x8a, 0x24, 0x71, 0x07, 0x48, 0x79, 0x94, 0x1d, 0x09, 0xa9, 0xe3, 0x4b, 0xb2, + 0x61, 0x77, 0xc8, 0x5e, 0x86, 0xad, 0x86, 0x55, 0x67, 0xf2, 0x13, 0x1e, 0x27, 0xee, 0xc8, 0xfb, + 0xd2, 0x29, 0xbb, 0x9e, 0xe1, 0x01, 0xcf, 0x61, 0xa8, 0x84, 0x6a, 0x3a, 0xa1, 0x15, 0xd1, 0x6a, + 0x57, 0xfc, 0x59, 0x70, 0xc1, 0xd3, 0xe8, 0x69, 0x1c, 0xe9, 0xa5, 0xb5, 0xab, 0xe9, 0x8a, 0x3f, + 0xbb, 0x5f, 0x62, 0xec, 0x2d, 0x98, 0x3e, 0x15, 0x49, 0x98, 0xad, 0x44, 0xa0, 0xc5, 0x33, 0x6d, + 0x3d, 0x73, 0x62, 0xb1, 0x73, 0xf1, 0x4c, 0xb3, 0x5d, 0x98, 0xe4, 0x42, 0xae, 0x62, 0x55, 0xda, + 0x3e, 0x9a, 0x6d, 0x13, 0xf2, 0xf6, 0x61, 0x76, 0xb4, 0xe4, 0xe8, 0xa3, 0xbe, 0x58, 0x65, 0xd7, + 0x02, 0xbd, 0x3a, 0x34, 0x40, 0x10, 0x47, 0xe4, 0xad, 0x33, 0x7f, 0x6c, 0x91, 0x87, 0x91, 0xf7, + 0x55, 0x17, 0xa6, 0xb6, 0xc3, 0x99, 0x46, 0x8b, 0xbe, 0xc9, 0x77, 0x5a, 0x7c, 0xe3, 0xf8, 0x52, + 0xa4, 0xda, 0x7e, 0x82, 0x95, 0xd0, 0x11, 0xc8, 0xc7, 0xcd, 0xa2, 0xa9, 0xcd, 0xb6, 0xa1, 0x9f, + 0xc4, 0xe9, 0x95, 0xf1, 0xd1, 0x99, 0x6f, 0x04, 0xfc, 0x86, 0x48, 0xa8, 0x50, 0xc6, 0xb9, 0xc6, + 0x9d, 0xea, 0x9b, 0xaf, 0x6c, 0x40, 0xec, 0x35, 0x18, 0x13, 0x35, 0xe0, 0x51, 0x34, 0x1f, 0x50, + 0xdf, 0x11, 0x01, 0x87, 0x51, 0x84, 0xbb, 0x64, 0x94, 0x92, 0xbe, 0x6f, 0x3e, 0x24, 0xfd, 0x84, + 0x30, 0xfb, 0xc9, 0xf7, 0x60, 0xac, 0xc5, 0x2a, 0xcf, 0x24, 0x97, 0x6b, 0xf2, 0x91, 0x2a, 0x06, + 0xd4, 0x38, 0xbb, 0x0b, 0xa3, 0x3c, 0x53, 0x31, 0xad, 0x01, 0xbd, 0xa4, 0xff, 0x91, 0xf3, 0xbe, + 0x5f, 0x41, 0xec, 0x5d, 0x70, 0x1b, 0x4b, 0x0a, 0x96, 0x5c, 0x2d, 0xc9, 0x55, 0xa6, 0xfe, 0x66, + 0x03, 0x3f, 0xe6, 0x6a, 0x89, 0xcb, 0xc5, 0xc3, 0xc5, 0xb0, 0xa6, 0xc8, 0x59, 0x66, 0xfe, 0x68, + 0xc5, 0x9f, 0xa1, 0x99, 0x29, 0xb6, 0x0f, 0x77, 0x62, 0x15, 0x88, 0x54, 0x0b, 0x19, 0x48, 0xa1, + 0xb4, 0x8c, 0x43, 0x2d, 0xa2, 0xf9, 0x14, 0x57, 0xe5, 0x6f, 0xc5, 0xea, 0x63, 0xd4, 0xf8, 0x95, + 0x02, 0x07, 0x0b, 0x79, 0x6a, 0x3a, 0xcc, 0x67, 0xc4, 0x1a, 0x85, 0x3c, 0x25, 0x9a, 0x77, 0x09, + 0x80, 0xa3, 0xda, 0xcf, 0x6c, 0x99, 0x5b, 0xa7, 0x69, 0x6e, 0xdb, 0xd0, 0xe7, 0xa1, 0xce, 0xa4, + 0x3d, 0x23, 0x23, 0x34, 0xdc, 0xae, 0xdb, 0x74, 0x3b, 0xe6, 0x42, 0xf7, 0x82, 0x9b, 0x80, 0x3f, + 0xf2, 0xb1, 0xe9, 0xfd, 0xb3, 0x07, 0x63, 0x9c, 0xc8, 0x58, 0xc4, 0x37, 0x9b, 0xf5, 0xed, 0xf3, + 0xdc, 0x66, 0x0a, 0xaf, 0xc2, 0x10, 0xf7, 0x07, 0x4d, 0xca, 0x84, 0xca, 0x01, 0x8a, 0x0f, 0xa3, + 0x1b, 0xe6, 0xd6, 0xbf, 0x69, 0x6e, 0x0c, 0x7a, 0xab, 0x42, 0x0b, 0x0a, 0x96, 0x23, 0x9f, 0xda, + 0x88, 0x45, 0x82, 0x5f, 0x52, 0x7c, 0x1c, 0xf9, 0xd4, 0xc6, 0x54, 0xa2, 0x8a, 0x3c, 0x97, 0x42, + 0x29, 0x73, 0xe2, 0x7e, 0x25, 0xe3, 0x96, 0x2a, 0x91, 0x5c, 0x06, 0x34, 0xd0, 0xd8, 0x2a, 0x45, + 0x72, 0x79, 0x8a, 0x83, 0x95, 0x4a, 0x1a, 0x11, 0x6a, 0xe5, 0x03, 0x1c, 0x75, 0x0e, 0x43, 0xf4, + 0xc4, 0x42, 0x0a, 0x3a, 0xd7, 0xa9, 0x5f, 0x8a, 0xec, 0x07, 0xb0, 0x91, 0x27, 0xc5, 0x22, 0x4e, + 0x83, 0x30, 0x4b, 0xc9, 0x5b, 0xa7, 0x44, 0x98, 0x19, 0xf4, 0xc8, 0x80, 0xec, 0x1d, 0xd8, 0xb4, + 0xb4, 0x38, 0xc2, 0xe0, 0xa1, 0xd7, 0x74, 0xa6, 0x63, 0xdf, 0xf6, 0x7e, 0x68, 0x51, 0x9c, 0x29, + 0xcc, 0x56, 0x2b, 0xf4, 0xab, 0x0d, 0x93, 0xa5, 0xad, 0x88, 0x5f, 0x4b, 0xc6, 0xb7, 0x69, 0x76, + 0x13, 0xdb, 0xe8, 0x03, 0x56, 0x6d, 0x0c, 0xd3, 0xa5, 0xb9, 0x27, 0x16, 0x3b, 0xb6, 0x14, 0xbb, + 0x56, 0x43, 0xd9, 0x32, 0x14, 0x8b, 0x11, 0xe5, 0x5d, 0x70, 0x73, 0x19, 0x67, 0x32, 0xd6, 0xeb, + 0x40, 0xe5, 0x82, 0x5f, 0x09, 0x39, 0x67, 0xb4, 0x03, 0x9b, 0x25, 0x7e, 0x66, 0x60, 0x4c, 0x96, + 0x52, 0x84, 0x99, 0x8c, 0xe2, 0x74, 0x31, 0xbf, 0x43, 0x9c, 0x1a, 0x60, 0x3f, 0x85, 0x57, 0x2b, + 0xbf, 0x0a, 0x78, 0x18, 0x0a, 0xa5, 0x02, 0x9b, 0xbc, 0xb7, 0x29, 0x79, 0xbf, 0x5c, 0xa9, 0x0f, + 0x49, 0x7b, 0x4e, 0x4a, 0xef, 0x0f, 0x1d, 0x18, 0xde, 0xe7, 0xe9, 0x49, 0xac, 0x34, 0xfb, 0x09, + 0xf4, 0x2e, 0x78, 0xaa, 0xe6, 0xce, 0x6e, 0x77, 0x6f, 0x72, 0x70, 0xb7, 0x95, 0x47, 0x2c, 0x07, + 0xff, 0x3f, 0x4e, 0xb5, 0x5c, 0xfb, 0x44, 0x65, 0xaf, 0x41, 0xff, 0x8b, 0x42, 0xc8, 0x35, 0x59, + 0x5f, 0xe5, 0xe2, 0x06, 0xdb, 0xf9, 0xca, 0x81, 0x51, 0xc9, 0xc7, 0xdd, 0xe5, 0x51, 0x44, 0xc6, + 0x61, 0xca, 0x95, 0x52, 0x24, 0xfb, 0xe2, 0xea, 0x6a, 0xde, 0x21, 0x07, 0xa2, 0xf6, 0xad, 0xf6, + 0x5b, 0x9e, 0x42, 0xaf, 0x71, 0x0a, 0xb5, 0x3f, 0xf5, 0x5b, 0xfe, 0xb4, 0x0d, 0x7d, 0xa5, 0xb9, + 0xd4, 0x64, 0xb4, 0x63, 0xdf, 0x08, 0x68, 0xa1, 0x51, 0x21, 0x39, 0xc5, 0x1b, 0x93, 0xd9, 0x2b, + 0xd9, 0xfb, 0xa3, 0x03, 0x13, 0x8c, 0xef, 0xa7, 0x42, 0x29, 0xbe, 0x10, 0xb5, 0x5f, 0x39, 0x4d, + 0xbf, 0x6a, 0xf8, 0x61, 0x87, 0x82, 0x5e, 0xe5, 0x87, 0x6d, 0x27, 0xea, 0x92, 0xb2, 0xe1, 0x44, + 0xaf, 0xc2, 0x50, 0x4b, 0x21, 0x8c, 0xf3, 0xa1, 0x6e, 0x80, 0xe2, 0xc3, 0x08, 0x47, 0x5c, 0x99, + 0x29, 0xe7, 0xfd, 0xdd, 0x0e, 0x5a, 0x9d, 0x15, 0x31, 0x2d, 0xb8, 0x8f, 0xab, 0xb4, 0xf2, 0x40, + 0xa4, 0xb1, 0x88, 0xd8, 0x1b, 0x00, 0x75, 0xaa, 0xb1, 0x6b, 0x6b, 0x20, 0x37, 0x96, 0xd1, 0xb9, + 0xe9, 0xcb, 0x8d, 0xf5, 0x77, 0xdb, 0x71, 0xa4, 0xde, 0xc9, 0x5e, 0x6b, 0x27, 0x3f, 0xb2, 0xc5, + 0x45, 0x9f, 0x8a, 0x8b, 0xb7, 0x5b, 0x46, 0x71, 0x73, 0x75, 0xfb, 0x0f, 0x44, 0xba, 0x6e, 0x14, + 0x19, 0xe5, 0x29, 0x0e, 0xea, 0x53, 0xf4, 0xfe, 0xee, 0xc0, 0xa8, 0xa4, 0x61, 0x79, 0x81, 0x7b, + 0xee, 0xbe, 0x84, 0x05, 0x40, 0x3d, 0x9a, 0xeb, 0xb0, 0x19, 0x8c, 0xcf, 0x8a, 0x5c, 0x48, 0x0c, + 0x81, 0xa6, 0xac, 0xb0, 0x19, 0xf2, 0x11, 0xd6, 0x19, 0x5d, 0x04, 0xb0, 0xe7, 0x79, 0x96, 0x9d, + 0x64, 0xe9, 0xc2, 0xed, 0xb1, 0x21, 0x74, 0x8f, 0x3f, 0xfc, 0x85, 0xdb, 0x67, 0xdb, 0xe0, 0x9e, + 0x97, 0xa6, 0x6e, 0xfb, 0xb8, 0x03, 0xf6, 0x0a, 0xb0, 0x53, 0x1c, 0x3c, 0x5d, 0xb4, 0xab, 0x8a, + 0x29, 0x8c, 0x70, 0x0a, 0x1a, 0x75, 0xd4, 0x98, 0x86, 0xea, 0x90, 0x31, 0x56, 0x3d, 0x8f, 0x84, + 0xd2, 0x71, 0xba, 0x38, 0x89, 0x57, 0xb1, 0x76, 0x01, 0xcb, 0x10, 0x4b, 0x39, 0xca, 0x8a, 0x54, + 0x1b, 0x78, 0xe2, 0xfd, 0xae, 0x0f, 0xdd, 0xc3, 0xa3, 0x93, 0x17, 0xa4, 0x7a, 0xf6, 0x0e, 0x4c, + 0xe3, 0x74, 0x29, 0x64, 0xac, 0x03, 0x1e, 0x26, 0xca, 0xba, 0x4d, 0x4f, 0xcb, 0x42, 0xf8, 0x13, + 0xab, 0x39, 0x0c, 0x13, 0xc5, 0x0e, 0x60, 0xb0, 0x90, 0x59, 0x91, 0x9b, 0xda, 0x7b, 0x72, 0xb0, + 0xd3, 0xda, 0xf8, 0xc3, 0xa3, 0x93, 0x7d, 0x5c, 0xc5, 0xcf, 0x91, 0xe2, 0x5b, 0x26, 0x7b, 0x0f, + 0x7a, 0x34, 0x68, 0x8f, 0x7a, 0xcc, 0x6f, 0xed, 0x71, 0x78, 0x74, 0xe2, 0x13, 0xab, 0x76, 0xdd, + 0xfe, 0x2d, 0xae, 0xfb, 0x0f, 0x07, 0xc6, 0xd5, 0x04, 0xd5, 0x39, 0x3a, 0x64, 0xa0, 0xc6, 0x1b, + 0x3d, 0x18, 0xdb, 0xf5, 0x8a, 0xa8, 0xf5, 0x19, 0x35, 0xcc, 0xde, 0x80, 0xa1, 0x15, 0xc8, 0xda, + 0x4a, 0x46, 0x09, 0xb2, 0xb7, 0xa1, 0xfc, 0x66, 0x7e, 0x91, 0x08, 0x93, 0xfd, 0x6e, 0x6c, 0x06, + 0x2a, 0x30, 0x3b, 0x62, 0x19, 0xd2, 0x27, 0xc7, 0xc1, 0xa6, 0xb1, 0x56, 0xaa, 0x3d, 0x4c, 0x6d, + 0x62, 0x25, 0xf6, 0x23, 0xd8, 0xaa, 0xa6, 0x0f, 0x56, 0x62, 0x75, 0x81, 0xf5, 0x80, 0x29, 0x4f, + 0xdc, 0x4a, 0x71, 0x6a, 0xf0, 0x9d, 0xbf, 0x39, 0x30, 0xb4, 0x7b, 0xc2, 0xee, 0x01, 0xf0, 0x3c, + 0x4f, 0xd6, 0xc1, 0x52, 0x48, 0x53, 0x49, 0x57, 0xdf, 0x43, 0xf8, 0xb1, 0x90, 0xa2, 0x26, 0xa9, + 0xe2, 0xa2, 0x7d, 0x76, 0x86, 0x74, 0x56, 0x5c, 0xa8, 0xf6, 0xc6, 0x74, 0x6f, 0xdf, 0x98, 0x6f, + 0x4c, 0xc5, 0xdb, 0xd0, 0xa7, 0xc3, 0xb4, 0xe1, 0xcc, 0x08, 0x06, 0xe5, 0xa9, 0xb6, 0xf7, 0x15, + 0x23, 0x98, 0x1c, 0x9c, 0xae, 0x6d, 0x24, 0xa3, 0xb6, 0xf7, 0x01, 0xc0, 0x2f, 0xf1, 0x00, 0x4d, + 0xe1, 0xe3, 0x42, 0x37, 0x8e, 0x4c, 0x3c, 0x9f, 0xf9, 0xd8, 0xc4, 0x91, 0xf0, 0xf4, 0x14, 0x45, + 0xaf, 0xb1, 0x6f, 0x04, 0x2f, 0x02, 0x38, 0x92, 0xeb, 0x5c, 0x9f, 0x09, 0x5d, 0xe4, 0xd8, 0xeb, + 0x4a, 0xac, 0x69, 0x0f, 0xa6, 0x3e, 0x36, 0x29, 0xd7, 0x25, 0x31, 0xa6, 0xba, 0x34, 0x4b, 0x43, + 0x73, 0x89, 0xc5, 0x5c, 0x47, 0xd8, 0x23, 0x84, 0x90, 0xa2, 0xa8, 0x0a, 0xb7, 0x94, 0xae, 0xa1, + 0x18, 0x8c, 0x28, 0xde, 0x7f, 0x1c, 0xb8, 0x63, 0x93, 0xf2, 0x61, 0x88, 0x31, 0xf7, 0x34, 0x8b, + 0xe2, 0xcb, 0x35, 0x9e, 0x25, 0x27, 0xd9, 0xda, 0x97, 0x95, 0xf0, 0xfb, 0x28, 0xab, 0x9b, 0x0b, + 0x0a, 0xb5, 0x4d, 0x8e, 0x4e, 0xab, 0xd2, 0x7c, 0xe6, 0x97, 0x22, 0x3b, 0x86, 0x71, 0x96, 0x0b, + 0x1b, 0xdc, 0x7b, 0x14, 0xac, 0x7e, 0xd8, 0xf2, 0x80, 0x5b, 0xa6, 0xde, 0xff, 0xb4, 0xec, 0xe1, + 0xd7, 0x9d, 0xbd, 0xf7, 0x60, 0x58, 0xd6, 0x0e, 0x00, 0x03, 0x73, 0xb7, 0x70, 0x1d, 0x36, 0x31, + 0xc6, 0x82, 0xe1, 0xa4, 0x83, 0x81, 0x8b, 0x22, 0x53, 0xcf, 0xdb, 0x85, 0x71, 0x35, 0x0a, 0x06, + 0xa1, 0xc3, 0x28, 0x72, 0x5f, 0xc2, 0x8e, 0xa6, 0x42, 0x74, 0x1d, 0xef, 0xd7, 0x30, 0x6b, 0xcd, + 0xfd, 0x2d, 0xc5, 0xdc, 0x0b, 0xa2, 0x77, 0xbd, 0x53, 0xdd, 0xe6, 0x4e, 0x79, 0x7f, 0x71, 0x4c, + 0x14, 0xa3, 0x2c, 0xfe, 0x3e, 0xf4, 0x4d, 0x19, 0xec, 0xdc, 0x12, 0x38, 0x4a, 0x16, 0x35, 0x7c, + 0x43, 0xdc, 0x51, 0xe6, 0x63, 0x9a, 0x56, 0x69, 0x02, 0x57, 0x69, 0x95, 0xa5, 0xff, 0x77, 0x1a, + 0xd9, 0x18, 0x2f, 0x08, 0x5c, 0xe9, 0x40, 0x09, 0x51, 0x16, 0xb3, 0x23, 0x04, 0xce, 0x84, 0x48, + 0xe9, 0x82, 0x80, 0x4a, 0xbb, 0x74, 0x6b, 0xe4, 0x13, 0xc4, 0xec, 0x1e, 0x7a, 0xff, 0x76, 0x60, + 0xf2, 0x24, 0x8b, 0x43, 0x71, 0xce, 0xe5, 0x42, 0x68, 0xb6, 0x01, 0x9d, 0xea, 0xae, 0xd3, 0x89, + 0x23, 0xf6, 0x21, 0x0c, 0x35, 0x69, 0x8c, 0xad, 0x4e, 0x0e, 0xde, 0x6c, 0x7d, 0x48, 0xa3, 0xeb, + 0xbe, 0xf9, 0xf3, 0x4b, 0xfe, 0xce, 0x9f, 0x1c, 0x18, 0xd8, 0x51, 0x5b, 0x5b, 0xdd, 0xfd, 0x1f, + 0xb6, 0xba, 0x72, 0xc4, 0x6e, 0xd3, 0x11, 0x5f, 0xab, 0x6f, 0x53, 0xcd, 0x98, 0x69, 0x2e, 0x55, + 0x6f, 0xc1, 0x28, 0x5c, 0xc6, 0x49, 0x24, 0x45, 0xda, 0x8e, 0xa9, 0x15, 0xec, 0x65, 0xb0, 0x59, + 0x67, 0x39, 0x72, 0xd4, 0x17, 0xdd, 0xf5, 0x6e, 0xdc, 0x36, 0xcd, 0x3a, 0x9b, 0x10, 0xae, 0xe9, + 0x32, 0x29, 0xd4, 0xd2, 0xc6, 0x9a, 0x72, 0x4d, 0x84, 0x79, 0xbf, 0x85, 0xe9, 0x51, 0x16, 0x89, + 0xb0, 0x7c, 0xa3, 0xc2, 0xaa, 0x26, 0xc9, 0x97, 0x9c, 0x0e, 0xb8, 0xef, 0x1b, 0x01, 0xcf, 0xf7, + 0x42, 0x68, 0x4e, 0x15, 0x58, 0xdf, 0xa7, 0x36, 0x66, 0xaa, 0x5c, 0x8a, 0x4b, 0x21, 0x03, 0xd3, + 0x01, 0x2d, 0xae, 0x0a, 0xce, 0x46, 0x73, 0x48, 0x9d, 0xcb, 0x87, 0x9e, 0xde, 0xf3, 0x0f, 0x3d, + 0x5f, 0x0f, 0xea, 0x3b, 0x8c, 0xfa, 0x16, 0xb3, 0xff, 0x3e, 0x80, 0x42, 0x4a, 0x90, 0xa5, 0xc9, + 0x8d, 0x52, 0x72, 0x4c, 0x8a, 0x4f, 0xd3, 0x64, 0xcd, 0x3c, 0x98, 0x86, 0x75, 0xee, 0x36, 0x89, + 0x71, 0xea, 0xb7, 0x30, 0xf6, 0x33, 0x98, 0x5c, 0xca, 0x6c, 0x15, 0x98, 0xd0, 0x44, 0x6b, 0x9a, + 0x1c, 0xbc, 0xfe, 0x9c, 0x0b, 0xd0, 0x82, 0xf6, 0xe9, 0xd7, 0x07, 0xec, 0x70, 0x44, 0xfc, 0xaa, + 0xbb, 0x09, 0x5b, 0x74, 0x8a, 0xdf, 0xa9, 0xbb, 0x09, 0x12, 0xff, 0x3f, 0xaf, 0x4b, 0x6c, 0xbf, + 0x7e, 0xcb, 0x9c, 0xd2, 0x26, 0x6c, 0xb7, 0xbd, 0xcf, 0xe8, 0xea, 0x17, 0xce, 0xe7, 0x9e, 0x04, + 0x67, 0xb7, 0x3c, 0x09, 0x36, 0xae, 0x00, 0x1b, 0xe6, 0x2a, 0x57, 0x5e, 0x01, 0x5e, 0x87, 0x71, + 0xfd, 0x2e, 0xb3, 0x69, 0x7c, 0xa0, 0x02, 0xb0, 0xe6, 0xcd, 0xd2, 0x24, 0x4e, 0x85, 0x12, 0xa1, + 0xa2, 0x8b, 0xd6, 0xcc, 0x6f, 0x20, 0x58, 0xd6, 0xc7, 0x51, 0x62, 0xb4, 0x5b, 0xa6, 0xac, 0x2f, + 0x65, 0xf6, 0x01, 0x30, 0xa5, 0x65, 0x96, 0x2e, 0x82, 0x86, 0x9d, 0x98, 0x2b, 0x56, 0x69, 0x62, + 0x5b, 0x86, 0xd0, 0xa8, 0x0b, 0x2b, 0x9b, 0xbe, 0xf3, 0x9c, 0x4d, 0xef, 0xfc, 0x0a, 0xfa, 0xc6, + 0x9c, 0xcb, 0xe7, 0x49, 0xe7, 0x96, 0xe7, 0xc9, 0xce, 0x2d, 0xcf, 0x93, 0xdd, 0x5b, 0x9f, 0x27, + 0x7b, 0xcd, 0xe7, 0x49, 0xef, 0x4b, 0x07, 0x26, 0xbe, 0xf8, 0xa2, 0x10, 0x4a, 0xdf, 0x4f, 0xb2, + 0x0b, 0xbc, 0xbb, 0x5a, 0x1f, 0x09, 0xca, 0x4b, 0xb0, 0x09, 0x63, 0x1b, 0x16, 0x3e, 0xb7, 0x77, + 0xe1, 0x06, 0xb1, 0xbc, 0xc3, 0x76, 0x5a, 0xc4, 0x23, 0x7b, 0x95, 0xfd, 0x31, 0xdc, 0x29, 0xc3, + 0x4d, 0xf3, 0x05, 0xc8, 0xdc, 0x57, 0x98, 0x55, 0x3d, 0xa8, 0x35, 0xde, 0xbf, 0x1c, 0x98, 0x1a, + 0xf3, 0x3e, 0xca, 0xd2, 0xcb, 0x78, 0xf1, 0xfc, 0x3b, 0x9a, 0xf3, 0x1d, 0xde, 0xd1, 0x3a, 0xcf, + 0xbf, 0xa3, 0xdd, 0x05, 0xe0, 0x49, 0x92, 0x3d, 0x0d, 0x96, 0x7a, 0x95, 0x98, 0xe0, 0xe5, 0x8f, + 0x09, 0x39, 0xd6, 0xab, 0x04, 0x6f, 0xf7, 0xf6, 0x22, 0x14, 0x24, 0x22, 0x5d, 0xe8, 0xa5, 0xdd, + 0xaa, 0x99, 0x45, 0x4f, 0x08, 0x64, 0xef, 0xc3, 0x76, 0xbc, 0x42, 0xd2, 0x0d, 0xb2, 0x79, 0xc5, + 0x60, 0xa4, 0x3b, 0x6d, 0xf5, 0x68, 0x3d, 0x15, 0x0d, 0xda, 0x4f, 0x45, 0xde, 0x15, 0xcc, 0xce, + 0x8a, 0xc5, 0x42, 0x28, 0x6d, 0xbf, 0xf6, 0x9b, 0x1f, 0xf5, 0xf1, 0x26, 0x66, 0x5f, 0xaa, 0x78, + 0x62, 0x82, 0x96, 0xdf, 0x40, 0xd0, 0xc9, 0xf2, 0x42, 0x2d, 0x03, 0x9d, 0x05, 0x9a, 0x27, 0x57, + 0xf6, 0x0b, 0x01, 0xb1, 0xf3, 0xec, 0x9c, 0x27, 0x57, 0xf7, 0x3b, 0xc7, 0xce, 0x7f, 0x03, 0x00, + 0x00, 0xff, 0xff, 0x86, 0xf1, 0xdf, 0x29, 0x5b, 0x18, 0x00, 0x00, +} diff --git a/vendor/layeh.com/gumble/gumble/MumbleProto/generate.go b/vendor/layeh.com/gumble/gumble/MumbleProto/generate.go new file mode 100644 index 00000000..37ecfaf4 --- /dev/null +++ b/vendor/layeh.com/gumble/gumble/MumbleProto/generate.go @@ -0,0 +1,2 @@ +//go:generate go run generate_main.go +package MumbleProto diff --git a/vendor/layeh.com/gumble/gumble/accesstokens.go b/vendor/layeh.com/gumble/gumble/accesstokens.go new file mode 100644 index 00000000..3bcbaa45 --- /dev/null +++ b/vendor/layeh.com/gumble/gumble/accesstokens.go @@ -0,0 +1,16 @@ +package gumble + +import ( + "layeh.com/gumble/gumble/MumbleProto" +) + +// AccessTokens are additional passwords that can be provided to the server to +// gain access to restricted channels. +type AccessTokens []string + +func (a AccessTokens) writeMessage(client *Client) error { + packet := MumbleProto.Authenticate{ + Tokens: a, + } + return client.Conn.WriteProto(&packet) +} diff --git a/vendor/layeh.com/gumble/gumble/acl.go b/vendor/layeh.com/gumble/gumble/acl.go new file mode 100644 index 00000000..beb167c4 --- /dev/null +++ b/vendor/layeh.com/gumble/gumble/acl.go @@ -0,0 +1,116 @@ +package gumble + +import ( + "github.com/golang/protobuf/proto" + "layeh.com/gumble/gumble/MumbleProto" +) + +// ACL contains a list of ACLGroups and ACLRules linked to a channel. +type ACL struct { + // The channel to which the ACL belongs. + Channel *Channel + // The ACL's groups. + Groups []*ACLGroup + // The ACL's rules. + Rules []*ACLRule + // Does the ACL inherits the parent channel's ACLs? + Inherits bool +} + +func (a *ACL) writeMessage(client *Client) error { + packet := MumbleProto.ACL{ + ChannelId: &a.Channel.ID, + Groups: make([]*MumbleProto.ACL_ChanGroup, len(a.Groups)), + Acls: make([]*MumbleProto.ACL_ChanACL, len(a.Rules)), + InheritAcls: &a.Inherits, + Query: proto.Bool(false), + } + + for i, group := range a.Groups { + packet.Groups[i] = &MumbleProto.ACL_ChanGroup{ + Name: &group.Name, + Inherit: &group.InheritUsers, + Inheritable: &group.Inheritable, + Add: make([]uint32, 0, len(group.UsersAdd)), + Remove: make([]uint32, 0, len(group.UsersRemove)), + } + for _, user := range group.UsersAdd { + packet.Groups[i].Add = append(packet.Groups[i].Add, user.UserID) + } + for _, user := range group.UsersRemove { + packet.Groups[i].Remove = append(packet.Groups[i].Remove, user.UserID) + } + } + + for i, rule := range a.Rules { + packet.Acls[i] = &MumbleProto.ACL_ChanACL{ + ApplyHere: &rule.AppliesCurrent, + ApplySubs: &rule.AppliesChildren, + Grant: proto.Uint32(uint32(rule.Granted)), + Deny: proto.Uint32(uint32(rule.Denied)), + } + if rule.User != nil { + packet.Acls[i].UserId = &rule.User.UserID + } + if rule.Group != nil { + packet.Acls[i].Group = &rule.Group.Name + } + } + + return client.Conn.WriteProto(&packet) +} + +// ACLUser is a registered user who is part of or can be part of an ACL group +// or rule. +type ACLUser struct { + // The user ID of the user. + UserID uint32 + // The name of the user. + Name string +} + +// ACLGroup is a named group of registered users which can be used in an +// ACLRule. +type ACLGroup struct { + // The ACL group name. + Name string + // Is the group inherited from the parent channel's ACL? + Inherited bool + // Are group members are inherited from the parent channel's ACL? + InheritUsers bool + // Can the group be inherited by child channels? + Inheritable bool + // The users who are explicitly added to, explicitly removed from, and + // inherited into the group. + UsersAdd, UsersRemove, UsersInherited map[uint32]*ACLUser +} + +// ACL group names that are built-in. +const ( + ACLGroupEveryone = "all" + ACLGroupAuthenticated = "auth" + ACLGroupInsideChannel = "in" + ACLGroupOutsideChannel = "out" +) + +// ACLRule is a set of granted and denied permissions given to an ACLUser or +// ACLGroup. +type ACLRule struct { + // Does the rule apply to the channel in which the rule is defined? + AppliesCurrent bool + // Does the rule apply to the children of the channel in which the rule is + // defined? + AppliesChildren bool + // Is the rule inherited from the parent channel's ACL? + Inherited bool + + // The permissions granted by the rule. + Granted Permission + // The permissions denied by the rule. + Denied Permission + + // The ACL user the rule applies to. Can be nil. + User *ACLUser + // The ACL group the rule applies to. Can be nil. + Group *ACLGroup +} diff --git a/vendor/layeh.com/gumble/gumble/audio.go b/vendor/layeh.com/gumble/gumble/audio.go new file mode 100644 index 00000000..e3ce8260 --- /dev/null +++ b/vendor/layeh.com/gumble/gumble/audio.go @@ -0,0 +1,85 @@ +package gumble + +import ( + "time" +) + +const ( + // AudioSampleRate is the audio sample rate (in hertz) for incoming and + // outgoing audio. + AudioSampleRate = 48000 + + // AudioDefaultInterval is the default interval that audio packets are sent + // at. + AudioDefaultInterval = 10 * time.Millisecond + + // AudioDefaultFrameSize is the number of audio frames that should be sent in + // a 10ms window. + AudioDefaultFrameSize = AudioSampleRate / 100 + + // AudioMaximumFrameSize is the maximum audio frame size from another user + // that will be processed. + AudioMaximumFrameSize = AudioSampleRate / 1000 * 60 + + // AudioDefaultDataBytes is the default number of bytes that an audio frame + // can use. + AudioDefaultDataBytes = 40 + + // AudioChannels is the number of audio channels that are contained in an + // audio stream. + AudioChannels = 1 +) + +// AudioListener is the interface that must be implemented by types wishing to +// receive incoming audio data from the server. +// +// OnAudioStream is called when an audio stream for a user starts. It is the +// implementer's responsibility to continuously process AudioStreamEvent.C +// until it is closed. +type AudioListener interface { + OnAudioStream(e *AudioStreamEvent) +} + +// AudioStreamEvent is event that is passed to AudioListener.OnAudioStream. +type AudioStreamEvent struct { + Client *Client + User *User + C <-chan *AudioPacket +} + +// AudioBuffer is a slice of PCM audio samples. +type AudioBuffer []int16 + +func (a AudioBuffer) writeAudio(client *Client, seq int64, final bool) error { + encoder := client.AudioEncoder + if encoder == nil { + return nil + } + dataBytes := client.Config.AudioDataBytes + raw, err := encoder.Encode(a, len(a), dataBytes) + if final { + defer encoder.Reset() + } + if err != nil { + return err + } + + var targetID byte + if target := client.VoiceTarget; target != nil { + targetID = byte(target.ID) + } + // TODO: re-enable positional audio + return client.Conn.WriteAudio(byte(4), targetID, seq, final, raw, nil, nil, nil) +} + +// AudioPacket contains incoming audio samples and information. +type AudioPacket struct { + Client *Client + Sender *User + Target *VoiceTarget + + AudioBuffer + + HasPosition bool + X, Y, Z float32 +} diff --git a/vendor/layeh.com/gumble/gumble/audiocodec.go b/vendor/layeh.com/gumble/gumble/audiocodec.go new file mode 100644 index 00000000..9f4883ed --- /dev/null +++ b/vendor/layeh.com/gumble/gumble/audiocodec.go @@ -0,0 +1,55 @@ +package gumble + +import ( + "sync" +) + +const ( + audioCodecIDOpus = 4 +) + +var ( + audioCodecsLock sync.Mutex + audioCodecs [8]AudioCodec +) + +// RegisterAudioCodec registers an audio codec that can be used for encoding +// and decoding outgoing and incoming audio data. The function panics if the +// ID is invalid. +func RegisterAudioCodec(id int, codec AudioCodec) { + audioCodecsLock.Lock() + defer audioCodecsLock.Unlock() + + if id < 0 || id >= len(audioCodecs) { + panic("id out of range") + } + audioCodecs[id] = codec +} + +func getAudioCodec(id int) AudioCodec { + audioCodecsLock.Lock() + defer audioCodecsLock.Unlock() + return audioCodecs[id] +} + +// AudioCodec can create a encoder and a decoder for outgoing and incoming +// data. +type AudioCodec interface { + ID() int + NewEncoder() AudioEncoder + NewDecoder() AudioDecoder +} + +// AudioEncoder encodes a chunk of PCM audio samples to a certain type. +type AudioEncoder interface { + ID() int + Encode(pcm []int16, mframeSize, maxDataBytes int) ([]byte, error) + Reset() +} + +// AudioDecoder decodes an encoded byte slice to a chunk of PCM audio samples. +type AudioDecoder interface { + ID() int + Decode(data []byte, frameSize int) ([]int16, error) + Reset() +} diff --git a/vendor/layeh.com/gumble/gumble/audiolisteners.go b/vendor/layeh.com/gumble/gumble/audiolisteners.go new file mode 100644 index 00000000..7bf0e80d --- /dev/null +++ b/vendor/layeh.com/gumble/gumble/audiolisteners.go @@ -0,0 +1,46 @@ +package gumble + +type audioEventItem struct { + parent *AudioListeners + prev, next *audioEventItem + listener AudioListener + streams map[*User]chan *AudioPacket +} + +func (e *audioEventItem) Detach() { + if e.prev == nil { + e.parent.head = e.next + } else { + e.prev.next = e.next + } + if e.next == nil { + e.parent.tail = e.prev + } else { + e.next.prev = e.prev + } +} + +// AudioListeners is a list of audio listeners. Each attached listener is +// called in sequence when a new user audio stream begins. +type AudioListeners struct { + head, tail *audioEventItem +} + +// Attach adds a new audio listener to the end of the current list of listeners. +func (e *AudioListeners) Attach(listener AudioListener) Detacher { + item := &audioEventItem{ + parent: e, + prev: e.tail, + listener: listener, + streams: make(map[*User]chan *AudioPacket), + } + if e.head == nil { + e.head = item + } + if e.tail == nil { + e.tail = item + } else { + e.tail.next = item + } + return item +} diff --git a/vendor/layeh.com/gumble/gumble/bans.go b/vendor/layeh.com/gumble/gumble/bans.go new file mode 100644 index 00000000..d1fd9cb7 --- /dev/null +++ b/vendor/layeh.com/gumble/gumble/bans.go @@ -0,0 +1,101 @@ +package gumble + +import ( + "net" + "time" + + "github.com/golang/protobuf/proto" + "layeh.com/gumble/gumble/MumbleProto" +) + +// BanList is a list of server ban entries. +// +// Whenever a ban is changed, it does not come into effect until the ban list +// is sent back to the server. +type BanList []*Ban + +// Add creates a new ban list entry with the given parameters. +func (b *BanList) Add(address net.IP, mask net.IPMask, reason string, duration time.Duration) *Ban { + ban := &Ban{ + Address: address, + Mask: mask, + Reason: reason, + Duration: duration, + } + *b = append(*b, ban) + return ban +} + +// Ban represents an entry in the server ban list. +// +// This type should not be initialized manually. Instead, create new ban +// entries using BanList.Add(). +type Ban struct { + // The banned IP address. + Address net.IP + // The IP mask that the ban applies to. + Mask net.IPMask + // The name of the banned user. + Name string + // The certificate hash of the banned user. + Hash string + // The reason for the ban. + Reason string + // The start time from which the ban applies. + Start time.Time + // How long the ban is for. + Duration time.Duration + + unban bool +} + +// SetAddress sets the banned IP address. +func (b *Ban) SetAddress(address net.IP) { + b.Address = address +} + +// SetMask sets the IP mask that the ban applies to. +func (b *Ban) SetMask(mask net.IPMask) { + b.Mask = mask +} + +// SetReason changes the reason for the ban. +func (b *Ban) SetReason(reason string) { + b.Reason = reason +} + +// SetDuration changes the duration of the ban. +func (b *Ban) SetDuration(duration time.Duration) { + b.Duration = duration +} + +// Unban will unban the user from the server. +func (b *Ban) Unban() { + b.unban = true +} + +// Ban will ban the user from the server. This is only useful if Unban() was +// called on the ban entry. +func (b *Ban) Ban() { + b.unban = false +} + +func (b BanList) writeMessage(client *Client) error { + packet := MumbleProto.BanList{ + Query: proto.Bool(false), + } + + for _, ban := range b { + if !ban.unban { + maskSize, _ := ban.Mask.Size() + packet.Bans = append(packet.Bans, &MumbleProto.BanList_BanEntry{ + Address: ban.Address, + Mask: proto.Uint32(uint32(maskSize)), + Reason: &ban.Reason, + Duration: proto.Uint32(uint32(ban.Duration / time.Second)), + }) + } + } + + return client.Conn.WriteProto(&packet) +} diff --git a/vendor/layeh.com/gumble/gumble/channel.go b/vendor/layeh.com/gumble/gumble/channel.go new file mode 100644 index 00000000..0179e3ca --- /dev/null +++ b/vendor/layeh.com/gumble/gumble/channel.go @@ -0,0 +1,207 @@ +package gumble + +import ( + "github.com/golang/protobuf/proto" + "layeh.com/gumble/gumble/MumbleProto" +) + +// Channel represents a channel in the server's channel tree. +type Channel struct { + // The channel's unique ID. + ID uint32 + // The channel's name. + Name string + // The channel's parent. nil if the channel is the root channel. + Parent *Channel + // The channels directly underneath the channel. + Children Channels + // The channels that are linked to the channel. + Links Channels + // The users currently in the channel. + Users Users + // The channel's description. Contains the empty string if the channel does + // not have a description, or if it needs to be requested. + Description string + // The channel's description hash. nil if Channel.Description has + // been populated. + DescriptionHash []byte + // The maximum number of users allowed in the channel. If the value is zero, + // the maximum number of users per-channel is dictated by the server's + // "usersperchannel" setting. + MaxUsers uint32 + // The position at which the channel should be displayed in an ordered list. + Position int32 + // Is the channel temporary? + Temporary bool + + client *Client +} + +// IsRoot returns true if the channel is the server's root channel. +func (c *Channel) IsRoot() bool { + return c.ID == 0 +} + +// Add will add a sub-channel to the given channel. +func (c *Channel) Add(name string, temporary bool) { + packet := MumbleProto.ChannelState{ + Parent: &c.ID, + Name: &name, + Temporary: &temporary, + } + c.client.Conn.WriteProto(&packet) +} + +// Remove will remove the given channel and all sub-channels from the server's +// channel tree. +func (c *Channel) Remove() { + packet := MumbleProto.ChannelRemove{ + ChannelId: &c.ID, + } + c.client.Conn.WriteProto(&packet) +} + +// SetName will set the name of the channel. This will have no effect if the +// channel is the server's root channel. +func (c *Channel) SetName(name string) { + packet := MumbleProto.ChannelState{ + ChannelId: &c.ID, + Name: &name, + } + c.client.Conn.WriteProto(&packet) +} + +// SetDescription will set the description of the channel. +func (c *Channel) SetDescription(description string) { + packet := MumbleProto.ChannelState{ + ChannelId: &c.ID, + Description: &description, + } + c.client.Conn.WriteProto(&packet) +} + +// SetPosition will set the position of the channel. +func (c *Channel) SetPosition(position int32) { + packet := MumbleProto.ChannelState{ + ChannelId: &c.ID, + Position: &position, + } + c.client.Conn.WriteProto(&packet) +} + +// SetMaxUsers will set the maximum number of users allowed in the channel. +func (c *Channel) SetMaxUsers(maxUsers uint32) { + packet := MumbleProto.ChannelState{ + ChannelId: &c.ID, + MaxUsers: &maxUsers, + } + c.client.Conn.WriteProto(&packet) +} + +// Find returns a channel whose path (by channel name) from the current channel +// is equal to the arguments passed. +// +// For example, given the following server channel tree: +// Root +// Child 1 +// Child 2 +// Child 2.1 +// Child 2.2 +// Child 2.2.1 +// Child 3 +// To get the "Child 2.2.1" channel: +// root.Find("Child 2", "Child 2.2", "Child 2.2.1") +func (c *Channel) Find(names ...string) *Channel { + if len(names) == 0 { + return c + } + for _, child := range c.Children { + if child.Name == names[0] { + return child.Find(names[1:]...) + } + } + return nil +} + +// RequestDescription requests that the actual channel description +// (i.e. non-hashed) be sent to the client. +func (c *Channel) RequestDescription() { + packet := MumbleProto.RequestBlob{ + ChannelDescription: []uint32{c.ID}, + } + c.client.Conn.WriteProto(&packet) +} + +// RequestACL requests that the channel's ACL to be sent to the client. +func (c *Channel) RequestACL() { + packet := MumbleProto.ACL{ + ChannelId: &c.ID, + Query: proto.Bool(true), + } + c.client.Conn.WriteProto(&packet) +} + +// RequestPermission requests that the channel's permission information to be +// sent to the client. +// +// Note: the server will not reply to the request if the client has up-to-date +// permission information. +func (c *Channel) RequestPermission() { + packet := MumbleProto.PermissionQuery{ + ChannelId: &c.ID, + } + c.client.Conn.WriteProto(&packet) +} + +// Send will send a text message to the channel. +func (c *Channel) Send(message string, recursive bool) { + textMessage := TextMessage{ + Message: message, + } + if recursive { + textMessage.Trees = []*Channel{c} + } else { + textMessage.Channels = []*Channel{c} + } + c.client.Send(&textMessage) +} + +// Permission returns the permissions the user has in the channel, or nil if +// the permissions are unknown. +func (c *Channel) Permission() *Permission { + return c.client.permissions[c.ID] +} + +// Link links the given channels to the channel. +func (c *Channel) Link(channel ...*Channel) { + packet := MumbleProto.ChannelState{ + ChannelId: &c.ID, + LinksAdd: make([]uint32, len(channel)), + } + for i, ch := range channel { + packet.LinksAdd[i] = ch.ID + } + c.client.Conn.WriteProto(&packet) +} + +// Unlink unlinks the given channels from the channel. If no arguments are +// passed, all linked channels are unlinked. +func (c *Channel) Unlink(channel ...*Channel) { + packet := MumbleProto.ChannelState{ + ChannelId: &c.ID, + } + if len(channel) == 0 { + packet.LinksRemove = make([]uint32, len(c.Links)) + i := 0 + for channelID := range c.Links { + packet.LinksRemove[i] = channelID + i++ + } + } else { + packet.LinksRemove = make([]uint32, len(channel)) + for i, ch := range channel { + packet.LinksRemove[i] = ch.ID + } + } + c.client.Conn.WriteProto(&packet) +} diff --git a/vendor/layeh.com/gumble/gumble/channels.go b/vendor/layeh.com/gumble/gumble/channels.go new file mode 100644 index 00000000..2058b0b1 --- /dev/null +++ b/vendor/layeh.com/gumble/gumble/channels.go @@ -0,0 +1,28 @@ +package gumble + +// Channels is a map of server channels. +type Channels map[uint32]*Channel + +// create adds a new channel with the given id to the collection. If a channel +// with the given id already exists, it is overwritten. +func (c Channels) create(id uint32) *Channel { + channel := &Channel{ + ID: id, + Links: Channels{}, + Children: Channels{}, + Users: Users{}, + } + c[id] = channel + return channel +} + +// Find returns a channel whose path (by channel name) from the server root +// channel is equal to the arguments passed. nil is returned if c does not +// containt the root channel. +func (c Channels) Find(names ...string) *Channel { + root := c[0] + if names == nil || root == nil { + return root + } + return root.Find(names...) +} diff --git a/vendor/layeh.com/gumble/gumble/client.go b/vendor/layeh.com/gumble/gumble/client.go new file mode 100644 index 00000000..2256f5fb --- /dev/null +++ b/vendor/layeh.com/gumble/gumble/client.go @@ -0,0 +1,289 @@ +package gumble + +import ( + "crypto/tls" + "errors" + "math" + "net" + "runtime" + "sync/atomic" + "time" + + "github.com/golang/protobuf/proto" + "layeh.com/gumble/gumble/MumbleProto" +) + +// State is the current state of the client's connection to the server. +type State int + +const ( + // StateDisconnected means the client is no longer connected to the server. + StateDisconnected State = iota + + // StateConnected means the client is connected to the server and is + // syncing initial information. This is an internal state that will + // never be returned by Client.State(). + StateConnected + + // StateSynced means the client is connected to a server and has been sent + // the server state. + StateSynced +) + +// ClientVersion is the protocol version that Client implements. +const ClientVersion = 1<<16 | 3<<8 | 0 + +// Client is the type used to create a connection to a server. +type Client struct { + // The User associated with the client. + Self *User + // The client's configuration. + Config *Config + // The underlying Conn to the server. + Conn *Conn + + // The users currently connected to the server. + Users Users + // The connected server's channels. + Channels Channels + permissions map[uint32]*Permission + tmpACL *ACL + + // Ping stats + tcpPacketsReceived uint32 + tcpPingTimes [12]float32 + tcpPingAvg uint32 + tcpPingVar uint32 + + // A collection containing the server's context actions. + ContextActions ContextActions + + // The audio encoder used when sending audio to the server. + AudioEncoder AudioEncoder + audioCodec AudioCodec + // To whom transmitted audio will be sent. The VoiceTarget must have already + // been sent to the server for targeting to work correctly. Setting to nil + // will disable voice targeting (i.e. switch back to regular speaking). + VoiceTarget *VoiceTarget + + state uint32 + + // volatile is held by the client when the internal data structures are being + // modified. + volatile rpwMutex + + connect chan *RejectError + end chan struct{} + disconnectEvent DisconnectEvent +} + +// Dial is an alias of DialWithDialer(new(net.Dialer), addr, config, nil). +func Dial(addr string, config *Config) (*Client, error) { + return DialWithDialer(new(net.Dialer), addr, config, nil) +} + +// DialWithDialer connects to the Mumble server at the given address. +// +// The function returns after the connection has been established, the initial +// server information has been synced, and the OnConnect handlers have been +// called. +// +// nil and an error is returned if server synchronization does not complete by +// min(time.Now() + dialer.Timeout, dialer.Deadline), or if the server rejects +// the client. +func DialWithDialer(dialer *net.Dialer, addr string, config *Config, tlsConfig *tls.Config) (*Client, error) { + start := time.Now() + + conn, err := tls.DialWithDialer(dialer, "tcp", addr, tlsConfig) + if err != nil { + return nil, err + } + + client := &Client{ + Conn: NewConn(conn), + Config: config, + Users: make(Users), + Channels: make(Channels), + + permissions: make(map[uint32]*Permission), + + state: uint32(StateConnected), + + connect: make(chan *RejectError), + end: make(chan struct{}), + } + + go client.readRoutine() + + // Initial packets + versionPacket := MumbleProto.Version{ + Version: proto.Uint32(ClientVersion), + Release: proto.String("gumble"), + Os: proto.String(runtime.GOOS), + OsVersion: proto.String(runtime.GOARCH), + } + authenticationPacket := MumbleProto.Authenticate{ + Username: &client.Config.Username, + Password: &client.Config.Password, + Opus: proto.Bool(getAudioCodec(audioCodecIDOpus) != nil), + Tokens: client.Config.Tokens, + } + client.Conn.WriteProto(&versionPacket) + client.Conn.WriteProto(&authenticationPacket) + + go client.pingRoutine() + + var timeout <-chan time.Time + { + var deadline time.Time + if !dialer.Deadline.IsZero() { + deadline = dialer.Deadline + } + if dialer.Timeout > 0 { + diff := start.Add(dialer.Timeout) + if deadline.IsZero() || diff.Before(deadline) { + deadline = diff + } + } + if !deadline.IsZero() { + timer := time.NewTimer(deadline.Sub(start)) + defer timer.Stop() + timeout = timer.C + } + } + + select { + case <-timeout: + client.Conn.Close() + return nil, errors.New("gumble: synchronization timeout") + case err := <-client.connect: + if err != nil { + client.Conn.Close() + return nil, err + } + + return client, nil + } +} + +// State returns the current state of the client. +func (c *Client) State() State { + return State(atomic.LoadUint32(&c.state)) +} + +// AudioOutgoing creates a new channel that outgoing audio data can be written +// to. The channel must be closed after the audio stream is completed. Only +// a single channel should be open at any given time (i.e. close the channel +// before opening another). +func (c *Client) AudioOutgoing() chan<- AudioBuffer { + ch := make(chan AudioBuffer) + go func() { + var seq int64 + previous := <-ch + for p := range ch { + previous.writeAudio(c, seq, false) + previous = p + seq = (seq + 1) % math.MaxInt32 + } + if previous != nil { + previous.writeAudio(c, seq, true) + } + }() + return ch +} + +// pingRoutine sends ping packets to the server at regular intervals. +func (c *Client) pingRoutine() { + ticker := time.NewTicker(time.Second * 5) + defer ticker.Stop() + + var timestamp uint64 + var tcpPingAvg float32 + var tcpPingVar float32 + packet := MumbleProto.Ping{ + Timestamp: ×tamp, + TcpPackets: &c.tcpPacketsReceived, + TcpPingAvg: &tcpPingAvg, + TcpPingVar: &tcpPingVar, + } + + t := time.Now() + for { + timestamp = uint64(t.UnixNano()) + tcpPingAvg = math.Float32frombits(atomic.LoadUint32(&c.tcpPingAvg)) + tcpPingVar = math.Float32frombits(atomic.LoadUint32(&c.tcpPingVar)) + c.Conn.WriteProto(&packet) + + select { + case <-c.end: + return + case t = <-ticker.C: + // continue to top of loop + } + } +} + +// readRoutine reads protocol buffer messages from the server. +func (c *Client) readRoutine() { + c.disconnectEvent = DisconnectEvent{ + Client: c, + Type: DisconnectError, + } + + for { + pType, data, err := c.Conn.ReadPacket() + if err != nil { + break + } + if int(pType) < len(handlers) { + handlers[pType](c, data) + } + } + + wasSynced := c.State() == StateSynced + atomic.StoreUint32(&c.state, uint32(StateDisconnected)) + close(c.end) + if wasSynced { + c.Config.Listeners.onDisconnect(&c.disconnectEvent) + } +} + +// RequestUserList requests that the server's registered user list be sent to +// the client. +func (c *Client) RequestUserList() { + packet := MumbleProto.UserList{} + c.Conn.WriteProto(&packet) +} + +// RequestBanList requests that the server's ban list be sent to the client. +func (c *Client) RequestBanList() { + packet := MumbleProto.BanList{ + Query: proto.Bool(true), + } + c.Conn.WriteProto(&packet) +} + +// Disconnect disconnects the client from the server. +func (c *Client) Disconnect() error { + if c.State() == StateDisconnected { + return errors.New("gumble: client is already disconnected") + } + c.disconnectEvent.Type = DisconnectUser + c.Conn.Close() + return nil +} + +// Do executes f in a thread-safe manner. It ensures that Client and its +// associated data will not be changed during the lifetime of the function +// call. +func (c *Client) Do(f func()) { + c.volatile.RLock() + defer c.volatile.RUnlock() + + f() +} + +// Send will send a Message to the server. +func (c *Client) Send(message Message) { + message.writeMessage(c) +} diff --git a/vendor/layeh.com/gumble/gumble/config.go b/vendor/layeh.com/gumble/gumble/config.go new file mode 100644 index 00000000..49603886 --- /dev/null +++ b/vendor/layeh.com/gumble/gumble/config.go @@ -0,0 +1,53 @@ +package gumble + +import ( + "time" +) + +// Config holds the Mumble configuration used by Client. A single Config should +// not be shared between multiple Client instances. +type Config struct { + // User name used when authenticating with the server. + Username string + // Password used when authenticating with the server. A password is not + // usually required to connect to a server. + Password string + // The initial access tokens to the send to the server. Access tokens can be + // resent to the server using: + // client.Send(config.Tokens) + Tokens AccessTokens + + // AudioInterval is the interval at which audio packets are sent. Valid + // values are: 10ms, 20ms, 40ms, and 60ms. + AudioInterval time.Duration + // AudioDataBytes is the number of bytes that an audio frame can use. + AudioDataBytes int + + // The event listeners used when client events are triggered. + Listeners Listeners + AudioListeners AudioListeners +} + +// NewConfig returns a new Config struct with default values set. +func NewConfig() *Config { + return &Config{ + AudioInterval: AudioDefaultInterval, + AudioDataBytes: AudioDefaultDataBytes, + } +} + +// Attach is an alias of c.Listeners.Attach. +func (c *Config) Attach(l EventListener) Detacher { + return c.Listeners.Attach(l) +} + +// AttachAudio is an alias of c.AudioListeners.Attach. +func (c *Config) AttachAudio(l AudioListener) Detacher { + return c.AudioListeners.Attach(l) +} + +// AudioFrameSize returns the appropriate audio frame size, based off of the +// audio interval. +func (c *Config) AudioFrameSize() int { + return int(c.AudioInterval/AudioDefaultInterval) * AudioDefaultFrameSize +} diff --git a/vendor/layeh.com/gumble/gumble/conn.go b/vendor/layeh.com/gumble/gumble/conn.go new file mode 100644 index 00000000..11e87489 --- /dev/null +++ b/vendor/layeh.com/gumble/gumble/conn.go @@ -0,0 +1,200 @@ +package gumble + +import ( + "encoding/binary" + "errors" + "io" + "net" + "sync" + "time" + + "github.com/golang/protobuf/proto" + "layeh.com/gumble/gumble/MumbleProto" + "layeh.com/gumble/gumble/varint" +) + +// DefaultPort is the default port on which Mumble servers listen. +const DefaultPort = 64738 + +// Conn represents a control protocol connection to a Mumble client/server. +type Conn struct { + sync.Mutex + net.Conn + + MaximumPacketBytes int + Timeout time.Duration + + buffer []byte +} + +// NewConn creates a new Conn with the given net.Conn. +func NewConn(conn net.Conn) *Conn { + return &Conn{ + Conn: conn, + Timeout: time.Second * 20, + MaximumPacketBytes: 1024 * 1024 * 10, + } +} + +// ReadPacket reads a packet from the server. Returns the packet type, the +// packet data, and nil on success. +// +// This function should only be called by a single go routine. +func (c *Conn) ReadPacket() (uint16, []byte, error) { + c.Conn.SetReadDeadline(time.Now().Add(c.Timeout)) + var header [6]byte + if _, err := io.ReadFull(c.Conn, header[:]); err != nil { + return 0, nil, err + } + pType := binary.BigEndian.Uint16(header[:]) + pLength := binary.BigEndian.Uint32(header[2:]) + pLengthInt := int(pLength) + if pLengthInt > c.MaximumPacketBytes { + return 0, nil, errors.New("gumble: packet larger than maximum allowed size") + } + if pLengthInt > len(c.buffer) { + c.buffer = make([]byte, pLengthInt) + } + if _, err := io.ReadFull(c.Conn, c.buffer[:pLengthInt]); err != nil { + return 0, nil, err + } + return pType, c.buffer[:pLengthInt], nil +} + +// WriteAudio writes an audio packet to the connection. +func (c *Conn) WriteAudio(format, target byte, sequence int64, final bool, data []byte, X, Y, Z *float32) error { + var buff [1 + varint.MaxVarintLen*2]byte + buff[0] = (format << 5) | target + n := varint.Encode(buff[1:], sequence) + if n == 0 { + return errors.New("gumble: varint out of range") + } + l := int64(len(data)) + if final { + l |= 0x2000 + } + m := varint.Encode(buff[1+n:], l) + if m == 0 { + return errors.New("gumble: varint out of range") + } + header := buff[:1+n+m] + + var positionalLength int + if X != nil { + positionalLength = 3 * 4 + } + + c.Lock() + defer c.Unlock() + + if err := c.writeHeader(1, uint32(len(header)+len(data)+positionalLength)); err != nil { + return err + } + if _, err := c.Conn.Write(header); err != nil { + return err + } + if _, err := c.Conn.Write(data); err != nil { + return err + } + + if positionalLength > 0 { + if err := binary.Write(c.Conn, binary.LittleEndian, *X); err != nil { + return err + } + if err := binary.Write(c.Conn, binary.LittleEndian, *Y); err != nil { + return err + } + if err := binary.Write(c.Conn, binary.LittleEndian, *Z); err != nil { + return err + } + } + + return nil +} + +// WritePacket writes a data packet of the given type to the connection. +func (c *Conn) WritePacket(ptype uint16, data []byte) error { + c.Lock() + defer c.Unlock() + if err := c.writeHeader(uint16(ptype), uint32(len(data))); err != nil { + return err + } + if _, err := c.Conn.Write(data); err != nil { + return err + } + return nil +} + +func (c *Conn) writeHeader(pType uint16, pLength uint32) error { + var header [6]byte + binary.BigEndian.PutUint16(header[:], pType) + binary.BigEndian.PutUint32(header[2:], pLength) + if _, err := c.Conn.Write(header[:]); err != nil { + return err + } + return nil +} + +// WriteProto writes a protocol buffer message to the connection. +func (c *Conn) WriteProto(message proto.Message) error { + var protoType uint16 + switch message.(type) { + case *MumbleProto.Version: + protoType = 0 + case *MumbleProto.Authenticate: + protoType = 2 + case *MumbleProto.Ping: + protoType = 3 + case *MumbleProto.Reject: + protoType = 4 + case *MumbleProto.ServerSync: + protoType = 5 + case *MumbleProto.ChannelRemove: + protoType = 6 + case *MumbleProto.ChannelState: + protoType = 7 + case *MumbleProto.UserRemove: + protoType = 8 + case *MumbleProto.UserState: + protoType = 9 + case *MumbleProto.BanList: + protoType = 10 + case *MumbleProto.TextMessage: + protoType = 11 + case *MumbleProto.PermissionDenied: + protoType = 12 + case *MumbleProto.ACL: + protoType = 13 + case *MumbleProto.QueryUsers: + protoType = 14 + case *MumbleProto.CryptSetup: + protoType = 15 + case *MumbleProto.ContextActionModify: + protoType = 16 + case *MumbleProto.ContextAction: + protoType = 17 + case *MumbleProto.UserList: + protoType = 18 + case *MumbleProto.VoiceTarget: + protoType = 19 + case *MumbleProto.PermissionQuery: + protoType = 20 + case *MumbleProto.CodecVersion: + protoType = 21 + case *MumbleProto.UserStats: + protoType = 22 + case *MumbleProto.RequestBlob: + protoType = 23 + case *MumbleProto.ServerConfig: + protoType = 24 + case *MumbleProto.SuggestConfig: + protoType = 25 + default: + return errors.New("gumble: unknown message type") + } + data, err := proto.Marshal(message) + if err != nil { + return err + } + return c.WritePacket(protoType, data) +} diff --git a/vendor/layeh.com/gumble/gumble/contextaction.go b/vendor/layeh.com/gumble/gumble/contextaction.go new file mode 100644 index 00000000..bee6b755 --- /dev/null +++ b/vendor/layeh.com/gumble/gumble/contextaction.go @@ -0,0 +1,57 @@ +package gumble + +import ( + "layeh.com/gumble/gumble/MumbleProto" +) + +// ContextActionType is a bitmask of contexts where a ContextAction can be +// triggered. +type ContextActionType int + +// Supported ContextAction contexts. +const ( + ContextActionServer ContextActionType = ContextActionType(MumbleProto.ContextActionModify_Server) + ContextActionChannel ContextActionType = ContextActionType(MumbleProto.ContextActionModify_Channel) + ContextActionUser ContextActionType = ContextActionType(MumbleProto.ContextActionModify_User) +) + +// ContextAction is an triggerable item that has been added by a server-side +// plugin. +type ContextAction struct { + // The context action type. + Type ContextActionType + // The name of the context action. + Name string + // The user-friendly description of the context action. + Label string + + client *Client +} + +// Trigger will trigger the context action in the context of the server. +func (c *ContextAction) Trigger() { + packet := MumbleProto.ContextAction{ + Action: &c.Name, + } + c.client.Conn.WriteProto(&packet) +} + +// TriggerUser will trigger the context action in the context of the given +// user. +func (c *ContextAction) TriggerUser(user *User) { + packet := MumbleProto.ContextAction{ + Session: &user.Session, + Action: &c.Name, + } + c.client.Conn.WriteProto(&packet) +} + +// TriggerChannel will trigger the context action in the context of the given +// channel. +func (c *ContextAction) TriggerChannel(channel *Channel) { + packet := MumbleProto.ContextAction{ + ChannelId: &channel.ID, + Action: &c.Name, + } + c.client.Conn.WriteProto(&packet) +} diff --git a/vendor/layeh.com/gumble/gumble/contextactions.go b/vendor/layeh.com/gumble/gumble/contextactions.go new file mode 100644 index 00000000..6dd0c169 --- /dev/null +++ b/vendor/layeh.com/gumble/gumble/contextactions.go @@ -0,0 +1,12 @@ +package gumble + +// ContextActions is a map of ContextActions. +type ContextActions map[string]*ContextAction + +func (c ContextActions) create(action string) *ContextAction { + contextAction := &ContextAction{ + Name: action, + } + c[action] = contextAction + return contextAction +} diff --git a/vendor/layeh.com/gumble/gumble/detacher.go b/vendor/layeh.com/gumble/gumble/detacher.go new file mode 100644 index 00000000..0594caac --- /dev/null +++ b/vendor/layeh.com/gumble/gumble/detacher.go @@ -0,0 +1,7 @@ +package gumble + +// Detacher is an interface that event listeners implement. After the Detach +// method is called, the listener will no longer receive events. +type Detacher interface { + Detach() +} diff --git a/vendor/layeh.com/gumble/gumble/doc.go b/vendor/layeh.com/gumble/gumble/doc.go new file mode 100644 index 00000000..29115423 --- /dev/null +++ b/vendor/layeh.com/gumble/gumble/doc.go @@ -0,0 +1,45 @@ +// Package gumble is a client for the Mumble voice chat software. +// +// Getting started +// +// 1. Create a new Config to hold your connection settings: +// +// config := gumble.NewConfig() +// config.Username = "gumble-test" +// +// 2. Attach event listeners to the configuration: +// +// config.Attach(gumbleutil.Listener{ +// TextMessage: func(e *gumble.TextMessageEvent) { +// fmt.Printf("Received text message: %s\n", e.Message) +// }, +// }) +// +// 3. Connect to the server: +// +// client, err := gumble.Dial("example.com:64738", config) +// if err != nil { +// panic(err) +// } +// +// Audio codecs +// +// Currently, only the Opus codec (https://www.opus-codec.org/) is supported +// for transmitting and receiving audio. It can be enabled by importing the +// following package for its side effect: +// import ( +// _ "layeh.com/gumble/opus" +// ) +// +// To ensure that gumble clients can always transmit and receive audio to and +// from your server, add the following line to your murmur configuration file: +// +// opusthreshold=0 +// +// Thread safety +// +// As a general rule, a Client everything that is associated with it +// (Users, Channels, Config, etc.), is thread-unsafe. Accessing or modifying +// those structures should only be done from inside of an event listener or via +// Client.Do. +package gumble diff --git a/vendor/layeh.com/gumble/gumble/event.go b/vendor/layeh.com/gumble/gumble/event.go new file mode 100644 index 00000000..cc088673 --- /dev/null +++ b/vendor/layeh.com/gumble/gumble/event.go @@ -0,0 +1,223 @@ +package gumble + +import ( + "layeh.com/gumble/gumble/MumbleProto" +) + +// EventListener is the interface that must be implemented by a type if it +// wishes to be notified of Client events. +// +// Listener methods are executed synchronously as event happen. They also block +// network reads from happening until all handlers for an event are called. +// Therefore, it is not recommended to do any long processing from inside of +// these methods. +type EventListener interface { + OnConnect(e *ConnectEvent) + OnDisconnect(e *DisconnectEvent) + OnTextMessage(e *TextMessageEvent) + OnUserChange(e *UserChangeEvent) + OnChannelChange(e *ChannelChangeEvent) + OnPermissionDenied(e *PermissionDeniedEvent) + OnUserList(e *UserListEvent) + OnACL(e *ACLEvent) + OnBanList(e *BanListEvent) + OnContextActionChange(e *ContextActionChangeEvent) + OnServerConfig(e *ServerConfigEvent) +} + +// ConnectEvent is the event that is passed to EventListener.OnConnect. +type ConnectEvent struct { + Client *Client + WelcomeMessage *string + MaximumBitrate *int +} + +// DisconnectType specifies why a Client disconnected from a server. +type DisconnectType int + +// Client disconnect reasons. +const ( + DisconnectError DisconnectType = iota + 1 + DisconnectKicked + DisconnectBanned + DisconnectUser +) + +// Has returns true if the DisconnectType has changeType part of its bitmask. +func (d DisconnectType) Has(changeType DisconnectType) bool { + return d&changeType == changeType +} + +// DisconnectEvent is the event that is passed to EventListener.OnDisconnect. +type DisconnectEvent struct { + Client *Client + Type DisconnectType + + String string +} + +// TextMessageEvent is the event that is passed to EventListener.OnTextMessage. +type TextMessageEvent struct { + Client *Client + TextMessage +} + +// UserChangeType is a bitmask of items that changed for a user. +type UserChangeType int + +// User change items. +const ( + UserChangeConnected UserChangeType = 1 << iota + UserChangeDisconnected + UserChangeKicked + UserChangeBanned + UserChangeRegistered + UserChangeUnregistered + UserChangeName + UserChangeChannel + UserChangeComment + UserChangeAudio + UserChangeTexture + UserChangePrioritySpeaker + UserChangeRecording + UserChangeStats +) + +// Has returns true if the UserChangeType has changeType part of its bitmask. +func (u UserChangeType) Has(changeType UserChangeType) bool { + return u&changeType == changeType +} + +// UserChangeEvent is the event that is passed to EventListener.OnUserChange. +type UserChangeEvent struct { + Client *Client + Type UserChangeType + User *User + Actor *User + + String string +} + +// ChannelChangeType is a bitmask of items that changed for a channel. +type ChannelChangeType int + +// Channel change items. +const ( + ChannelChangeCreated ChannelChangeType = 1 << iota + ChannelChangeRemoved + ChannelChangeMoved + ChannelChangeName + ChannelChangeLinks + ChannelChangeDescription + ChannelChangePosition + ChannelChangePermission + ChannelChangeMaxUsers +) + +// Has returns true if the ChannelChangeType has changeType part of its +// bitmask. +func (c ChannelChangeType) Has(changeType ChannelChangeType) bool { + return c&changeType == changeType +} + +// ChannelChangeEvent is the event that is passed to +// EventListener.OnChannelChange. +type ChannelChangeEvent struct { + Client *Client + Type ChannelChangeType + Channel *Channel +} + +// PermissionDeniedType specifies why a Client was denied permission to perform +// a particular action. +type PermissionDeniedType int + +// Permission denied types. +const ( + PermissionDeniedOther PermissionDeniedType = PermissionDeniedType(MumbleProto.PermissionDenied_Text) + PermissionDeniedPermission PermissionDeniedType = PermissionDeniedType(MumbleProto.PermissionDenied_Permission) + PermissionDeniedSuperUser PermissionDeniedType = PermissionDeniedType(MumbleProto.PermissionDenied_SuperUser) + PermissionDeniedInvalidChannelName PermissionDeniedType = PermissionDeniedType(MumbleProto.PermissionDenied_ChannelName) + PermissionDeniedTextTooLong PermissionDeniedType = PermissionDeniedType(MumbleProto.PermissionDenied_TextTooLong) + PermissionDeniedTemporaryChannel PermissionDeniedType = PermissionDeniedType(MumbleProto.PermissionDenied_TemporaryChannel) + PermissionDeniedMissingCertificate PermissionDeniedType = PermissionDeniedType(MumbleProto.PermissionDenied_MissingCertificate) + PermissionDeniedInvalidUserName PermissionDeniedType = PermissionDeniedType(MumbleProto.PermissionDenied_UserName) + PermissionDeniedChannelFull PermissionDeniedType = PermissionDeniedType(MumbleProto.PermissionDenied_ChannelFull) + PermissionDeniedNestingLimit PermissionDeniedType = PermissionDeniedType(MumbleProto.PermissionDenied_NestingLimit) + PermissionDeniedChannelCountLimit PermissionDeniedType = PermissionDeniedType(MumbleProto.PermissionDenied_ChannelCountLimit) +) + +// Has returns true if the PermissionDeniedType has changeType part of its +// bitmask. +func (p PermissionDeniedType) Has(changeType PermissionDeniedType) bool { + return p&changeType == changeType +} + +// PermissionDeniedEvent is the event that is passed to +// EventListener.OnPermissionDenied. +type PermissionDeniedEvent struct { + Client *Client + Type PermissionDeniedType + Channel *Channel + User *User + + Permission Permission + String string +} + +// UserListEvent is the event that is passed to EventListener.OnUserList. +type UserListEvent struct { + Client *Client + UserList RegisteredUsers +} + +// ACLEvent is the event that is passed to EventListener.OnACL. +type ACLEvent struct { + Client *Client + ACL *ACL +} + +// BanListEvent is the event that is passed to EventListener.OnBanList. +type BanListEvent struct { + Client *Client + BanList BanList +} + +// ContextActionChangeType specifies how a ContextAction changed. +type ContextActionChangeType int + +// ContextAction change types. +const ( + ContextActionAdd ContextActionChangeType = ContextActionChangeType(MumbleProto.ContextActionModify_Add) + ContextActionRemove ContextActionChangeType = ContextActionChangeType(MumbleProto.ContextActionModify_Remove) +) + +// ContextActionChangeEvent is the event that is passed to +// EventListener.OnContextActionChange. +type ContextActionChangeEvent struct { + Client *Client + Type ContextActionChangeType + ContextAction *ContextAction +} + +// ServerConfigEvent is the event that is passed to +// EventListener.OnServerConfig. +type ServerConfigEvent struct { + Client *Client + + MaximumBitrate *int + WelcomeMessage *string + AllowHTML *bool + MaximumMessageLength *int + MaximumImageMessageLength *int + MaximumUsers *int + + CodecAlpha *int32 + CodecBeta *int32 + CodecPreferAlpha *bool + CodecOpus *bool + + SuggestVersion *Version + SuggestPositional *bool + SuggestPushToTalk *bool +} diff --git a/vendor/layeh.com/gumble/gumble/handlers.go b/vendor/layeh.com/gumble/gumble/handlers.go new file mode 100644 index 00000000..a5b012d6 --- /dev/null +++ b/vendor/layeh.com/gumble/gumble/handlers.go @@ -0,0 +1,1261 @@ +package gumble + +import ( + "crypto/x509" + "encoding/binary" + "errors" + "math" + "net" + "sync/atomic" + "time" + + "github.com/golang/protobuf/proto" + "layeh.com/gumble/gumble/MumbleProto" + "layeh.com/gumble/gumble/varint" +) + +var ( + errUnimplementedHandler = errors.New("gumble: the handler has not been implemented") + errIncompleteProtobuf = errors.New("gumble: protobuf message is missing a required field") + errInvalidProtobuf = errors.New("gumble: protobuf message has an invalid field") + errUnsupportedAudio = errors.New("gumble: unsupported audio codec") + errNoCodec = errors.New("gumble: no audio codec") +) + +var handlers = [...]func(*Client, []byte) error{ + (*Client).handleVersion, + (*Client).handleUDPTunnel, + (*Client).handleAuthenticate, + (*Client).handlePing, + (*Client).handleReject, + (*Client).handleServerSync, + (*Client).handleChannelRemove, + (*Client).handleChannelState, + (*Client).handleUserRemove, + (*Client).handleUserState, + (*Client).handleBanList, + (*Client).handleTextMessage, + (*Client).handlePermissionDenied, + (*Client).handleACL, + (*Client).handleQueryUsers, + (*Client).handleCryptSetup, + (*Client).handleContextActionModify, + (*Client).handleContextAction, + (*Client).handleUserList, + (*Client).handleVoiceTarget, + (*Client).handlePermissionQuery, + (*Client).handleCodecVersion, + (*Client).handleUserStats, + (*Client).handleRequestBlob, + (*Client).handleServerConfig, + (*Client).handleSuggestConfig, +} + +func parseVersion(packet *MumbleProto.Version) Version { + var version Version + if packet.Version != nil { + version.Version = *packet.Version + } + if packet.Release != nil { + version.Release = *packet.Release + } + if packet.Os != nil { + version.OS = *packet.Os + } + if packet.OsVersion != nil { + version.OSVersion = *packet.OsVersion + } + return version +} + +func (c *Client) handleVersion(buffer []byte) error { + var packet MumbleProto.Version + if err := proto.Unmarshal(buffer, &packet); err != nil { + return err + } + return nil +} + +func (c *Client) handleUDPTunnel(buffer []byte) error { + if len(buffer) < 1 { + return errInvalidProtobuf + } + audioType := (buffer[0] >> 5) & 0x7 + audioTarget := buffer[0] & 0x1F + + // Opus only + // TODO: add handling for other packet types + if audioType != audioCodecIDOpus { + return errUnsupportedAudio + } + + // Session + buffer = buffer[1:] + session, n := varint.Decode(buffer) + if n <= 0 { + return errInvalidProtobuf + } + buffer = buffer[n:] + user := c.Users[uint32(session)] + if user == nil { + return errInvalidProtobuf + } + decoder := user.decoder + if decoder == nil { + // TODO: decoder pool + // TODO: de-reference after stream is done + codec := c.audioCodec + if codec == nil { + return errNoCodec + } + decoder = codec.NewDecoder() + user.decoder = decoder + } + + // Sequence + // TODO: use in jitter buffer + _, n = varint.Decode(buffer) + if n <= 0 { + return errInvalidProtobuf + } + buffer = buffer[n:] + + // Length + length, n := varint.Decode(buffer) + if n <= 0 { + return errInvalidProtobuf + } + buffer = buffer[n:] + // Opus audio packets set the 13th bit in the size field as the terminator. + audioLength := int(length) &^ 0x2000 + if audioLength > len(buffer) { + return errInvalidProtobuf + } + + pcm, err := decoder.Decode(buffer[:audioLength], AudioMaximumFrameSize) + if err != nil { + return err + } + + event := AudioPacket{ + Client: c, + Sender: user, + Target: &VoiceTarget{ + ID: uint32(audioTarget), + }, + AudioBuffer: AudioBuffer(pcm), + } + + if len(buffer)-audioLength == 3*4 { + // the packet has positional audio data; 3x float32 + buffer = buffer[audioLength:] + + event.X = math.Float32frombits(binary.LittleEndian.Uint32(buffer)) + event.Y = math.Float32frombits(binary.LittleEndian.Uint32(buffer[4:])) + event.Z = math.Float32frombits(binary.LittleEndian.Uint32(buffer[8:])) + event.HasPosition = true + } + + c.volatile.Lock() + for item := c.Config.AudioListeners.head; item != nil; item = item.next { + c.volatile.Unlock() + ch := item.streams[user] + if ch == nil { + ch = make(chan *AudioPacket) + item.streams[user] = ch + event := AudioStreamEvent{ + Client: c, + User: user, + C: ch, + } + item.listener.OnAudioStream(&event) + } + ch <- &event + c.volatile.Lock() + } + c.volatile.Unlock() + + return nil +} + +func (c *Client) handleAuthenticate(buffer []byte) error { + return errUnimplementedHandler +} + +func (c *Client) handlePing(buffer []byte) error { + var packet MumbleProto.Ping + if err := proto.Unmarshal(buffer, &packet); err != nil { + return err + } + + atomic.AddUint32(&c.tcpPacketsReceived, 1) + + if packet.Timestamp != nil { + diff := time.Since(time.Unix(0, int64(*packet.Timestamp))) + + index := int(c.tcpPacketsReceived) - 1 + if index >= len(c.tcpPingTimes) { + for i := 1; i < len(c.tcpPingTimes); i++ { + c.tcpPingTimes[i-1] = c.tcpPingTimes[i] + } + index = len(c.tcpPingTimes) - 1 + } + + // average is in milliseconds + ping := float32(diff.Seconds() * 1000) + c.tcpPingTimes[index] = ping + + var sum float32 + for i := 0; i <= index; i++ { + sum += c.tcpPingTimes[i] + } + avg := sum / float32(index+1) + + sum = 0 + for i := 0; i <= index; i++ { + sum += (avg - c.tcpPingTimes[i]) * (avg - c.tcpPingTimes[i]) + } + variance := sum / float32(index+1) + + atomic.StoreUint32(&c.tcpPingAvg, math.Float32bits(avg)) + atomic.StoreUint32(&c.tcpPingVar, math.Float32bits(variance)) + } + return nil +} + +func (c *Client) handleReject(buffer []byte) error { + var packet MumbleProto.Reject + if err := proto.Unmarshal(buffer, &packet); err != nil { + return err + } + + if c.State() != StateConnected { + return errInvalidProtobuf + } + + err := &RejectError{} + + if packet.Type != nil { + err.Type = RejectType(*packet.Type) + } + if packet.Reason != nil { + err.Reason = *packet.Reason + } + c.connect <- err + c.Conn.Close() + return nil +} + +func (c *Client) handleServerSync(buffer []byte) error { + var packet MumbleProto.ServerSync + if err := proto.Unmarshal(buffer, &packet); err != nil { + return err + } + event := ConnectEvent{ + Client: c, + } + + if packet.Session != nil { + { + c.volatile.Lock() + + c.Self = c.Users[*packet.Session] + + c.volatile.Unlock() + } + } + if packet.WelcomeText != nil { + event.WelcomeMessage = packet.WelcomeText + } + if packet.MaxBandwidth != nil { + val := int(*packet.MaxBandwidth) + event.MaximumBitrate = &val + } + atomic.StoreUint32(&c.state, uint32(StateSynced)) + c.Config.Listeners.onConnect(&event) + close(c.connect) + return nil +} + +func (c *Client) handleChannelRemove(buffer []byte) error { + var packet MumbleProto.ChannelRemove + if err := proto.Unmarshal(buffer, &packet); err != nil { + return err + } + + if packet.ChannelId == nil { + return errIncompleteProtobuf + } + + var channel *Channel + { + c.volatile.Lock() + + channelID := *packet.ChannelId + channel = c.Channels[channelID] + if channel == nil { + c.volatile.Unlock() + return errInvalidProtobuf + } + channel.client = nil + delete(c.Channels, channelID) + delete(c.permissions, channelID) + if parent := channel.Parent; parent != nil { + delete(parent.Children, channel.ID) + } + for _, link := range channel.Links { + delete(link.Links, channelID) + } + + c.volatile.Unlock() + } + + if c.State() == StateSynced { + event := ChannelChangeEvent{ + Client: c, + Type: ChannelChangeRemoved, + Channel: channel, + } + c.Config.Listeners.onChannelChange(&event) + } + return nil +} + +func (c *Client) handleChannelState(buffer []byte) error { + var packet MumbleProto.ChannelState + if err := proto.Unmarshal(buffer, &packet); err != nil { + return err + } + + if packet.ChannelId == nil { + return errIncompleteProtobuf + } + event := ChannelChangeEvent{ + Client: c, + } + + { + c.volatile.Lock() + + channelID := *packet.ChannelId + channel := c.Channels[channelID] + if channel == nil { + channel = c.Channels.create(channelID) + channel.client = c + + event.Type |= ChannelChangeCreated + } + event.Channel = channel + if packet.Parent != nil { + if channel.Parent != nil { + delete(channel.Parent.Children, channelID) + } + newParent := c.Channels[*packet.Parent] + if newParent != channel.Parent { + event.Type |= ChannelChangeMoved + } + channel.Parent = newParent + if channel.Parent != nil { + channel.Parent.Children[channel.ID] = channel + } + } + if packet.Name != nil { + if *packet.Name != channel.Name { + event.Type |= ChannelChangeName + } + channel.Name = *packet.Name + } + if packet.Links != nil { + channel.Links = make(Channels) + event.Type |= ChannelChangeLinks + for _, channelID := range packet.Links { + if c := c.Channels[channelID]; c != nil { + channel.Links[channelID] = c + } + } + } + for _, channelID := range packet.LinksAdd { + if c := c.Channels[channelID]; c != nil { + event.Type |= ChannelChangeLinks + channel.Links[channelID] = c + c.Links[channel.ID] = channel + } + } + for _, channelID := range packet.LinksRemove { + if c := c.Channels[channelID]; c != nil { + event.Type |= ChannelChangeLinks + delete(channel.Links, channelID) + delete(c.Links, channel.ID) + } + } + if packet.Description != nil { + if *packet.Description != channel.Description { + event.Type |= ChannelChangeDescription + } + channel.Description = *packet.Description + channel.DescriptionHash = nil + } + if packet.Temporary != nil { + channel.Temporary = *packet.Temporary + } + if packet.Position != nil { + if *packet.Position != channel.Position { + event.Type |= ChannelChangePosition + } + channel.Position = *packet.Position + } + if packet.DescriptionHash != nil { + event.Type |= ChannelChangeDescription + channel.DescriptionHash = packet.DescriptionHash + channel.Description = "" + } + if packet.MaxUsers != nil { + event.Type |= ChannelChangeMaxUsers + channel.MaxUsers = *packet.MaxUsers + } + + c.volatile.Unlock() + } + + if c.State() == StateSynced { + c.Config.Listeners.onChannelChange(&event) + } + return nil +} + +func (c *Client) handleUserRemove(buffer []byte) error { + var packet MumbleProto.UserRemove + if err := proto.Unmarshal(buffer, &packet); err != nil { + return err + } + + if packet.Session == nil { + return errIncompleteProtobuf + } + event := UserChangeEvent{ + Client: c, + Type: UserChangeDisconnected, + } + + { + c.volatile.Lock() + + session := *packet.Session + event.User = c.Users[session] + if event.User == nil { + c.volatile.Unlock() + return errInvalidProtobuf + } + if packet.Actor != nil { + event.Actor = c.Users[*packet.Actor] + if event.Actor == nil { + c.volatile.Unlock() + return errInvalidProtobuf + } + event.Type |= UserChangeKicked + } + + event.User.client = nil + if event.User.Channel != nil { + delete(event.User.Channel.Users, session) + } + delete(c.Users, session) + if packet.Reason != nil { + event.String = *packet.Reason + } + if packet.Ban != nil && *packet.Ban { + event.Type |= UserChangeBanned + } + if event.User == c.Self { + if packet.Ban != nil && *packet.Ban { + c.disconnectEvent.Type = DisconnectBanned + } else { + c.disconnectEvent.Type = DisconnectKicked + } + } + + c.volatile.Unlock() + } + + if c.State() == StateSynced { + c.Config.Listeners.onUserChange(&event) + } + return nil +} + +func (c *Client) handleUserState(buffer []byte) error { + var packet MumbleProto.UserState + if err := proto.Unmarshal(buffer, &packet); err != nil { + return err + } + + if packet.Session == nil { + return errIncompleteProtobuf + } + event := UserChangeEvent{ + Client: c, + } + var user, actor *User + { + c.volatile.Lock() + + session := *packet.Session + user = c.Users[session] + if user == nil { + user = c.Users.create(session) + user.Channel = c.Channels[0] + user.client = c + + event.Type |= UserChangeConnected + + if user.Channel == nil { + c.volatile.Unlock() + return errInvalidProtobuf + } + event.Type |= UserChangeChannel + user.Channel.Users[session] = user + } + + event.User = user + if packet.Actor != nil { + actor = c.Users[*packet.Actor] + if actor == nil { + c.volatile.Unlock() + return errInvalidProtobuf + } + event.Actor = actor + } + if packet.Name != nil { + if *packet.Name != user.Name { + event.Type |= UserChangeName + } + user.Name = *packet.Name + } + if packet.UserId != nil { + if *packet.UserId != user.UserID && !event.Type.Has(UserChangeConnected) { + if *packet.UserId != math.MaxUint32 { + event.Type |= UserChangeRegistered + user.UserID = *packet.UserId + } else { + event.Type |= UserChangeUnregistered + user.UserID = 0 + } + } else { + user.UserID = *packet.UserId + } + } + if packet.ChannelId != nil { + if user.Channel != nil { + delete(user.Channel.Users, user.Session) + } + newChannel := c.Channels[*packet.ChannelId] + if newChannel == nil { + c.volatile.Lock() + return errInvalidProtobuf + } + if newChannel != user.Channel { + event.Type |= UserChangeChannel + user.Channel = newChannel + } + user.Channel.Users[user.Session] = user + } + if packet.Mute != nil { + if *packet.Mute != user.Muted { + event.Type |= UserChangeAudio + } + user.Muted = *packet.Mute + } + if packet.Deaf != nil { + if *packet.Deaf != user.Deafened { + event.Type |= UserChangeAudio + } + user.Deafened = *packet.Deaf + } + if packet.Suppress != nil { + if *packet.Suppress != user.Suppressed { + event.Type |= UserChangeAudio + } + user.Suppressed = *packet.Suppress + } + if packet.SelfMute != nil { + if *packet.SelfMute != user.SelfMuted { + event.Type |= UserChangeAudio + } + user.SelfMuted = *packet.SelfMute + } + if packet.SelfDeaf != nil { + if *packet.SelfDeaf != user.SelfDeafened { + event.Type |= UserChangeAudio + } + user.SelfDeafened = *packet.SelfDeaf + } + if packet.Texture != nil { + event.Type |= UserChangeTexture + user.Texture = packet.Texture + user.TextureHash = nil + } + if packet.Comment != nil { + if *packet.Comment != user.Comment { + event.Type |= UserChangeComment + } + user.Comment = *packet.Comment + user.CommentHash = nil + } + if packet.Hash != nil { + user.Hash = *packet.Hash + } + if packet.CommentHash != nil { + event.Type |= UserChangeComment + user.CommentHash = packet.CommentHash + user.Comment = "" + } + if packet.TextureHash != nil { + event.Type |= UserChangeTexture + user.TextureHash = packet.TextureHash + user.Texture = nil + } + if packet.PrioritySpeaker != nil { + if *packet.PrioritySpeaker != user.PrioritySpeaker { + event.Type |= UserChangePrioritySpeaker + } + user.PrioritySpeaker = *packet.PrioritySpeaker + } + if packet.Recording != nil { + if *packet.Recording != user.Recording { + event.Type |= UserChangeRecording + } + user.Recording = *packet.Recording + } + + c.volatile.Unlock() + } + + if c.State() == StateSynced { + c.Config.Listeners.onUserChange(&event) + } + return nil +} + +func (c *Client) handleBanList(buffer []byte) error { + var packet MumbleProto.BanList + if err := proto.Unmarshal(buffer, &packet); err != nil { + return err + } + + event := BanListEvent{ + Client: c, + BanList: make(BanList, 0, len(packet.Bans)), + } + + for _, banPacket := range packet.Bans { + ban := &Ban{ + Address: net.IP(banPacket.Address), + } + if banPacket.Mask != nil { + size := net.IPv4len * 8 + if len(ban.Address) == net.IPv6len { + size = net.IPv6len * 8 + } + ban.Mask = net.CIDRMask(int(*banPacket.Mask), size) + } + if banPacket.Name != nil { + ban.Name = *banPacket.Name + } + if banPacket.Hash != nil { + ban.Hash = *banPacket.Hash + } + if banPacket.Reason != nil { + ban.Reason = *banPacket.Reason + } + if banPacket.Start != nil { + ban.Start, _ = time.Parse(time.RFC3339, *banPacket.Start) + } + if banPacket.Duration != nil { + ban.Duration = time.Duration(*banPacket.Duration) * time.Second + } + event.BanList = append(event.BanList, ban) + } + + c.Config.Listeners.onBanList(&event) + return nil +} + +func (c *Client) handleTextMessage(buffer []byte) error { + var packet MumbleProto.TextMessage + if err := proto.Unmarshal(buffer, &packet); err != nil { + return err + } + + event := TextMessageEvent{ + Client: c, + } + if packet.Actor != nil { + event.Sender = c.Users[*packet.Actor] + } + if packet.Session != nil { + event.Users = make([]*User, 0, len(packet.Session)) + for _, session := range packet.Session { + if user := c.Users[session]; user != nil { + event.Users = append(event.Users, user) + } + } + } + if packet.ChannelId != nil { + event.Channels = make([]*Channel, 0, len(packet.ChannelId)) + for _, id := range packet.ChannelId { + if channel := c.Channels[id]; channel != nil { + event.Channels = append(event.Channels, channel) + } + } + } + if packet.TreeId != nil { + event.Trees = make([]*Channel, 0, len(packet.TreeId)) + for _, id := range packet.TreeId { + if channel := c.Channels[id]; channel != nil { + event.Trees = append(event.Trees, channel) + } + } + } + if packet.Message != nil { + event.Message = *packet.Message + } + + c.Config.Listeners.onTextMessage(&event) + return nil +} + +func (c *Client) handlePermissionDenied(buffer []byte) error { + var packet MumbleProto.PermissionDenied + if err := proto.Unmarshal(buffer, &packet); err != nil { + return err + } + + if packet.Type == nil || *packet.Type == MumbleProto.PermissionDenied_H9K { + return errInvalidProtobuf + } + + event := PermissionDeniedEvent{ + Client: c, + Type: PermissionDeniedType(*packet.Type), + } + if packet.Reason != nil { + event.String = *packet.Reason + } + if packet.Name != nil { + event.String = *packet.Name + } + if packet.Session != nil { + event.User = c.Users[*packet.Session] + if event.User == nil { + return errInvalidProtobuf + } + } + if packet.ChannelId != nil { + event.Channel = c.Channels[*packet.ChannelId] + if event.Channel == nil { + return errInvalidProtobuf + } + } + if packet.Permission != nil { + event.Permission = Permission(*packet.Permission) + } + + c.Config.Listeners.onPermissionDenied(&event) + return nil +} + +func (c *Client) handleACL(buffer []byte) error { + var packet MumbleProto.ACL + if err := proto.Unmarshal(buffer, &packet); err != nil { + return err + } + + acl := &ACL{ + Inherits: packet.GetInheritAcls(), + } + if packet.ChannelId == nil { + return errInvalidProtobuf + } + acl.Channel = c.Channels[*packet.ChannelId] + if acl.Channel == nil { + return errInvalidProtobuf + } + + if packet.Groups != nil { + acl.Groups = make([]*ACLGroup, 0, len(packet.Groups)) + for _, group := range packet.Groups { + aclGroup := &ACLGroup{ + Name: *group.Name, + Inherited: group.GetInherited(), + InheritUsers: group.GetInherit(), + Inheritable: group.GetInheritable(), + } + if group.Add != nil { + aclGroup.UsersAdd = make(map[uint32]*ACLUser) + for _, userID := range group.Add { + aclGroup.UsersAdd[userID] = &ACLUser{ + UserID: userID, + } + } + } + if group.Remove != nil { + aclGroup.UsersRemove = make(map[uint32]*ACLUser) + for _, userID := range group.Remove { + aclGroup.UsersRemove[userID] = &ACLUser{ + UserID: userID, + } + } + } + if group.InheritedMembers != nil { + aclGroup.UsersInherited = make(map[uint32]*ACLUser) + for _, userID := range group.InheritedMembers { + aclGroup.UsersInherited[userID] = &ACLUser{ + UserID: userID, + } + } + } + acl.Groups = append(acl.Groups, aclGroup) + } + } + if packet.Acls != nil { + acl.Rules = make([]*ACLRule, 0, len(packet.Acls)) + for _, rule := range packet.Acls { + aclRule := &ACLRule{ + AppliesCurrent: rule.GetApplyHere(), + AppliesChildren: rule.GetApplySubs(), + Inherited: rule.GetInherited(), + Granted: Permission(rule.GetGrant()), + Denied: Permission(rule.GetDeny()), + } + if rule.UserId != nil { + aclRule.User = &ACLUser{ + UserID: *rule.UserId, + } + } else if rule.Group != nil { + var group *ACLGroup + for _, g := range acl.Groups { + if g.Name == *rule.Group { + group = g + break + } + } + if group == nil { + group = &ACLGroup{ + Name: *rule.Group, + } + } + aclRule.Group = group + } + acl.Rules = append(acl.Rules, aclRule) + } + } + c.tmpACL = acl + return nil +} + +func (c *Client) handleQueryUsers(buffer []byte) error { + var packet MumbleProto.QueryUsers + if err := proto.Unmarshal(buffer, &packet); err != nil { + return err + } + + acl := c.tmpACL + if acl == nil { + return errIncompleteProtobuf + } + c.tmpACL = nil + + userMap := make(map[uint32]string) + for i := 0; i < len(packet.Ids) && i < len(packet.Names); i++ { + userMap[packet.Ids[i]] = packet.Names[i] + } + + for _, group := range acl.Groups { + for _, user := range group.UsersAdd { + user.Name = userMap[user.UserID] + } + for _, user := range group.UsersRemove { + user.Name = userMap[user.UserID] + } + for _, user := range group.UsersInherited { + user.Name = userMap[user.UserID] + } + } + for _, rule := range acl.Rules { + if rule.User != nil { + rule.User.Name = userMap[rule.User.UserID] + } + } + + event := ACLEvent{ + Client: c, + ACL: acl, + } + c.Config.Listeners.onACL(&event) + return nil +} + +func (c *Client) handleCryptSetup(buffer []byte) error { + return errUnimplementedHandler +} + +func (c *Client) handleContextActionModify(buffer []byte) error { + var packet MumbleProto.ContextActionModify + if err := proto.Unmarshal(buffer, &packet); err != nil { + return err + } + + if packet.Action == nil || packet.Operation == nil { + return errInvalidProtobuf + } + + event := ContextActionChangeEvent{ + Client: c, + } + + { + c.volatile.Lock() + + switch *packet.Operation { + case MumbleProto.ContextActionModify_Add: + if ca := c.ContextActions[*packet.Action]; ca != nil { + c.volatile.Unlock() + return nil + } + event.Type = ContextActionAdd + contextAction := c.ContextActions.create(*packet.Action) + if packet.Text != nil { + contextAction.Label = *packet.Text + } + if packet.Context != nil { + contextAction.Type = ContextActionType(*packet.Context) + } + event.ContextAction = contextAction + case MumbleProto.ContextActionModify_Remove: + contextAction := c.ContextActions[*packet.Action] + if contextAction == nil { + c.volatile.Unlock() + return nil + } + event.Type = ContextActionRemove + delete(c.ContextActions, *packet.Action) + event.ContextAction = contextAction + default: + c.volatile.Unlock() + return errInvalidProtobuf + } + + c.volatile.Unlock() + } + + c.Config.Listeners.onContextActionChange(&event) + return nil +} + +func (c *Client) handleContextAction(buffer []byte) error { + return errUnimplementedHandler +} + +func (c *Client) handleUserList(buffer []byte) error { + var packet MumbleProto.UserList + if err := proto.Unmarshal(buffer, &packet); err != nil { + return err + } + + event := UserListEvent{ + Client: c, + UserList: make(RegisteredUsers, 0, len(packet.Users)), + } + + for _, user := range packet.Users { + registeredUser := &RegisteredUser{ + UserID: *user.UserId, + } + if user.Name != nil { + registeredUser.Name = *user.Name + } + if user.LastSeen != nil { + registeredUser.LastSeen, _ = time.ParseInLocation(time.RFC3339, *user.LastSeen, nil) + } + if user.LastChannel != nil { + if lastChannel := c.Channels[*user.LastChannel]; lastChannel != nil { + registeredUser.LastChannel = lastChannel + } + } + event.UserList = append(event.UserList, registeredUser) + } + + c.Config.Listeners.onUserList(&event) + return nil +} + +func (c *Client) handleVoiceTarget(buffer []byte) error { + return errUnimplementedHandler +} + +func (c *Client) handlePermissionQuery(buffer []byte) error { + var packet MumbleProto.PermissionQuery + if err := proto.Unmarshal(buffer, &packet); err != nil { + return err + } + + var singleChannel *Channel + if packet.ChannelId != nil && packet.Permissions != nil { + singleChannel = c.Channels[*packet.ChannelId] + if singleChannel == nil { + return errInvalidProtobuf + } + } + + var changedChannels []*Channel + + { + c.volatile.Lock() + + if packet.GetFlush() { + oldPermissions := c.permissions + c.permissions = make(map[uint32]*Permission) + changedChannels = make([]*Channel, 0, len(oldPermissions)) + for channelID := range oldPermissions { + changedChannels = append(changedChannels, c.Channels[channelID]) + } + } + + if singleChannel != nil { + p := Permission(*packet.Permissions) + c.permissions[singleChannel.ID] = &p + changedChannels = append(changedChannels, singleChannel) + } + + c.volatile.Unlock() + } + + for _, channel := range changedChannels { + event := ChannelChangeEvent{ + Client: c, + Type: ChannelChangePermission, + Channel: channel, + } + c.Config.Listeners.onChannelChange(&event) + } + + return nil +} + +func (c *Client) handleCodecVersion(buffer []byte) error { + var packet MumbleProto.CodecVersion + if err := proto.Unmarshal(buffer, &packet); err != nil { + return err + } + event := ServerConfigEvent{ + Client: c, + } + event.CodecAlpha = packet.Alpha + event.CodecBeta = packet.Beta + { + val := packet.GetPreferAlpha() + event.CodecPreferAlpha = &val + } + { + val := packet.GetOpus() + event.CodecOpus = &val + } + + var codec AudioCodec + switch { + case *event.CodecOpus: + codec = getAudioCodec(audioCodecIDOpus) + } + if codec != nil { + c.audioCodec = codec + + { + c.volatile.Lock() + + c.AudioEncoder = codec.NewEncoder() + + c.volatile.Unlock() + } + } + + c.Config.Listeners.onServerConfig(&event) + return nil +} + +func (c *Client) handleUserStats(buffer []byte) error { + var packet MumbleProto.UserStats + if err := proto.Unmarshal(buffer, &packet); err != nil { + return err + } + + if packet.Session == nil { + return errIncompleteProtobuf + } + user := c.Users[*packet.Session] + if user == nil { + return errInvalidProtobuf + } + + { + c.volatile.Lock() + + if user.Stats == nil { + user.Stats = &UserStats{} + } + *user.Stats = UserStats{ + User: user, + } + stats := user.Stats + + if packet.FromClient != nil { + if packet.FromClient.Good != nil { + stats.FromClient.Good = *packet.FromClient.Good + } + if packet.FromClient.Late != nil { + stats.FromClient.Late = *packet.FromClient.Late + } + if packet.FromClient.Lost != nil { + stats.FromClient.Lost = *packet.FromClient.Lost + } + if packet.FromClient.Resync != nil { + stats.FromClient.Resync = *packet.FromClient.Resync + } + } + if packet.FromServer != nil { + if packet.FromServer.Good != nil { + stats.FromServer.Good = *packet.FromServer.Good + } + if packet.FromClient.Late != nil { + stats.FromServer.Late = *packet.FromServer.Late + } + if packet.FromClient.Lost != nil { + stats.FromServer.Lost = *packet.FromServer.Lost + } + if packet.FromClient.Resync != nil { + stats.FromServer.Resync = *packet.FromServer.Resync + } + } + + if packet.UdpPackets != nil { + stats.UDPPackets = *packet.UdpPackets + } + if packet.UdpPingAvg != nil { + stats.UDPPingAverage = *packet.UdpPingAvg + } + if packet.UdpPingVar != nil { + stats.UDPPingVariance = *packet.UdpPingVar + } + if packet.TcpPackets != nil { + stats.TCPPackets = *packet.TcpPackets + } + if packet.TcpPingAvg != nil { + stats.TCPPingAverage = *packet.TcpPingAvg + } + if packet.TcpPingVar != nil { + stats.TCPPingVariance = *packet.TcpPingVar + } + + if packet.Version != nil { + stats.Version = parseVersion(packet.Version) + } + if packet.Onlinesecs != nil { + stats.Connected = time.Now().Add(time.Duration(*packet.Onlinesecs) * -time.Second) + } + if packet.Idlesecs != nil { + stats.Idle = time.Duration(*packet.Idlesecs) * time.Second + } + if packet.Bandwidth != nil { + stats.Bandwidth = int(*packet.Bandwidth) + } + if packet.Address != nil { + stats.IP = net.IP(packet.Address) + } + if packet.Certificates != nil { + stats.Certificates = make([]*x509.Certificate, 0, len(packet.Certificates)) + for _, data := range packet.Certificates { + if data != nil { + if cert, err := x509.ParseCertificate(data); err == nil { + stats.Certificates = append(stats.Certificates, cert) + } + } + } + } + stats.StrongCertificate = packet.GetStrongCertificate() + stats.CELTVersions = packet.GetCeltVersions() + if packet.Opus != nil { + stats.Opus = *packet.Opus + } + + c.volatile.Unlock() + } + + event := UserChangeEvent{ + Client: c, + Type: UserChangeStats, + User: user, + } + + c.Config.Listeners.onUserChange(&event) + return nil +} + +func (c *Client) handleRequestBlob(buffer []byte) error { + return errUnimplementedHandler +} + +func (c *Client) handleServerConfig(buffer []byte) error { + var packet MumbleProto.ServerConfig + if err := proto.Unmarshal(buffer, &packet); err != nil { + return err + } + event := ServerConfigEvent{ + Client: c, + } + if packet.MaxBandwidth != nil { + val := int(*packet.MaxBandwidth) + event.MaximumBitrate = &val + } + if packet.WelcomeText != nil { + event.WelcomeMessage = packet.WelcomeText + } + if packet.AllowHtml != nil { + event.AllowHTML = packet.AllowHtml + } + if packet.MessageLength != nil { + val := int(*packet.MessageLength) + event.MaximumMessageLength = &val + } + if packet.ImageMessageLength != nil { + val := int(*packet.ImageMessageLength) + event.MaximumImageMessageLength = &val + } + if packet.MaxUsers != nil { + val := int(*packet.MaxUsers) + event.MaximumUsers = &val + } + c.Config.Listeners.onServerConfig(&event) + return nil +} + +func (c *Client) handleSuggestConfig(buffer []byte) error { + var packet MumbleProto.SuggestConfig + if err := proto.Unmarshal(buffer, &packet); err != nil { + return err + } + event := ServerConfigEvent{ + Client: c, + } + if packet.Version != nil { + event.SuggestVersion = &Version{ + Version: packet.GetVersion(), + } + } + if packet.Positional != nil { + event.SuggestPositional = packet.Positional + } + if packet.PushToTalk != nil { + event.SuggestPushToTalk = packet.PushToTalk + } + c.Config.Listeners.onServerConfig(&event) + return nil +} diff --git a/vendor/layeh.com/gumble/gumble/listeners.go b/vendor/layeh.com/gumble/gumble/listeners.go new file mode 100644 index 00000000..3d100c01 --- /dev/null +++ b/vendor/layeh.com/gumble/gumble/listeners.go @@ -0,0 +1,153 @@ +package gumble + +type eventItem struct { + parent *Listeners + prev, next *eventItem + listener EventListener +} + +func (e *eventItem) Detach() { + if e.prev == nil { + e.parent.head = e.next + } else { + e.prev.next = e.next + } + if e.next == nil { + e.parent.tail = e.prev + } else { + e.next.prev = e.prev + } +} + +// Listeners is a list of event listeners. Each attached listener is called in +// sequence when a Client event is triggered. +type Listeners struct { + head, tail *eventItem +} + +// Attach adds a new event listener to the end of the current list of listeners. +func (e *Listeners) Attach(listener EventListener) Detacher { + item := &eventItem{ + parent: e, + prev: e.tail, + listener: listener, + } + if e.head == nil { + e.head = item + } + if e.tail != nil { + e.tail.next = item + } + e.tail = item + return item +} + +func (e *Listeners) onConnect(event *ConnectEvent) { + event.Client.volatile.Lock() + for item := e.head; item != nil; item = item.next { + event.Client.volatile.Unlock() + item.listener.OnConnect(event) + event.Client.volatile.Lock() + } + event.Client.volatile.Unlock() +} + +func (e *Listeners) onDisconnect(event *DisconnectEvent) { + event.Client.volatile.Lock() + for item := e.head; item != nil; item = item.next { + event.Client.volatile.Unlock() + item.listener.OnDisconnect(event) + event.Client.volatile.Lock() + } + event.Client.volatile.Unlock() +} + +func (e *Listeners) onTextMessage(event *TextMessageEvent) { + event.Client.volatile.Lock() + for item := e.head; item != nil; item = item.next { + event.Client.volatile.Unlock() + item.listener.OnTextMessage(event) + event.Client.volatile.Lock() + } + event.Client.volatile.Unlock() +} + +func (e *Listeners) onUserChange(event *UserChangeEvent) { + event.Client.volatile.Lock() + for item := e.head; item != nil; item = item.next { + event.Client.volatile.Unlock() + item.listener.OnUserChange(event) + event.Client.volatile.Lock() + } + event.Client.volatile.Unlock() +} + +func (e *Listeners) onChannelChange(event *ChannelChangeEvent) { + event.Client.volatile.Lock() + for item := e.head; item != nil; item = item.next { + event.Client.volatile.Unlock() + item.listener.OnChannelChange(event) + event.Client.volatile.Lock() + } + event.Client.volatile.Unlock() +} + +func (e *Listeners) onPermissionDenied(event *PermissionDeniedEvent) { + event.Client.volatile.Lock() + for item := e.head; item != nil; item = item.next { + event.Client.volatile.Unlock() + item.listener.OnPermissionDenied(event) + event.Client.volatile.Lock() + } + event.Client.volatile.Unlock() +} + +func (e *Listeners) onUserList(event *UserListEvent) { + event.Client.volatile.Lock() + for item := e.head; item != nil; item = item.next { + event.Client.volatile.Unlock() + item.listener.OnUserList(event) + event.Client.volatile.Lock() + } + event.Client.volatile.Unlock() +} + +func (e *Listeners) onACL(event *ACLEvent) { + event.Client.volatile.Lock() + for item := e.head; item != nil; item = item.next { + event.Client.volatile.Unlock() + item.listener.OnACL(event) + event.Client.volatile.Lock() + } + event.Client.volatile.Unlock() +} + +func (e *Listeners) onBanList(event *BanListEvent) { + event.Client.volatile.Lock() + for item := e.head; item != nil; item = item.next { + event.Client.volatile.Unlock() + item.listener.OnBanList(event) + event.Client.volatile.Lock() + } + event.Client.volatile.Unlock() +} + +func (e *Listeners) onContextActionChange(event *ContextActionChangeEvent) { + event.Client.volatile.Lock() + for item := e.head; item != nil; item = item.next { + event.Client.volatile.Unlock() + item.listener.OnContextActionChange(event) + event.Client.volatile.Lock() + } + event.Client.volatile.Unlock() +} + +func (e *Listeners) onServerConfig(event *ServerConfigEvent) { + event.Client.volatile.Lock() + for item := e.head; item != nil; item = item.next { + event.Client.volatile.Unlock() + item.listener.OnServerConfig(event) + event.Client.volatile.Lock() + } + event.Client.volatile.Unlock() +} diff --git a/vendor/layeh.com/gumble/gumble/message.go b/vendor/layeh.com/gumble/gumble/message.go new file mode 100644 index 00000000..a2309661 --- /dev/null +++ b/vendor/layeh.com/gumble/gumble/message.go @@ -0,0 +1,13 @@ +package gumble + +// Message is data that be encoded and sent to the server. The following +// types implement this interface: +// AccessTokens +// ACL +// BanList +// RegisteredUsers +// TextMessage +// VoiceTarget +type Message interface { + writeMessage(client *Client) error +} diff --git a/vendor/layeh.com/gumble/gumble/permission.go b/vendor/layeh.com/gumble/gumble/permission.go new file mode 100644 index 00000000..b467a641 --- /dev/null +++ b/vendor/layeh.com/gumble/gumble/permission.go @@ -0,0 +1,33 @@ +package gumble + +// Permission is a bitmask of permissions given to a certain user. +type Permission int + +// Permissions that can be applied in any channel. +const ( + PermissionWrite Permission = 1 << iota + PermissionTraverse + PermissionEnter + PermissionSpeak + PermissionMuteDeafen + PermissionMove + PermissionMakeChannel + PermissionLinkChannel + PermissionWhisper + PermissionTextMessage + PermissionMakeTemporaryChannel +) + +// Permissions that can only be applied in the root channel. +const ( + PermissionKick Permission = 0x10000 << iota + PermissionBan + PermissionRegister + PermissionRegisterSelf +) + +// Has returns true if the Permission p contains Permission o has part of its +// bitmask. +func (p Permission) Has(o Permission) bool { + return p&o == o +} diff --git a/vendor/layeh.com/gumble/gumble/ping.go b/vendor/layeh.com/gumble/gumble/ping.go new file mode 100644 index 00000000..ad9c804e --- /dev/null +++ b/vendor/layeh.com/gumble/gumble/ping.go @@ -0,0 +1,108 @@ +package gumble + +import ( + "crypto/rand" + "encoding/binary" + "errors" + "io" + "net" + "sync" + "time" +) + +// PingResponse contains information about a server that responded to a UDP +// ping packet. +type PingResponse struct { + // The address of the pinged server. + Address *net.UDPAddr + // The round-trip time from the client to the server. + Ping time.Duration + // The server's version. Only the Version field and SemanticVersion method of + // the value will be valid. + Version Version + // The number users currently connected to the server. + ConnectedUsers int + // The maximum number of users that can connect to the server. + MaximumUsers int + // The maximum audio bitrate per user for the server. + MaximumBitrate int +} + +// Ping sends a UDP ping packet to the given server. If interval is positive, +// the packet is retransmitted at every interval. +// +// Returns a PingResponse and nil on success. The function will return nil and +// an error if a valid response is not received after the given timeout. +func Ping(address string, interval, timeout time.Duration) (*PingResponse, error) { + if timeout < 0 { + return nil, errors.New("gumble: timeout must be positive") + } + deadline := time.Now().Add(timeout) + conn, err := net.DialTimeout("udp", address, timeout) + if err != nil { + return nil, err + } + defer conn.Close() + conn.SetReadDeadline(deadline) + + var ( + idsLock sync.Mutex + ids = make(map[string]time.Time) + ) + + buildSendPacket := func() { + var packet [12]byte + if _, err := rand.Read(packet[4:]); err != nil { + return + } + id := string(packet[4:]) + idsLock.Lock() + ids[id] = time.Now() + idsLock.Unlock() + conn.Write(packet[:]) + } + + if interval > 0 { + end := make(chan struct{}) + defer close(end) + go func() { + ticker := time.NewTicker(interval) + defer ticker.Stop() + for { + select { + case <-ticker.C: + buildSendPacket() + case <-end: + return + } + } + }() + } + + buildSendPacket() + + for { + var incoming [24]byte + if _, err := io.ReadFull(conn, incoming[:]); err != nil { + return nil, err + } + id := string(incoming[4:12]) + idsLock.Lock() + sendTime, ok := ids[id] + idsLock.Unlock() + if !ok { + continue + } + + return &PingResponse{ + Address: conn.RemoteAddr().(*net.UDPAddr), + Ping: time.Since(sendTime), + Version: Version{ + Version: binary.BigEndian.Uint32(incoming[0:]), + }, + ConnectedUsers: int(binary.BigEndian.Uint32(incoming[12:])), + MaximumUsers: int(binary.BigEndian.Uint32(incoming[16:])), + MaximumBitrate: int(binary.BigEndian.Uint32(incoming[20:])), + }, nil + } +} diff --git a/vendor/layeh.com/gumble/gumble/reject.go b/vendor/layeh.com/gumble/gumble/reject.go new file mode 100644 index 00000000..f110982e --- /dev/null +++ b/vendor/layeh.com/gumble/gumble/reject.go @@ -0,0 +1,61 @@ +package gumble + +import ( + "strconv" + + "layeh.com/gumble/gumble/MumbleProto" +) + +// RejectType describes why a client connection was rejected by the server. +type RejectType int + +// The possible reason why a client connection was rejected by the server. +const ( + RejectNone RejectType = RejectType(MumbleProto.Reject_None) + RejectVersion RejectType = RejectType(MumbleProto.Reject_WrongVersion) + RejectUserName RejectType = RejectType(MumbleProto.Reject_InvalidUsername) + RejectUserCredentials RejectType = RejectType(MumbleProto.Reject_WrongUserPW) + RejectServerPassword RejectType = RejectType(MumbleProto.Reject_WrongServerPW) + RejectUsernameInUse RejectType = RejectType(MumbleProto.Reject_UsernameInUse) + RejectServerFull RejectType = RejectType(MumbleProto.Reject_ServerFull) + RejectNoCertificate RejectType = RejectType(MumbleProto.Reject_NoCertificate) + RejectAuthenticatorFail RejectType = RejectType(MumbleProto.Reject_AuthenticatorFail) +) + +// RejectError is returned by DialWithDialer when the server rejects the client +// connection. +type RejectError struct { + Type RejectType + Reason string +} + +// Error implements error. +func (e RejectError) Error() string { + var msg string + switch e.Type { + case RejectNone: + msg = "none" + case RejectVersion: + msg = "wrong client version" + case RejectUserName: + msg = "invalid username" + case RejectUserCredentials: + msg = "incorrect user credentials" + case RejectServerPassword: + msg = "incorrect server password" + case RejectUsernameInUse: + msg = "username in use" + case RejectServerFull: + msg = "server full" + case RejectNoCertificate: + msg = "no certificate" + case RejectAuthenticatorFail: + msg = "authenticator fail" + default: + msg = "unknown type " + strconv.Itoa(int(e.Type)) + } + if e.Reason != "" { + msg += ": " + e.Reason + } + return msg +} diff --git a/vendor/layeh.com/gumble/gumble/rpwmutex.go b/vendor/layeh.com/gumble/gumble/rpwmutex.go new file mode 100644 index 00000000..ca881a62 --- /dev/null +++ b/vendor/layeh.com/gumble/gumble/rpwmutex.go @@ -0,0 +1,36 @@ +package gumble + +import "sync" + +// rpwMutex is a reader-preferred RWMutex. +type rpwMutex struct { + w sync.Mutex + r sync.Mutex + n int +} + +func (m *rpwMutex) Lock() { + m.w.Lock() +} + +func (m *rpwMutex) Unlock() { + m.w.Unlock() +} + +func (m *rpwMutex) RLock() { + m.r.Lock() + m.n++ + if m.n == 1 { + m.w.Lock() + } + m.r.Unlock() +} + +func (m *rpwMutex) RUnlock() { + m.r.Lock() + m.n-- + if m.n == 0 { + m.w.Unlock() + } + m.r.Unlock() +} diff --git a/vendor/layeh.com/gumble/gumble/textmessage.go b/vendor/layeh.com/gumble/gumble/textmessage.go new file mode 100644 index 00000000..0f69cbd5 --- /dev/null +++ b/vendor/layeh.com/gumble/gumble/textmessage.go @@ -0,0 +1,45 @@ +package gumble + +import ( + "layeh.com/gumble/gumble/MumbleProto" +) + +// TextMessage is a chat message that can be received from and sent to the +// server. +type TextMessage struct { + // User who sent the message (can be nil). + Sender *User + // Users that receive the message. + Users []*User + // Channels that receive the message. + Channels []*Channel + // Channels that receive the message and send it recursively to sub-channels. + Trees []*Channel + // Chat message. + Message string +} + +func (t *TextMessage) writeMessage(client *Client) error { + packet := MumbleProto.TextMessage{ + Message: &t.Message, + } + if t.Users != nil { + packet.Session = make([]uint32, len(t.Users)) + for i, user := range t.Users { + packet.Session[i] = user.Session + } + } + if t.Channels != nil { + packet.ChannelId = make([]uint32, len(t.Channels)) + for i, channel := range t.Channels { + packet.ChannelId[i] = channel.ID + } + } + if t.Trees != nil { + packet.TreeId = make([]uint32, len(t.Trees)) + for i, channel := range t.Trees { + packet.TreeId[i] = channel.ID + } + } + return client.Conn.WriteProto(&packet) +} diff --git a/vendor/layeh.com/gumble/gumble/user.go b/vendor/layeh.com/gumble/gumble/user.go new file mode 100644 index 00000000..6274d443 --- /dev/null +++ b/vendor/layeh.com/gumble/gumble/user.go @@ -0,0 +1,233 @@ +package gumble + +import ( + "github.com/golang/protobuf/proto" + "layeh.com/gumble/gumble/MumbleProto" +) + +// User represents a user that is currently connected to the server. +type User struct { + // The user's unique session ID. + Session uint32 + // The user's ID. Contains an invalid value if the user is not registered. + UserID uint32 + // The user's name. + Name string + // The channel that the user is currently in. + Channel *Channel + + // Has the user has been muted? + Muted bool + // Has the user been deafened? + Deafened bool + // Has the user been suppressed? + Suppressed bool + // Has the user been muted by him/herself? + SelfMuted bool + // Has the user been deafened by him/herself? + SelfDeafened bool + // Is the user a priority speaker in the channel? + PrioritySpeaker bool + // Is the user recording audio? + Recording bool + + // The user's comment. Contains the empty string if the user does not have a + // comment, or if the comment needs to be requested. + Comment string + // The user's comment hash. nil if User.Comment has been populated. + CommentHash []byte + // The hash of the user's certificate (can be empty). + Hash string + // The user's texture (avatar). nil if the user does not have a + // texture, or if the texture needs to be requested. + Texture []byte + // The user's texture hash. nil if User.Texture has been populated. + TextureHash []byte + + // The user's stats. Contains nil if the stats have not yet been requested. + Stats *UserStats + + client *Client + decoder AudioDecoder +} + +// SetTexture sets the user's texture. +func (u *User) SetTexture(texture []byte) { + packet := MumbleProto.UserState{ + Session: &u.Session, + Texture: texture, + } + u.client.Conn.WriteProto(&packet) +} + +// SetPrioritySpeaker sets if the user is a priority speaker in the channel. +func (u *User) SetPrioritySpeaker(prioritySpeaker bool) { + packet := MumbleProto.UserState{ + Session: &u.Session, + PrioritySpeaker: &prioritySpeaker, + } + u.client.Conn.WriteProto(&packet) +} + +// SetRecording sets if the user is recording audio. +func (u *User) SetRecording(recording bool) { + packet := MumbleProto.UserState{ + Session: &u.Session, + Recording: &recording, + } + u.client.Conn.WriteProto(&packet) +} + +// IsRegistered returns true if the user's certificate has been registered with +// the server. A registered user will have a valid user ID. +func (u *User) IsRegistered() bool { + return u.UserID > 0 +} + +// Register will register the user with the server. If the client has +// permission to do so, the user will shortly be given a UserID. +func (u *User) Register() { + packet := MumbleProto.UserState{ + Session: &u.Session, + UserId: proto.Uint32(0), + } + u.client.Conn.WriteProto(&packet) +} + +// SetComment will set the user's comment to the given string. The user's +// comment will be erased if the comment is set to the empty string. +func (u *User) SetComment(comment string) { + packet := MumbleProto.UserState{ + Session: &u.Session, + Comment: &comment, + } + u.client.Conn.WriteProto(&packet) +} + +// Move will move the user to the given channel. +func (u *User) Move(channel *Channel) { + packet := MumbleProto.UserState{ + Session: &u.Session, + ChannelId: &channel.ID, + } + u.client.Conn.WriteProto(&packet) +} + +// Kick will kick the user from the server. +func (u *User) Kick(reason string) { + packet := MumbleProto.UserRemove{ + Session: &u.Session, + Reason: &reason, + } + u.client.Conn.WriteProto(&packet) +} + +// Ban will ban the user from the server. +func (u *User) Ban(reason string) { + packet := MumbleProto.UserRemove{ + Session: &u.Session, + Reason: &reason, + Ban: proto.Bool(true), + } + u.client.Conn.WriteProto(&packet) +} + +// SetMuted sets whether the user can transmit audio or not. +func (u *User) SetMuted(muted bool) { + packet := MumbleProto.UserState{ + Session: &u.Session, + Mute: &muted, + } + u.client.Conn.WriteProto(&packet) +} + +// SetSuppressed sets whether the user is suppressed by the server or not. +func (u *User) SetSuppressed(supressed bool) { + packet := MumbleProto.UserState{ + Session: &u.Session, + Suppress: &supressed, + } + u.client.Conn.WriteProto(&packet) +} + +// SetDeafened sets whether the user can receive audio or not. +func (u *User) SetDeafened(muted bool) { + packet := MumbleProto.UserState{ + Session: &u.Session, + Deaf: &muted, + } + u.client.Conn.WriteProto(&packet) +} + +// SetSelfMuted sets whether the user can transmit audio or not. +// +// This method should only be called on Client.Self(). +func (u *User) SetSelfMuted(muted bool) { + packet := MumbleProto.UserState{ + Session: &u.Session, + SelfMute: &muted, + } + u.client.Conn.WriteProto(&packet) +} + +// SetSelfDeafened sets whether the user can receive audio or not. +// +// This method should only be called on Client.Self(). +func (u *User) SetSelfDeafened(muted bool) { + packet := MumbleProto.UserState{ + Session: &u.Session, + SelfDeaf: &muted, + } + u.client.Conn.WriteProto(&packet) +} + +// RequestStats requests that the user's stats be sent to the client. +func (u *User) RequestStats() { + packet := MumbleProto.UserStats{ + Session: &u.Session, + } + u.client.Conn.WriteProto(&packet) +} + +// RequestTexture requests that the user's actual texture (i.e. non-hashed) be +// sent to the client. +func (u *User) RequestTexture() { + packet := MumbleProto.RequestBlob{ + SessionTexture: []uint32{u.Session}, + } + u.client.Conn.WriteProto(&packet) +} + +// RequestComment requests that the user's actual comment (i.e. non-hashed) be +// sent to the client. +func (u *User) RequestComment() { + packet := MumbleProto.RequestBlob{ + SessionComment: []uint32{u.Session}, + } + u.client.Conn.WriteProto(&packet) +} + +// Send will send a text message to the user. +func (u *User) Send(message string) { + textMessage := TextMessage{ + Users: []*User{u}, + Message: message, + } + u.client.Send(&textMessage) +} + +// SetPlugin sets the user's plugin data. +// +// Plugins are currently only used for positional audio. Clients will receive +// positional audio information from other users if their plugin context is the +// same. The official Mumble client sets the context to: +// +// PluginShortName + "\x00" + AdditionalContextInformation +func (u *User) SetPlugin(context []byte, identity string) { + packet := MumbleProto.UserState{ + Session: &u.Session, + PluginContext: context, + PluginIdentity: &identity, + } + u.client.Conn.WriteProto(&packet) +} diff --git a/vendor/layeh.com/gumble/gumble/userlist.go b/vendor/layeh.com/gumble/gumble/userlist.go new file mode 100644 index 00000000..1837abda --- /dev/null +++ b/vendor/layeh.com/gumble/gumble/userlist.go @@ -0,0 +1,74 @@ +package gumble + +import ( + "time" + + "layeh.com/gumble/gumble/MumbleProto" +) + +// RegisteredUser represents a registered user on the server. +type RegisteredUser struct { + // The registered user's ID. + UserID uint32 + // The registered user's name. + Name string + // The last time the user was seen by the server. + LastSeen time.Time + // The last channel the user was seen in. + LastChannel *Channel + + changed bool + deregister bool +} + +// SetName sets the new name for the user. +func (r *RegisteredUser) SetName(name string) { + r.Name = name + r.changed = true +} + +// Deregister will remove the registered user from the server. +func (r *RegisteredUser) Deregister() { + r.deregister = true +} + +// Register will keep the user registered on the server. This is only useful if +// Deregister() was called on the registered user. +func (r *RegisteredUser) Register() { + r.deregister = false +} + +// ACLUser returns an ACLUser for the given registered user. +func (r *RegisteredUser) ACLUser() *ACLUser { + return &ACLUser{ + UserID: r.UserID, + Name: r.Name, + } +} + +// RegisteredUsers is a list of users who are registered on the server. +// +// Whenever a registered user is changed, it does not come into effect until +// the registered user list is sent back to the server. +type RegisteredUsers []*RegisteredUser + +func (r RegisteredUsers) writeMessage(client *Client) error { + packet := MumbleProto.UserList{} + + for _, user := range r { + if user.deregister || user.changed { + userListUser := &MumbleProto.UserList_User{ + UserId: &user.UserID, + } + if !user.deregister { + userListUser.Name = &user.Name + } + packet.Users = append(packet.Users, userListUser) + } + } + + if len(packet.Users) <= 0 { + return nil + } + return client.Conn.WriteProto(&packet) +} diff --git a/vendor/layeh.com/gumble/gumble/users.go b/vendor/layeh.com/gumble/gumble/users.go new file mode 100644 index 00000000..c2725915 --- /dev/null +++ b/vendor/layeh.com/gumble/gumble/users.go @@ -0,0 +1,30 @@ +package gumble + +// Users is a map of server users. +// +// When accessed through client.Users, it contains all users currently on the +// server. When accessed through a specific channel +// (e.g. client.Channels[0].Users), it contains only the users in the +// channel. +type Users map[uint32]*User + +// create adds a new user with the given session to the collection. If a user +// with the given session already exists, it is overwritten. +func (u Users) create(session uint32) *User { + user := &User{ + Session: session, + } + u[session] = user + return user +} + +// Find returns the user with the given name. nil is returned if no user exists +// with the given name. +func (u Users) Find(name string) *User { + for _, user := range u { + if user.Name == name { + return user + } + } + return nil +} diff --git a/vendor/layeh.com/gumble/gumble/userstats.go b/vendor/layeh.com/gumble/gumble/userstats.go new file mode 100644 index 00000000..15f04518 --- /dev/null +++ b/vendor/layeh.com/gumble/gumble/userstats.go @@ -0,0 +1,62 @@ +package gumble + +import ( + "crypto/x509" + "net" + "time" +) + +// UserStats contains additional information about a user. +type UserStats struct { + // The owner of the stats. + User *User + + // Stats about UDP packets sent from the client. + FromClient UserStatsUDP + // Stats about UDP packets sent by the server. + FromServer UserStatsUDP + + // Number of UDP packets sent by the user. + UDPPackets uint32 + // Average UDP ping. + UDPPingAverage float32 + // UDP ping variance. + UDPPingVariance float32 + + // Number of TCP packets sent by the user. + TCPPackets uint32 + // Average TCP ping. + TCPPingAverage float32 + // TCP ping variance. + TCPPingVariance float32 + + // The user's version. + Version Version + // When the user connected to the server. + Connected time.Time + // How long the user has been idle. + Idle time.Duration + // How much bandwidth the user is current using. + Bandwidth int + // The user's certificate chain. + Certificates []*x509.Certificate + // Does the user have a strong certificate? A strong certificate is one that + // is not self signed, nor expired, etc. + StrongCertificate bool + // A list of CELT versions supported by the user's client. + CELTVersions []int32 + // Does the user's client supports the Opus audio codec? + Opus bool + + // The user's IP address. + IP net.IP +} + +// UserStatsUDP contains stats about UDP packets that have been sent to or from +// the server. +type UserStatsUDP struct { + Good uint32 + Late uint32 + Lost uint32 + Resync uint32 +} diff --git a/vendor/layeh.com/gumble/gumble/varint/read.go b/vendor/layeh.com/gumble/gumble/varint/read.go new file mode 100644 index 00000000..6b5820d3 --- /dev/null +++ b/vendor/layeh.com/gumble/gumble/varint/read.go @@ -0,0 +1,52 @@ +package varint + +import ( + "encoding/binary" +) + +// Decode reads the first varint encoded number from the given buffer. +// +// On success, the function returns the varint as an int64, and the number of +// bytes read (0 if there was an error). +func Decode(b []byte) (int64, int) { + if len(b) == 0 { + return 0, 0 + } + // 0xxxxxxx 7-bit positive number + if (b[0] & 0x80) == 0 { + return int64(b[0]), 1 + } + // 10xxxxxx + 1 byte 14-bit positive number + if (b[0]&0xC0) == 0x80 && len(b) >= 2 { + return int64(b[0]&0x3F)<<8 | int64(b[1]), 2 + } + // 110xxxxx + 2 bytes 21-bit positive number + if (b[0]&0xE0) == 0xC0 && len(b) >= 3 { + return int64(b[0]&0x1F)<<16 | int64(b[1])<<8 | int64(b[2]), 3 + } + // 1110xxxx + 3 bytes 28-bit positive number + if (b[0]&0xF0) == 0xE0 && len(b) >= 4 { + return int64(b[0]&0xF)<<24 | int64(b[1])<<16 | int64(b[2])<<8 | int64(b[3]), 4 + } + // 111100__ + int (32-bit) 32-bit positive number + if (b[0]&0xFC) == 0xF0 && len(b) >= 5 { + return int64(binary.BigEndian.Uint32(b[1:])), 5 + } + // 111101__ + long (64-bit) 64-bit number + if (b[0]&0xFC) == 0xF4 && len(b) >= 9 { + return int64(binary.BigEndian.Uint64(b[1:])), 9 + } + // 111110__ + varint Negative recursive varint + if b[0]&0xFC == 0xF8 { + if v, n := Decode(b[1:]); n > 0 { + return -v, n + 1 + } + return 0, 0 + } + // 111111xx Byte-inverted negative two bit number (~xx) + if b[0]&0xFC == 0xFC { + return ^int64(b[0] & 0x03), 1 + } + + return 0, 0 +} diff --git a/vendor/layeh.com/gumble/gumble/varint/write.go b/vendor/layeh.com/gumble/gumble/varint/write.go new file mode 100644 index 00000000..29d931bc --- /dev/null +++ b/vendor/layeh.com/gumble/gumble/varint/write.go @@ -0,0 +1,64 @@ +package varint + +import ( + "encoding/binary" + "math" +) + +// MaxVarintLen is the maximum number of bytes required to encode a varint +// number. +const MaxVarintLen = 10 + +// Encode encodes the given value to varint format. +func Encode(b []byte, value int64) int { + // 111111xx Byte-inverted negative two bit number (~xx) + if value <= -1 && value >= -4 { + b[0] = 0xFC | byte(^value&0xFF) + return 1 + } + // 111110__ + varint Negative recursive varint + if value < 0 { + b[0] = 0xF8 + return 1 + Encode(b[1:], -value) + } + // 0xxxxxxx 7-bit positive number + if value <= 0x7F { + b[0] = byte(value) + return 1 + } + // 10xxxxxx + 1 byte 14-bit positive number + if value <= 0x3FFF { + b[0] = byte(((value >> 8) & 0x3F) | 0x80) + b[1] = byte(value & 0xFF) + return 2 + } + // 110xxxxx + 2 bytes 21-bit positive number + if value <= 0x1FFFFF { + b[0] = byte((value>>16)&0x1F | 0xC0) + b[1] = byte((value >> 8) & 0xFF) + b[2] = byte(value & 0xFF) + return 3 + } + // 1110xxxx + 3 bytes 28-bit positive number + if value <= 0xFFFFFFF { + b[0] = byte((value>>24)&0xF | 0xE0) + b[1] = byte((value >> 16) & 0xFF) + b[2] = byte((value >> 8) & 0xFF) + b[3] = byte(value & 0xFF) + return 4 + } + // 111100__ + int (32-bit) 32-bit positive number + if value <= math.MaxInt32 { + b[0] = 0xF0 + binary.BigEndian.PutUint32(b[1:], uint32(value)) + return 5 + } + // 111101__ + long (64-bit) 64-bit number + if value <= math.MaxInt64 { + b[0] = 0xF4 + binary.BigEndian.PutUint64(b[1:], uint64(value)) + return 9 + } + + return 0 +} diff --git a/vendor/layeh.com/gumble/gumble/version.go b/vendor/layeh.com/gumble/gumble/version.go new file mode 100644 index 00000000..5203b9d2 --- /dev/null +++ b/vendor/layeh.com/gumble/gumble/version.go @@ -0,0 +1,24 @@ +package gumble + +// Version represents a Mumble client or server version. +type Version struct { + // The semantic version information as a single unsigned integer. + // + // Bits 0-15 are the major version, bits 16-23 are the minor version, and + // bits 24-31 are the patch version. + Version uint32 + // The name of the client. + Release string + // The operating system name. + OS string + // The operating system version. + OSVersion string +} + +// SemanticVersion returns the version's semantic version components. +func (v *Version) SemanticVersion() (major uint16, minor, patch uint8) { + major = uint16(v.Version>>16) & 0xFFFF + minor = uint8(v.Version>>8) & 0xFF + patch = uint8(v.Version) & 0xFF + return +} diff --git a/vendor/layeh.com/gumble/gumble/voicetarget.go b/vendor/layeh.com/gumble/gumble/voicetarget.go new file mode 100644 index 00000000..914dcfb5 --- /dev/null +++ b/vendor/layeh.com/gumble/gumble/voicetarget.go @@ -0,0 +1,76 @@ +package gumble + +import ( + "layeh.com/gumble/gumble/MumbleProto" +) + +// VoiceTargetLoopback is a special voice target which causes any audio sent to +// the server to be returned to the client. +// +// Its ID should not be modified, and it does not have to to be sent to the +// server before use. +var VoiceTargetLoopback *VoiceTarget = &VoiceTarget{ + ID: 31, +} + +type voiceTargetChannel struct { + channel *Channel + links, recursive bool + group string +} + +// VoiceTarget represents a set of users and/or channels that the client can +// whisper to. +type VoiceTarget struct { + // The voice target ID. This value must be in the range [1, 30]. + ID uint32 + users []*User + channels []*voiceTargetChannel +} + +// Clear removes all users and channels from the voice target. +func (v *VoiceTarget) Clear() { + v.users = nil + v.channels = nil +} + +// AddUser adds a user to the voice target. +func (v *VoiceTarget) AddUser(user *User) { + v.users = append(v.users, user) +} + +// AddChannel adds a user to the voice target. If group is non-empty, only +// users belonging to that ACL group will be targeted. +func (v *VoiceTarget) AddChannel(channel *Channel, recursive, links bool, group string) { + v.channels = append(v.channels, &voiceTargetChannel{ + channel: channel, + links: links, + recursive: recursive, + group: group, + }) +} + +func (v *VoiceTarget) writeMessage(client *Client) error { + packet := MumbleProto.VoiceTarget{ + Id: &v.ID, + Targets: make([]*MumbleProto.VoiceTarget_Target, 0, len(v.users)+len(v.channels)), + } + for _, user := range v.users { + packet.Targets = append(packet.Targets, &MumbleProto.VoiceTarget_Target{ + Session: []uint32{user.Session}, + }) + } + for _, vtChannel := range v.channels { + target := &MumbleProto.VoiceTarget_Target{ + ChannelId: &vtChannel.channel.ID, + Links: &vtChannel.links, + Children: &vtChannel.recursive, + } + if vtChannel.group != "" { + target.Group = &vtChannel.group + } + packet.Targets = append(packet.Targets, target) + } + + return client.Conn.WriteProto(&packet) +} diff --git a/vendor/layeh.com/gumble/gumbleutil/acl.go b/vendor/layeh.com/gumble/gumbleutil/acl.go new file mode 100644 index 00000000..67cd86d5 --- /dev/null +++ b/vendor/layeh.com/gumble/gumbleutil/acl.go @@ -0,0 +1,55 @@ +package gumbleutil + +import ( + "layeh.com/gumble/gumble" +) + +// UserGroups fetches the group names the given user belongs to in the given +// channel. The slice of group names sent via the returned channel. On error, +// the returned channel is closed without without sending a slice. +func UserGroups(client *gumble.Client, user *gumble.User, channel *gumble.Channel) <-chan []string { + ch := make(chan []string) + + if !user.IsRegistered() { + close(ch) + return ch + } + + var detacher gumble.Detacher + listener := Listener{ + Disconnect: func(e *gumble.DisconnectEvent) { + detacher.Detach() + close(ch) + }, + ChannelChange: func(e *gumble.ChannelChangeEvent) { + if e.Channel == channel && e.Type.Has(gumble.ChannelChangeRemoved) { + detacher.Detach() + close(ch) + } + }, + PermissionDenied: func(e *gumble.PermissionDeniedEvent) { + if e.Channel == channel && e.Type == gumble.PermissionDeniedPermission && (e.Permission&gumble.PermissionWrite) != 0 { + detacher.Detach() + close(ch) + } + }, + ACL: func(e *gumble.ACLEvent) { + if e.ACL.Channel != channel { + return + } + var names []string + for _, g := range e.ACL.Groups { + if (g.UsersAdd[user.UserID] != nil || g.UsersInherited[user.UserID] != nil) && g.UsersRemove[user.UserID] == nil { + names = append(names, g.Name) + } + } + detacher.Detach() + ch <- names + close(ch) + }, + } + detacher = client.Config.Attach(&listener) + channel.RequestACL() + + return ch +} diff --git a/vendor/layeh.com/gumble/gumbleutil/bitrate.go b/vendor/layeh.com/gumble/gumbleutil/bitrate.go new file mode 100644 index 00000000..6b93caa9 --- /dev/null +++ b/vendor/layeh.com/gumble/gumbleutil/bitrate.go @@ -0,0 +1,27 @@ +package gumbleutil + +import ( + "time" + + "layeh.com/gumble/gumble" +) + +var autoBitrate = &Listener{ + Connect: func(e *gumble.ConnectEvent) { + if e.MaximumBitrate != nil { + const safety = 5 + interval := e.Client.Config.AudioInterval + dataBytes := (*e.MaximumBitrate / (8 * (int(time.Second/interval) + safety))) - 32 - 10 + + e.Client.Config.AudioDataBytes = dataBytes + } + }, +} + +// AutoBitrate is a gumble.EventListener that automatically sets the client's +// AudioDataBytes to suitable value, based on the server's bitrate. +var AutoBitrate gumble.EventListener + +func init() { + AutoBitrate = autoBitrate +} diff --git a/vendor/layeh.com/gumble/gumbleutil/channel.go b/vendor/layeh.com/gumble/gumbleutil/channel.go new file mode 100644 index 00000000..ecf8bbef --- /dev/null +++ b/vendor/layeh.com/gumble/gumbleutil/channel.go @@ -0,0 +1,18 @@ +package gumbleutil + +import ( + "layeh.com/gumble/gumble" +) + +// ChannelPath returns a slice of channel names, starting from the root channel +// to the given channel. +func ChannelPath(channel *gumble.Channel) []string { + var pieces []string + for ; channel != nil; channel = channel.Parent { + pieces = append(pieces, channel.Name) + } + for i := 0; i < (len(pieces) / 2); i++ { + pieces[len(pieces)-1-i], pieces[i] = pieces[i], pieces[len(pieces)-1-i] + } + return pieces +} diff --git a/vendor/layeh.com/gumble/gumbleutil/doc.go b/vendor/layeh.com/gumble/gumbleutil/doc.go new file mode 100644 index 00000000..864a3b89 --- /dev/null +++ b/vendor/layeh.com/gumble/gumbleutil/doc.go @@ -0,0 +1,2 @@ +// Package gumbleutil provides extras that can make working with gumble easier. +package gumbleutil diff --git a/vendor/layeh.com/gumble/gumbleutil/listener.go b/vendor/layeh.com/gumble/gumbleutil/listener.go new file mode 100644 index 00000000..5bc3167d --- /dev/null +++ b/vendor/layeh.com/gumble/gumbleutil/listener.go @@ -0,0 +1,100 @@ +package gumbleutil + +import ( + "layeh.com/gumble/gumble" +) + +// Listener is a struct that implements the gumble.EventListener interface. The +// corresponding event function in the struct is called if it is non-nil. +type Listener struct { + Connect func(e *gumble.ConnectEvent) + Disconnect func(e *gumble.DisconnectEvent) + TextMessage func(e *gumble.TextMessageEvent) + UserChange func(e *gumble.UserChangeEvent) + ChannelChange func(e *gumble.ChannelChangeEvent) + PermissionDenied func(e *gumble.PermissionDeniedEvent) + UserList func(e *gumble.UserListEvent) + ACL func(e *gumble.ACLEvent) + BanList func(e *gumble.BanListEvent) + ContextActionChange func(e *gumble.ContextActionChangeEvent) + ServerConfig func(e *gumble.ServerConfigEvent) +} + +var _ gumble.EventListener = (*Listener)(nil) + +// OnConnect implements gumble.EventListener.OnConnect. +func (l Listener) OnConnect(e *gumble.ConnectEvent) { + if l.Connect != nil { + l.Connect(e) + } +} + +// OnDisconnect implements gumble.EventListener.OnDisconnect. +func (l Listener) OnDisconnect(e *gumble.DisconnectEvent) { + if l.Disconnect != nil { + l.Disconnect(e) + } +} + +// OnTextMessage implements gumble.EventListener.OnTextMessage. +func (l Listener) OnTextMessage(e *gumble.TextMessageEvent) { + if l.TextMessage != nil { + l.TextMessage(e) + } +} + +// OnUserChange implements gumble.EventListener.OnUserChange. +func (l Listener) OnUserChange(e *gumble.UserChangeEvent) { + if l.UserChange != nil { + l.UserChange(e) + } +} + +// OnChannelChange implements gumble.EventListener.OnChannelChange. +func (l Listener) OnChannelChange(e *gumble.ChannelChangeEvent) { + if l.ChannelChange != nil { + l.ChannelChange(e) + } +} + +// OnPermissionDenied implements gumble.EventListener.OnPermissionDenied. +func (l Listener) OnPermissionDenied(e *gumble.PermissionDeniedEvent) { + if l.PermissionDenied != nil { + l.PermissionDenied(e) + } +} + +// OnUserList implements gumble.EventListener.OnUserList. +func (l Listener) OnUserList(e *gumble.UserListEvent) { + if l.UserList != nil { + l.UserList(e) + } +} + +// OnACL implements gumble.EventListener.OnACL. +func (l Listener) OnACL(e *gumble.ACLEvent) { + if l.ACL != nil { + l.ACL(e) + } +} + +// OnBanList implements gumble.EventListener.OnBanList. +func (l Listener) OnBanList(e *gumble.BanListEvent) { + if l.BanList != nil { + l.BanList(e) + } +} + +// OnContextActionChange implements gumble.EventListener.OnContextActionChange. +func (l Listener) OnContextActionChange(e *gumble.ContextActionChangeEvent) { + if l.ContextActionChange != nil { + l.ContextActionChange(e) + } +} + +// OnServerConfig implements gumble.EventListener.OnServerConfig. +func (l Listener) OnServerConfig(e *gumble.ServerConfigEvent) { + if l.ServerConfig != nil { + l.ServerConfig(e) + } +} diff --git a/vendor/layeh.com/gumble/gumbleutil/listenerfunc.go b/vendor/layeh.com/gumble/gumbleutil/listenerfunc.go new file mode 100644 index 00000000..14af0d10 --- /dev/null +++ b/vendor/layeh.com/gumble/gumbleutil/listenerfunc.go @@ -0,0 +1,80 @@ +package gumbleutil + +import ( + "layeh.com/gumble/gumble" +) + +// ListenerFunc is a single listener function that implements the +// gumble.EventListener interface. This is useful if you would like to use a +// type-switch for handling the different event types. +// +// Example: +// handler := func(e interface{}) { +// switch e.(type) { +// case *gumble.ConnectEvent: +// println("Connected") +// case *gumble.DisconnectEvent: +// println("Disconnected") +// // ... +// } +// } +// +// client.Attach(gumbleutil.ListenerFunc(handler)) +type ListenerFunc func(e interface{}) + +var _ gumble.EventListener = ListenerFunc(nil) + +// OnConnect implements gumble.EventListener.OnConnect. +func (lf ListenerFunc) OnConnect(e *gumble.ConnectEvent) { + lf(e) +} + +// OnDisconnect implements gumble.EventListener.OnDisconnect. +func (lf ListenerFunc) OnDisconnect(e *gumble.DisconnectEvent) { + lf(e) +} + +// OnTextMessage implements gumble.EventListener.OnTextMessage. +func (lf ListenerFunc) OnTextMessage(e *gumble.TextMessageEvent) { + lf(e) +} + +// OnUserChange implements gumble.EventListener.OnUserChange. +func (lf ListenerFunc) OnUserChange(e *gumble.UserChangeEvent) { + lf(e) +} + +// OnChannelChange implements gumble.EventListener.OnChannelChange. +func (lf ListenerFunc) OnChannelChange(e *gumble.ChannelChangeEvent) { + lf(e) +} + +// OnPermissionDenied implements gumble.EventListener.OnPermissionDenied. +func (lf ListenerFunc) OnPermissionDenied(e *gumble.PermissionDeniedEvent) { + lf(e) +} + +// OnUserList implements gumble.EventListener.OnUserList. +func (lf ListenerFunc) OnUserList(e *gumble.UserListEvent) { + lf(e) +} + +// OnACL implements gumble.EventListener.OnACL. +func (lf ListenerFunc) OnACL(e *gumble.ACLEvent) { + lf(e) +} + +// OnBanList implements gumble.EventListener.OnBanList. +func (lf ListenerFunc) OnBanList(e *gumble.BanListEvent) { + lf(e) +} + +// OnContextActionChange implements gumble.EventListener.OnContextActionChange. +func (lf ListenerFunc) OnContextActionChange(e *gumble.ContextActionChangeEvent) { + lf(e) +} + +// OnServerConfig implements gumble.EventListener.OnServerConfig. +func (lf ListenerFunc) OnServerConfig(e *gumble.ServerConfigEvent) { + lf(e) +} diff --git a/vendor/layeh.com/gumble/gumbleutil/main.go b/vendor/layeh.com/gumble/gumbleutil/main.go new file mode 100644 index 00000000..36419ea6 --- /dev/null +++ b/vendor/layeh.com/gumble/gumbleutil/main.go @@ -0,0 +1,79 @@ +package gumbleutil + +import ( + "crypto/tls" + "flag" + "fmt" + "net" + "os" + "strconv" + + "layeh.com/gumble/gumble" +) + +// Main aids in the creation of a basic command line gumble bot. It accepts the +// following flag arguments: +// --server +// --username +// --password +// --insecure +// --certificate +// --key +func Main(listeners ...gumble.EventListener) { + server := flag.String("server", "localhost:64738", "Mumble server address") + username := flag.String("username", "gumble-bot", "client username") + password := flag.String("password", "", "client password") + insecure := flag.Bool("insecure", false, "skip server certificate verification") + certificateFile := flag.String("certificate", "", "user certificate file (PEM)") + keyFile := flag.String("key", "", "user certificate key file (PEM)") + + if !flag.Parsed() { + flag.Parse() + } + + host, port, err := net.SplitHostPort(*server) + if err != nil { + host = *server + port = strconv.Itoa(gumble.DefaultPort) + } + + keepAlive := make(chan bool) + + config := gumble.NewConfig() + config.Username = *username + config.Password = *password + address := net.JoinHostPort(host, port) + + var tlsConfig tls.Config + + if *insecure { + tlsConfig.InsecureSkipVerify = true + } + if *certificateFile != "" { + if *keyFile == "" { + keyFile = certificateFile + } + if certificate, err := tls.LoadX509KeyPair(*certificateFile, *keyFile); err != nil { + fmt.Fprintf(os.Stderr, "%s: %s\n", os.Args[0], err) + os.Exit(1) + } else { + tlsConfig.Certificates = append(tlsConfig.Certificates, certificate) + } + } + config.Attach(AutoBitrate) + for _, listener := range listeners { + config.Attach(listener) + } + config.Attach(Listener{ + Disconnect: func(e *gumble.DisconnectEvent) { + keepAlive <- true + }, + }) + _, err = gumble.DialWithDialer(new(net.Dialer), address, config, &tlsConfig) + if err != nil { + fmt.Fprintf(os.Stderr, "%s: %s\n", os.Args[0], err) + os.Exit(1) + } + + <-keepAlive +} diff --git a/vendor/layeh.com/gumble/gumbleutil/textmessage.go b/vendor/layeh.com/gumble/gumbleutil/textmessage.go new file mode 100644 index 00000000..1ccb62b4 --- /dev/null +++ b/vendor/layeh.com/gumble/gumbleutil/textmessage.go @@ -0,0 +1,45 @@ +package gumbleutil + +import ( + "bytes" + "encoding/xml" + "strings" + + "layeh.com/gumble/gumble" +) + +// PlainText returns the Message string without HTML tags or entities. +func PlainText(tm *gumble.TextMessage) string { + d := xml.NewDecoder(strings.NewReader(tm.Message)) + d.Strict = false + d.AutoClose = xml.HTMLAutoClose + d.Entity = xml.HTMLEntity + + var b bytes.Buffer + newline := false + for { + t, _ := d.Token() + if t == nil { + break + } + switch node := t.(type) { + case xml.CharData: + if len(node) > 0 { + b.Write(node) + newline = false + } + case xml.StartElement: + switch node.Name.Local { + case "address", "article", "aside", "audio", "blockquote", "canvas", "dd", "div", "dl", "fieldset", "figcaption", "figure", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "header", "hgroup", "hr", "noscript", "ol", "output", "p", "pre", "section", "table", "tfoot", "ul", "video": + if !newline { + b.WriteByte('\n') + newline = true + } + case "br": + b.WriteByte('\n') + newline = true + } + } + } + return b.String() +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 40b63237..1c695de0 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -213,6 +213,8 @@ github.com/technoweenie/multipartstreamer github.com/valyala/bytebufferpool # github.com/valyala/fasttemplate v1.2.1 github.com/valyala/fasttemplate +# github.com/vincent-petithory/dataurl v0.0.0-20191104211930-d1553a71de50 +github.com/vincent-petithory/dataurl # github.com/writeas/go-strip-markdown v2.0.1+incompatible github.com/writeas/go-strip-markdown # github.com/yaegashi/msgraph.go v0.1.4 @@ -343,3 +345,8 @@ gopkg.in/olahol/melody.v1 gopkg.in/yaml.v2 # gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c gopkg.in/yaml.v3 +# layeh.com/gumble v0.0.0-20200818122324-146f9205029b +layeh.com/gumble/gumble +layeh.com/gumble/gumble/MumbleProto +layeh.com/gumble/gumble/varint +layeh.com/gumble/gumbleutil