Add GeoIP Local mirror support

This commit is contained in:
Maxim Pogozhiy 2020-12-28 15:28:16 +10:00
parent 944d36fdba
commit b55f4371e3
4 changed files with 29 additions and 2 deletions

View file

@ -173,6 +173,7 @@ Takes the form "<host>:port". If not provided, no admission controller is starte
statusUpdateInterval = flags.Int("status-update-interval", status.UpdateInterval, "Time interval in seconds in which the status should check if an update is required. Default is 60 seconds")
)
flags.StringVar(&nginx.MaxmindMirror, "maxmind-mirror", "", `Maxmind mirror url (example: http://geoip.local/databases`)
flags.StringVar(&nginx.MaxmindLicenseKey, "maxmind-license-key", "", `Maxmind license key to download GeoLite2 Databases.
https://blog.maxmind.com/2019/12/18/significant-changes-to-accessing-and-using-geolite2-databases`)
flags.StringVar(&nginx.MaxmindEditionIDs, "maxmind-edition-ids", "GeoLite2-City,GeoLite2-ASN", `Maxmind edition ids to download GeoLite2 Databases.`)
@ -299,7 +300,7 @@ https://blog.maxmind.com/2019/12/18/significant-changes-to-accessing-and-using-g
config.RootCAFile = *rootCAFile
}
if nginx.MaxmindLicenseKey != "" && nginx.MaxmindEditionIDs != "" {
if (nginx.MaxmindLicenseKey != "" || nginx.MaxmindMirror != "") && nginx.MaxmindEditionIDs != "" {
if err := nginx.ValidateGeoLite2DBEditions(); err != nil {
return false, nil, err
}

View file

@ -92,3 +92,16 @@ func TestMaxmindEdition(t *testing.T) {
t.Fatalf("Expected an error parsing flags but none returned")
}
}
func TestMaxmindMirror(t *testing.T) {
resetForTesting(func() { t.Fatal("Parsing failed") })
oldArgs := os.Args
defer func() { os.Args = oldArgs }()
os.Args = []string{"cmd", "--publish-service", "namespace/test", "--http-port", "0", "--https-port", "0", "--maxmind-mirror", "http://geoip.local", "--maxmind-license-key", "0000000", "--maxmind-edition-ids", "GeoLite2-City, TestCheck"}
_, _, err := parseFlags()
if err == nil {
t.Fatalf("Expected an error parsing flags but none returned")
}
}