This commit is contained in:
skidoodle 2024-09-07 03:21:10 +02:00
parent 9240ecbf98
commit 0d760f38ae
8 changed files with 394 additions and 431 deletions

35
db.go Normal file
View file

@ -0,0 +1,35 @@
package main
import (
"log"
"sync"
"github.com/oschwald/maxminddb-golang"
)
var cityDB *maxminddb.Reader
var asnDB *maxminddb.Reader
var dbMtx = new(sync.RWMutex)
const (
cityDBPath = "./GeoLite2-City.mmdb"
asnDBPath = "./GeoLite2-ASN.mmdb"
)
func initDatabases() {
var err error
cityDB, err = maxminddb.Open(cityDBPath)
if err != nil {
log.Fatalf("Error opening city database: %v", err)
}
asnDB, err = maxminddb.Open(asnDBPath)
if err != nil {
log.Fatalf("Error opening ASN database: %v", err)
}
}
func startUpdater() {
log.Println("MaxMind GeoIP databases will be updated by geoipupdate automatically.")
}