* added version in user agent * lint code * removed compat with config v2
This commit is contained in:
parent
1f56bd64ca
commit
b8521f050a
@ -65,8 +65,9 @@ func migrate(cfg *config.Config) (err error) {
|
|||||||
for _, v := range rs {
|
for _, v := range rs {
|
||||||
if v != "" {
|
if v != "" {
|
||||||
n := models.CfgExpr{
|
n := models.CfgExpr{
|
||||||
Expr: v,
|
Expr: v,
|
||||||
Set: &cfgset,
|
Set: &cfgset,
|
||||||
|
Enabled: true,
|
||||||
}
|
}
|
||||||
cfg.Db.Insert(&n)
|
cfg.Db.Insert(&n)
|
||||||
}
|
}
|
||||||
|
@ -157,7 +157,7 @@ func ScanOrphan(wg *sync.WaitGroup, orphans chan IP, thr int, cfg *config.Config
|
|||||||
log.Println(err)
|
log.Println(err)
|
||||||
}
|
}
|
||||||
var query QueryIP
|
var query QueryIP
|
||||||
query, err := QueryInfo(&queryclient, orphan.IP)
|
query, err := QueryInfo(cfg, &queryclient, orphan.IP)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
time.Sleep(1 * time.Minute)
|
time.Sleep(1 * time.Minute)
|
||||||
@ -200,14 +200,14 @@ func ScanOrphan(wg *sync.WaitGroup, orphans chan IP, thr int, cfg *config.Config
|
|||||||
return nil
|
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)
|
var url = fmt.Sprintf("%s/%s", IPINFO_WS, ip)
|
||||||
req, err := http.NewRequest("GET", url, nil)
|
req, err := http.NewRequest("GET", url, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
}
|
}
|
||||||
req.Header.Add("Accept", "*/*")
|
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)
|
res, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
|
@ -117,11 +117,7 @@ func RegisterRoutes(e *echo.Echo, ctx *context.Context, cfg *config.Config) {
|
|||||||
return Result(c, err, "")
|
return Result(c, err, "")
|
||||||
})
|
})
|
||||||
e.GET("/config", func(c echo.Context) (err error) {
|
e.GET("/config", func(c echo.Context) (err error) {
|
||||||
if c.QueryParam("v") == "2" {
|
globalconfig, err := models.GetAllConfigv2(cfg)
|
||||||
globalconfig, err := models.GetAllConfigv2(cfg)
|
|
||||||
return Result(c, err, globalconfig)
|
|
||||||
}
|
|
||||||
globalconfig, err := models.GetGlobalConfig(cfg)
|
|
||||||
return Result(c, err, globalconfig)
|
return Result(c, err, globalconfig)
|
||||||
})
|
})
|
||||||
e.GET("/config/trustlist", func(c echo.Context) (err error) {
|
e.GET("/config/trustlist", func(c echo.Context) (err error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user