33 lines
648 B
Go
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)
|
|
}
|
|
}
|
|
}
|