Skip to content

Commit

Permalink
Update blacklist.go
Browse files Browse the repository at this point in the history
Fixed blacklist CIDR not working bug
  • Loading branch information
tobychui committed Apr 30, 2024
1 parent a9695e9 commit e2a449a
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/mod/access/blacklist.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package access

import (
"strings"

"imuslab.com/zoraxy/mod/netutils"
)

/*
Expand Down Expand Up @@ -71,5 +73,22 @@ func (s *AccessRule) GetAllBlacklistedIp() []string {
func (s *AccessRule) IsIPBlacklisted(ipAddr string) bool {
IPBlacklist := *s.BlackListIP
_, 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
}

0 comments on commit e2a449a

Please sign in to comment.