fix when password is empty

This commit is contained in:
aluvare 2021-12-02 18:08:26 +01:00
parent 9a1ec51ddb
commit 0aff2846b2
2 changed files with 14 additions and 3 deletions

3
.gitignore vendored
View File

@ -8,6 +8,9 @@
# Test binary, build with `go test -c`
*.test
vnc-recorder
output.mp4
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
/vendor

14
main.go
View File

@ -20,7 +20,7 @@ func main() {
app := &cli.App{
Name: path.Base(os.Args[0]),
Usage: "Connect to a vnc server and record the screen to a video.",
Version: "0.3.0",
Version: "0.4.2",
Authors: []*cli.Author{
&cli.Author{
Name: "Daniel Widerin",
@ -80,6 +80,7 @@ func main() {
}
func recorder(c *cli.Context) error {
fmt.Println("PASSWORD", c.String("password"))
address := fmt.Sprintf("%s:%d", c.String("host"), c.Int("port"))
dialer, err := net.DialTimeout("tcp", address, 5*time.Second)
if err != nil {
@ -96,13 +97,20 @@ func recorder(c *cli.Context) error {
errorCh := make(chan error)
var secHandlers []vnc.SecurityHandler
if c.String("password") == "" {
var password string
if c.String("password") != "secret" {
password = c.String("password")
}
if password == "" {
secHandlers = []vnc.SecurityHandler{
&vnc.ClientAuthNone{},
}
} else {
secHandlers = []vnc.SecurityHandler{
&vnc.ClientAuthVNC{Password: []byte(c.String("password"))},
&vnc.ClientAuthVNC{Password: []byte(password)},
}
}