48 lines
845 B
Go
48 lines
845 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
|
|
"git.paulbsd.com/paulbsd/ipbl/src/config"
|
|
"git.paulbsd.com/paulbsd/ipbl/src/database"
|
|
"git.paulbsd.com/paulbsd/ipbl/src/models"
|
|
"git.paulbsd.com/paulbsd/ipbl/src/routers"
|
|
_ "github.com/lib/pq"
|
|
)
|
|
|
|
//go:generate ../../scripts/version.sh
|
|
|
|
func main() {
|
|
var ctx context.Context
|
|
var cfg config.Config
|
|
cfg.GetConfig()
|
|
cfg.Options.Version = version
|
|
if cfg.Switchs.Version {
|
|
fmt.Printf("ipbl version %s\n", cfg.Options.Version)
|
|
os.Exit(0)
|
|
}
|
|
|
|
err := database.Initialize(&ctx, &cfg)
|
|
if err != nil {
|
|
log.Fatalln(err)
|
|
}
|
|
defer cfg.Db.Close()
|
|
|
|
go models.ScanIP(&cfg)
|
|
|
|
// Add cron task to handle them
|
|
//cr := cron.New()
|
|
//cr.AddFunc("0 * * * * *", func() {
|
|
// models.ScanIP(&cfg)
|
|
//})
|
|
//cr.Start()
|
|
|
|
err = routers.RunServer(&ctx, &cfg)
|
|
if err != nil {
|
|
log.Fatalln(err)
|
|
}
|
|
}
|