plugin/geoip: Upgrade to geoip2-golang v2 (#7732)

Signed-off-by: Eric Case <eric.case@gmail.com>
This commit is contained in:
Eric Case
2025-12-08 12:19:47 -08:00
committed by GitHub
parent 2a96ac10fd
commit 8f48704abe
7 changed files with 44 additions and 44 deletions

View File

@@ -2,7 +2,6 @@ package geoip
import (
"fmt"
"net"
"path/filepath"
"strings"
"testing"
@@ -19,7 +18,7 @@ var (
)
func TestProbingIP(t *testing.T) {
if probingIP == nil {
if !probingIP.IsValid() {
t.Fatalf("Invalid probing IP: %q", probingIP)
}
}
@@ -96,19 +95,4 @@ func TestGeoIPParse(t *testing.T) {
t.Errorf("Test %d: expected db type %d not found, database file provides %d", i, test.expectedDBType, geoIP.db.provides)
}
}
// Set nil probingIP to test unexpected validate error()
defer func(ip net.IP) { probingIP = ip }(probingIP)
probingIP = nil
c = caddy.NewTestController("dns", fmt.Sprintf("%s %s\n", pluginName, cityDBPath))
_, err := geoipParse(c)
if err != nil {
expectedErr := "unexpected failure looking up database"
if !strings.Contains(err.Error(), expectedErr) {
t.Errorf("expected error to contain: %s", expectedErr)
}
} else {
t.Errorf("with a nil probingIP test is expected to fail")
}
}