mirror of
https://github.com/therootcompany/golib.git
synced 2026-04-24 12:48:00 +00:00
refactor(geoip,check-ip): inline literal mmdb filenames
Use 'GeoLite2-City.mmdb' / 'GeoLite2-ASN.mmdb' directly instead of composing from the edition constants. Reads plainly — the actual filename is right there.
This commit is contained in:
parent
359b740cec
commit
cb39f30d91
@ -134,8 +134,8 @@ func main() {
|
||||
// downloaded via httpcache conditional GETs; otherwise the files are
|
||||
// expected to exist on disk and are polled for out-of-band changes.
|
||||
func geoFetcher(confPath, dir string) dataset.Fetcher {
|
||||
cityPath := filepath.Join(dir, geoip.CityEdition+".mmdb")
|
||||
asnPath := filepath.Join(dir, geoip.ASNEdition+".mmdb")
|
||||
cityPath := filepath.Join(dir, "GeoLite2-City.mmdb")
|
||||
asnPath := filepath.Join(dir, "GeoLite2-ASN.mmdb")
|
||||
if confPath == "" {
|
||||
for _, p := range geoip.DefaultConfPaths() {
|
||||
if _, err := os.Stat(p); err == nil {
|
||||
|
||||
@ -17,8 +17,8 @@ type Databases struct {
|
||||
|
||||
// Open opens <dir>/GeoLite2-City.mmdb and <dir>/GeoLite2-ASN.mmdb.
|
||||
func Open(dir string) (*Databases, error) {
|
||||
cityPath := filepath.Join(dir, CityEdition+".mmdb")
|
||||
asnPath := filepath.Join(dir, ASNEdition+".mmdb")
|
||||
cityPath := filepath.Join(dir, "GeoLite2-City.mmdb")
|
||||
asnPath := filepath.Join(dir, "GeoLite2-ASN.mmdb")
|
||||
city, err := geoip2.Open(cityPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("open %s: %w", cityPath, err)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user