Skip to content

Commit

Permalink
🐞 fix: correct IP handling in AllowVisitByIP function to ensure prope…
Browse files Browse the repository at this point in the history
…r error checking and return values
  • Loading branch information
sohaha committed Jan 4, 2025
1 parent 5319eba commit c9edbf1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions znet/limiter/limiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ func (r *Rule) AllowVisit(keys ...interface{}) bool {

// AllowVisitByIP AllowVisit IP
func (r *Rule) AllowVisitByIP(ip string) bool {
i, _ := znet.IPToLong(ip)
if i == 0 {
return false
i, err := znet.IPToLong(ip)
if err == nil {
return r.AllowVisit(i)
}
return r.AllowVisit(i)

return r.AllowVisit(ip)
}

0 comments on commit c9edbf1

Please sign in to comment.