增加鼠标绘制代码

This commit is contained in:
lwch
2021-11-02 14:39:38 +08:00
parent 72019cea31
commit 0dfa417e42
20 changed files with 203 additions and 90 deletions
+2 -1
View File
@@ -134,6 +134,7 @@ func main() {
version := flag.Bool("version", false, "show version info")
act := flag.String("action", "", "install or uninstall")
vport := flag.Uint("vport", 6155, "vnc worker listen port")
vcursor := flag.Bool("vcursor", false, "vnc show cursor")
flag.Parse()
if *version {
@@ -174,7 +175,7 @@ func main() {
defer utils.Recover("vnc.worker")
logging.SetSizeRotate(cfg.LogDir, "np-cli.vnc", int(cfg.LogSize.Bytes()), cfg.LogRotate, true)
defer logging.Flush()
vnc.RunWorker(uint16(*vport))
vnc.RunWorker(uint16(*vport), *vcursor)
return
}
+2 -1
View File
@@ -68,7 +68,7 @@ func (conn *Conn) SendConnectReq(id string, cfg global.Tunnel) {
}
// SendConnectVnc send connect vnc request message
func (conn *Conn) SendConnectVnc(id string, cfg global.Tunnel, quality uint64) {
func (conn *Conn) SendConnectVnc(id string, cfg global.Tunnel, quality uint64, showCursor bool) {
var msg network.Msg
msg.To = cfg.Target
msg.XType = network.Msg_connect_req
@@ -87,6 +87,7 @@ func (conn *Conn) SendConnectVnc(id string, cfg global.Tunnel, quality uint64) {
Cvnc: &network.ConnectVnc{
Fps: cfg.Fps,
Quality: uint32(quality),
Cursor: showCursor,
},
},
},
@@ -11,4 +11,39 @@ var (
FuncGetDesktopWindow, _ = syscall.GetProcAddress(syscall.Handle(libUser32), "GetDesktopWindow")
FuncGetDC, _ = syscall.GetProcAddress(syscall.Handle(libUser32), "GetDC")
FuncReleaseDC, _ = syscall.GetProcAddress(syscall.Handle(libUser32), "ReleaseDC")
FuncGetCursorInfo, _ = syscall.GetProcAddress(syscall.Handle(libUser32), "GetCursorInfo")
FuncDrawIcon, _ = syscall.GetProcAddress(syscall.Handle(libUser32), "DrawIcon")
)
type (
HANDLE uintptr
BOOL int32
DWORD uint32
LONG int32
HCURSOR HANDLE
HBITMAP HANDLE
)
type POINT struct {
X LONG
Y LONG
}
type CURSORINFO struct {
CbSize DWORD
Flags DWORD
HCursor HCURSOR
PTScreenPos POINT
}
type ICONINFO struct {
FIcon BOOL
XHotspot DWORD
YHotspot DWORD
HbmMask HBITMAP
HbmColor HBITMAP
}
const (
CURSOR_SHOWING = 0x00000001
)
+7 -2
View File
@@ -18,9 +18,14 @@ func (v *VNC) New(pool *pool.Pool, w http.ResponseWriter, r *http.Request) {
v.link.close()
}
q := r.FormValue("quality")
s := r.FormValue("show_cursor")
quality, err := strconv.ParseUint(q, 10, 32)
if err != nil {
quality = 75
quality = 50
}
showCursor, err := strconv.ParseBool(s)
if err != nil {
showCursor = false
}
id, err := runtime.UUID(16, "0123456789abcdef")
if err != nil {
@@ -36,7 +41,7 @@ func (v *VNC) New(pool *pool.Pool, w http.ResponseWriter, r *http.Request) {
old.SendDisconnect(v.link.target, v.link.targetIdx, v.link.id)
}
}
conn.SendConnectVnc(id, v.cfg, quality)
conn.SendConnectVnc(id, v.cfg, quality, showCursor)
v.link = v.NewLink(id, v.cfg.Target, 0, nil, conn).(*Link)
ch := conn.ChanRead(id)
timeout := time.After(conn.ReadTimeout)
+2 -2
View File
@@ -9,8 +9,8 @@ import (
)
// RunWorker run vnc worker
func RunWorker(port uint16) {
worker := worker.NewWorker()
func RunWorker(port uint16, cursor bool) {
worker := worker.NewWorker(cursor)
if worker == nil {
panic("build context failed")
}
@@ -77,7 +77,31 @@ func (worker *Worker) capture() error {
return errors.New("bitblt: " + err.Error())
}
defer worker.copyImageData(bitmap)
// TODO: draw cursor
if !worker.showCursor {
return
}
var curInfo CURSORINFO
curInfo.CbSize = DWORD(unsafe.Sizeof(curInfo))
ok, _, err = syscall.Syscall(define.FuncGetCursorInfo, 1, uintptr(unsafe.Pointer(&curInfo)), 0, 0)
if ok == 0 {
logging.Error("get cursor info: %v", err)
return nil
}
if curInfo.Flags == CURSOR_SHOWING {
var info ICONINFO
ok, _, err = syscall.Syscall(define.FuncGetIconInfo, 2, uintptr(curInfo.HCursor), uintptr(unsafe.Pointer(&info)), 0)
if ok == 0 {
logging.Error("get icon info: %v", err)
return nil
}
x := curInfo.PTScreenPos.X - LONG(info.XHotspot)
y := curInfo.PTScreenPos.Y - LONG(info.YHotspot)
ok, _, err = syscall.Syscall6(define.FuncDrawIcon, 4, memDC, uintptr(x), uintptr(y), uintptr(curInfo.HCursor), 0, 0)
if ok == 0 {
logging.Error("draw icon: %v", err)
return nil
}
}
return nil
}
+6 -3
View File
@@ -20,11 +20,14 @@ type desktopInfo struct {
type Worker struct {
workerOsBased
info desktopInfo
info desktopInfo
showCursor bool
}
func NewWorker() *Worker {
worker := &Worker{}
func NewWorker(showCursor bool) *Worker {
worker := &Worker{
showCursor: showCursor,
}
err := worker.init()
if err != nil {
return nil
+35 -25
View File
@@ -1,7 +1,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.27.1
// protoc v3.16.0
// protoc v3.6.1
// source: connect.proto
package network
@@ -189,6 +189,7 @@ type ConnectVnc struct {
Fps uint32 `protobuf:"varint,1,opt,name=fps,proto3" json:"fps,omitempty"`
Quality uint32 `protobuf:"varint,2,opt,name=quality,proto3" json:"quality,omitempty"` // image quality, percent
Cursor bool `protobuf:"varint,3,opt,name=cursor,proto3" json:"cursor,omitempty"` // show cursor
}
func (x *ConnectVnc) Reset() {
@@ -237,6 +238,13 @@ func (x *ConnectVnc) GetQuality() uint32 {
return 0
}
func (x *ConnectVnc) GetCursor() bool {
if x != nil {
return x.Cursor
}
return false
}
type ConnectRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@@ -413,33 +421,35 @@ var file_connect_proto_rawDesc = []byte{
0x22, 0x35, 0x0a, 0x0d, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x5f, 0x73, 0x68, 0x65, 0x6c,
0x6c, 0x12, 0x12, 0x0a, 0x04, 0x65, 0x78, 0x65, 0x63, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x04, 0x65, 0x78, 0x65, 0x63, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x6e, 0x76, 0x18, 0x02, 0x20, 0x03,
0x28, 0x09, 0x52, 0x03, 0x65, 0x6e, 0x76, 0x22, 0x39, 0x0a, 0x0b, 0x63, 0x6f, 0x6e, 0x6e, 0x65,
0x28, 0x09, 0x52, 0x03, 0x65, 0x6e, 0x76, 0x22, 0x51, 0x0a, 0x0b, 0x63, 0x6f, 0x6e, 0x6e, 0x65,
0x63, 0x74, 0x5f, 0x76, 0x6e, 0x63, 0x12, 0x10, 0x0a, 0x03, 0x66, 0x70, 0x73, 0x18, 0x01, 0x20,
0x01, 0x28, 0x0d, 0x52, 0x03, 0x66, 0x70, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x71, 0x75, 0x61, 0x6c,
0x69, 0x74, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x71, 0x75, 0x61, 0x6c, 0x69,
0x74, 0x79, 0x22, 0x9f, 0x02, 0x0a, 0x0f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x5f, 0x72,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01,
0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x32, 0x0a, 0x05, 0x5f, 0x74,
0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1d, 0x2e, 0x6e, 0x65, 0x74, 0x77,
0x6f, 0x72, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x52, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x2d,
0x0a, 0x05, 0x63, 0x61, 0x64, 0x64, 0x72, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e,
0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x5f,
0x61, 0x64, 0x64, 0x72, 0x48, 0x00, 0x52, 0x05, 0x63, 0x61, 0x64, 0x64, 0x72, 0x12, 0x30, 0x0a,
0x06, 0x63, 0x73, 0x68, 0x65, 0x6c, 0x6c, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e,
0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x5f,
0x73, 0x68, 0x65, 0x6c, 0x6c, 0x48, 0x00, 0x52, 0x06, 0x63, 0x73, 0x68, 0x65, 0x6c, 0x6c, 0x12,
0x2a, 0x0a, 0x04, 0x63, 0x76, 0x6e, 0x63, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e,
0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x5f,
0x76, 0x6e, 0x63, 0x48, 0x00, 0x52, 0x04, 0x63, 0x76, 0x6e, 0x63, 0x22, 0x2c, 0x0a, 0x04, 0x74,
0x79, 0x70, 0x65, 0x12, 0x07, 0x0a, 0x03, 0x74, 0x63, 0x70, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03,
0x75, 0x64, 0x70, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x73, 0x68, 0x65, 0x6c, 0x6c, 0x10, 0x02,
0x12, 0x07, 0x0a, 0x03, 0x76, 0x6e, 0x63, 0x10, 0x03, 0x42, 0x09, 0x0a, 0x07, 0x70, 0x61, 0x79,
0x6c, 0x6f, 0x61, 0x64, 0x22, 0x34, 0x0a, 0x10, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x5f,
0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x6f, 0x6b, 0x18, 0x01,
0x20, 0x01, 0x28, 0x08, 0x52, 0x02, 0x6f, 0x6b, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18,
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x42, 0x0c, 0x5a, 0x0a, 0x2e, 0x2f,
0x3b, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x74, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x75, 0x72, 0x73, 0x6f, 0x72, 0x18, 0x03, 0x20, 0x01,
0x28, 0x08, 0x52, 0x06, 0x63, 0x75, 0x72, 0x73, 0x6f, 0x72, 0x22, 0x9f, 0x02, 0x0a, 0x0f, 0x63,
0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12,
0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61,
0x6d, 0x65, 0x12, 0x32, 0x0a, 0x05, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
0x0e, 0x32, 0x1d, 0x2e, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x6e,
0x65, 0x63, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x74, 0x79, 0x70, 0x65,
0x52, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x2d, 0x0a, 0x05, 0x63, 0x61, 0x64, 0x64, 0x72, 0x18,
0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e,
0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x48, 0x00, 0x52, 0x05,
0x63, 0x61, 0x64, 0x64, 0x72, 0x12, 0x30, 0x0a, 0x06, 0x63, 0x73, 0x68, 0x65, 0x6c, 0x6c, 0x18,
0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e,
0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x5f, 0x73, 0x68, 0x65, 0x6c, 0x6c, 0x48, 0x00, 0x52,
0x06, 0x63, 0x73, 0x68, 0x65, 0x6c, 0x6c, 0x12, 0x2a, 0x0a, 0x04, 0x63, 0x76, 0x6e, 0x63, 0x18,
0x0c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e,
0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x5f, 0x76, 0x6e, 0x63, 0x48, 0x00, 0x52, 0x04, 0x63,
0x76, 0x6e, 0x63, 0x22, 0x2c, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x07, 0x0a, 0x03, 0x74,
0x63, 0x70, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x75, 0x64, 0x70, 0x10, 0x01, 0x12, 0x09, 0x0a,
0x05, 0x73, 0x68, 0x65, 0x6c, 0x6c, 0x10, 0x02, 0x12, 0x07, 0x0a, 0x03, 0x76, 0x6e, 0x63, 0x10,
0x03, 0x42, 0x09, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x22, 0x34, 0x0a, 0x10,
0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x12, 0x0e, 0x0a, 0x02, 0x6f, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x02, 0x6f, 0x6b,
0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d,
0x73, 0x67, 0x42, 0x0c, 0x5a, 0x0a, 0x2e, 0x2f, 0x3b, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b,
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
+1
View File
@@ -16,6 +16,7 @@ message connect_shell {
message connect_vnc {
uint32 fps = 1;
uint32 quality = 2; // image quality, percent
bool cursor = 3; // show cursor
}
message connect_request {
+1 -1
View File
@@ -1,7 +1,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.27.1
// protoc v3.16.0
// protoc v3.6.1
// source: forward.proto
package network
+1 -1
View File
@@ -1,7 +1,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.27.1
// protoc v3.16.0
// protoc v3.6.1
// source: msg.proto
package network
+1 -1
View File
@@ -1,7 +1,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.27.1
// protoc v3.16.0
// protoc v3.6.1
// source: shell.proto
package network
+56 -47
View File
@@ -1,7 +1,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.27.1
// protoc v3.16.0
// protoc v3.6.1
// source: vnc.proto
package network
@@ -176,6 +176,7 @@ type VncControl struct {
unknownFields protoimpl.UnknownFields
Quality uint32 `protobuf:"varint,1,opt,name=quality,proto3" json:"quality,omitempty"` // image quality, percent
Cursor bool `protobuf:"varint,2,opt,name=cursor,proto3" json:"cursor,omitempty"` // show cursor
}
func (x *VncControl) Reset() {
@@ -217,6 +218,13 @@ func (x *VncControl) GetQuality() uint32 {
return 0
}
func (x *VncControl) GetCursor() bool {
if x != nil {
return x.Cursor
}
return false
}
type VncImage struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@@ -498,53 +506,54 @@ var File_vnc_proto protoreflect.FileDescriptor
var file_vnc_proto_rawDesc = []byte{
0x0a, 0x09, 0x76, 0x6e, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x07, 0x6e, 0x65, 0x74,
0x77, 0x6f, 0x72, 0x6b, 0x22, 0x27, 0x0a, 0x0b, 0x76, 0x6e, 0x63, 0x5f, 0x63, 0x6f, 0x6e, 0x74,
0x77, 0x6f, 0x72, 0x6b, 0x22, 0x3f, 0x0a, 0x0b, 0x76, 0x6e, 0x63, 0x5f, 0x63, 0x6f, 0x6e, 0x74,
0x72, 0x6f, 0x6c, 0x12, 0x18, 0x0a, 0x07, 0x71, 0x75, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x18, 0x01,
0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x71, 0x75, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x22, 0xe9, 0x02,
0x0a, 0x09, 0x76, 0x6e, 0x63, 0x5f, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x12, 0x2c, 0x0a, 0x05, 0x5f,
0x69, 0x6e, 0x66, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x6e, 0x65, 0x74,
0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x76, 0x6e, 0x63, 0x5f, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2e, 0x69,
0x6e, 0x66, 0x6f, 0x52, 0x04, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x33, 0x0a, 0x06, 0x65, 0x6e, 0x63,
0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1b, 0x2e, 0x6e, 0x65, 0x74, 0x77,
0x6f, 0x72, 0x6b, 0x2e, 0x76, 0x6e, 0x63, 0x5f, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2e, 0x65, 0x6e,
0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x52, 0x06, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x12,
0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61,
0x74, 0x61, 0x1a, 0xbc, 0x01, 0x0a, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x12, 0x21, 0x0a, 0x0c, 0x73,
0x63, 0x72, 0x65, 0x65, 0x6e, 0x5f, 0x77, 0x69, 0x64, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28,
0x0d, 0x52, 0x0b, 0x73, 0x63, 0x72, 0x65, 0x65, 0x6e, 0x57, 0x69, 0x64, 0x74, 0x68, 0x12, 0x23,
0x0a, 0x0d, 0x73, 0x63, 0x72, 0x65, 0x65, 0x6e, 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18,
0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0c, 0x73, 0x63, 0x72, 0x65, 0x65, 0x6e, 0x48, 0x65, 0x69,
0x67, 0x68, 0x74, 0x12, 0x15, 0x0a, 0x06, 0x72, 0x65, 0x63, 0x74, 0x5f, 0x78, 0x18, 0x03, 0x20,
0x01, 0x28, 0x0d, 0x52, 0x05, 0x72, 0x65, 0x63, 0x74, 0x58, 0x12, 0x15, 0x0a, 0x06, 0x72, 0x65,
0x63, 0x74, 0x5f, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x72, 0x65, 0x63, 0x74,
0x59, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x63, 0x74, 0x5f, 0x77, 0x69, 0x64, 0x74, 0x68, 0x18,
0x05, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x72, 0x65, 0x63, 0x74, 0x57, 0x69, 0x64, 0x74, 0x68,
0x12, 0x1f, 0x0a, 0x0b, 0x72, 0x65, 0x63, 0x74, 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18,
0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0a, 0x72, 0x65, 0x63, 0x74, 0x48, 0x65, 0x69, 0x67, 0x68,
0x74, 0x22, 0x26, 0x0a, 0x08, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x12, 0x07, 0x0a,
0x03, 0x72, 0x61, 0x77, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x6a, 0x70, 0x65, 0x67, 0x10, 0x01,
0x12, 0x07, 0x0a, 0x03, 0x70, 0x6e, 0x67, 0x10, 0x02, 0x22, 0xb7, 0x01, 0x0a, 0x09, 0x76, 0x6e,
0x63, 0x5f, 0x6d, 0x6f, 0x75, 0x73, 0x65, 0x12, 0x27, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18,
0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x13, 0x2e, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e,
0x76, 0x6e, 0x63, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65,
0x12, 0x2b, 0x0a, 0x03, 0x62, 0x74, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x19, 0x2e,
0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x76, 0x6e, 0x63, 0x5f, 0x6d, 0x6f, 0x75, 0x73,
0x65, 0x2e, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x52, 0x03, 0x62, 0x74, 0x6e, 0x12, 0x0c, 0x0a,
0x01, 0x78, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79,
0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x01, 0x79, 0x22, 0x38, 0x0a, 0x06, 0x62, 0x75, 0x74,
0x74, 0x6f, 0x6e, 0x12, 0x0d, 0x0a, 0x09, 0x75, 0x6e, 0x73, 0x65, 0x74, 0x5f, 0x62, 0x74, 0x6e,
0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x6c, 0x65, 0x66, 0x74, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06,
0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x72, 0x69, 0x67, 0x68,
0x74, 0x10, 0x03, 0x22, 0x49, 0x0a, 0x0c, 0x76, 0x6e, 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x62, 0x6f,
0x61, 0x72, 0x64, 0x12, 0x27, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
0x0e, 0x32, 0x13, 0x2e, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x76, 0x6e, 0x63, 0x5f,
0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x10, 0x0a, 0x03,
0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x2a, 0x2c,
0x0a, 0x0a, 0x76, 0x6e, 0x63, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x0c, 0x0a, 0x08,
0x75, 0x6e, 0x73, 0x65, 0x74, 0x5f, 0x73, 0x74, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x64, 0x6f,
0x77, 0x6e, 0x10, 0x01, 0x12, 0x06, 0x0a, 0x02, 0x75, 0x70, 0x10, 0x02, 0x42, 0x0c, 0x5a, 0x0a,
0x2e, 0x2f, 0x3b, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x33,
0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x71, 0x75, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x12, 0x16, 0x0a,
0x06, 0x63, 0x75, 0x72, 0x73, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x63,
0x75, 0x72, 0x73, 0x6f, 0x72, 0x22, 0xe9, 0x02, 0x0a, 0x09, 0x76, 0x6e, 0x63, 0x5f, 0x69, 0x6d,
0x61, 0x67, 0x65, 0x12, 0x2c, 0x0a, 0x05, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x01, 0x20, 0x01,
0x28, 0x0b, 0x32, 0x17, 0x2e, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x76, 0x6e, 0x63,
0x5f, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2e, 0x69, 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x49, 0x6e, 0x66,
0x6f, 0x12, 0x33, 0x0a, 0x06, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
0x0e, 0x32, 0x1b, 0x2e, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x76, 0x6e, 0x63, 0x5f,
0x69, 0x6d, 0x61, 0x67, 0x65, 0x2e, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x52, 0x06,
0x65, 0x6e, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03,
0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x1a, 0xbc, 0x01, 0x0a, 0x04, 0x69,
0x6e, 0x66, 0x6f, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x63, 0x72, 0x65, 0x65, 0x6e, 0x5f, 0x77, 0x69,
0x64, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0b, 0x73, 0x63, 0x72, 0x65, 0x65,
0x6e, 0x57, 0x69, 0x64, 0x74, 0x68, 0x12, 0x23, 0x0a, 0x0d, 0x73, 0x63, 0x72, 0x65, 0x65, 0x6e,
0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0c, 0x73,
0x63, 0x72, 0x65, 0x65, 0x6e, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x15, 0x0a, 0x06, 0x72,
0x65, 0x63, 0x74, 0x5f, 0x78, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x72, 0x65, 0x63,
0x74, 0x58, 0x12, 0x15, 0x0a, 0x06, 0x72, 0x65, 0x63, 0x74, 0x5f, 0x79, 0x18, 0x04, 0x20, 0x01,
0x28, 0x0d, 0x52, 0x05, 0x72, 0x65, 0x63, 0x74, 0x59, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x63,
0x74, 0x5f, 0x77, 0x69, 0x64, 0x74, 0x68, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x72,
0x65, 0x63, 0x74, 0x57, 0x69, 0x64, 0x74, 0x68, 0x12, 0x1f, 0x0a, 0x0b, 0x72, 0x65, 0x63, 0x74,
0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0a, 0x72,
0x65, 0x63, 0x74, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x22, 0x26, 0x0a, 0x08, 0x65, 0x6e, 0x63,
0x6f, 0x64, 0x69, 0x6e, 0x67, 0x12, 0x07, 0x0a, 0x03, 0x72, 0x61, 0x77, 0x10, 0x00, 0x12, 0x08,
0x0a, 0x04, 0x6a, 0x70, 0x65, 0x67, 0x10, 0x01, 0x12, 0x07, 0x0a, 0x03, 0x70, 0x6e, 0x67, 0x10,
0x02, 0x22, 0xb7, 0x01, 0x0a, 0x09, 0x76, 0x6e, 0x63, 0x5f, 0x6d, 0x6f, 0x75, 0x73, 0x65, 0x12,
0x27, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x13, 0x2e,
0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x76, 0x6e, 0x63, 0x5f, 0x73, 0x74, 0x61, 0x74,
0x75, 0x73, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x2b, 0x0a, 0x03, 0x62, 0x74, 0x6e, 0x18,
0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x19, 0x2e, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e,
0x76, 0x6e, 0x63, 0x5f, 0x6d, 0x6f, 0x75, 0x73, 0x65, 0x2e, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e,
0x52, 0x03, 0x62, 0x74, 0x6e, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d,
0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x01,
0x79, 0x22, 0x38, 0x0a, 0x06, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x12, 0x0d, 0x0a, 0x09, 0x75,
0x6e, 0x73, 0x65, 0x74, 0x5f, 0x62, 0x74, 0x6e, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x6c, 0x65,
0x66, 0x74, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x10, 0x02,
0x12, 0x09, 0x0a, 0x05, 0x72, 0x69, 0x67, 0x68, 0x74, 0x10, 0x03, 0x22, 0x49, 0x0a, 0x0c, 0x76,
0x6e, 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x12, 0x27, 0x0a, 0x04, 0x74,
0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x13, 0x2e, 0x6e, 0x65, 0x74, 0x77,
0x6f, 0x72, 0x6b, 0x2e, 0x76, 0x6e, 0x63, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x04,
0x74, 0x79, 0x70, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28,
0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x2a, 0x2c, 0x0a, 0x0a, 0x76, 0x6e, 0x63, 0x5f, 0x73, 0x74,
0x61, 0x74, 0x75, 0x73, 0x12, 0x0c, 0x0a, 0x08, 0x75, 0x6e, 0x73, 0x65, 0x74, 0x5f, 0x73, 0x74,
0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x64, 0x6f, 0x77, 0x6e, 0x10, 0x01, 0x12, 0x06, 0x0a, 0x02,
0x75, 0x70, 0x10, 0x02, 0x42, 0x0c, 0x5a, 0x0a, 0x2e, 0x2f, 0x3b, 0x6e, 0x65, 0x74, 0x77, 0x6f,
0x72, 0x6b, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
+1
View File
@@ -5,6 +5,7 @@ option go_package="./;network";
message vnc_control {
uint32 quality = 1; // image quality, percent
bool cursor = 2; // show cursor
}
message vnc_image {
+1 -1
View File
@@ -11,7 +11,7 @@ require (
github.com/lwch/logging v0.0.0-20210831025517-ae81047d6190
github.com/lwch/runtime v0.0.0-20190520054850-8c97e19e0c6d
github.com/lwch/yaml v0.0.0-20211009070949-2d4c64e2b789
golang.org/x/sys v0.0.0-20211015200801-69063c4bb744
golang.org/x/sys v0.0.0-20211101204403-39c9dd37992c
golang.org/x/text v0.3.7
google.golang.org/protobuf v1.27.1
)
+2 -2
View File
@@ -26,8 +26,8 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20211015200801-69063c4bb744 h1:KzbpndAYEM+4oHRp9JmB2ewj0NHHxO3Z0g7Gus2O1kk=
golang.org/x/sys v0.0.0-20211015200801-69063c4bb744/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211101204403-39c9dd37992c h1:rnNohYBMnXA07uGnZ9CSWNhIu4Gob4FqWS43lLqZ2sU=
golang.org/x/sys v0.0.0-20211101204403-39c9dd37992c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
+1
View File
@@ -0,0 +1 @@
../AdminLTE-3.1.0
+1
View File
@@ -0,0 +1 @@
../bootstrap-5.1.3
+20 -1
View File
@@ -5,11 +5,30 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>vnc - [{{.Name}}]</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/bootstrap/css/bootstrap.min.css" />
<link rel="stylesheet" href="/AdminLTE/css/adminlte.min.css" />
<script src="/jquery/jquery-3.6.0.min.js"></script>
<script src="/bootstrap/js/bootstrap.min.js"></script>
<script src="/AdminLTE/js/adminlte.min.js"></script>
<link rel="stylesheet" href="/index.css" />
<script src="/index.js"></script>
</head>
<body>
<canvas id="vnc"></canvas>
<div class="container-fluid">
<div class="display:inline-block">
<div class="form-check form-check-inline">
<input id="draw-cursor" class="form-check-input" type="checkbox">
<label class="form-check-label">绘制鼠标</label>
</div>
<select id="quality" class="form-select">
<option value="50"></option>
<option value="70"></option>
<option value="90"></option>
<option value="100">原始</option>
</select>
</div>
<!-- header -->
<canvas id="vnc"></canvas>
</div>
</body>
</html>
+3 -1
View File
@@ -5,7 +5,9 @@ var page = {
page.connect();
},
connect: function() {
$.get('/new?quality=50', function(ret) {
var quality = $('#quality').val();
var show_cursor = $('#show-cursor').val();
$.get('/new?quality='+quality+'&show_cursor='+show_cursor, function(ret) {
page.id = ret;
page.ws = new WebSocket('ws://'+location.host+'/ws/'+ret);
page.ws.onmessage = page.render;