You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
alaska/cmd/alaskad.go

33 lines
648 B

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)
}
}
}