mirror of
https://github.com/lwch/natpass.git
synced 2026-10-21 05:22:00 +00:00
支持ctrl+alt+del
This commit is contained in:
@@ -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")
|
||||
)
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user