diff --git a/go-backend/internal/middleware/geoip.go b/go-backend/internal/middleware/geoip.go index 2062bd6..c560a91 100644 --- a/go-backend/internal/middleware/geoip.go +++ b/go-backend/internal/middleware/geoip.go @@ -54,8 +54,6 @@ func (g *SimpleGeoBlockMiddleware) Middleware() gin.HandlerFunc { // isBlockedIP checks if the IP falls into known problematic ranges func (g *SimpleGeoBlockMiddleware) isBlockedIP(ip net.IP) bool { - ipStr := ip.String() - // Block common bot/scanner IP ranges blockedRanges := []string{ // Chinese IP ranges (simplified) @@ -109,8 +107,6 @@ func (g *SimpleGeoBlockMiddleware) isBlockedIP(ip net.IP) bool { // isHostingProvider checks if IP is from known hosting providers often used by bots func (g *SimpleGeoBlockMiddleware) isHostingProvider(ip net.IP) bool { - ipStr := ip.String() - // Common hosting provider ASN prefixes (simplified) hostingPrefixes := []string{ "34.", "35.", "52.", "54.", // AWS @@ -122,7 +118,7 @@ func (g *SimpleGeoBlockMiddleware) isHostingProvider(ip net.IP) bool { } for _, prefix := range hostingPrefixes { - if strings.HasPrefix(ipStr, prefix) { + if strings.HasPrefix(ip.String(), prefix) { // Additional check - if it's a known datacenter IP range if g.isDatacenterIP(ip) { return true