Files
barnard/main.go
Tim Cooper 4b86035511 move barnard main package to package root
There's only a single executable, so this makes things cleaner
2018-05-08 18:00:30 -03:00

48 lines
1.0 KiB
Go

package main
import (
"crypto/tls"
"flag"
"fmt"
"os"
"layeh.com/barnard/uiterm"
"layeh.com/gumble/gumble"
_ "layeh.com/gumble/opus"
)
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")
password := flag.String("password", "", "the password of the server")
insecure := flag.Bool("insecure", false, "skip server certificate verification")
certificate := flag.String("certificate", "", "PEM encoded certificate and private key")
flag.Parse()
// Initialize
b := Barnard{
Config: gumble.NewConfig(),
Address: *server,
}
b.Config.Username = *username
b.Config.Password = *password
if *insecure {
b.TLSConfig.InsecureSkipVerify = true
}
if *certificate != "" {
cert, err := tls.LoadX509KeyPair(*certificate, *certificate)
if err != nil {
fmt.Fprintf(os.Stderr, "%s\n", err)
os.Exit(1)
}
b.TLSConfig.Certificates = append(b.TLSConfig.Certificates, cert)
}
b.Ui = uiterm.New(&b)
b.Ui.Run()
}