Merge pull request #6685 from foxdalas/geoip_local_mirror
Add GeoIP Local mirror support
This commit is contained in:
commit
cff52e69c7
4 changed files with 29 additions and 2 deletions
|
|
@ -36,6 +36,9 @@ var MaxmindEditionIDs = ""
|
|||
// MaxmindEditionFiles maxmind databases on disk
|
||||
var MaxmindEditionFiles []string
|
||||
|
||||
// MaxmindMirror maxmind database mirror url (http://geoip.local)
|
||||
var MaxmindMirror = ""
|
||||
|
||||
const (
|
||||
geoIPPath = "/etc/nginx/geoip"
|
||||
dbExtension = ".mmdb"
|
||||
|
|
@ -68,8 +71,15 @@ func DownloadGeoLite2DB() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func createURL(mirror, licenseKey, dbName string) string {
|
||||
if len(mirror) > 0 {
|
||||
return fmt.Sprintf("%s/%s.tar.gz", mirror, dbName)
|
||||
}
|
||||
return fmt.Sprintf(maxmindURL, licenseKey, dbName)
|
||||
}
|
||||
|
||||
func downloadDatabase(dbName string) error {
|
||||
url := fmt.Sprintf(maxmindURL, MaxmindLicenseKey, dbName)
|
||||
url := createURL(MaxmindMirror, MaxmindLicenseKey, dbName)
|
||||
req, err := http.NewRequest(http.MethodGet, url, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue