]> git.0d.be Git - barnard.git/blobdiff - cmd/barnard/main.go
relicense as GPLv2
[barnard.git] / cmd / barnard / main.go
index 812a395f47d4177990c22bc06588ee6ead58d116..a426c3ec3702de1f5a535d1f767508cca93c13d6 100644 (file)
@@ -1,4 +1,4 @@
-package main
+package main // import "layeh.com/barnard/cmd/barnard"
 
 import (
        "crypto/tls"
@@ -6,58 +6,43 @@ import (
        "fmt"
        "os"
 
-       "github.com/layeh/barnard"
-       "github.com/layeh/barnard/uiterm"
-       "github.com/layeh/gumble/gumble"
-       "github.com/layeh/gumble/gumbleutil"
-       "github.com/layeh/gumble/gumble_openal"
+       "layeh.com/barnard"
+       "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.Barnard{}
-       b.Ui = uiterm.New(&b)
-
-       // Gumble
-       b.Config = gumble.Config{
-               Username: *username,
-               Address:  *server,
+       b := barnard.Barnard{
+               Config: gumble.NewConfig(),
+               Address: *server,
        }
+
+       b.Config.Username = *username
+       b.Config.Password = *password
+
        if *insecure {
-               b.Config.TLSConfig.InsecureSkipVerify = true
+               b.TLSConfig.InsecureSkipVerify = true
        }
        if *certificate != "" {
-               if cert, err := tls.LoadX509KeyPair(*certificate, *certificate); err != nil {
+               cert, err := tls.LoadX509KeyPair(*certificate, *certificate)
+               if err != nil {
                        fmt.Fprintf(os.Stderr, "%s\n", err)
                        os.Exit(1)
-               } else {
-                       b.Config.TLSConfig.Certificates = []tls.Certificate{cert}
                }
+               b.TLSConfig.Certificates = append(b.TLSConfig.Certificates, cert)
        }
 
-       b.Client = gumble.NewClient(&b.Config)
-       b.Client.Attach(gumbleutil.AutoBitrate)
-       b.Client.Attach(&b)
-       // Audio
-       if stream, err := gumble_openal.New(b.Client); err != nil {
-               fmt.Fprintf(os.Stderr, "%s\n", err)
-               os.Exit(1)
-       } else {
-               b.Stream = stream
-       }
-
-       if err := b.Client.Connect(); err != nil {
-               fmt.Fprintf(os.Stderr, "%s\n", err)
-               os.Exit(1)
-       }
-
+       b.Ui = uiterm.New(&b)
        b.Ui.Run()
 }