mirror of
https://github.com/dragonheim/gagent.git
synced 2025-04-26 01:08:59 -07:00
Populating AgentDetails and sending it, instead of just the script.
This commit is contained in:
parent
abba1972d1
commit
27045c94d6
2 changed files with 9 additions and 6 deletions
|
@ -36,12 +36,14 @@ func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) {
|
||||||
log.Printf("[ERROR] No such file or directory: %s", config.File)
|
log.Printf("[ERROR] No such file or directory: %s", config.File)
|
||||||
os.Exit(4)
|
os.Exit(4)
|
||||||
}
|
}
|
||||||
agent.Shasum = fmt.Sprintf("%x", sha.Sum256(agent.ScriptCode))
|
log.Printf("[DEBUG] Agent file contents: \n----- -----\n%s\n----- -----\n", agent.ScriptCode)
|
||||||
agent.Status = "loaded"
|
|
||||||
log.Printf("[INFO] SHA256 of Agent file: %s", agent.Shasum)
|
|
||||||
log.Printf("[DEBUG] Agent file contents: \n%s\n", agent.ScriptCode)
|
|
||||||
}
|
}
|
||||||
|
agent.Client = config.UUID
|
||||||
|
agent.Shasum = fmt.Sprintf("%x", sha.Sum256(agent.ScriptCode))
|
||||||
|
log.Printf("[INFO] SHA256 of Agent file: %s", agent.Shasum)
|
||||||
|
agent.Status = "loaded"
|
||||||
agent.Hints = getTagsFromHints(agent)
|
agent.Hints = getTagsFromHints(agent)
|
||||||
|
agent.Answer = nil
|
||||||
|
|
||||||
for key := range config.Routers {
|
for key := range config.Routers {
|
||||||
/*
|
/*
|
||||||
|
@ -54,7 +56,7 @@ func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) {
|
||||||
connectString := fmt.Sprintf("tcp://%s:%d", config.Routers[key].RouterAddr, rport)
|
connectString := fmt.Sprintf("tcp://%s:%d", config.Routers[key].RouterAddr, rport)
|
||||||
|
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go sendAgent(wg, config.UUID, connectString, agent.ScriptCode)
|
go sendAgent(wg, config.UUID, connectString, agent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +77,7 @@ func getTagsFromHints(agent gstructs.AgentDetails) []string {
|
||||||
return tags
|
return tags
|
||||||
}
|
}
|
||||||
|
|
||||||
func sendAgent(wg *sync.WaitGroup, uuid string, connectString string, agent []byte) {
|
func sendAgent(wg *sync.WaitGroup, uuid string, connectString string, agent gstructs.AgentDetails) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
|
|
||||||
var mu sync.Mutex
|
var mu sync.Mutex
|
||||||
|
|
|
@ -129,4 +129,5 @@ type AgentDetails struct {
|
||||||
Status string `hcl:"status"`
|
Status string `hcl:"status"`
|
||||||
ScriptCode []byte
|
ScriptCode []byte
|
||||||
Hints []string
|
Hints []string
|
||||||
|
Answer []byte
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue