mirror of
https://github.com/tobychui/zoraxy.git
synced 2025-06-06 15:47:19 +02:00
Update blacklist.go
Fixed blacklist CIDR not working bug
This commit is contained in:
parent
a9695e969e
commit
e2a449a7bc
@ -2,6 +2,8 @@ package access
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"imuslab.com/zoraxy/mod/netutils"
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -71,5 +73,22 @@ func (s *AccessRule) GetAllBlacklistedIp() []string {
|
|||||||
func (s *AccessRule) IsIPBlacklisted(ipAddr string) bool {
|
func (s *AccessRule) IsIPBlacklisted(ipAddr string) bool {
|
||||||
IPBlacklist := *s.BlackListIP
|
IPBlacklist := *s.BlackListIP
|
||||||
_, ok := IPBlacklist[ipAddr]
|
_, ok := IPBlacklist[ipAddr]
|
||||||
return ok
|
if ok {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
//Check for CIDR
|
||||||
|
for ipOrCIDR, _ := range IPBlacklist {
|
||||||
|
wildcardMatch := netutils.MatchIpWildcard(ipAddr, ipOrCIDR)
|
||||||
|
if wildcardMatch {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
cidrMatch := netutils.MatchIpCIDR(ipAddr, ipOrCIDR)
|
||||||
|
if cidrMatch {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user