diff --git a/CHANGELOG.md b/CHANGELOG.md index b31d4a7..44fd5a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -63,4 +63,8 @@ 1. bootstrap降版到4.6.1 2. dashboard页面支持规则类型筛选 -3. **为遵守中国法律,移除内网穿透功能**,保留shell和vnc功能不变 \ No newline at end of file +3. **为遵守中国法律,移除内网穿透功能**,保留shell和vnc功能不变 + +# v0.7.1 + +1. vnc页面支持远程设置或读取剪贴板(仅支持文本内容) \ No newline at end of file diff --git a/README.md b/README.md index 660d86e..7be4840 100644 --- a/README.md +++ b/README.md @@ -19,10 +19,19 @@ 3. 支持多路异步IO 4. 支持虚拟链路层 5. 支持链路和终端会话监控 -6. 支持web shell -7. 支持web vnc -8. 支持多种操作系统 -9. protobuf数据编码 +6. protobuf数据编码 +7. 支持web shell + - linux和mac系统支持创建pty设备和颜色输出 + - windows系统支持powershell +8. 支持web vnc + - 支持基本的键盘鼠标操作 + - 支持全屏显示 + - 支持滚动 + - 支持远程剪贴板设置与读取 +9. 支持多种操作系统 + - [x] linux + - [x] windows + - [x] macos ## 效果图 @@ -50,6 +59,10 @@ windows11远程桌面  +windows读取剪贴板内容 + + + ## TODO 1. ~~支持include的yaml配置文件~~ @@ -72,4 +85,8 @@ windows11远程桌面 1. 严禁用于黑客攻击、远程控制他人计算机等违法违规行为 2. 软件使用者使用该软件造成的任何损失均与软件作者无关, 一切后果由使用者自己负责 -3. 严禁用于一切商业用途,包括但不限于提供云桌面、云主机等 \ No newline at end of file +3. 严禁用于一切商业用途,包括但不限于提供云桌面、云主机等 + +## 贡献代码 + +为了更好的发展,我们鼓励大家为natpass项目做出贡献及提出建议,项目的地址为[https://github.com/lwch/natpass](https://github.com/lwch/natpass),因此在gitee上提交的pr将不被接受,请大家将pr提交到github的同名项目中。 \ No newline at end of file diff --git a/build b/build index 49d941f..188cf3f 100755 --- a/build +++ b/build @@ -1,6 +1,6 @@ #!/bin/sh -VERSION=0.7.0 +VERSION=0.7.1 DOCKER_BUILDKIT=1 docker build -t natpass -f contrib/build/Dockerfile . docker run --rm \ diff --git a/build_all b/build_all index 62e15ae..f1f0def 100755 --- a/build_all +++ b/build_all @@ -1,6 +1,6 @@ #!/bin/sh -VERSION=0.7.0 +VERSION=0.7.1 DOCKER_BUILDKIT=1 docker build -t natpass -f contrib/build/Dockerfile . docker run --rm \ diff --git a/code/client/global/conf.go b/code/client/global/conf.go index 696e264..14cbf44 100644 --- a/code/client/global/conf.go +++ b/code/client/global/conf.go @@ -12,13 +12,11 @@ import ( // Rule rule config type Rule struct { - Name string `yaml:"name"` - Target string `yaml:"target"` - Type string `yaml:"type"` - LocalAddr string `yaml:"local_addr"` - LocalPort uint16 `yaml:"local_port"` - RemoteAddr string `yaml:"remote_addr"` - RemotePort uint16 `yaml:"remote_port"` + Name string `yaml:"name"` + Target string `yaml:"target"` + Type string `yaml:"type"` + LocalAddr string `yaml:"local_addr"` + LocalPort uint16 `yaml:"local_port"` // shell Exec string `yaml:"exec"` Env []string `yaml:"env"` diff --git a/code/client/pool/send_vnc.go b/code/client/pool/send_vnc.go index 4cefaa8..3d5875b 100644 --- a/code/client/pool/send_vnc.go +++ b/code/client/pool/send_vnc.go @@ -154,3 +154,25 @@ func (conn *Conn) SendVNCScroll(to string, toIdx uint32, id string, x, y int32) case <-time.After(conn.parent.cfg.WriteTimeout): } } + +// SendVNCClipboardData send vnc clipboard data +func (conn *Conn) SendVNCClipboardData(to string, toIdx uint32, id string, set bool, data string) { + var msg network.Msg + msg.To = to + msg.ToIdx = toIdx + msg.XType = network.Msg_vnc_clipboard + msg.LinkId = id + msg.Payload = &network.Msg_Vclipboard{ + Vclipboard: &network.VncClipboard{ + Set: set, + XType: network.VncClipboard_text, + Payload: &network.VncClipboard_Data{ + Data: data, + }, + }, + } + select { + case conn.write <- &msg: + case <-time.After(conn.parent.cfg.WriteTimeout): + } +} diff --git a/code/client/rule/vnc/h_clipboard.go b/code/client/rule/vnc/h_clipboard.go new file mode 100644 index 0000000..3272f00 --- /dev/null +++ b/code/client/rule/vnc/h_clipboard.go @@ -0,0 +1,38 @@ +package vnc + +import ( + "fmt" + "natpass/code/client/pool" + "net/http" +) + +// Clipboard get/set clipboard +func (v *VNC) Clipboard(pool *pool.Pool, w http.ResponseWriter, r *http.Request) { + if r.Method == http.MethodGet { + v.getClipboard(pool, w, r) + return + } + v.setClipboard(pool, w, r) +} + +func (v *VNC) getClipboard(pool *pool.Pool, w http.ResponseWriter, r *http.Request) { + if v.link == nil { + http.NotFound(w, r) + return + } + conn := pool.Get(v.link.id) + conn.SendVNCClipboardData(v.link.target, v.link.targetIdx, v.link.id, false, "") + data := <-v.chClipboard + fmt.Fprint(w, data.GetData()) +} + +func (v *VNC) setClipboard(pool *pool.Pool, w http.ResponseWriter, r *http.Request) { + data := r.FormValue("data") + if v.link == nil { + http.NotFound(w, r) + return + } + conn := pool.Get(v.link.id) + conn.SendVNCClipboardData(v.link.target, v.link.targetIdx, v.link.id, true, data) + fmt.Fprint(w, "ok") +} diff --git a/code/client/rule/vnc/h_ws.go b/code/client/rule/vnc/h_ws.go index 90279e9..1329ebc 100644 --- a/code/client/rule/vnc/h_ws.go +++ b/code/client/rule/vnc/h_ws.go @@ -71,6 +71,8 @@ func (v *VNC) remoteRead(ctx context.Context, ch <-chan *network.Msg, local *web data, err := decodeImage(msg.GetVimg()) runtime.Assert(err) replyImage(local, msg.GetVimg(), data, len(msg.GetVimg().GetData())) + case network.Msg_vnc_clipboard: + v.chClipboard <- msg.GetVclipboard() default: logging.Error("on message: %s", msg.GetXType().String()) return diff --git a/code/client/rule/vnc/link.go b/code/client/rule/vnc/link.go index 462048f..fc0f638 100644 --- a/code/client/rule/vnc/link.go +++ b/code/client/rule/vnc/link.go @@ -109,6 +109,13 @@ func (link *Link) remoteRead() { link.ps.CADEvent() case network.Msg_vnc_scroll: link.ps.ScrollEvent(msg.GetVscroll()) + case network.Msg_vnc_clipboard: + if msg.GetVclipboard().GetSet() { + link.ps.SetClipboard(msg.GetVclipboard()) + } else { + data := link.ps.GetClipboard() + link.remote.SendVNCClipboardData(link.target, link.targetIdx, link.id, true, data) + } case network.Msg_disconnect: logging.Info("link %s disconnected", link.id) return diff --git a/code/client/rule/vnc/process/event.go b/code/client/rule/vnc/process/event.go index aab92e4..92c9b44 100644 --- a/code/client/rule/vnc/process/event.go +++ b/code/client/rule/vnc/process/event.go @@ -78,3 +78,42 @@ func (p *Process) ScrollEvent(data *network.VncScroll) { } p.chWrite <- &msg } + +// SetClipboard set clipboard data to child process +func (p *Process) SetClipboard(data *network.VncClipboard) { + t := vncnetwork.ClipboardData_unset_type + var payload vncnetwork.ClipboardData_Data + switch data.GetXType() { + case network.VncClipboard_file: + t = vncnetwork.ClipboardData_file + case network.VncClipboard_image: + t = vncnetwork.ClipboardData_image + case network.VncClipboard_text: + t = vncnetwork.ClipboardData_text + payload.Data = data.GetData() + } + var msg vncnetwork.VncMsg + msg.XType = vncnetwork.VncMsg_clipboard_event + msg.Payload = &vncnetwork.VncMsg_Clipboard{ + Clipboard: &vncnetwork.ClipboardData{ + Set: data.GetSet(), + XType: t, + Payload: &payload, + }, + } + p.chWrite <- &msg +} + +// GetClipboard get clipboard data from child process +func (p *Process) GetClipboard() string { + var msg vncnetwork.VncMsg + msg.XType = vncnetwork.VncMsg_clipboard_event + msg.Payload = &vncnetwork.VncMsg_Clipboard{ + Clipboard: &vncnetwork.ClipboardData{ + Set: false, + }, + } + p.chWrite <- &msg + data := <-p.chClipboard + return data.GetData() +} diff --git a/code/client/rule/vnc/process/process.go b/code/client/rule/vnc/process/process.go index a85d3f8..722b7fe 100644 --- a/code/client/rule/vnc/process/process.go +++ b/code/client/rule/vnc/process/process.go @@ -22,10 +22,11 @@ const ( // Process process type Process struct { - pid int - srv *http.Server - chWrite chan *vncnetwork.VncMsg - chImage chan *vncnetwork.ImageData + pid int + srv *http.Server + chWrite chan *vncnetwork.VncMsg + chImage chan *vncnetwork.ImageData + chClipboard chan *vncnetwork.ClipboardData } func (p *Process) listenAndServe() (uint16, error) { @@ -80,6 +81,8 @@ func (p *Process) ws(w http.ResponseWriter, r *http.Request) { switch msg.GetXType() { case vncnetwork.VncMsg_capture_data: p.chImage <- msg.GetData() + case vncnetwork.VncMsg_clipboard_event: + p.chClipboard <- msg.GetClipboard() default: } } diff --git a/code/client/rule/vnc/process/process_windows.go b/code/client/rule/vnc/process/process_windows.go index ca19e84..9f6204d 100644 --- a/code/client/rule/vnc/process/process_windows.go +++ b/code/client/rule/vnc/process/process_windows.go @@ -95,6 +95,7 @@ func createWorker(name, confDir string, tk windows.Token, showCursor bool) (*Pro var p Process p.chWrite = make(chan *vncnetwork.VncMsg) p.chImage = make(chan *vncnetwork.ImageData) + p.chClipboard = make(chan *vncnetwork.ClipboardData) port, err := p.listenAndServe() if err != nil { return nil, err @@ -132,6 +133,10 @@ func (p *Process) Close() { close(p.chImage) p.chImage = nil } + if p.chClipboard != nil { + close(p.chClipboard) + p.chClipboard = nil + } if p.chWrite != nil { close(p.chWrite) p.chWrite = nil diff --git a/code/client/rule/vnc/vnc.go b/code/client/rule/vnc/vnc.go index 3daa795..61d0688 100644 --- a/code/client/rule/vnc/vnc.go +++ b/code/client/rule/vnc/vnc.go @@ -5,6 +5,7 @@ import ( "natpass/code/client/global" "natpass/code/client/pool" "natpass/code/client/rule" + "natpass/code/network" "net" "net/http" "sync" @@ -16,16 +17,18 @@ import ( // VNC vnc handler type VNC struct { sync.RWMutex - Name string - cfg global.Rule - link *Link + Name string + cfg global.Rule + link *Link + chClipboard chan *network.VncClipboard } // New new vnc func New(cfg global.Rule) *VNC { return &VNC{ - Name: cfg.Name, - cfg: cfg, + Name: cfg.Name, + cfg: cfg, + chClipboard: make(chan *network.VncClipboard), } } @@ -96,6 +99,7 @@ func (v *VNC) Handle(pl *pool.Pool) { mux := http.NewServeMux() mux.HandleFunc("/new", pf(v.New)) mux.HandleFunc("/ctrl", pf(v.Ctrl)) + mux.HandleFunc("/clipboard", pf(v.Clipboard)) mux.HandleFunc("/ws/", pf(v.WS)) mux.HandleFunc("/", v.Render) svr := &http.Server{ diff --git a/code/client/rule/vnc/vncnetwork/vncmsg.pb.go b/code/client/rule/vnc/vncnetwork/vncmsg.pb.go index f569f3c..9ce0e30 100644 --- a/code/client/rule/vnc/vncnetwork/vncmsg.pb.go +++ b/code/client/rule/vnc/vncnetwork/vncmsg.pb.go @@ -121,15 +121,68 @@ func (MouseDataButton) EnumDescriptor() ([]byte, []int) { return file_vncmsg_proto_rawDescGZIP(), []int{1, 0} } +type ClipboardDataType int32 + +const ( + ClipboardData_unset_type ClipboardDataType = 0 + ClipboardData_text ClipboardDataType = 1 + ClipboardData_image ClipboardDataType = 2 + ClipboardData_file ClipboardDataType = 3 +) + +// Enum value maps for ClipboardDataType. +var ( + ClipboardDataType_name = map[int32]string{ + 0: "unset_type", + 1: "text", + 2: "image", + 3: "file", + } + ClipboardDataType_value = map[string]int32{ + "unset_type": 0, + "text": 1, + "image": 2, + "file": 3, + } +) + +func (x ClipboardDataType) Enum() *ClipboardDataType { + p := new(ClipboardDataType) + *p = x + return p +} + +func (x ClipboardDataType) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (ClipboardDataType) Descriptor() protoreflect.EnumDescriptor { + return file_vncmsg_proto_enumTypes[2].Descriptor() +} + +func (ClipboardDataType) Type() protoreflect.EnumType { + return &file_vncmsg_proto_enumTypes[2] +} + +func (x ClipboardDataType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use ClipboardDataType.Descriptor instead. +func (ClipboardDataType) EnumDescriptor() ([]byte, []int) { + return file_vncmsg_proto_rawDescGZIP(), []int{4, 0} +} + type VncMsgType int32 const ( - VncMsg_capture_req VncMsgType = 0 - VncMsg_capture_data VncMsgType = 1 - VncMsg_mouse_event VncMsgType = 2 - VncMsg_keyboard_event VncMsgType = 3 - VncMsg_set_cursor VncMsgType = 4 - VncMsg_scroll_event VncMsgType = 5 + VncMsg_capture_req VncMsgType = 0 + VncMsg_capture_data VncMsgType = 1 + VncMsg_mouse_event VncMsgType = 2 + VncMsg_keyboard_event VncMsgType = 3 + VncMsg_set_cursor VncMsgType = 4 + VncMsg_scroll_event VncMsgType = 5 + VncMsg_clipboard_event VncMsgType = 6 ) // Enum value maps for VncMsgType. @@ -141,14 +194,16 @@ var ( 3: "keyboard_event", 4: "set_cursor", 5: "scroll_event", + 6: "clipboard_event", } VncMsgType_value = map[string]int32{ - "capture_req": 0, - "capture_data": 1, - "mouse_event": 2, - "keyboard_event": 3, - "set_cursor": 4, - "scroll_event": 5, + "capture_req": 0, + "capture_data": 1, + "mouse_event": 2, + "keyboard_event": 3, + "set_cursor": 4, + "scroll_event": 5, + "clipboard_event": 6, } ) @@ -163,11 +218,11 @@ func (x VncMsgType) String() string { } func (VncMsgType) Descriptor() protoreflect.EnumDescriptor { - return file_vncmsg_proto_enumTypes[2].Descriptor() + return file_vncmsg_proto_enumTypes[3].Descriptor() } func (VncMsgType) Type() protoreflect.EnumType { - return &file_vncmsg_proto_enumTypes[2] + return &file_vncmsg_proto_enumTypes[3] } func (x VncMsgType) Number() protoreflect.EnumNumber { @@ -176,7 +231,7 @@ func (x VncMsgType) Number() protoreflect.EnumNumber { // Deprecated: Use VncMsgType.Descriptor instead. func (VncMsgType) EnumDescriptor() ([]byte, []int) { - return file_vncmsg_proto_rawDescGZIP(), []int{4, 0} + return file_vncmsg_proto_rawDescGZIP(), []int{5, 0} } type ImageData struct { @@ -447,6 +502,88 @@ func (x *ScrollData) GetY() int32 { return 0 } +type ClipboardData struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Set bool `protobuf:"varint,1,opt,name=set,proto3" json:"set,omitempty"` + XType ClipboardDataType `protobuf:"varint,2,opt,name=_type,json=Type,proto3,enum=vncnetwork.ClipboardDataType" json:"_type,omitempty"` + // Types that are assignable to Payload: + // *ClipboardData_Data + Payload isClipboardData_Payload `protobuf_oneof:"payload"` +} + +func (x *ClipboardData) Reset() { + *x = ClipboardData{} + if protoimpl.UnsafeEnabled { + mi := &file_vncmsg_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ClipboardData) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ClipboardData) ProtoMessage() {} + +func (x *ClipboardData) ProtoReflect() protoreflect.Message { + mi := &file_vncmsg_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ClipboardData.ProtoReflect.Descriptor instead. +func (*ClipboardData) Descriptor() ([]byte, []int) { + return file_vncmsg_proto_rawDescGZIP(), []int{4} +} + +func (x *ClipboardData) GetSet() bool { + if x != nil { + return x.Set + } + return false +} + +func (x *ClipboardData) GetXType() ClipboardDataType { + if x != nil { + return x.XType + } + return ClipboardData_unset_type +} + +func (m *ClipboardData) GetPayload() isClipboardData_Payload { + if m != nil { + return m.Payload + } + return nil +} + +func (x *ClipboardData) GetData() string { + if x, ok := x.GetPayload().(*ClipboardData_Data); ok { + return x.Data + } + return "" +} + +type isClipboardData_Payload interface { + isClipboardData_Payload() +} + +type ClipboardData_Data struct { + Data string `protobuf:"bytes,10,opt,name=data,proto3,oneof"` // text data +} + +func (*ClipboardData_Data) isClipboardData_Payload() {} + type VncMsg struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -459,13 +596,14 @@ type VncMsg struct { // *VncMsg_Keyboard // *VncMsg_ShowCursor // *VncMsg_Scroll + // *VncMsg_Clipboard Payload isVncMsg_Payload `protobuf_oneof:"payload"` } func (x *VncMsg) Reset() { *x = VncMsg{} if protoimpl.UnsafeEnabled { - mi := &file_vncmsg_proto_msgTypes[4] + mi := &file_vncmsg_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -478,7 +616,7 @@ func (x *VncMsg) String() string { func (*VncMsg) ProtoMessage() {} func (x *VncMsg) ProtoReflect() protoreflect.Message { - mi := &file_vncmsg_proto_msgTypes[4] + mi := &file_vncmsg_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -491,7 +629,7 @@ func (x *VncMsg) ProtoReflect() protoreflect.Message { // Deprecated: Use VncMsg.ProtoReflect.Descriptor instead. func (*VncMsg) Descriptor() ([]byte, []int) { - return file_vncmsg_proto_rawDescGZIP(), []int{4} + return file_vncmsg_proto_rawDescGZIP(), []int{5} } func (x *VncMsg) GetXType() VncMsgType { @@ -543,6 +681,13 @@ func (x *VncMsg) GetScroll() *ScrollData { return nil } +func (x *VncMsg) GetClipboard() *ClipboardData { + if x, ok := x.GetPayload().(*VncMsg_Clipboard); ok { + return x.Clipboard + } + return nil +} + type isVncMsg_Payload interface { isVncMsg_Payload() } @@ -567,6 +712,10 @@ type VncMsg_Scroll struct { Scroll *ScrollData `protobuf:"bytes,6,opt,name=scroll,proto3,oneof"` } +type VncMsg_Clipboard struct { + Clipboard *ClipboardData `protobuf:"bytes,7,opt,name=clipboard,proto3,oneof"` +} + func (*VncMsg_Data) isVncMsg_Payload() {} func (*VncMsg_Mouse) isVncMsg_Payload() {} @@ -577,6 +726,8 @@ func (*VncMsg_ShowCursor) isVncMsg_Payload() {} func (*VncMsg_Scroll) isVncMsg_Payload() {} +func (*VncMsg_Clipboard) isVncMsg_Payload() {} + var File_vncmsg_proto protoreflect.FileDescriptor var file_vncmsg_proto_rawDesc = []byte{ @@ -609,37 +760,54 @@ var file_vncmsg_proto_rawDesc = []byte{ 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x22, 0x29, 0x0a, 0x0b, 0x73, 0x63, 0x72, 0x6f, 0x6c, 0x6c, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x01, 0x79, 0x22, 0xa2, 0x03, 0x0a, 0x07, 0x76, 0x6e, 0x63, 0x5f, 0x6d, 0x73, - 0x67, 0x12, 0x2d, 0x0a, 0x05, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, - 0x32, 0x18, 0x2e, 0x76, 0x6e, 0x63, 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, 0x2c, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, - 0x2e, 0x76, 0x6e, 0x63, 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, 0x2e, - 0x0a, 0x05, 0x6d, 0x6f, 0x75, 0x73, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, - 0x76, 0x6e, 0x63, 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, 0x37, - 0x0a, 0x08, 0x6b, 0x65, 0x79, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x19, 0x2e, 0x76, 0x6e, 0x63, 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, 0x12, 0x21, 0x0a, 0x0b, 0x73, 0x68, 0x6f, 0x77, 0x5f, - 0x63, 0x75, 0x72, 0x73, 0x6f, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x0a, - 0x73, 0x68, 0x6f, 0x77, 0x43, 0x75, 0x72, 0x73, 0x6f, 0x72, 0x12, 0x31, 0x0a, 0x06, 0x73, 0x63, - 0x72, 0x6f, 0x6c, 0x6c, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x76, 0x6e, 0x63, - 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x73, 0x63, 0x72, 0x6f, 0x6c, 0x6c, 0x5f, 0x64, - 0x61, 0x74, 0x61, 0x48, 0x00, 0x52, 0x06, 0x73, 0x63, 0x72, 0x6f, 0x6c, 0x6c, 0x22, 0x70, 0x0a, + 0x28, 0x05, 0x52, 0x01, 0x79, 0x22, 0xb0, 0x01, 0x0a, 0x0e, 0x63, 0x6c, 0x69, 0x70, 0x62, 0x6f, + 0x61, 0x72, 0x64, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x65, 0x74, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x03, 0x73, 0x65, 0x74, 0x12, 0x34, 0x0a, 0x05, 0x5f, 0x74, + 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1f, 0x2e, 0x76, 0x6e, 0x63, 0x6e, + 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x63, 0x6c, 0x69, 0x70, 0x62, 0x6f, 0x61, 0x72, 0x64, + 0x5f, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x52, 0x04, 0x54, 0x79, 0x70, 0x65, + 0x12, 0x14, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, + 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x35, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x0e, + 0x0a, 0x0a, 0x75, 0x6e, 0x73, 0x65, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x10, 0x00, 0x12, 0x08, + 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x69, 0x6d, 0x61, 0x67, + 0x65, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x66, 0x69, 0x6c, 0x65, 0x10, 0x03, 0x42, 0x09, 0x0a, + 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x22, 0xf4, 0x03, 0x0a, 0x07, 0x76, 0x6e, 0x63, + 0x5f, 0x6d, 0x73, 0x67, 0x12, 0x2d, 0x0a, 0x05, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x76, 0x6e, 0x63, 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, 0x2c, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x16, 0x2e, 0x76, 0x6e, 0x63, 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, 0x2e, 0x0a, 0x05, 0x6d, 0x6f, 0x75, 0x73, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x16, 0x2e, 0x76, 0x6e, 0x63, 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, 0x37, 0x0a, 0x08, 0x6b, 0x65, 0x79, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x76, 0x6e, 0x63, 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, 0x12, 0x21, 0x0a, 0x0b, 0x73, 0x68, + 0x6f, 0x77, 0x5f, 0x63, 0x75, 0x72, 0x73, 0x6f, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x48, + 0x00, 0x52, 0x0a, 0x73, 0x68, 0x6f, 0x77, 0x43, 0x75, 0x72, 0x73, 0x6f, 0x72, 0x12, 0x31, 0x0a, + 0x06, 0x73, 0x63, 0x72, 0x6f, 0x6c, 0x6c, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, + 0x76, 0x6e, 0x63, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x73, 0x63, 0x72, 0x6f, 0x6c, + 0x6c, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x48, 0x00, 0x52, 0x06, 0x73, 0x63, 0x72, 0x6f, 0x6c, 0x6c, + 0x12, 0x3a, 0x0a, 0x09, 0x63, 0x6c, 0x69, 0x70, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x18, 0x07, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x76, 0x6e, 0x63, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, + 0x2e, 0x63, 0x6c, 0x69, 0x70, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x48, + 0x00, 0x52, 0x09, 0x63, 0x6c, 0x69, 0x70, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x22, 0x85, 0x01, 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, 0x0e, 0x0a, 0x0a, 0x73, 0x65, 0x74, 0x5f, 0x63, 0x75, 0x72, 0x73, 0x6f, 0x72, 0x10, 0x04, 0x12, 0x10, 0x0a, - 0x0c, 0x73, 0x63, 0x72, 0x6f, 0x6c, 0x6c, 0x5f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x10, 0x05, 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, 0x0f, 0x5a, 0x0d, 0x2e, 0x2f, 0x3b, 0x76, 0x6e, 0x63, 0x6e, 0x65, - 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x0c, 0x73, 0x63, 0x72, 0x6f, 0x6c, 0x6c, 0x5f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x10, 0x05, 0x12, + 0x13, 0x0a, 0x0f, 0x63, 0x6c, 0x69, 0x70, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x5f, 0x65, 0x76, 0x65, + 0x6e, 0x74, 0x10, 0x06, 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, 0x0f, 0x5a, 0x0d, 0x2e, 0x2f, 0x3b, + 0x76, 0x6e, 0x63, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( @@ -654,32 +822,36 @@ func file_vncmsg_proto_rawDescGZIP() []byte { return file_vncmsg_proto_rawDescData } -var file_vncmsg_proto_enumTypes = make([]protoimpl.EnumInfo, 3) -var file_vncmsg_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_vncmsg_proto_enumTypes = make([]protoimpl.EnumInfo, 4) +var file_vncmsg_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_vncmsg_proto_goTypes = []interface{}{ - (Status)(0), // 0: vncnetwork.status - (MouseDataButton)(0), // 1: vncnetwork.mouse_data.button - (VncMsgType)(0), // 2: vncnetwork.vnc_msg.type - (*ImageData)(nil), // 3: vncnetwork.image_data - (*MouseData)(nil), // 4: vncnetwork.mouse_data - (*KeyboardData)(nil), // 5: vncnetwork.keyboard_data - (*ScrollData)(nil), // 6: vncnetwork.scroll_data - (*VncMsg)(nil), // 7: vncnetwork.vnc_msg + (Status)(0), // 0: vncnetwork.status + (MouseDataButton)(0), // 1: vncnetwork.mouse_data.button + (ClipboardDataType)(0), // 2: vncnetwork.clipboard_data.type + (VncMsgType)(0), // 3: vncnetwork.vnc_msg.type + (*ImageData)(nil), // 4: vncnetwork.image_data + (*MouseData)(nil), // 5: vncnetwork.mouse_data + (*KeyboardData)(nil), // 6: vncnetwork.keyboard_data + (*ScrollData)(nil), // 7: vncnetwork.scroll_data + (*ClipboardData)(nil), // 8: vncnetwork.clipboard_data + (*VncMsg)(nil), // 9: vncnetwork.vnc_msg } var file_vncmsg_proto_depIdxs = []int32{ - 0, // 0: vncnetwork.mouse_data.type:type_name -> vncnetwork.status - 1, // 1: vncnetwork.mouse_data.btn:type_name -> vncnetwork.mouse_data.button - 0, // 2: vncnetwork.keyboard_data.type:type_name -> vncnetwork.status - 2, // 3: vncnetwork.vnc_msg._type:type_name -> vncnetwork.vnc_msg.type - 3, // 4: vncnetwork.vnc_msg.data:type_name -> vncnetwork.image_data - 4, // 5: vncnetwork.vnc_msg.mouse:type_name -> vncnetwork.mouse_data - 5, // 6: vncnetwork.vnc_msg.keyboard:type_name -> vncnetwork.keyboard_data - 6, // 7: vncnetwork.vnc_msg.scroll:type_name -> vncnetwork.scroll_data - 8, // [8:8] is the sub-list for method output_type - 8, // [8:8] is the sub-list for method input_type - 8, // [8:8] is the sub-list for extension type_name - 8, // [8:8] is the sub-list for extension extendee - 0, // [0:8] is the sub-list for field type_name + 0, // 0: vncnetwork.mouse_data.type:type_name -> vncnetwork.status + 1, // 1: vncnetwork.mouse_data.btn:type_name -> vncnetwork.mouse_data.button + 0, // 2: vncnetwork.keyboard_data.type:type_name -> vncnetwork.status + 2, // 3: vncnetwork.clipboard_data._type:type_name -> vncnetwork.clipboard_data.type + 3, // 4: vncnetwork.vnc_msg._type:type_name -> vncnetwork.vnc_msg.type + 4, // 5: vncnetwork.vnc_msg.data:type_name -> vncnetwork.image_data + 5, // 6: vncnetwork.vnc_msg.mouse:type_name -> vncnetwork.mouse_data + 6, // 7: vncnetwork.vnc_msg.keyboard:type_name -> vncnetwork.keyboard_data + 7, // 8: vncnetwork.vnc_msg.scroll:type_name -> vncnetwork.scroll_data + 8, // 9: vncnetwork.vnc_msg.clipboard:type_name -> vncnetwork.clipboard_data + 10, // [10:10] is the sub-list for method output_type + 10, // [10:10] is the sub-list for method input_type + 10, // [10:10] is the sub-list for extension type_name + 10, // [10:10] is the sub-list for extension extendee + 0, // [0:10] is the sub-list for field type_name } func init() { file_vncmsg_proto_init() } @@ -737,6 +909,18 @@ func file_vncmsg_proto_init() { } } file_vncmsg_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ClipboardData); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_vncmsg_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*VncMsg); i { case 0: return &v.state @@ -750,19 +934,23 @@ func file_vncmsg_proto_init() { } } file_vncmsg_proto_msgTypes[4].OneofWrappers = []interface{}{ + (*ClipboardData_Data)(nil), + } + file_vncmsg_proto_msgTypes[5].OneofWrappers = []interface{}{ (*VncMsg_Data)(nil), (*VncMsg_Mouse)(nil), (*VncMsg_Keyboard)(nil), (*VncMsg_ShowCursor)(nil), (*VncMsg_Scroll)(nil), + (*VncMsg_Clipboard)(nil), } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_vncmsg_proto_rawDesc, - NumEnums: 3, - NumMessages: 5, + NumEnums: 4, + NumMessages: 6, NumExtensions: 0, NumServices: 0, }, diff --git a/code/client/rule/vnc/vncnetwork/vncmsg.proto b/code/client/rule/vnc/vncnetwork/vncmsg.proto index 0cb74ed..c7a32f5 100644 --- a/code/client/rule/vnc/vncnetwork/vncmsg.proto +++ b/code/client/rule/vnc/vncnetwork/vncmsg.proto @@ -41,21 +41,38 @@ message scroll_data { int32 y = 2; } +message clipboard_data { + enum type { + unset_type = 0; + text = 1; + image = 2; + file = 3; + } + bool set = 1; + type _type = 2; + oneof payload { + string data = 10; // text data + // TODO + } +} + message vnc_msg { enum type { - capture_req = 0; - capture_data = 1; - mouse_event = 2; - keyboard_event = 3; - set_cursor = 4; - scroll_event = 5; + capture_req = 0; + capture_data = 1; + mouse_event = 2; + keyboard_event = 3; + set_cursor = 4; + scroll_event = 5; + clipboard_event = 6; } type _type = 1; oneof payload { - image_data data = 2; - mouse_data mouse = 3; - keyboard_data keyboard = 4; - bool show_cursor = 5; - scroll_data scroll = 6; + image_data data = 2; + mouse_data mouse = 3; + keyboard_data keyboard = 4; + bool show_cursor = 5; + scroll_data scroll = 6; + clipboard_data clipboard = 7; } } \ No newline at end of file diff --git a/code/client/rule/vnc/worker/event.go b/code/client/rule/vnc/worker/event.go index 28e51aa..471d360 100644 --- a/code/client/rule/vnc/worker/event.go +++ b/code/client/rule/vnc/worker/event.go @@ -3,7 +3,11 @@ package worker -import "natpass/code/client/rule/vnc/vncnetwork" +import ( + "natpass/code/client/rule/vnc/vncnetwork" + + "github.com/gorilla/websocket" +) func runMouse(data *vncnetwork.MouseData) { } @@ -13,3 +17,6 @@ func runKeyboard(data *vncnetwork.KeyboardData) { func runScroll(data *vncnetwork.ScrollData) { } + +func runClipboard(conn *websocket.Conn, data *vncnetwork.ClipboardData) { +} diff --git a/code/client/rule/vnc/worker/event_auto.go b/code/client/rule/vnc/worker/event_auto.go index e649183..bc4ed4e 100644 --- a/code/client/rule/vnc/worker/event_auto.go +++ b/code/client/rule/vnc/worker/event_auto.go @@ -7,7 +7,9 @@ import ( "natpass/code/client/rule/vnc/vncnetwork" "github.com/go-vgo/robotgo" + "github.com/gorilla/websocket" "github.com/lwch/logging" + "google.golang.org/protobuf/proto" ) func runMouse(data *vncnetwork.MouseData) { @@ -59,3 +61,43 @@ func runScroll(data *vncnetwork.ScrollData) { defer detach() robotgo.Scroll(int(data.X), int(data.Y), 1) } + +func runClipboard(conn *websocket.Conn, data *vncnetwork.ClipboardData) { + detach, err := attachDesktop() + if err != nil { + logging.Error("attach desktop: %v", err) + return + } + defer detach() + if data.GetSet() { + setClipboard(data) + } else { + getClipboard(conn) + } +} + +func setClipboard(data *vncnetwork.ClipboardData) { + switch data.GetXType() { + case vncnetwork.ClipboardData_file: + case vncnetwork.ClipboardData_image: + case vncnetwork.ClipboardData_text: + robotgo.WriteAll(data.GetData()) + } +} + +func getClipboard(conn *websocket.Conn) { + data, _ := robotgo.ReadAll() + var msg vncnetwork.VncMsg + msg.XType = vncnetwork.VncMsg_clipboard_event + msg.Payload = &vncnetwork.VncMsg_Clipboard{ + Clipboard: &vncnetwork.ClipboardData{ + Set: true, + XType: vncnetwork.ClipboardData_text, + Payload: &vncnetwork.ClipboardData_Data{ + Data: data, + }, + }, + } + enc, _ := proto.Marshal(&msg) + conn.WriteMessage(websocket.BinaryMessage, enc) +} diff --git a/code/client/rule/vnc/worker/worker.go b/code/client/rule/vnc/worker/worker.go index 2f5ea2a..183468a 100644 --- a/code/client/rule/vnc/worker/worker.go +++ b/code/client/rule/vnc/worker/worker.go @@ -72,6 +72,8 @@ func (worker *Worker) Do(conn *websocket.Conn) { worker.showCursor = msg.GetShowCursor() case vncnetwork.VncMsg_scroll_event: runScroll(msg.GetScroll()) + case vncnetwork.VncMsg_clipboard_event: + runClipboard(conn, msg.GetClipboard()) } } } diff --git a/code/network/msg.pb.go b/code/network/msg.pb.go index d0202fb..66055a7 100644 --- a/code/network/msg.pb.go +++ b/code/network/msg.pb.go @@ -34,12 +34,13 @@ const ( Msg_shell_resize MsgType = 10 Msg_shell_data MsgType = 11 // vnc - Msg_vnc_ctrl MsgType = 20 - Msg_vnc_image MsgType = 21 - Msg_vnc_mouse MsgType = 22 - Msg_vnc_keyboard MsgType = 23 - Msg_vnc_cad MsgType = 24 // ctrl+alt+del - Msg_vnc_scroll MsgType = 25 + Msg_vnc_ctrl MsgType = 20 + Msg_vnc_image MsgType = 21 + Msg_vnc_mouse MsgType = 22 + Msg_vnc_keyboard MsgType = 23 + Msg_vnc_cad MsgType = 24 // ctrl+alt+del + Msg_vnc_scroll MsgType = 25 + Msg_vnc_clipboard MsgType = 26 ) // Enum value maps for MsgType. @@ -60,23 +61,25 @@ var ( 23: "vnc_keyboard", 24: "vnc_cad", 25: "vnc_scroll", + 26: "vnc_clipboard", } MsgType_value = map[string]int32{ - "unknown": 0, - "handshake": 1, - "keepalive": 2, - "connect_req": 3, - "connect_rep": 4, - "disconnect": 5, - "forward": 6, - "shell_resize": 10, - "shell_data": 11, - "vnc_ctrl": 20, - "vnc_image": 21, - "vnc_mouse": 22, - "vnc_keyboard": 23, - "vnc_cad": 24, - "vnc_scroll": 25, + "unknown": 0, + "handshake": 1, + "keepalive": 2, + "connect_req": 3, + "connect_rep": 4, + "disconnect": 5, + "forward": 6, + "shell_resize": 10, + "shell_data": 11, + "vnc_ctrl": 20, + "vnc_image": 21, + "vnc_mouse": 22, + "vnc_keyboard": 23, + "vnc_cad": 24, + "vnc_scroll": 25, + "vnc_clipboard": 26, } ) @@ -177,6 +180,7 @@ type Msg struct { // *Msg_Vmouse // *Msg_Vkbd // *Msg_Vscroll + // *Msg_Vclipboard Payload isMsg_Payload `protobuf_oneof:"payload"` } @@ -338,6 +342,13 @@ func (x *Msg) GetVscroll() *VncScroll { return nil } +func (x *Msg) GetVclipboard() *VncClipboard { + if x, ok := x.GetPayload().(*Msg_Vclipboard); ok { + return x.Vclipboard + } + return nil +} + type isMsg_Payload interface { isMsg_Payload() } @@ -388,6 +399,10 @@ type Msg_Vscroll struct { Vscroll *VncScroll `protobuf:"bytes,34,opt,name=vscroll,proto3,oneof"` } +type Msg_Vclipboard struct { + Vclipboard *VncClipboard `protobuf:"bytes,35,opt,name=vclipboard,proto3,oneof"` +} + func (*Msg_Hsp) isMsg_Payload() {} func (*Msg_Creq) isMsg_Payload() {} @@ -410,6 +425,8 @@ func (*Msg_Vkbd) isMsg_Payload() {} func (*Msg_Vscroll) isMsg_Payload() {} +func (*Msg_Vclipboard) isMsg_Payload() {} + var File_msg_proto protoreflect.FileDescriptor var file_msg_proto_rawDesc = []byte{ @@ -420,7 +437,7 @@ var file_msg_proto_rawDesc = []byte{ 0x09, 0x76, 0x6e, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x25, 0x0a, 0x11, 0x68, 0x61, 0x6e, 0x64, 0x73, 0x68, 0x61, 0x6b, 0x65, 0x5f, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x6e, 0x63, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x65, 0x6e, - 0x63, 0x22, 0x92, 0x07, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x12, 0x26, 0x0a, 0x05, 0x5f, 0x74, 0x79, + 0x63, 0x22, 0xdf, 0x07, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x12, 0x26, 0x0a, 0x05, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x11, 0x2e, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x6d, 0x73, 0x67, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x52, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, @@ -461,24 +478,29 @@ var file_msg_proto_rawDesc = []byte{ 0x72, 0x64, 0x48, 0x00, 0x52, 0x04, 0x76, 0x6b, 0x62, 0x64, 0x12, 0x2f, 0x0a, 0x07, 0x76, 0x73, 0x63, 0x72, 0x6f, 0x6c, 0x6c, 0x18, 0x22, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x76, 0x6e, 0x63, 0x5f, 0x73, 0x63, 0x72, 0x6f, 0x6c, 0x6c, - 0x48, 0x00, 0x52, 0x07, 0x76, 0x73, 0x63, 0x72, 0x6f, 0x6c, 0x6c, 0x22, 0xed, 0x01, 0x0a, 0x04, - 0x74, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x75, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, - 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x68, 0x61, 0x6e, 0x64, 0x73, 0x68, 0x61, 0x6b, 0x65, 0x10, 0x01, - 0x12, 0x0d, 0x0a, 0x09, 0x6b, 0x65, 0x65, 0x70, 0x61, 0x6c, 0x69, 0x76, 0x65, 0x10, 0x02, 0x12, - 0x0f, 0x0a, 0x0b, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x10, 0x03, - 0x12, 0x0f, 0x0a, 0x0b, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x5f, 0x72, 0x65, 0x70, 0x10, - 0x04, 0x12, 0x0e, 0x0a, 0x0a, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x10, - 0x05, 0x12, 0x0b, 0x0a, 0x07, 0x66, 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, 0x10, 0x06, 0x12, 0x10, - 0x0a, 0x0c, 0x73, 0x68, 0x65, 0x6c, 0x6c, 0x5f, 0x72, 0x65, 0x73, 0x69, 0x7a, 0x65, 0x10, 0x0a, - 0x12, 0x0e, 0x0a, 0x0a, 0x73, 0x68, 0x65, 0x6c, 0x6c, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x10, 0x0b, - 0x12, 0x0c, 0x0a, 0x08, 0x76, 0x6e, 0x63, 0x5f, 0x63, 0x74, 0x72, 0x6c, 0x10, 0x14, 0x12, 0x0d, - 0x0a, 0x09, 0x76, 0x6e, 0x63, 0x5f, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x10, 0x15, 0x12, 0x0d, 0x0a, - 0x09, 0x76, 0x6e, 0x63, 0x5f, 0x6d, 0x6f, 0x75, 0x73, 0x65, 0x10, 0x16, 0x12, 0x10, 0x0a, 0x0c, - 0x76, 0x6e, 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x10, 0x17, 0x12, 0x0b, - 0x0a, 0x07, 0x76, 0x6e, 0x63, 0x5f, 0x63, 0x61, 0x64, 0x10, 0x18, 0x12, 0x0e, 0x0a, 0x0a, 0x76, - 0x6e, 0x63, 0x5f, 0x73, 0x63, 0x72, 0x6f, 0x6c, 0x6c, 0x10, 0x19, 0x42, 0x09, 0x0a, 0x07, 0x70, - 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x42, 0x0c, 0x5a, 0x0a, 0x2e, 0x2f, 0x3b, 0x6e, 0x65, 0x74, - 0x77, 0x6f, 0x72, 0x6b, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x48, 0x00, 0x52, 0x07, 0x76, 0x73, 0x63, 0x72, 0x6f, 0x6c, 0x6c, 0x12, 0x38, 0x0a, 0x0a, 0x76, + 0x63, 0x6c, 0x69, 0x70, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x18, 0x23, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x16, 0x2e, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x76, 0x6e, 0x63, 0x5f, 0x63, 0x6c, + 0x69, 0x70, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x48, 0x00, 0x52, 0x0a, 0x76, 0x63, 0x6c, 0x69, 0x70, + 0x62, 0x6f, 0x61, 0x72, 0x64, 0x22, 0x80, 0x02, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x0b, + 0x0a, 0x07, 0x75, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x68, + 0x61, 0x6e, 0x64, 0x73, 0x68, 0x61, 0x6b, 0x65, 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x6b, 0x65, + 0x65, 0x70, 0x61, 0x6c, 0x69, 0x76, 0x65, 0x10, 0x02, 0x12, 0x0f, 0x0a, 0x0b, 0x63, 0x6f, 0x6e, + 0x6e, 0x65, 0x63, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x10, 0x03, 0x12, 0x0f, 0x0a, 0x0b, 0x63, 0x6f, + 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x5f, 0x72, 0x65, 0x70, 0x10, 0x04, 0x12, 0x0e, 0x0a, 0x0a, 0x64, + 0x69, 0x73, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x10, 0x05, 0x12, 0x0b, 0x0a, 0x07, 0x66, + 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, 0x10, 0x06, 0x12, 0x10, 0x0a, 0x0c, 0x73, 0x68, 0x65, 0x6c, + 0x6c, 0x5f, 0x72, 0x65, 0x73, 0x69, 0x7a, 0x65, 0x10, 0x0a, 0x12, 0x0e, 0x0a, 0x0a, 0x73, 0x68, + 0x65, 0x6c, 0x6c, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x10, 0x0b, 0x12, 0x0c, 0x0a, 0x08, 0x76, 0x6e, + 0x63, 0x5f, 0x63, 0x74, 0x72, 0x6c, 0x10, 0x14, 0x12, 0x0d, 0x0a, 0x09, 0x76, 0x6e, 0x63, 0x5f, + 0x69, 0x6d, 0x61, 0x67, 0x65, 0x10, 0x15, 0x12, 0x0d, 0x0a, 0x09, 0x76, 0x6e, 0x63, 0x5f, 0x6d, + 0x6f, 0x75, 0x73, 0x65, 0x10, 0x16, 0x12, 0x10, 0x0a, 0x0c, 0x76, 0x6e, 0x63, 0x5f, 0x6b, 0x65, + 0x79, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x10, 0x17, 0x12, 0x0b, 0x0a, 0x07, 0x76, 0x6e, 0x63, 0x5f, + 0x63, 0x61, 0x64, 0x10, 0x18, 0x12, 0x0e, 0x0a, 0x0a, 0x76, 0x6e, 0x63, 0x5f, 0x73, 0x63, 0x72, + 0x6f, 0x6c, 0x6c, 0x10, 0x19, 0x12, 0x11, 0x0a, 0x0d, 0x76, 0x6e, 0x63, 0x5f, 0x63, 0x6c, 0x69, + 0x70, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x10, 0x1a, 0x42, 0x09, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, + 0x6f, 0x61, 0x64, 0x42, 0x0c, 0x5a, 0x0a, 0x2e, 0x2f, 0x3b, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, + 0x6b, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -509,6 +531,7 @@ var file_msg_proto_goTypes = []interface{}{ (*VncMouse)(nil), // 10: network.vnc_mouse (*VncKeyboard)(nil), // 11: network.vnc_keyboard (*VncScroll)(nil), // 12: network.vnc_scroll + (*VncClipboard)(nil), // 13: network.vnc_clipboard } var file_msg_proto_depIdxs = []int32{ 0, // 0: network.msg._type:type_name -> network.msg.type @@ -523,11 +546,12 @@ var file_msg_proto_depIdxs = []int32{ 10, // 9: network.msg.vmouse:type_name -> network.vnc_mouse 11, // 10: network.msg.vkbd:type_name -> network.vnc_keyboard 12, // 11: network.msg.vscroll:type_name -> network.vnc_scroll - 12, // [12:12] is the sub-list for method output_type - 12, // [12:12] is the sub-list for method input_type - 12, // [12:12] is the sub-list for extension type_name - 12, // [12:12] is the sub-list for extension extendee - 0, // [0:12] is the sub-list for field type_name + 13, // 12: network.msg.vclipboard:type_name -> network.vnc_clipboard + 13, // [13:13] is the sub-list for method output_type + 13, // [13:13] is the sub-list for method input_type + 13, // [13:13] is the sub-list for extension type_name + 13, // [13:13] is the sub-list for extension extendee + 0, // [0:13] is the sub-list for field type_name } func init() { file_msg_proto_init() } @@ -577,6 +601,7 @@ func file_msg_proto_init() { (*Msg_Vmouse)(nil), (*Msg_Vkbd)(nil), (*Msg_Vscroll)(nil), + (*Msg_Vclipboard)(nil), } type x struct{} out := protoimpl.TypeBuilder{ diff --git a/code/network/msg.proto b/code/network/msg.proto index ce1d163..53f3395 100644 --- a/code/network/msg.proto +++ b/code/network/msg.proto @@ -25,12 +25,13 @@ message msg { shell_resize = 10; shell_data = 11; // vnc - vnc_ctrl = 20; - vnc_image = 21; - vnc_mouse = 22; - vnc_keyboard = 23; - vnc_cad = 24; // ctrl+alt+del - vnc_scroll = 25; + vnc_ctrl = 20; + vnc_image = 21; + vnc_mouse = 22; + vnc_keyboard = 23; + vnc_cad = 24; // ctrl+alt+del + vnc_scroll = 25; + vnc_clipboard = 26; } type _type = 1; string from = 2; @@ -47,10 +48,11 @@ message msg { shell_resize sresize = 20; shell_data sdata = 21; // vnc - vnc_control vctrl = 30; - vnc_image vimg = 31; - vnc_mouse vmouse = 32; - vnc_keyboard vkbd = 33; - vnc_scroll vscroll = 34; + vnc_control vctrl = 30; + vnc_image vimg = 31; + vnc_mouse vmouse = 32; + vnc_keyboard vkbd = 33; + vnc_scroll vscroll = 34; + vnc_clipboard vclipboard = 35; } } \ No newline at end of file diff --git a/code/network/vnc.pb.go b/code/network/vnc.pb.go index 4695cc8..706ce66 100644 --- a/code/network/vnc.pb.go +++ b/code/network/vnc.pb.go @@ -170,6 +170,58 @@ func (VncMouseButton) EnumDescriptor() ([]byte, []int) { return file_vnc_proto_rawDescGZIP(), []int{2, 0} } +type VncClipboardType int32 + +const ( + VncClipboard_unset_type VncClipboardType = 0 + VncClipboard_text VncClipboardType = 1 + VncClipboard_image VncClipboardType = 2 + VncClipboard_file VncClipboardType = 3 +) + +// Enum value maps for VncClipboardType. +var ( + VncClipboardType_name = map[int32]string{ + 0: "unset_type", + 1: "text", + 2: "image", + 3: "file", + } + VncClipboardType_value = map[string]int32{ + "unset_type": 0, + "text": 1, + "image": 2, + "file": 3, + } +) + +func (x VncClipboardType) Enum() *VncClipboardType { + p := new(VncClipboardType) + *p = x + return p +} + +func (x VncClipboardType) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (VncClipboardType) Descriptor() protoreflect.EnumDescriptor { + return file_vnc_proto_enumTypes[3].Descriptor() +} + +func (VncClipboardType) Type() protoreflect.EnumType { + return &file_vnc_proto_enumTypes[3] +} + +func (x VncClipboardType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use VncClipboardType.Descriptor instead. +func (VncClipboardType) EnumDescriptor() ([]byte, []int) { + return file_vnc_proto_rawDescGZIP(), []int{5, 0} +} + type VncControl struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -470,6 +522,88 @@ func (x *VncScroll) GetY() int32 { return 0 } +type VncClipboard struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Set bool `protobuf:"varint,1,opt,name=set,proto3" json:"set,omitempty"` + XType VncClipboardType `protobuf:"varint,2,opt,name=_type,json=Type,proto3,enum=network.VncClipboardType" json:"_type,omitempty"` + // Types that are assignable to Payload: + // *VncClipboard_Data + Payload isVncClipboard_Payload `protobuf_oneof:"payload"` +} + +func (x *VncClipboard) Reset() { + *x = VncClipboard{} + if protoimpl.UnsafeEnabled { + mi := &file_vnc_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *VncClipboard) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*VncClipboard) ProtoMessage() {} + +func (x *VncClipboard) ProtoReflect() protoreflect.Message { + mi := &file_vnc_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use VncClipboard.ProtoReflect.Descriptor instead. +func (*VncClipboard) Descriptor() ([]byte, []int) { + return file_vnc_proto_rawDescGZIP(), []int{5} +} + +func (x *VncClipboard) GetSet() bool { + if x != nil { + return x.Set + } + return false +} + +func (x *VncClipboard) GetXType() VncClipboardType { + if x != nil { + return x.XType + } + return VncClipboard_unset_type +} + +func (m *VncClipboard) GetPayload() isVncClipboard_Payload { + if m != nil { + return m.Payload + } + return nil +} + +func (x *VncClipboard) GetData() string { + if x, ok := x.GetPayload().(*VncClipboard_Data); ok { + return x.Data + } + return "" +} + +type isVncClipboard_Payload interface { + isVncClipboard_Payload() +} + +type VncClipboard_Data struct { + Data string `protobuf:"bytes,10,opt,name=data,proto3,oneof"` // text data +} + +func (*VncClipboard_Data) isVncClipboard_Payload() {} + type VncImageInfo struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -486,7 +620,7 @@ type VncImageInfo struct { func (x *VncImageInfo) Reset() { *x = VncImageInfo{} if protoimpl.UnsafeEnabled { - mi := &file_vnc_proto_msgTypes[5] + mi := &file_vnc_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -499,7 +633,7 @@ func (x *VncImageInfo) String() string { func (*VncImageInfo) ProtoMessage() {} func (x *VncImageInfo) ProtoReflect() protoreflect.Message { - mi := &file_vnc_proto_msgTypes[5] + mi := &file_vnc_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -607,11 +741,22 @@ var file_vnc_proto_rawDesc = []byte{ 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x22, 0x28, 0x0a, 0x0a, 0x76, 0x6e, 0x63, 0x5f, 0x73, 0x63, 0x72, 0x6f, 0x6c, 0x6c, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 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, + 0x22, 0xab, 0x01, 0x0a, 0x0d, 0x76, 0x6e, 0x63, 0x5f, 0x63, 0x6c, 0x69, 0x70, 0x62, 0x6f, 0x61, + 0x72, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x65, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, + 0x03, 0x73, 0x65, 0x74, 0x12, 0x30, 0x0a, 0x05, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0e, 0x32, 0x1b, 0x2e, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x76, 0x6e, + 0x63, 0x5f, 0x63, 0x6c, 0x69, 0x70, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x2e, 0x74, 0x79, 0x70, 0x65, + 0x52, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x0a, + 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x35, 0x0a, 0x04, + 0x74, 0x79, 0x70, 0x65, 0x12, 0x0e, 0x0a, 0x0a, 0x75, 0x6e, 0x73, 0x65, 0x74, 0x5f, 0x74, 0x79, + 0x70, 0x65, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x10, 0x01, 0x12, 0x09, + 0x0a, 0x05, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x66, 0x69, 0x6c, + 0x65, 0x10, 0x03, 0x42, 0x09, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 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 ( @@ -626,30 +771,33 @@ func file_vnc_proto_rawDescGZIP() []byte { return file_vnc_proto_rawDescData } -var file_vnc_proto_enumTypes = make([]protoimpl.EnumInfo, 3) -var file_vnc_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_vnc_proto_enumTypes = make([]protoimpl.EnumInfo, 4) +var file_vnc_proto_msgTypes = make([]protoimpl.MessageInfo, 7) var file_vnc_proto_goTypes = []interface{}{ (VncStatus)(0), // 0: network.vnc_status (VncImageEncoding)(0), // 1: network.vnc_image.encoding (VncMouseButton)(0), // 2: network.vnc_mouse.button - (*VncControl)(nil), // 3: network.vnc_control - (*VncImage)(nil), // 4: network.vnc_image - (*VncMouse)(nil), // 5: network.vnc_mouse - (*VncKeyboard)(nil), // 6: network.vnc_keyboard - (*VncScroll)(nil), // 7: network.vnc_scroll - (*VncImageInfo)(nil), // 8: network.vnc_image.info + (VncClipboardType)(0), // 3: network.vnc_clipboard.type + (*VncControl)(nil), // 4: network.vnc_control + (*VncImage)(nil), // 5: network.vnc_image + (*VncMouse)(nil), // 6: network.vnc_mouse + (*VncKeyboard)(nil), // 7: network.vnc_keyboard + (*VncScroll)(nil), // 8: network.vnc_scroll + (*VncClipboard)(nil), // 9: network.vnc_clipboard + (*VncImageInfo)(nil), // 10: network.vnc_image.info } var file_vnc_proto_depIdxs = []int32{ - 8, // 0: network.vnc_image._info:type_name -> network.vnc_image.info - 1, // 1: network.vnc_image.encode:type_name -> network.vnc_image.encoding - 0, // 2: network.vnc_mouse.type:type_name -> network.vnc_status - 2, // 3: network.vnc_mouse.btn:type_name -> network.vnc_mouse.button - 0, // 4: network.vnc_keyboard.type:type_name -> network.vnc_status - 5, // [5:5] is the sub-list for method output_type - 5, // [5:5] is the sub-list for method input_type - 5, // [5:5] is the sub-list for extension type_name - 5, // [5:5] is the sub-list for extension extendee - 0, // [0:5] is the sub-list for field type_name + 10, // 0: network.vnc_image._info:type_name -> network.vnc_image.info + 1, // 1: network.vnc_image.encode:type_name -> network.vnc_image.encoding + 0, // 2: network.vnc_mouse.type:type_name -> network.vnc_status + 2, // 3: network.vnc_mouse.btn:type_name -> network.vnc_mouse.button + 0, // 4: network.vnc_keyboard.type:type_name -> network.vnc_status + 3, // 5: network.vnc_clipboard._type:type_name -> network.vnc_clipboard.type + 6, // [6:6] is the sub-list for method output_type + 6, // [6:6] is the sub-list for method input_type + 6, // [6:6] is the sub-list for extension type_name + 6, // [6:6] is the sub-list for extension extendee + 0, // [0:6] is the sub-list for field type_name } func init() { file_vnc_proto_init() } @@ -719,6 +867,18 @@ func file_vnc_proto_init() { } } file_vnc_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*VncClipboard); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_vnc_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*VncImageInfo); i { case 0: return &v.state @@ -731,13 +891,16 @@ func file_vnc_proto_init() { } } } + file_vnc_proto_msgTypes[5].OneofWrappers = []interface{}{ + (*VncClipboard_Data)(nil), + } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_vnc_proto_rawDesc, - NumEnums: 3, - NumMessages: 6, + NumEnums: 4, + NumMessages: 7, NumExtensions: 0, NumServices: 0, }, diff --git a/code/network/vnc.proto b/code/network/vnc.proto index 3f55ad9..fd4d192 100644 --- a/code/network/vnc.proto +++ b/code/network/vnc.proto @@ -55,4 +55,19 @@ message vnc_keyboard { message vnc_scroll { int32 x = 1; int32 y = 2; +} + +message vnc_clipboard { + enum type { + unset_type = 0; + text = 1; + image = 2; + file = 3; + } + bool set = 1; + type _type = 2; + oneof payload { + string data = 10; // text data + // TODO + } } \ No newline at end of file diff --git a/docs/imgs/vnc_clipboard.png b/docs/imgs/vnc_clipboard.png new file mode 100644 index 0000000..f360e20 Binary files /dev/null and b/docs/imgs/vnc_clipboard.png differ diff --git a/docs/startup.md b/docs/startup.md index 2544b24..c328526 100644 --- a/docs/startup.md +++ b/docs/startup.md @@ -29,7 +29,7 @@ 3. 修改conf.d/conn.yaml配置文件,修改*secret*密钥,该密钥必须与服务器端保持一致 4. 使用以下命令将np-cli注册为系统服务,其中-conf参数后跟配置文件所在路径,-user参数后为程序启动身份(建议使用nobody身份启动) - sudo ./np-cli -conf server.yaml -action install -user nobody + sudo ./np-cli -conf client.yaml -action install -user nobody 5. 将该服务设置为系统启动项,并启动服务 sudo systemctl enable np-cli @@ -43,7 +43,7 @@ 4. 修改rule.d目录下的规则配置文件,[rule配置方法](rules.md) 5. 使用以下命令将np-cli注册为系统服务,其中-conf参数后跟配置文件所在路径,-user参数后为程序启动身份(建议使用nobody身份启动) - sudo ./np-cli -conf server.yaml -action install -user nobody + sudo ./np-cli -conf client.yaml -action install -user nobody 6. 将该服务设置为系统启动项,并启动服务 sudo systemctl enable np-cli diff --git a/html/vnc/clipboard_dialog.js b/html/vnc/clipboard_dialog.js new file mode 100644 index 0000000..42ae26b --- /dev/null +++ b/html/vnc/clipboard_dialog.js @@ -0,0 +1,19 @@ +var clipboard_dialog = { + init: function() { + $('#dlg-clipboard #set-clipboard').click(clipboard_dialog.set); + $('#dlg-clipboard #get-clipboard').click(clipboard_dialog.get); + }, + modal: function() { + $('#dlg-clipboard textarea').val(''); + $('#dlg-clipboard').modal(); + }, + set: function() { + $.post('/clipboard', {data: $('#dlg-clipboard textarea').val()}); + }, + get: function() { + $.get('/clipboard', function(ret) { + $('#dlg-clipboard textarea').val(ret); + }); + } +}; +$(document).ready(clipboard_dialog.init); \ No newline at end of file diff --git a/html/vnc/index.css b/html/vnc/index.css index 4255398..14a5465 100644 --- a/html/vnc/index.css +++ b/html/vnc/index.css @@ -13,6 +13,7 @@ float: right; } #cad, +#clipboard, #info { float: right; margin-right: 5px; @@ -29,4 +30,12 @@ label, span { #fullscreen { cursor: pointer; font-size: 38px; +} + +#dlg-clipboard textarea { + resize: vertical; + min-height: 300px; +} +#dlg-clipboard #row-data { + margin-top: 10px; } \ No newline at end of file diff --git a/html/vnc/index.html b/html/vnc/index.html index a830734..ba55e73 100644 --- a/html/vnc/index.html +++ b/html/vnc/index.html @@ -14,6 +14,7 @@ +
@@ -32,11 +33,37 @@ + fps: 0, bandwidth: 0 B/s +