Skip to content

Commit

Permalink
feat(api): added goroutine refresh geoip database
Browse files Browse the repository at this point in the history
  • Loading branch information
Tbaile committed Sep 17, 2024
1 parent 1ea2380 commit 3af5388
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ func main() {

// init geoip
utils.InitGeoIP()
// start geoip refresh loop
go routines.RefreshGeoIPDatabase()

// starts remote info loop
go routines.RefreshRemoteInfoLoop()
Expand Down
11 changes: 11 additions & 0 deletions api/routines/routines.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
package routines

import (
"github.com/NethServer/nethsecurity-controller/api/utils"
"time"

"github.com/NethServer/nethsecurity-controller/api/logs"
Expand All @@ -33,3 +34,13 @@ func RefreshRemoteInfoLoop() {
}
}
}

func RefreshGeoIPDatabase() {
ticker := time.NewTicker(24 * time.Hour)
for range ticker.C {
err := utils.InitGeoIP()
if err != nil {
logs.Logs.Println("[ERR][ROUTINE] loop for geoip database failed: " + err.Error())
}
}
}

0 comments on commit 3af5388

Please sign in to comment.