Matthieu Grieger 2015-02-07 18:20:00 -08:00
parent d8b31e60c2
commit c8c59c2970
3 changed files with 17 additions and 2 deletions

View File

@ -8,6 +8,7 @@ MumbleDJ Changelog
* Now uses `gumbleutil.PlainText` for removing HTML tags instead of `sanitize`.
* Added `!setcomment` which allows admin users to set the comment for the bot.
* Made "Now Playing" notification and `!currentsong` show the playlist title of the song if it is included in a playlist.
* Added ability to connect to Mumble server using a PEM cert/key pair. Use the commandline flags `cert` and `key` to make use of this.
### February 3, 2015 -- `v2.4.1`
* Made it possible to place MumbleDJ binary in `~/bin` instead of `/usr/local/bin` if the folder exists.

View File

@ -3,7 +3,7 @@ MumbleDJ
A Mumble bot that plays music fetched from YouTube videos.
## USAGE
`$ mumbledj -server=localhost -port=64738 -username=MumbleDJ -password="" -channel=root`
`$ mumbledj -server=localhost -port=64738 -username=MumbleDJ -password="" -channel=root -cert="" -key=""`
All parameters are optional, the example above shows the default values for each field.
## COMMANDS

16
main.go
View File

@ -8,6 +8,7 @@
package main
import (
"crypto/tls"
"flag"
"fmt"
"github.com/layeh/gopus"
@ -120,13 +121,15 @@ var dj = mumbledj{
// Main function, but only really performs startup tasks. Grabs and parses commandline
// args, sets up the gumble client and its listeners, and then connects to the server.
func main() {
var address, port, username, password, channel string
var address, port, username, password, channel, pemCert, pemKey string
flag.StringVar(&address, "server", "localhost", "address for Mumble server")
flag.StringVar(&port, "port", "64738", "port for Mumble server")
flag.StringVar(&username, "username", "MumbleDJ", "username of MumbleDJ on server")
flag.StringVar(&password, "password", "", "password for Mumble server (if needed)")
flag.StringVar(&channel, "channel", "root", "default channel for MumbleDJ")
flag.StringVar(&pemCert, "cert", "", "path to user PEM certificate for MumbleDJ")
flag.StringVar(&pemKey, "key", "", "path to user PEM key for MumbleDJ")
flag.Parse()
dj.client = gumble.NewClient(&dj.config)
@ -135,6 +138,17 @@ func main() {
Password: password,
Address: address + ":" + port,
}
if pemCert != "" {
if pemKey == "" {
pemKey = pemCert
}
if certificate, err := tls.LoadX509KeyPair(pemCert, pemKey); err != nil {
panic(err)
} else {
dj.config.TLSConfig.Certificates = append(dj.config.TLSConfig.Certificates, certificate)
}
}
dj.defaultChannel = channel
dj.client.Attach(gumbleutil.Listener{