예제 #1
0
  /** 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();
  }
예제 #2
0
  @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;
  }
예제 #3
0
 /** Determines if any blacklisted hosts exist. */
 public boolean hasBlacklistedHosts() {
   return (FilterSettings.USE_NETWORK_FILTER.getValue()
           && hostileNetworkFilter.hasBlacklistedHosts())
       || !badHosts.isEmpty();
 }