func (p *Proxy) isRatelimited(addr net.Addr) bool {
	if p.Ratelimit <= 0 { // 0 -- disabled
		return false
	}

	ip := getIPString(addr)
	if ip == "" {
		log.Printf("failed to split %v into host/port", addr)
		return false
	}

	if len(p.RatelimitWhitelist) > 0 {
		i := sort.SearchStrings(p.RatelimitWhitelist, ip)

		if i < len(p.RatelimitWhitelist) && p.RatelimitWhitelist[i] == ip {
			// found, don't ratelimit
			return false
		}
	}

	value := p.limiterForIP(ip)
	rl, ok := value.(*rate.RateLimiter)
	if !ok {
		log.Println("SHOULD NOT HAPPEN: non-bool entry found in safebrowsing lookup cache")
		return false
	}

	allow, _ := rl.Try()
	return !allow
}
// isRatelimited checks if the specified IP is ratelimited
isRatelimited checks if the specified IP is ratelimited
// isRatelimited checks if the specified IP is ratelimited
func (p *Proxy) isRatelimited(addr net.Addr) bool {
	if p.Ratelimit <= 0 { 
		return false
	}
	ip := getIPString(addr)
	if ip == "" {
		log.Printf("failed to split %v into host/port", addr)
		return false
	}
	if len(p.RatelimitWhitelist) > 0 {
		i := sort.SearchStrings(p.RatelimitWhitelist, ip)
		if i < len(p.RatelimitWhitelist) && p.RatelimitWhitelist[i] == ip {
			return false
		}
	}
	value := p.limiterForIP(ip)
	rl, ok := value.(*rate.RateLimiter)
	if !ok {
		log.Println("SHOULD NOT HAPPEN: non-bool entry found in safebrowsing lookup cache")
		return false
	}
	allow, _ := rl.Try()
	return !allow
}
func ( p * Proxy ) isRatelimited ( addr net . Addr ) bool { if p . Ratelimit <= 0 { return false } ip := getIPString ( addr ) if ip == " " { log . Printf ( " " , addr ) return false } if len ( p . RatelimitWhitelist ) > 0 { i := sort . SearchStrings ( p . RatelimitWhitelist , ip ) if i < len ( p . RatelimitWhitelist ) && p . RatelimitWhitelist [ i ] == ip { return false } } value := p . limiterForIP ( ip ) rl , ok := value . ( * rate . RateLimiter ) if ! ok { log . Println ( " " ) return false } allow , _ := rl . Try ( ) return ! allow }
isRatelimited checks if the specified IP is ratelimited
isRatelimited checks if the specified IP is ratelimited
// 0 -- disabled // found, don't ratelimit