mirror of
https://github.com/dragonheim/gagent.git
synced 2025-04-25 22:48:59 -07:00
Started moving to a chainDB for tracking history.
This commit is contained in:
parent
749bd6557e
commit
458214aaa9
6 changed files with 31 additions and 18 deletions
|
@ -39,7 +39,7 @@ func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) {
|
|||
log.Printf("[DEBUG] Agent file contents: \n----- -----\n%s\n----- -----\n", agent.ScriptCode)
|
||||
}
|
||||
agent.Client = config.UUID
|
||||
agent.Shasum = fmt.Sprintf("%x", sha.Sum256(agent.ScriptCode))
|
||||
agent.Shasum = fmt.Sprintf("%s", sha.Sum256(agent.ScriptCode))
|
||||
log.Printf("[INFO] SHA256 of Agent file: %s", agent.Shasum)
|
||||
agent.Status = "loaded"
|
||||
agent.Hints = getTagsFromHints(agent)
|
||||
|
@ -86,10 +86,10 @@ func sendAgent(wg *sync.WaitGroup, uuid string, connectString string, agent gstr
|
|||
sock, _ := zmq.NewSocket(zmq.REQ)
|
||||
defer sock.Close()
|
||||
|
||||
err := sock.SetIdentity(uuid)
|
||||
_ = sock.SetIdentity(uuid)
|
||||
|
||||
log.Printf("[DEBUG] Attempting to connect to %s\n", connectString)
|
||||
err = sock.Connect(connectString)
|
||||
err := sock.Connect(connectString)
|
||||
if err != nil {
|
||||
log.Printf("[ERROR] Failed to connect to %s\n", connectString)
|
||||
os.Exit(10)
|
||||
|
|
|
@ -10,6 +10,7 @@ type GagentConfig struct {
|
|||
ClientPort int64 `hcl:"clientport,optional"`
|
||||
RouterPort int64 `hcl:"routerport,optional"`
|
||||
WorkerPort int64 `hcl:"workerport,optional"`
|
||||
ChainDBPath string `hcl:"chaindbpath,optional"`
|
||||
Clients []*ClientDetails `hcl:"client,block"`
|
||||
Routers []*RouterDetails `hcl:"router,block"`
|
||||
Workers []*WorkerDetails `hcl:"worker,block"`
|
||||
|
@ -119,10 +120,6 @@ type WorkerDetails struct {
|
|||
WorkerTags []string `hcl:"tags,optional"`
|
||||
}
|
||||
|
||||
type BlockChainDB struct {
|
||||
DBName string `hcl:"chainid,optional"`
|
||||
Agents []*AgentDetails `hcl:"agent,block"`
|
||||
}
|
||||
type AgentDetails struct {
|
||||
Client string `hcl:"client"`
|
||||
Shasum string `hcl:"shasum"`
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
http "net/http"
|
||||
sync "sync"
|
||||
|
||||
gcdb "git.dragonheim.net/dragonheim/gagent/internal/chaindb"
|
||||
gstructs "git.dragonheim.net/dragonheim/gagent/internal/gstructs"
|
||||
|
||||
prometheus "github.com/prometheus/client_golang/prometheus"
|
||||
|
@ -18,6 +19,8 @@ var (
|
|||
opsProcessed = promauto.NewCounter(prometheus.CounterOpts{
|
||||
Name: "client_requests_recieved",
|
||||
})
|
||||
|
||||
db gcdb.GagentDb
|
||||
)
|
||||
|
||||
/*
|
||||
|
@ -38,6 +41,8 @@ func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) {
|
|||
workerSock, _ := zmq.NewSocket(zmq.DEALER)
|
||||
defer workerSock.Close()
|
||||
|
||||
db.Init()
|
||||
|
||||
workerListener := fmt.Sprintf("tcp://%s:%d", config.ListenAddr, config.WorkerPort)
|
||||
_ = workerSock.Bind(workerListener)
|
||||
|
||||
|
|
|
@ -28,6 +28,13 @@ func Main(wg *sync.WaitGroup, config gs.GagentConfig) {
|
|||
|
||||
clientBlock1 := rootBody.AppendNewBlock("client", []string{config.Name})
|
||||
clientBody1 := clientBlock1.Body()
|
||||
// clientBody1.AppendUnstructuredTokens(
|
||||
// hclwrite.TokensForTraversal(hcl.Traversal{
|
||||
// hcl.TraverseRoot{
|
||||
// Name: hcl.CommentGenerator("comment"),
|
||||
// },
|
||||
// },
|
||||
// ))
|
||||
clientBody1.SetAttributeValue("clientid", cty.StringVal(config.UUID))
|
||||
rootBody.AppendNewline()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue