initial commit
This commit is contained in:
62
cmd/barnard/main.go
Normal file
62
cmd/barnard/main.go
Normal 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()
|
||||
}
|
||||
Reference in New Issue
Block a user