mirror of
https://github.com/amitbet/vncproxy.git
synced 2025-04-28 11:03:27 +00:00
now I should get to tying up the proxying connections and checking what should be written to the file. (server init?)
45 lines
1.1 KiB
Go
45 lines
1.1 KiB
Go
package server
|
|
|
|
import (
|
|
"context"
|
|
"log"
|
|
"net"
|
|
"testing"
|
|
"vncproxy/common"
|
|
"vncproxy/encodings"
|
|
)
|
|
|
|
func TestServer(t *testing.T) {
|
|
ln, err := net.Listen("tcp", ":5903")
|
|
if err != nil {
|
|
log.Fatalf("Error listen. %v", err)
|
|
}
|
|
|
|
chServer := make(chan common.ClientMessage)
|
|
chClient := make(chan common.ServerMessage)
|
|
|
|
cfg := &ServerConfig{
|
|
//SecurityHandlers: []SecurityHandler{&ServerAuthNone{}, &ServerAuthVNC{}},
|
|
SecurityHandlers: []SecurityHandler{&ServerAuthVNC{}},
|
|
Encodings: []common.Encoding{&encodings.RawEncoding{}, &encodings.TightEncoding{}, &encodings.CopyRectEncoding{}},
|
|
PixelFormat: common.NewPixelFormat(32),
|
|
ClientMessageCh: chServer,
|
|
ServerMessageCh: chClient,
|
|
ClientMessages: DefaultClientMessages,
|
|
DesktopName: []byte("workDesk"),
|
|
Height: uint16(768),
|
|
Width: uint16(1024),
|
|
|
|
}
|
|
go Serve(context.Background(), ln, cfg)
|
|
|
|
// Process messages coming in on the ClientMessage channel.
|
|
for {
|
|
msg := <-chClient
|
|
switch msg.Type() {
|
|
default:
|
|
log.Printf("Received message type:%v msg:%v\n", msg.Type(), msg)
|
|
}
|
|
}
|
|
}
|