-
Notifications
You must be signed in to change notification settings - Fork 414
/
Copy pathshell.go
47 lines (39 loc) · 994 Bytes
/
shell.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package handler
import (
"fmt"
"Stowaway/admin/manager"
"Stowaway/global"
"Stowaway/protocol"
)
func LetShellStart(route string, uuid string) {
sMessage := protocol.NewDownMsg(global.G_Component.Conn, global.G_Component.Secret, global.G_Component.UUID)
header := &protocol.Header{
Sender: protocol.ADMIN_UUID,
Accepter: uuid,
MessageType: protocol.SHELLREQ,
RouteLen: uint32(len([]byte(route))),
Route: route,
}
shellReqMess := &protocol.ShellReq{
Start: 1,
}
protocol.ConstructMessage(sMessage, header, shellReqMess, false)
sMessage.SendMessage()
}
func DispatchShellMess(mgr *manager.Manager) {
for {
message := <-mgr.ShellManager.ShellMessChan
switch mess := message.(type) {
case *protocol.ShellRes:
if mess.OK == 1 {
mgr.ConsoleManager.OK <- true
} else {
mgr.ConsoleManager.OK <- false
}
case *protocol.ShellResult:
fmt.Print(mess.Result)
case *protocol.ShellExit:
mgr.ConsoleManager.Exit <- true
}
}
}