]> git.0d.be Git - barnard.git/blobdiff - main.go
move barnard main package to package root
[barnard.git] / main.go
diff --git a/main.go b/main.go
new file mode 100644 (file)
index 0000000..7a779d5
--- /dev/null
+++ b/main.go
@@ -0,0 +1,47 @@
+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()
+}