From 062c6a5caacbec8e613f765fe7d4713e5b7ea479 Mon Sep 17 00:00:00 2001 From: lwch Date: Mon, 1 Nov 2021 12:00:25 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=9B=AE=E5=BD=95=E7=BB=93?= =?UTF-8?q?=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vnc/{core => }/define/gdi32_windows.go | 0 .../vnc/{core => }/define/kernel32_windows.go | 0 .../vnc/{core => }/define/user32_windows.go | 0 code/client/tunnel/vnc/link.go | 6 +- .../client/tunnel/vnc/{core => network}/build | 0 .../tunnel/vnc/{core => network}/vncmsg.pb.go | 135 +++++++++--------- .../tunnel/vnc/{core => network}/vncmsg.proto | 4 +- .../tunnel/vnc/{core => process}/errors.go | 2 +- .../tunnel/vnc/{core => process}/process.go | 11 +- .../vnc/{core => process}/process_windows.go | 19 +-- .../vnc/{core => process}/process_xx.go | 6 +- code/client/tunnel/vnc/worker.go | 4 +- .../tunnel/vnc/{core => worker}/capture.go | 20 +-- .../vnc/{core => worker}/capture_windows.go | 4 +- .../tunnel/vnc/{core => worker}/capture_xx.go | 2 +- .../tunnel/vnc/{core => worker}/worker.go | 8 +- .../vnc/{core => worker}/worker_windows.go | 4 +- .../tunnel/vnc/{core => worker}/worker_xx.go | 3 +- 18 files changed, 118 insertions(+), 110 deletions(-) rename code/client/tunnel/vnc/{core => }/define/gdi32_windows.go (100%) rename code/client/tunnel/vnc/{core => }/define/kernel32_windows.go (100%) rename code/client/tunnel/vnc/{core => }/define/user32_windows.go (100%) rename code/client/tunnel/vnc/{core => network}/build (100%) rename code/client/tunnel/vnc/{core => network}/vncmsg.pb.go (70%) rename code/client/tunnel/vnc/{core => network}/vncmsg.proto (94%) rename code/client/tunnel/vnc/{core => process}/errors.go (86%) rename code/client/tunnel/vnc/{core => process}/process.go (91%) rename code/client/tunnel/vnc/{core => process}/process_windows.go (89%) rename code/client/tunnel/vnc/{core => process}/process_xx.go (67%) rename code/client/tunnel/vnc/{core => worker}/capture.go (63%) rename code/client/tunnel/vnc/{core => worker}/capture_windows.go (97%) rename code/client/tunnel/vnc/{core => worker}/capture_xx.go (90%) rename code/client/tunnel/vnc/{core => worker}/worker.go (85%) rename code/client/tunnel/vnc/{core => worker}/worker_windows.go (97%) rename code/client/tunnel/vnc/{core => worker}/worker_xx.go (74%) diff --git a/code/client/tunnel/vnc/core/define/gdi32_windows.go b/code/client/tunnel/vnc/define/gdi32_windows.go similarity index 100% rename from code/client/tunnel/vnc/core/define/gdi32_windows.go rename to code/client/tunnel/vnc/define/gdi32_windows.go diff --git a/code/client/tunnel/vnc/core/define/kernel32_windows.go b/code/client/tunnel/vnc/define/kernel32_windows.go similarity index 100% rename from code/client/tunnel/vnc/core/define/kernel32_windows.go rename to code/client/tunnel/vnc/define/kernel32_windows.go diff --git a/code/client/tunnel/vnc/core/define/user32_windows.go b/code/client/tunnel/vnc/define/user32_windows.go similarity index 100% rename from code/client/tunnel/vnc/core/define/user32_windows.go rename to code/client/tunnel/vnc/define/user32_windows.go diff --git a/code/client/tunnel/vnc/link.go b/code/client/tunnel/vnc/link.go index 0b2ae23..5d0007f 100644 --- a/code/client/tunnel/vnc/link.go +++ b/code/client/tunnel/vnc/link.go @@ -5,7 +5,7 @@ import ( "image" "image/jpeg" "natpass/code/client/pool" - "natpass/code/client/tunnel/vnc/core" + "natpass/code/client/tunnel/vnc/process" "natpass/code/network" "natpass/code/utils" "time" @@ -26,7 +26,7 @@ type Link struct { targetIdx uint32 // target idx remote *pool.Conn // vnc - ps *core.Process + ps *process.Process quality uint32 img *image.RGBA // runtime @@ -66,7 +66,7 @@ func (link *Link) SetQuality(q uint32) { // Fork fork worker process func (link *Link) Fork(confDir string) error { - p, err := core.CreateWorkerProcess(confDir) + p, err := process.CreateWorker(confDir) if err != nil { return err } diff --git a/code/client/tunnel/vnc/core/build b/code/client/tunnel/vnc/network/build similarity index 100% rename from code/client/tunnel/vnc/core/build rename to code/client/tunnel/vnc/network/build diff --git a/code/client/tunnel/vnc/core/vncmsg.pb.go b/code/client/tunnel/vnc/network/vncmsg.pb.go similarity index 70% rename from code/client/tunnel/vnc/core/vncmsg.pb.go rename to code/client/tunnel/vnc/network/vncmsg.pb.go index 82d5540..18246af 100644 --- a/code/client/tunnel/vnc/core/vncmsg.pb.go +++ b/code/client/tunnel/vnc/network/vncmsg.pb.go @@ -4,7 +4,7 @@ // protoc v3.16.0 // source: vncmsg.proto -package core +package network import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" @@ -268,8 +268,8 @@ type MouseData struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Type Status `protobuf:"varint,1,opt,name=type,proto3,enum=core.Status" json:"type,omitempty"` - Btn MouseDataButton `protobuf:"varint,2,opt,name=btn,proto3,enum=core.MouseDataButton" json:"btn,omitempty"` + Type Status `protobuf:"varint,1,opt,name=type,proto3,enum=network.Status" json:"type,omitempty"` + Btn MouseDataButton `protobuf:"varint,2,opt,name=btn,proto3,enum=network.MouseDataButton" json:"btn,omitempty"` X uint32 `protobuf:"varint,3,opt,name=x,proto3" json:"x,omitempty"` Y uint32 `protobuf:"varint,4,opt,name=y,proto3" json:"y,omitempty"` } @@ -339,7 +339,7 @@ type KeyboardData struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Type Status `protobuf:"varint,1,opt,name=type,proto3,enum=core.Status" json:"type,omitempty"` + Type Status `protobuf:"varint,1,opt,name=type,proto3,enum=network.Status" json:"type,omitempty"` Key string `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` } @@ -394,7 +394,7 @@ type VncMsg struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - XType VncMsgType `protobuf:"varint,1,opt,name=_type,json=Type,proto3,enum=core.VncMsgType" json:"_type,omitempty"` + XType VncMsgType `protobuf:"varint,1,opt,name=_type,json=Type,proto3,enum=network.VncMsgType" json:"_type,omitempty"` // Types that are assignable to Payload: // *VncMsg_Data // *VncMsg_Mouse @@ -494,54 +494,55 @@ func (*VncMsg_Keyboard) isVncMsg_Payload() {} var File_vncmsg_proto protoreflect.FileDescriptor var file_vncmsg_proto_rawDesc = []byte{ - 0x0a, 0x0c, 0x76, 0x6e, 0x63, 0x6d, 0x73, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, - 0x63, 0x6f, 0x72, 0x65, 0x22, 0x84, 0x01, 0x0a, 0x0a, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x5f, 0x64, - 0x61, 0x74, 0x61, 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, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x69, 0x74, 0x73, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x0d, 0x52, 0x04, 0x62, 0x69, 0x74, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x77, 0x69, 0x64, - 0x74, 0x68, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x77, 0x69, 0x64, 0x74, 0x68, 0x12, - 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0d, 0x52, - 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, - 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0xaf, 0x01, 0x0a, 0x0a, - 0x6d, 0x6f, 0x75, 0x73, 0x65, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x12, 0x20, 0x0a, 0x04, 0x74, 0x79, - 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0c, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, - 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x29, 0x0a, 0x03, - 0x62, 0x74, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x17, 0x2e, 0x63, 0x6f, 0x72, 0x65, - 0x2e, 0x6d, 0x6f, 0x75, 0x73, 0x65, 0x5f, 0x64, 0x61, 0x74, 0x61, 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, 0x43, 0x0a, - 0x0d, 0x6b, 0x65, 0x79, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x12, 0x20, - 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0c, 0x2e, 0x63, - 0x6f, 0x72, 0x65, 0x2e, 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, 0x22, 0xa1, 0x02, 0x0a, 0x07, 0x76, 0x6e, 0x63, 0x5f, 0x6d, 0x73, 0x67, 0x12, 0x27, - 0x0a, 0x05, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x12, 0x2e, - 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x6e, 0x63, 0x5f, 0x6d, 0x73, 0x67, 0x2e, 0x74, 0x79, 0x70, - 0x65, 0x52, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x26, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x69, 0x6d, 0x61, - 0x67, 0x65, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x48, 0x00, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, - 0x28, 0x0a, 0x05, 0x6d, 0x6f, 0x75, 0x73, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, - 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x6d, 0x6f, 0x75, 0x73, 0x65, 0x5f, 0x64, 0x61, 0x74, 0x61, - 0x48, 0x00, 0x52, 0x05, 0x6d, 0x6f, 0x75, 0x73, 0x65, 0x12, 0x31, 0x0a, 0x08, 0x6b, 0x65, 0x79, - 0x62, 0x6f, 0x61, 0x72, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x63, 0x6f, - 0x72, 0x65, 0x2e, 0x6b, 0x65, 0x79, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x5f, 0x64, 0x61, 0x74, 0x61, - 0x48, 0x00, 0x52, 0x08, 0x6b, 0x65, 0x79, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x22, 0x5d, 0x0a, 0x04, - 0x74, 0x79, 0x70, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x63, 0x61, 0x70, 0x74, 0x75, 0x72, 0x65, 0x5f, - 0x72, 0x65, 0x71, 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x63, 0x61, 0x70, 0x74, 0x75, 0x72, 0x65, - 0x5f, 0x64, 0x61, 0x74, 0x61, 0x10, 0x01, 0x12, 0x0f, 0x0a, 0x0b, 0x6d, 0x6f, 0x75, 0x73, 0x65, - 0x5f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x10, 0x02, 0x12, 0x12, 0x0a, 0x0e, 0x6b, 0x65, 0x79, 0x62, - 0x6f, 0x61, 0x72, 0x64, 0x5f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x10, 0x03, 0x12, 0x0d, 0x0a, 0x09, - 0x63, 0x61, 0x64, 0x5f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x10, 0x04, 0x42, 0x09, 0x0a, 0x07, 0x70, - 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2a, 0x28, 0x0a, 0x06, 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, 0x09, 0x5a, 0x07, 0x2e, 0x2f, 0x3b, 0x63, 0x6f, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x0a, 0x0c, 0x76, 0x6e, 0x63, 0x6d, 0x73, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x07, + 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x22, 0x84, 0x01, 0x0a, 0x0a, 0x69, 0x6d, 0x61, 0x67, + 0x65, 0x5f, 0x64, 0x61, 0x74, 0x61, 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, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x69, 0x74, 0x73, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x62, 0x69, 0x74, 0x73, 0x12, 0x14, 0x0a, 0x05, + 0x77, 0x69, 0x64, 0x74, 0x68, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x77, 0x69, 0x64, + 0x74, 0x68, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x0d, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, + 0x74, 0x61, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0xb5, + 0x01, 0x0a, 0x0a, 0x6d, 0x6f, 0x75, 0x73, 0x65, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x12, 0x23, 0x0a, + 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0f, 0x2e, 0x6e, 0x65, + 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x04, 0x74, 0x79, + 0x70, 0x65, 0x12, 0x2c, 0x0a, 0x03, 0x62, 0x74, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, + 0x1a, 0x2e, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x6d, 0x6f, 0x75, 0x73, 0x65, 0x5f, + 0x64, 0x61, 0x74, 0x61, 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, 0x46, 0x0a, 0x0d, 0x6b, 0x65, 0x79, 0x62, 0x6f, 0x61, + 0x72, 0x64, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x12, 0x23, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0f, 0x2e, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, + 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, 0x22, 0xad, + 0x02, 0x0a, 0x07, 0x76, 0x6e, 0x63, 0x5f, 0x6d, 0x73, 0x67, 0x12, 0x2a, 0x0a, 0x05, 0x5f, 0x74, + 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x6e, 0x65, 0x74, 0x77, + 0x6f, 0x72, 0x6b, 0x2e, 0x76, 0x6e, 0x63, 0x5f, 0x6d, 0x73, 0x67, 0x2e, 0x74, 0x79, 0x70, 0x65, + 0x52, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x29, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x69, + 0x6d, 0x61, 0x67, 0x65, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x48, 0x00, 0x52, 0x04, 0x64, 0x61, 0x74, + 0x61, 0x12, 0x2b, 0x0a, 0x05, 0x6d, 0x6f, 0x75, 0x73, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x13, 0x2e, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x6d, 0x6f, 0x75, 0x73, 0x65, + 0x5f, 0x64, 0x61, 0x74, 0x61, 0x48, 0x00, 0x52, 0x05, 0x6d, 0x6f, 0x75, 0x73, 0x65, 0x12, 0x34, + 0x0a, 0x08, 0x6b, 0x65, 0x79, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x16, 0x2e, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x6b, 0x65, 0x79, 0x62, 0x6f, + 0x61, 0x72, 0x64, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x48, 0x00, 0x52, 0x08, 0x6b, 0x65, 0x79, 0x62, + 0x6f, 0x61, 0x72, 0x64, 0x22, 0x5d, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x0f, 0x0a, 0x0b, + 0x63, 0x61, 0x70, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x72, 0x65, 0x71, 0x10, 0x00, 0x12, 0x10, 0x0a, + 0x0c, 0x63, 0x61, 0x70, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x10, 0x01, 0x12, + 0x0f, 0x0a, 0x0b, 0x6d, 0x6f, 0x75, 0x73, 0x65, 0x5f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x10, 0x02, + 0x12, 0x12, 0x0a, 0x0e, 0x6b, 0x65, 0x79, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x5f, 0x65, 0x76, 0x65, + 0x6e, 0x74, 0x10, 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x63, 0x61, 0x64, 0x5f, 0x65, 0x76, 0x65, 0x6e, + 0x74, 0x10, 0x04, 0x42, 0x09, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2a, 0x28, + 0x0a, 0x06, 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 ( @@ -559,22 +560,22 @@ func file_vncmsg_proto_rawDescGZIP() []byte { var file_vncmsg_proto_enumTypes = make([]protoimpl.EnumInfo, 3) var file_vncmsg_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_vncmsg_proto_goTypes = []interface{}{ - (Status)(0), // 0: core.status - (MouseDataButton)(0), // 1: core.mouse_data.button - (VncMsgType)(0), // 2: core.vnc_msg.type - (*ImageData)(nil), // 3: core.image_data - (*MouseData)(nil), // 4: core.mouse_data - (*KeyboardData)(nil), // 5: core.keyboard_data - (*VncMsg)(nil), // 6: core.vnc_msg + (Status)(0), // 0: network.status + (MouseDataButton)(0), // 1: network.mouse_data.button + (VncMsgType)(0), // 2: network.vnc_msg.type + (*ImageData)(nil), // 3: network.image_data + (*MouseData)(nil), // 4: network.mouse_data + (*KeyboardData)(nil), // 5: network.keyboard_data + (*VncMsg)(nil), // 6: network.vnc_msg } var file_vncmsg_proto_depIdxs = []int32{ - 0, // 0: core.mouse_data.type:type_name -> core.status - 1, // 1: core.mouse_data.btn:type_name -> core.mouse_data.button - 0, // 2: core.keyboard_data.type:type_name -> core.status - 2, // 3: core.vnc_msg._type:type_name -> core.vnc_msg.type - 3, // 4: core.vnc_msg.data:type_name -> core.image_data - 4, // 5: core.vnc_msg.mouse:type_name -> core.mouse_data - 5, // 6: core.vnc_msg.keyboard:type_name -> core.keyboard_data + 0, // 0: network.mouse_data.type:type_name -> network.status + 1, // 1: network.mouse_data.btn:type_name -> network.mouse_data.button + 0, // 2: network.keyboard_data.type:type_name -> network.status + 2, // 3: network.vnc_msg._type:type_name -> network.vnc_msg.type + 3, // 4: network.vnc_msg.data:type_name -> network.image_data + 4, // 5: network.vnc_msg.mouse:type_name -> network.mouse_data + 5, // 6: network.vnc_msg.keyboard:type_name -> network.keyboard_data 7, // [7:7] is the sub-list for method output_type 7, // [7:7] is the sub-list for method input_type 7, // [7:7] is the sub-list for extension type_name diff --git a/code/client/tunnel/vnc/core/vncmsg.proto b/code/client/tunnel/vnc/network/vncmsg.proto similarity index 94% rename from code/client/tunnel/vnc/core/vncmsg.proto rename to code/client/tunnel/vnc/network/vncmsg.proto index 140afe8..afba688 100644 --- a/code/client/tunnel/vnc/core/vncmsg.proto +++ b/code/client/tunnel/vnc/network/vncmsg.proto @@ -1,7 +1,7 @@ syntax = "proto3"; -package core; -option go_package="./;core"; +package network; +option go_package="./;network"; message image_data { bool ok = 1; diff --git a/code/client/tunnel/vnc/core/errors.go b/code/client/tunnel/vnc/process/errors.go similarity index 86% rename from code/client/tunnel/vnc/core/errors.go rename to code/client/tunnel/vnc/process/errors.go index 07e2785..6d81011 100644 --- a/code/client/tunnel/vnc/core/errors.go +++ b/code/client/tunnel/vnc/process/errors.go @@ -1,4 +1,4 @@ -package core +package process import "errors" diff --git a/code/client/tunnel/vnc/core/process.go b/code/client/tunnel/vnc/process/process.go similarity index 91% rename from code/client/tunnel/vnc/core/process.go rename to code/client/tunnel/vnc/process/process.go index 6b9b126..1ea5dee 100644 --- a/code/client/tunnel/vnc/core/process.go +++ b/code/client/tunnel/vnc/process/process.go @@ -1,8 +1,9 @@ -package core +package process import ( "errors" "fmt" + "natpass/code/client/tunnel/vnc/network" "natpass/code/utils" "net" "net/http" @@ -23,8 +24,8 @@ const ( type Process struct { pid int srv *http.Server - chWrite chan *VncMsg - chImage chan *ImageData + chWrite chan *network.VncMsg + chImage chan *network.ImageData } func (p *Process) listenAndServe() (uint16, error) { @@ -71,13 +72,13 @@ func (p *Process) ws(w http.ResponseWriter, r *http.Request) { logging.Error("read message: %v", err) return } - var msg VncMsg + var msg network.VncMsg err = proto.Unmarshal(data, &msg) if err != nil { continue } switch msg.GetXType() { - case VncMsg_capture_data: + case network.VncMsg_capture_data: p.chImage <- msg.GetData() default: } diff --git a/code/client/tunnel/vnc/core/process_windows.go b/code/client/tunnel/vnc/process/process_windows.go similarity index 89% rename from code/client/tunnel/vnc/core/process_windows.go rename to code/client/tunnel/vnc/process/process_windows.go index bb33d5a..931c1ca 100644 --- a/code/client/tunnel/vnc/core/process_windows.go +++ b/code/client/tunnel/vnc/process/process_windows.go @@ -1,10 +1,11 @@ -package core +package process import ( "errors" "fmt" "image" - "natpass/code/client/tunnel/vnc/core/define" + "natpass/code/client/tunnel/vnc/define" + "natpass/code/client/tunnel/vnc/network" "os" "strings" "syscall" @@ -75,8 +76,8 @@ func getSessionUserTokenWin() windows.Token { return ret } -// CreateWorkerProcess create worker process -func CreateWorkerProcess(confDir string) (*Process, error) { +// CreateWorker create worker process +func CreateWorker(confDir string) (*Process, error) { tk := getSessionUserTokenWin() if tk != 0 { defer windows.CloseHandle(windows.Handle(tk)) @@ -90,8 +91,8 @@ func createWorker(confDir string, tk windows.Token) (*Process, error) { return nil, err } var p Process - p.chWrite = make(chan *VncMsg) - p.chImage = make(chan *ImageData) + p.chWrite = make(chan *network.VncMsg) + p.chImage = make(chan *network.ImageData) port, err := p.listenAndServe() if err != nil { return nil, err @@ -131,10 +132,10 @@ func (p *Process) Close() { } func (p *Process) Capture(timeout time.Duration) (*image.RGBA, error) { - var msg VncMsg - msg.XType = VncMsg_capture_req + var msg network.VncMsg + msg.XType = network.VncMsg_capture_req p.chWrite <- &msg - trans := func(data *ImageData) *image.RGBA { + trans := func(data *network.ImageData) *image.RGBA { img := image.NewRGBA(image.Rect(0, 0, int(data.GetWidth()), int(data.GetHeight()))) switch data.GetBits() { case 8: diff --git a/code/client/tunnel/vnc/core/process_xx.go b/code/client/tunnel/vnc/process/process_xx.go similarity index 67% rename from code/client/tunnel/vnc/core/process_xx.go rename to code/client/tunnel/vnc/process/process_xx.go index 2cbb2d7..60a66a9 100644 --- a/code/client/tunnel/vnc/core/process_xx.go +++ b/code/client/tunnel/vnc/process/process_xx.go @@ -1,15 +1,15 @@ //go:build !windows // +build !windows -package core +package process import ( "image" "time" ) -// CreateWorkerProcess create worker process -func CreateWorkerProcess(confDir string) (*Process, error) { +// CreateWorker create worker process +func CreateWorker(confDir string) (*Process, error) { return nil, ErrNotSupported } diff --git a/code/client/tunnel/vnc/worker.go b/code/client/tunnel/vnc/worker.go index 77d02c2..cb871ed 100644 --- a/code/client/tunnel/vnc/worker.go +++ b/code/client/tunnel/vnc/worker.go @@ -2,7 +2,7 @@ package vnc import ( "fmt" - "natpass/code/client/tunnel/vnc/core" + "natpass/code/client/tunnel/vnc/worker" "github.com/gorilla/websocket" "github.com/lwch/runtime" @@ -10,7 +10,7 @@ import ( // RunWorker run vnc worker func RunWorker(port uint16) { - worker := core.NewWorker() + worker := worker.NewWorker() if worker == nil { panic("build context failed") } diff --git a/code/client/tunnel/vnc/core/capture.go b/code/client/tunnel/vnc/worker/capture.go similarity index 63% rename from code/client/tunnel/vnc/core/capture.go rename to code/client/tunnel/vnc/worker/capture.go index 4e779d2..8e91122 100644 --- a/code/client/tunnel/vnc/core/capture.go +++ b/code/client/tunnel/vnc/worker/capture.go @@ -1,15 +1,17 @@ -package core +package worker import ( + "natpass/code/client/tunnel/vnc/network" + "github.com/gorilla/websocket" "google.golang.org/protobuf/proto" ) func captureError(conn *websocket.Conn, msg string) { - var m VncMsg - m.XType = VncMsg_capture_data - m.Payload = &VncMsg_Data{ - Data: &ImageData{ + var m network.VncMsg + m.XType = network.VncMsg_capture_data + m.Payload = &network.VncMsg_Data{ + Data: &network.ImageData{ Ok: false, Msg: msg, }, @@ -19,10 +21,10 @@ func captureError(conn *websocket.Conn, msg string) { } func captureOK(conn *websocket.Conn, bits, width, height int, data []byte) { - var msg VncMsg - msg.XType = VncMsg_capture_data - msg.Payload = &VncMsg_Data{ - Data: &ImageData{ + var msg network.VncMsg + msg.XType = network.VncMsg_capture_data + msg.Payload = &network.VncMsg_Data{ + Data: &network.ImageData{ Ok: true, Bits: uint32(bits), Width: uint32(width), diff --git a/code/client/tunnel/vnc/core/capture_windows.go b/code/client/tunnel/vnc/worker/capture_windows.go similarity index 97% rename from code/client/tunnel/vnc/core/capture_windows.go rename to code/client/tunnel/vnc/worker/capture_windows.go index edb3ef0..1c025e7 100644 --- a/code/client/tunnel/vnc/core/capture_windows.go +++ b/code/client/tunnel/vnc/worker/capture_windows.go @@ -1,8 +1,8 @@ -package core +package worker import ( "errors" - "natpass/code/client/tunnel/vnc/core/define" + "natpass/code/client/tunnel/vnc/define" "syscall" "unsafe" diff --git a/code/client/tunnel/vnc/core/capture_xx.go b/code/client/tunnel/vnc/worker/capture_xx.go similarity index 90% rename from code/client/tunnel/vnc/core/capture_xx.go rename to code/client/tunnel/vnc/worker/capture_xx.go index 8cf5414..09c604d 100644 --- a/code/client/tunnel/vnc/core/capture_xx.go +++ b/code/client/tunnel/vnc/worker/capture_xx.go @@ -1,7 +1,7 @@ //go:build !windows // +build !windows -package core +package worker import "github.com/gorilla/websocket" diff --git a/code/client/tunnel/vnc/core/worker.go b/code/client/tunnel/vnc/worker/worker.go similarity index 85% rename from code/client/tunnel/vnc/core/worker.go rename to code/client/tunnel/vnc/worker/worker.go index d30d107..10cf0d3 100644 --- a/code/client/tunnel/vnc/core/worker.go +++ b/code/client/tunnel/vnc/worker/worker.go @@ -1,6 +1,8 @@ -package core +package worker import ( + "natpass/code/client/tunnel/vnc/network" + "github.com/gorilla/websocket" "github.com/lwch/logging" "github.com/lwch/runtime" @@ -32,14 +34,14 @@ func (worker *Worker) Do(conn *websocket.Conn) { for { _, data, err := conn.ReadMessage() runtime.Assert(err) - var msg VncMsg + var msg network.VncMsg err = proto.Unmarshal(data, &msg) if err != nil { logging.Error("proto unmarshal: %v", err) continue } switch msg.GetXType() { - case VncMsg_capture_req: + case network.VncMsg_capture_req: worker.runCapture(conn) } } diff --git a/code/client/tunnel/vnc/core/worker_windows.go b/code/client/tunnel/vnc/worker/worker_windows.go similarity index 97% rename from code/client/tunnel/vnc/core/worker_windows.go rename to code/client/tunnel/vnc/worker/worker_windows.go index 22433e8..f89e937 100644 --- a/code/client/tunnel/vnc/core/worker_windows.go +++ b/code/client/tunnel/vnc/worker/worker_windows.go @@ -1,8 +1,8 @@ -package core +package worker import ( "fmt" - "natpass/code/client/tunnel/vnc/core/define" + "natpass/code/client/tunnel/vnc/define" "runtime" "syscall" diff --git a/code/client/tunnel/vnc/core/worker_xx.go b/code/client/tunnel/vnc/worker/worker_xx.go similarity index 74% rename from code/client/tunnel/vnc/core/worker_xx.go rename to code/client/tunnel/vnc/worker/worker_xx.go index 3dbe40a..3400f94 100644 --- a/code/client/tunnel/vnc/core/worker_xx.go +++ b/code/client/tunnel/vnc/worker/worker_xx.go @@ -1,6 +1,7 @@ +//go:build !windows // +build !windows -package core +package worker type workerOsBased struct { }