mirror of
https://github.com/nxtrace/NTrace-core.git
synced 2025-08-12 06:26:39 +00:00
fix: filter switch-case condition
This commit is contained in:
@@ -25,57 +25,62 @@ func Filter(ip string) (*IPGeoData, bool) {
|
||||
asn = ""
|
||||
whois = "RFC1918"
|
||||
isFiltered = true
|
||||
break
|
||||
//IANA Reserved Address Space
|
||||
case cidrRangeContains("100.64.0.0/10", ip):
|
||||
asn = ""
|
||||
whois = "RFC6598"
|
||||
isFiltered = true
|
||||
break
|
||||
case cidrRangeContains("198.18.0.0/15", ip):
|
||||
asn = ""
|
||||
whois = "RFC2544"
|
||||
isFiltered = true
|
||||
break
|
||||
case cidrRangeContains("198.51.100.0/24", ip):
|
||||
fallthrough
|
||||
case cidrRangeContains("203.0.113.0/24", ip):
|
||||
asn = ""
|
||||
whois = "RFC5737"
|
||||
isFiltered = true
|
||||
break
|
||||
case cidrRangeContains("240.0.0.0/4", ip):
|
||||
asn = ""
|
||||
whois = "RFC1112"
|
||||
isFiltered = true
|
||||
break
|
||||
//Defense Information System Network
|
||||
case cidrRangeContains("6.0.0.0/8", ip):
|
||||
fallthrough
|
||||
case cidrRangeContains("7.0.0.0/8", ip):
|
||||
fallthrough
|
||||
case cidrRangeContains("11.0.0.0/8", ip):
|
||||
fallthrough
|
||||
case cidrRangeContains("21.0.0.0/8", ip):
|
||||
fallthrough
|
||||
case cidrRangeContains("22.0.0.0/8", ip):
|
||||
fallthrough
|
||||
case cidrRangeContains("26.0.0.0/8", ip):
|
||||
fallthrough
|
||||
case cidrRangeContains("28.0.0.0/8", ip):
|
||||
fallthrough
|
||||
case cidrRangeContains("29.0.0.0/8", ip):
|
||||
fallthrough
|
||||
case cidrRangeContains("30.0.0.0/8", ip):
|
||||
fallthrough
|
||||
case cidrRangeContains("33.0.0.0/8", ip):
|
||||
fallthrough
|
||||
case cidrRangeContains("55.0.0.0/8", ip):
|
||||
fallthrough
|
||||
case cidrRangeContains("214.0.0.0/8", ip):
|
||||
fallthrough
|
||||
case cidrRangeContains("215.0.0.0/8", ip):
|
||||
asn = ""
|
||||
whois = "DOD"
|
||||
isFiltered = true
|
||||
break
|
||||
default:
|
||||
}
|
||||
if isFiltered == false {
|
||||
if !isFiltered {
|
||||
return nil, false
|
||||
} else {
|
||||
return &IPGeoData{
|
||||
Asnumber: asn,
|
||||
//Isp: isp,
|
||||
//Owner: isp,
|
||||
Whois: whois,
|
||||
Whois: whois,
|
||||
}, true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user