plugin/geoip: Add ASN schema support (#7730)

Adds the ability to query ASN .mmdb databases, in addition to the existing City db functionality.

Signed-off-by: Eric Case <eric.case@gmail.com>
This commit is contained in:
Eric Case
2025-11-30 08:36:33 -08:00
committed by GitHub
parent 604e1675cf
commit 54dd258d57
7 changed files with 213 additions and 37 deletions

View File

@@ -14,6 +14,7 @@ import (
var (
fixturesDir = "./testdata"
cityDBPath = filepath.Join(fixturesDir, "GeoLite2-City.mmdb")
asnDBPath = filepath.Join(fixturesDir, "GeoLite2-ASN.mmdb")
unknownDBPath = filepath.Join(fixturesDir, "GeoLite2-UnknownDbType.mmdb")
)
@@ -50,9 +51,12 @@ func TestGeoIPParse(t *testing.T) {
expectedErr string
expectedDBType int
}{
// Valid
// Valid - City database
{false, fmt.Sprintf("%s %s\n", pluginName, cityDBPath), "", city},
{false, fmt.Sprintf("%s %s { edns-subnet }", pluginName, cityDBPath), "", city},
// Valid - ASN database
{false, fmt.Sprintf("%s %s\n", pluginName, asnDBPath), "", asn},
{false, fmt.Sprintf("%s %s { edns-subnet }", pluginName, asnDBPath), "", asn},
// Invalid
{true, pluginName, "Wrong argument count", 0},