updated ipbl
All checks were successful
continuous-integration/drone/push Build is passing

* added version in user agent
* lint code
* removed compat with config v2
This commit is contained in:
Paul 2024-07-17 23:12:44 +02:00
parent 1f56bd64ca
commit b8521f050a
3 changed files with 7 additions and 10 deletions

View File

@ -67,6 +67,7 @@ func migrate(cfg *config.Config) (err error) {
n := models.CfgExpr{
Expr: v,
Set: &cfgset,
Enabled: true,
}
cfg.Db.Insert(&n)
}

View File

@ -157,7 +157,7 @@ func ScanOrphan(wg *sync.WaitGroup, orphans chan IP, thr int, cfg *config.Config
log.Println(err)
}
var query QueryIP
query, err := QueryInfo(&queryclient, orphan.IP)
query, err := QueryInfo(cfg, &queryclient, orphan.IP)
if err != nil {
log.Println(err)
time.Sleep(1 * time.Minute)
@ -200,14 +200,14 @@ func ScanOrphan(wg *sync.WaitGroup, orphans chan IP, thr int, cfg *config.Config
return nil
}
func QueryInfo(client *http.Client, ip string) (query QueryIP, err error) {
func QueryInfo(cfg *config.Config, client *http.Client, ip string) (query QueryIP, err error) {
var url = fmt.Sprintf("%s/%s", IPINFO_WS, ip)
req, err := http.NewRequest("GET", url, nil)
if err != nil {
log.Println(err)
}
req.Header.Add("Accept", "*/*")
req.Header.Add("User-Agent", "ipbl")
req.Header.Add("User-Agent", fmt.Sprintf("ipbl %s", cfg.Options.Version))
res, err := client.Do(req)
if err != nil {
log.Println(err)

View File

@ -117,12 +117,8 @@ func RegisterRoutes(e *echo.Echo, ctx *context.Context, cfg *config.Config) {
return Result(c, err, "")
})
e.GET("/config", func(c echo.Context) (err error) {
if c.QueryParam("v") == "2" {
globalconfig, err := models.GetAllConfigv2(cfg)
return Result(c, err, globalconfig)
}
globalconfig, err := models.GetGlobalConfig(cfg)
return Result(c, err, globalconfig)
})
e.GET("/config/trustlist", func(c echo.Context) (err error) {
trustlists, err := models.GetTrustlists(cfg)