geoip: read source IP from EDNS0 subnet if provided (#5183)

* geoip: read source IP from EDNS0 subnet if provided

This patch implements EDNS backend processing (similar in powerdns: https://doc.powerdns.com/authoritative/settings.html#setting-edns-subnet-processing). This feature comes very handy to test whether your geo config is working properly.

Signed-off-by: Balazs Nagy <julsevern@gmail.com>
This commit is contained in:
Balazs Nagy 2022-05-02 19:25:02 +02:00 committed by GitHub
parent 66f2ac7568
commit 4ae29a449c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 122 additions and 50 deletions

View file

@ -52,14 +52,15 @@ func TestGeoIPParse(t *testing.T) {
}{
// Valid
{false, fmt.Sprintf("%s %s\n", pluginName, cityDBPath), "", city},
{false, fmt.Sprintf("%s %s { edns-subnet }", pluginName, cityDBPath), "", city},
// Invalid
{true, pluginName, "Wrong argument count", 0},
{true, fmt.Sprintf("%s %s {\n\tlanguages en fr es zh-CN\n}\n", pluginName, cityDBPath), "unexpected config block", 0},
{true, fmt.Sprintf("%s %s {\n\tlanguages en fr es zh-CN\n}\n", pluginName, cityDBPath), "unknown property \"languages\"", 0},
{true, fmt.Sprintf("%s %s\n%s %s\n", pluginName, cityDBPath, pluginName, cityDBPath), "configuring multiple databases is not supported", 0},
{true, fmt.Sprintf("%s 1 2 3", pluginName), "Wrong argument count", 0},
{true, fmt.Sprintf("%s { }", pluginName), "Error during parsing", 0},
{true, fmt.Sprintf("%s /dbpath { city }", pluginName), "unexpected config block", 0},
{true, fmt.Sprintf("%s /dbpath { city }", pluginName), "unknown property \"city\"", 0},
{true, fmt.Sprintf("%s /invalidPath\n", pluginName), "failed to open database file: open /invalidPath: no such file or directory", 0},
{true, fmt.Sprintf("%s %s\n", pluginName, unknownDBPath), "reader does not support the \"UnknownDbType\" database type", 0},
}