调整目录结构

This commit is contained in:
lwch
2021-11-01 12:00:25 +08:00
parent 31ce7dfc19
commit 062c6a5caa
18 changed files with 118 additions and 110 deletions
+3 -3
View File
@@ -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
}
@@ -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
@@ -1,7 +1,7 @@
syntax = "proto3";
package core;
option go_package="./;core";
package network;
option go_package="./;network";
message image_data {
bool ok = 1;
@@ -1,4 +1,4 @@
package core
package process
import "errors"
@@ -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:
}
@@ -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:
@@ -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
}
+2 -2
View File
@@ -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")
}
@@ -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),
@@ -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"
@@ -1,7 +1,7 @@
//go:build !windows
// +build !windows
package core
package worker
import "github.com/gorilla/websocket"
@@ -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)
}
}
@@ -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"
@@ -1,6 +1,7 @@
//go:build !windows
// +build !windows
package core
package worker
type workerOsBased struct {
}