]> git.0d.be Git - barnard.git/blob - cmd/barnard/main.go
update import path
[barnard.git] / cmd / barnard / main.go
1 package main // import "layeh.com/barnard/cmd/barnard"
2
3 import (
4         "crypto/tls"
5         "flag"
6         "fmt"
7         "os"
8
9         "layeh.com/barnard"
10         "layeh.com/barnard/uiterm"
11         "layeh.com/gumble/gumble"
12         _ "layeh.com/gumble/opus"
13 )
14
15 func main() {
16         // Command line flags
17         server := flag.String("server", "localhost:64738", "the server to connect to")
18         username := flag.String("username", "", "the username of the client")
19         password := flag.String("password", "", "the password of the server")
20         insecure := flag.Bool("insecure", false, "skip server certificate verification")
21         certificate := flag.String("certificate", "", "PEM encoded certificate and private key")
22
23         flag.Parse()
24
25         // Initialize
26         b := barnard.Barnard{
27                 Config: gumble.NewConfig(),
28                 Address: *server,
29         }
30
31         b.Config.Username = *username
32         b.Config.Password = *password
33
34         if *insecure {
35                 b.TLSConfig.InsecureSkipVerify = true
36         }
37         if *certificate != "" {
38                 cert, err := tls.LoadX509KeyPair(*certificate, *certificate)
39                 if err != nil {
40                         fmt.Fprintf(os.Stderr, "%s\n", err)
41                         os.Exit(1)
42                 }
43                 b.TLSConfig.Certificates = append(b.TLSConfig.Certificates, cert)
44         }
45
46         b.Ui = uiterm.New(&b)
47         b.Ui.Run()
48 }