Merge pull request #54 from dylanetaft/master

Fix https://github.com/matthieugrieger/mumbledj/issues/50: Load config before connecting to mumble server
This commit is contained in:
Matthieu Grieger 2015-03-27 20:44:11 -07:00
commit 3af978fb38

21
main.go
View file

@ -44,12 +44,6 @@ func (dj *mumbledj) OnConnect(e *gumble.ConnectEvent) {
fmt.Println("Channel doesn't exist or one was not provided, staying in root channel...") fmt.Println("Channel doesn't exist or one was not provided, staying in root channel...")
} }
if err := loadConfiguration(); err == nil {
fmt.Println("Configuration successfully loaded!")
} else {
panic(err)
}
if audioStream, err := gumble_ffmpeg.New(dj.client); err == nil { if audioStream, err := gumble_ffmpeg.New(dj.client); err == nil {
dj.audioStream = audioStream dj.audioStream = audioStream
dj.audioStream.Volume = dj.conf.Volume.DefaultVolume dj.audioStream.Volume = dj.conf.Volume.DefaultVolume
@ -149,6 +143,17 @@ var dj = mumbledj{
// Main function, but only really performs startup tasks. Grabs and parses commandline // 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. // args, sets up the gumble client and its listeners, and then connects to the server.
func main() { func main() {
if currentUser, err := user.Current(); err == nil {
dj.homeDir = currentUser.HomeDir
}
if err := loadConfiguration(); err == nil {
fmt.Println("Configuration successfully loaded!")
} else {
panic(err)
}
var address, port, username, password, channel, pemCert, pemKey string var address, port, username, password, channel, pemCert, pemKey string
var insecure bool var insecure bool
@ -169,10 +174,6 @@ func main() {
} }
dj.client = gumble.NewClient(&dj.config) dj.client = gumble.NewClient(&dj.config)
if currentUser, err := user.Current(); err == nil {
dj.homeDir = currentUser.HomeDir
}
dj.config.TLSConfig.InsecureSkipVerify = true dj.config.TLSConfig.InsecureSkipVerify = true
if !insecure { if !insecure {
gumbleutil.CertificateLockFile(dj.client, fmt.Sprintf("%s/.mumbledj/cert.lock", dj.homeDir)) gumbleutil.CertificateLockFile(dj.client, fmt.Sprintf("%s/.mumbledj/cert.lock", dj.homeDir))