示例#1
0
func invoke(client *CEBClient, name string, typ string, data map[string]interface{}) {
	//client.outgoing <- message

	tcpComm := messaging.CEBTCPCommand{}
	tcpComm.Command = "command"

	fwsCommand := messaging.CommandTCPCommand{}
	fwsCommand.Name = name
	fwsCommand.Type = typ
	data["from"] = client.agentName
	fwsCommand.Data = data

	tcpComm.Data = fwsCommand

	byteSet, err := json.Marshal(&tcpComm)

	if err != nil {
		fmt.Println(err.Error())
	}

	message := string(byteSet[:len(byteSet)])

	client.outgoing <- string(message)

}
示例#2
0
func (client *CEBClient) ClientCommand(to string, class string, typ string, data interface{}) {
	//client.outgoing <- message

	tcpComm := messaging.CEBTCPCommand{}
	tcpComm.Command = "command"

	fwsCommand := messaging.CommandTCPCommand{}
	fwsCommand.Name = "commandforward"
	fwsCommand.Type = "command"

	forwardComm := messaging.CommandForwardTCPParamters{}

	forwardComm.To = to
	forwardComm.Command = "agentResponse"
	forwardComm.PersistIfOffline = false
	forwardComm.AlwaysPersist = false

	servMonitorCommand := messaging.ServerMonitorCommand{}
	servMonitorCommand.Class = class
	servMonitorCommand.Type = typ
	servMonitorCommand.Data = data

	forwardComm.Data = servMonitorCommand

	fwsCommand.Data = forwardComm
	tcpComm.Data = fwsCommand

	/*

		To               string      `json:"to"`
		Command          string      `json:"command"`
		Data             interface{} `json:"data"`
		PersistIfOffline bool        `json:"persistIfOffline"`
		AlwaysPersist    bool        `json:"alwaysPersist"`
	*/

	byteSet, err := json.Marshal(&tcpComm)

	if err != nil {
		fmt.Println(err.Error())
	}

	message := string(byteSet[:len(byteSet)])

	client.outgoing <- string(message)

}