fixup client
Signed-off-by: Vasiliy Tolstov <v.tolstov@selfip.ru>
This commit is contained in:
parent
7915e89e38
commit
faf8458fa3
@ -4,13 +4,15 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
vnc "github.com/vtolstov/go-vnc"
|
vnc "github.com/vtolstov/go-vnc"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// Establish TCP connection to VNC server.
|
// Establish TCP connection to VNC server.
|
||||||
nc, err := net.Dial("tcp", "192.168.100.41:5900")
|
nc, err := net.DialTimeout("tcp", os.Args[1], 5*time.Second)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Error connecting to VNC host. %v", err)
|
log.Fatalf("Error connecting to VNC host. %v", err)
|
||||||
}
|
}
|
||||||
@ -18,18 +20,16 @@ func main() {
|
|||||||
// Negotiate connection with the server.
|
// Negotiate connection with the server.
|
||||||
cchServer := make(chan vnc.ServerMessage)
|
cchServer := make(chan vnc.ServerMessage)
|
||||||
cchClient := make(chan vnc.ClientMessage)
|
cchClient := make(chan vnc.ClientMessage)
|
||||||
|
errorCh := make(chan error)
|
||||||
|
|
||||||
ccfg := &vnc.ClientConfig{
|
ccfg := &vnc.ClientConfig{
|
||||||
VersionHandler: vnc.ClientVersionHandler,
|
SecurityHandlers: []vnc.SecurityHandler{&vnc.ClientAuthATEN{Username: []byte(os.Args[2]), Password: []byte(os.Args[3])}},
|
||||||
SecurityHandler: vnc.ClientSecurityHandler,
|
|
||||||
SecurityHandlers: []vnc.SecurityHandler{&vnc.ClientAuthATEN{Username: []byte("ADMIN"), Password: []byte("ADMIN")}},
|
|
||||||
ClientInitHandler: vnc.ClientClientInitHandler,
|
|
||||||
ServerInitHandler: vnc.ClientServerInitHandler,
|
|
||||||
PixelFormat: vnc.PixelFormat32bit,
|
PixelFormat: vnc.PixelFormat32bit,
|
||||||
ClientMessageCh: cchClient,
|
ClientMessageCh: cchClient,
|
||||||
ServerMessageCh: cchServer,
|
ServerMessageCh: cchServer,
|
||||||
ServerMessages: vnc.DefaultServerMessages,
|
ServerMessages: vnc.DefaultServerMessages,
|
||||||
Encodings: []vnc.Encoding{&vnc.RawEncoding{}},
|
Encodings: []vnc.Encoding{&vnc.RawEncoding{}},
|
||||||
|
ErrorCh: errorCh,
|
||||||
}
|
}
|
||||||
|
|
||||||
cc, err := vnc.Connect(context.Background(), nc, ccfg)
|
cc, err := vnc.Connect(context.Background(), nc, ccfg)
|
||||||
@ -37,17 +37,16 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Error negotiating connection to VNC host. %v", err)
|
log.Fatalf("Error negotiating connection to VNC host. %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Listen and handle server messages.
|
|
||||||
go cc.Handle()
|
|
||||||
|
|
||||||
// Process messages coming in on the ServerMessage channel.
|
// Process messages coming in on the ServerMessage channel.
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
|
case err := <-errorCh:
|
||||||
|
panic(err)
|
||||||
case msg := <-cchClient:
|
case msg := <-cchClient:
|
||||||
log.Printf("Received message type:%v msg:%v\n", msg.Type(), msg)
|
log.Printf("Received message type:%v msg:%v\n", msg.Type(), msg)
|
||||||
case msg := <-cchServer:
|
case msg := <-cchServer:
|
||||||
log.Printf("Received message type:%v msg:%v\n", msg.Type(), msg)
|
log.Printf("Received message type:%v msg:%v\n", msg.Type(), msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
cc.Wait()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user