2020-01-22 15:49:52 +01:00
|
|
|
package parser
|
|
|
|
|
2020-01-26 17:27:20 +01:00
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"io/ioutil"
|
|
|
|
|
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
"gitlab.dcso.lolcat/LABS/styx/models"
|
|
|
|
"gitlab.dcso.lolcat/LABS/styx/utils"
|
|
|
|
)
|
|
|
|
|
2020-01-22 15:49:52 +01:00
|
|
|
// read node recieved on kafka
|
|
|
|
// create a node in the node file
|
|
|
|
// save domains in another file with node ID
|
|
|
|
|
|
|
|
// parallel routine
|
|
|
|
// look throught domain names and if find some that exists already, create the
|
|
|
|
// edge file
|
|
|
|
|
|
|
|
const (
|
|
|
|
NodesFilename = "nodes.json"
|
|
|
|
EdgesFilename = "edges.json"
|
|
|
|
)
|
|
|
|
|
|
|
|
func ParseEvent(domains []string) {
|
2020-01-26 17:27:20 +01:00
|
|
|
nodeFile, err := ioutil.ReadFile(NodesFilename)
|
|
|
|
if err != nil {
|
|
|
|
logrus.Error(err)
|
|
|
|
}
|
|
|
|
nodeDatas := []models.Node{}
|
|
|
|
|
|
|
|
if err := json.Unmarshal(nodeFile, &nodeDatas); err != nil {
|
|
|
|
logrus.Error(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, node := range nodeDatas {
|
|
|
|
utils.SaveDomains(node.Data.Data.LeafCert.AllDomains)
|
|
|
|
}
|
2020-01-22 15:49:52 +01:00
|
|
|
|
|
|
|
// saveDomains()
|
|
|
|
// go findDomainEdges()
|
|
|
|
}
|
|
|
|
|
|
|
|
// Helpers
|