]> git.0d.be Git - barnard.git/blob - cmd/barnard/main.go
c23c2d620af92ccabe72c7476edfdb647a8e0e88
[barnard.git] / cmd / barnard / main.go
1 package main
2
3 import (
4         "crypto/tls"
5         "flag"
6         "fmt"
7         "os"
8
9         "github.com/layeh/barnard"
10         "github.com/layeh/barnard/uiterm"
11         "github.com/layeh/gumble/gumble"
12         _ "github.com/layeh/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         insecure := flag.Bool("insecure", false, "skip server certificate verification")
20         certificate := flag.String("certificate", "", "PEM encoded certificate and private key")
21
22         flag.Parse()
23
24         // Initialize
25         b := barnard.Barnard{
26                 Config: gumble.NewConfig(),
27                 Address: *server,
28         }
29
30         b.Config.Username = *username
31
32         if *insecure {
33                 b.TLSConfig.InsecureSkipVerify = true
34         }
35         if *certificate != "" {
36                 cert, err := tls.LoadX509KeyPair(*certificate, *certificate)
37                 if err != nil {
38                         fmt.Fprintf(os.Stderr, "%s\n", err)
39                         os.Exit(1)
40                 }
41                 b.TLSConfig.Certificates = append(b.TLSConfig.Certificates, cert)
42         }
43
44         b.Ui = uiterm.New(&b)
45         b.Ui.Run()
46 }