My mirror of the Barnard terminal client for Mumble.

64 lines
1.4 KiB

  1. package main
  2. import (
  3. "crypto/tls"
  4. "flag"
  5. "fmt"
  6. "os"
  7. "github.com/layeh/barnard"
  8. "github.com/layeh/barnard/uiterm"
  9. "github.com/layeh/gumble/gumble"
  10. "github.com/layeh/gumble/gumbleutil"
  11. "github.com/layeh/gumble/gumble_openal"
  12. )
  13. func main() {
  14. // Command line flags
  15. server := flag.String("server", "localhost:64738", "the server to connect to")
  16. username := flag.String("username", "", "the username of the client")
  17. insecure := flag.Bool("insecure", false, "skip server certificate verification")
  18. certificate := flag.String("certificate", "", "PEM encoded certificate and private key")
  19. flag.Parse()
  20. // Initialize
  21. b := barnard.Barnard{}
  22. b.Ui = uiterm.New(&b)
  23. // Gumble
  24. b.Config = gumble.Config{
  25. Username: *username,
  26. Address: *server,
  27. }
  28. if *insecure {
  29. b.Config.TLSConfig.InsecureSkipVerify = true
  30. }
  31. if *certificate != "" {
  32. if cert, err := tls.LoadX509KeyPair(*certificate, *certificate); err != nil {
  33. fmt.Fprintf(os.Stderr, "%s\n", err)
  34. os.Exit(1)
  35. } else {
  36. b.Config.TLSConfig.Certificates = []tls.Certificate{cert}
  37. }
  38. }
  39. b.Client = gumble.NewClient(&b.Config)
  40. b.Client.Attach(gumbleutil.AutoBitrate)
  41. b.Client.Attach(&b)
  42. // Audio
  43. if stream, err := gumble_openal.New(b.Client); err != nil {
  44. fmt.Fprintf(os.Stderr, "%s\n", err)
  45. os.Exit(1)
  46. } else {
  47. b.Stream = stream
  48. }
  49. if err := b.Client.Connect(); err != nil {
  50. fmt.Fprintf(os.Stderr, "%s\n", err)
  51. os.Exit(1)
  52. }
  53. b.Ui.Run()
  54. }