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