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), } }