initial commit

This commit is contained in:
Tim Cooper
2014-12-04 17:08:26 -04:00
commit 562dec1e35
14 changed files with 1171 additions and 0 deletions

62
cmd/barnard/main.go Normal file
View File

@@ -0,0 +1,62 @@
package main
import (
"crypto/tls"
"flag"
"fmt"
"os"
"github.com/layeh/barnard"
"github.com/layeh/barnard/uiterm"
"github.com/layeh/gumble/gumble"
"github.com/layeh/gumble/gumble_openal"
)
func main() {
// Command line flags
server := flag.String("server", "localhost:64738", "the server to connect to")
username := flag.String("username", "", "the username of the client")
insecure := flag.Bool("insecure", false, "skip server certificate verification")
certificate := flag.String("certificate", "", "PEM encoded certificate and private key")
flag.Parse()
// Initialize
b := barnard.Barnard{}
b.Ui = uiterm.New(&b)
// Gumble
b.Config = gumble.Config{
Username: *username,
Address: *server,
Listener: &b,
}
if *insecure {
b.Config.TlsConfig.InsecureSkipVerify = true
}
if *certificate != "" {
if cert, err := tls.LoadX509KeyPair(*certificate, *certificate); err != nil {
fmt.Fprintf(os.Stderr, "%s\n", err)
os.Exit(1)
} else {
b.Config.TlsConfig.Certificates = []tls.Certificate{cert}
}
}
b.Client = gumble.NewClient(&b.Config)
// Audio
if stream, err := gumble_openal.New(b.Client); err != nil {
fmt.Fprintf(os.Stderr, "%s\n", err)
os.Exit(1)
} else {
b.Config.AudioListener = stream
b.Stream = stream
}
if err := b.Client.Connect(); err != nil {
fmt.Fprintf(os.Stderr, "%s\n", err)
os.Exit(1)
}
b.Ui.Run()
}