7785372e3a
This work refactors saving and extracting function from the utils package to the models package as it is a main component of the tool. `utils` will take care of not related to models functions (such as finding the files for example). Also creating unique files for each type of source we are parsing.
34 lines
742 B
Go
34 lines
742 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/CaliDog/certstream-go"
|
|
"github.com/sirupsen/logrus"
|
|
"gitlab.dcso.lolcat/LABS/styx/broker"
|
|
"gitlab.dcso.lolcat/LABS/styx/models"
|
|
)
|
|
|
|
func main() {
|
|
// The false flag specifies that we want heartbeat messages.
|
|
stream, errStream := certstream.CertStreamEventStream(false)
|
|
fmt.Println("Starting to get data from CertStream...")
|
|
Conn, err := broker.SetUpKafkaConnecter()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
go broker.ReadEventFromKafka()
|
|
for {
|
|
select {
|
|
case jq := <-stream:
|
|
if data, err := models.ExtractCertFromStream(jq); err == nil {
|
|
|
|
node := models.BuildNode("certstream", *data)
|
|
broker.SendEventToKafka(Conn, *node)
|
|
}
|
|
|
|
case err := <-errStream:
|
|
logrus.Error(err)
|
|
}
|
|
}
|
|
}
|