-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
66 lines (57 loc) · 1.46 KB
/
Copy pathmain.go
File metadata and controls
66 lines (57 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package main
import (
"fmt"
"os"
"path/filepath"
"strconv"
"strings"
"fyne.io/fyne/app"
"fyne.io/fyne/widget"
"github.com/deluan/bring"
"github.com/sirupsen/logrus"
)
const (
guacdAddress = "localhost:4822"
defaultWidth = 1024
defaultHeight = 768
)
// Creates and initialize Bring's Session and Client
func createBringClient(protocol, hostname, port, username, password string) *bring.Client {
logger := logrus.New()
logger.SetFormatter(&logrus.TextFormatter{DisableTimestamp: true, ForceColors: true})
logger.SetLevel(logrus.DebugLevel)
client, err := bring.NewClient(guacdAddress, protocol, map[string]string{
"hostname": hostname,
"port": port,
"username": username,
"password": password,
"width": strconv.Itoa(defaultWidth),
"height": strconv.Itoa(defaultHeight),
}, logger)
if err != nil {
panic(err)
}
return client
}
func main() {
if len(os.Args) < 4 {
cmd := filepath.Base(os.Args[0])
fmt.Printf("Usage: %s <vnc|rdp> address port", cmd)
os.Exit(1)
}
client := createBringClient(os.Args[1], os.Args[2], os.Args[3], os.Args[4], os.Args[5])
bringApp := app.New()
title := fmt.Sprintf("%s (%s:%s)", strings.ToUpper(os.Args[1]), os.Args[2], os.Args[3])
w := bringApp.NewWindow(title)
bringDisplay := NewBringDisplay(client, defaultWidth, defaultHeight)
w.CenterOnScreen()
w.SetContent(widget.NewVBox(
widget.NewHBox(
widget.NewButton("Quit", func() {
bringApp.Quit()
}),
),
bringDisplay,
))
w.ShowAndRun()
}