/** * Checks individual count only. Does not increment. * @since 0.9.3 */ boolean isThrottled(Hash h) { if (_max > 0) return this.counter.count(h) > _max; return false; }
/** * Checks if individual count is over the limit by this much. Does not increment. * @since 0.9.34 */ boolean isOverBy(Hash h, int over) { if (_max > 0) return this.counter.count(h) > _max + over; return false; }
public boolean isCached(Hash h) { if (counter.count(h) >= _maxFails) return true; synchronized(badDests) { return badDests.get(h) != null; } }
/** * For reliability reasons, don't allow a peer in more than x% of * client and exploratory tunnels. * * This also will prevent a single huge-capacity (or malicious) peer from * taking all the tunnels in the network (although it would be nice to limit * the % of total network tunnels to 10% or so, but that appears to be * too low to set as a default here... much lower than 33% will push client * tunnels out of the fast tier into high cap or beyond...) * * Possible improvement - restrict based on count per IP, or IP block, * to slightly increase costs of collusion * * @return Set of peers that should not be allowed in another tunnel */ public Set<Hash> selectPeersInTooManyTunnels() { ObjectCounter<Hash> lc = new ObjectCounter<Hash>(); int tunnelCount = countTunnelsPerPeer(lc); Set<Hash> rv = new HashSet<Hash>(); if (tunnelCount >= 4 && _context.router().getUptime() > 10*60*1000) { int max = _context.getProperty("router.maxTunnelPercentage", DEFAULT_MAX_PCT_TUNNELS); for (Hash h : lc.objects()) { if (lc.count(h) > 0 && (lc.count(h) + 1) * 100 / (tunnelCount + 1) > max) rv.add(h); } } return rv; }
int count = _blockedIPs.count(ba); if (count > 0) { count = _blockedIPs.increment(ba);
/** * @return null if not found */ private String query(String host, boolean isv6, List<String> toQuery) { for (String url : toQuery) { if (fails.count(url) > MAX_FAILS) continue; int tcode = isv6 ? V6_CODE : V4_CODE; String furl = url + "name=" + host + "&type=" + tcode; log("Fetching " + furl); baos.reset(); SSLEepGet eepget = new SSLEepGet(ctx, baos, furl, state); if (ctx.isRouterContext()) eepget.addStatusListener(this); else fetchStart = System.currentTimeMillis(); // debug String rv = fetch(eepget, host, isv6); if (rv != null) { fails.clear(url); return rv; } if (state == null) state = eepget.getSSLState(); // we treat all fails the same, whether server responded or not fails.increment(url); log("No result from " + furl); } return null; }
/** * Checks individual count only. Does not increment. * @since 0.9.3 */ boolean isThrottled(Hash h) { if (_max > 0) return this.counter.count(h) > _max; return false; }
/** * Checks if individual count is over the limit by this much. Does not increment. * @since 0.9.34 */ boolean isOverBy(Hash h, int over) { if (_max > 0) return this.counter.count(h) > _max + over; return false; }
continue; int bad = _badCounter.count(h); if (bad >= MAX_BAD) { if (_log.shouldLog(Log.WARN))