alaska/cmd/alaskad.go
Christopher Talib 8645eccdbd First commit
2020-09-13 23:07:25 +02:00

33 lines
648 B
Go

package main
import (
"git.postblue.info/chris/alaska/models"
"github.com/CaliDog/certstream-go"
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/sqlite"
"github.com/prometheus/common/log"
)
func main() {
db, err := gorm.Open("sqlite3", "certs.db")
if err != nil {
log.Fatal(err)
}
defer db.Close()
stream, errStream := certstream.CertStreamEventStream(false)
log.Info("Starting to get data from Certstream...")
for {
select {
case jq := <-stream:
model, err := models.ExtractCertFromStream(jq)
if err != nil {
log.Warn(err)
}
db.Create(&model)
case err := <-errStream:
log.Error(err)
}
}
}