修正读取剪贴板内容时无法正确设置返回值

This commit is contained in:
lwch
2021-11-22 14:40:51 +08:00
parent 8a4e242023
commit 6e9043e09d
4 changed files with 17 additions and 6 deletions
+5 -1
View File
@@ -63,4 +63,8 @@
1. bootstrap降版到4.6.1
2. dashboard页面支持规则类型筛选
3. **为遵守中国法律,移除内网穿透功能**,保留shell和vnc功能不变
3. **为遵守中国法律,移除内网穿透功能**,保留shell和vnc功能不变
# v0.7.1
1. vnc页面支持远程设置或读取剪贴板(仅支持文本内容)
+2
View File
@@ -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) {
+2
View File
@@ -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
+8 -5
View File
@@ -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),
}
}