/** Constructs an IPFilter that automatically loads the content. */ @Inject public LocalIPFilter( @Named("hostileFilter") IPFilter hostileNetworkFilter, @Named("backgroundExecutor") ScheduledExecutorService ipLoader) { this.hostileNetworkFilter = hostileNetworkFilter; this.ipLoader = ipLoader; File hostiles = new File(CommonUtils.getUserSettingsDir(), "hostiles.txt"); shouldLoadHostiles = hostiles.exists(); hostileNetworkFilter.refreshHosts(); refreshHosts(); }
@Override protected boolean allowImpl(IP ip) { if (goodHosts.contains(ip)) { whitelistings++; return true; } if (badHosts.contains(ip)) { blacklistings++; return false; } if (FilterSettings.USE_NETWORK_FILTER.getValue() && !hostileNetworkFilter.allow(ip)) { netblockings++; return false; } implicitings++; return true; }
/** Determines if any blacklisted hosts exist. */ public boolean hasBlacklistedHosts() { return (FilterSettings.USE_NETWORK_FILTER.getValue() && hostileNetworkFilter.hasBlacklistedHosts()) || !badHosts.isEmpty(); }