Fix unused variable compilation error in geoip.go
This commit is contained in:
parent
3b91a48c06
commit
400f4116eb
|
|
@ -54,8 +54,6 @@ func (g *SimpleGeoBlockMiddleware) Middleware() gin.HandlerFunc {
|
||||||
|
|
||||||
// isBlockedIP checks if the IP falls into known problematic ranges
|
// isBlockedIP checks if the IP falls into known problematic ranges
|
||||||
func (g *SimpleGeoBlockMiddleware) isBlockedIP(ip net.IP) bool {
|
func (g *SimpleGeoBlockMiddleware) isBlockedIP(ip net.IP) bool {
|
||||||
ipStr := ip.String()
|
|
||||||
|
|
||||||
// Block common bot/scanner IP ranges
|
// Block common bot/scanner IP ranges
|
||||||
blockedRanges := []string{
|
blockedRanges := []string{
|
||||||
// Chinese IP ranges (simplified)
|
// 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
|
// isHostingProvider checks if IP is from known hosting providers often used by bots
|
||||||
func (g *SimpleGeoBlockMiddleware) isHostingProvider(ip net.IP) bool {
|
func (g *SimpleGeoBlockMiddleware) isHostingProvider(ip net.IP) bool {
|
||||||
ipStr := ip.String()
|
|
||||||
|
|
||||||
// Common hosting provider ASN prefixes (simplified)
|
// Common hosting provider ASN prefixes (simplified)
|
||||||
hostingPrefixes := []string{
|
hostingPrefixes := []string{
|
||||||
"34.", "35.", "52.", "54.", // AWS
|
"34.", "35.", "52.", "54.", // AWS
|
||||||
|
|
@ -122,7 +118,7 @@ func (g *SimpleGeoBlockMiddleware) isHostingProvider(ip net.IP) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, prefix := range hostingPrefixes {
|
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
|
// Additional check - if it's a known datacenter IP range
|
||||||
if g.isDatacenterIP(ip) {
|
if g.isDatacenterIP(ip) {
|
||||||
return true
|
return true
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue