44 lines
849 B
Go
44 lines
849 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"
|
|
"git.paulbsd.com/paulbsd/ipbl/src/zmqrouter"
|
|
"git.paulbsd.com/paulbsd/ipbl/utils"
|
|
_ "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)
|
|
go zmqrouter.Init(&cfg)
|
|
go func() { err = routers.RunServer(&ctx, &cfg) }()
|
|
if err != nil {
|
|
log.Fatalln(err)
|
|
}
|
|
utils.Server()
|
|
}
|