支持ctrl+alt+del

This commit is contained in:
lwch
2021-11-03 12:18:51 +08:00
parent a6757b4f37
commit 1fa1d650e7
7 changed files with 47 additions and 1 deletions
+13
View File
@@ -122,3 +122,16 @@ func (conn *Conn) SendVNCKeyboard(to string, toIdx uint32, id string,
case <-time.After(conn.parent.cfg.WriteTimeout):
}
}
// SendVNC send vnc keyboard event
func (conn *Conn) SendVNCCADEvent(to string, toIdx uint32, id string) {
var msg network.Msg
msg.To = to
msg.ToIdx = toIdx
msg.XType = network.Msg_vnc_cad
msg.LinkId = id
select {
case conn.write <- &msg:
case <-time.After(conn.parent.cfg.WriteTimeout):
}
}
@@ -0,0 +1,8 @@
package define
import "syscall"
var (
libSas, _ = syscall.LoadLibrary("Sas.dll")
FuncSendSAS, _ = syscall.GetProcAddress(syscall.Handle(libSas), "SendSAS")
)
+4
View File
@@ -40,3 +40,7 @@ func (v *VNC) keyboardEvent(remote *pool.Conn, data []byte) {
remote.SendVNCKeyboard(v.link.target, v.link.targetIdx, v.link.id,
payload.Payload.Status, payload.Payload.Key)
}
func (v *VNC) cadEvent(remote *pool.Conn) {
remote.SendVNCCADEvent(v.link.target, v.link.targetIdx, v.link.id)
}
+1
View File
@@ -103,6 +103,7 @@ func (v *VNC) localRead(ctx context.Context, local *websocket.Conn, remote *pool
case "keyboard":
v.keyboardEvent(remote, data)
case "cad":
v.cadEvent(remote)
}
}
}
+2
View File
@@ -101,6 +101,8 @@ func (link *Link) remoteRead() {
link.ps.MouseEvent(msg.GetVmouse())
case network.Msg_vnc_keyboard:
link.ps.KeyboardEvent(msg.GetVkbd())
case network.Msg_vnc_cad:
link.ps.CADEvent()
case network.Msg_disconnect:
logging.Info("link %s disconnected", link.id)
return
@@ -0,0 +1,15 @@
package process
import (
"natpass/code/client/tunnel/vnc/define"
"syscall"
"github.com/lwch/logging"
)
func (p *Process) CADEvent() {
ok, _, err := syscall.Syscall(define.FuncSendSAS, 1, 0, 0, 0)
if ok == 0 {
logging.Error("send sas failed: %v", err)
}
}
+4 -1
View File
@@ -64,7 +64,10 @@ var page = {
});
},
cad: function() {
// TODO
if (!page.ws) {
return;
}
page.ws.send(JSON.stringify({action: 'cad'}));
},
mousemove: function(e) {
if (!page.ws) {