From 6e9043e09d69ecf0bc7a4972ef63421caefe2c06 Mon Sep 17 00:00:00 2001 From: lwch Date: Mon, 22 Nov 2021 14:40:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E8=AF=BB=E5=8F=96=E5=89=AA?= =?UTF-8?q?=E8=B4=B4=E6=9D=BF=E5=86=85=E5=AE=B9=E6=97=B6=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E6=AD=A3=E7=A1=AE=E8=AE=BE=E7=BD=AE=E8=BF=94=E5=9B=9E=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 6 +++++- code/client/rule/vnc/h_clipboard.go | 2 ++ code/client/rule/vnc/h_ws.go | 2 ++ code/client/rule/vnc/vnc.go | 13 ++++++++----- 4 files changed, 17 insertions(+), 6 deletions(-) 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/code/client/rule/vnc/h_clipboard.go b/code/client/rule/vnc/h_clipboard.go index db339ae..3272f00 100644 --- a/code/client/rule/vnc/h_clipboard.go +++ b/code/client/rule/vnc/h_clipboard.go @@ -22,6 +22,8 @@ func (v *VNC) getClipboard(pool *pool.Pool, w http.ResponseWriter, r *http.Reque } 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) { 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/vnc.go b/code/client/rule/vnc/vnc.go index 5fc1dfc..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), } }