/** Does the work of setting new good & bad hosts. */ private void refreshHostsImpl() { LOG.debug("refreshing hosts"); // Load the local blacklist, stripping out invalid entries IPList newBad = new IPList(); String[] allHosts = FilterSettings.BLACK_LISTED_IP_ADDRESSES.get(); ArrayList<String> valid = new ArrayList<String>(allHosts.length); for (int i = 0; i < allHosts.length; i++) { if (newBad.add(allHosts[i])) valid.add(allHosts[i]); } if (valid.size() != allHosts.length) { allHosts = valid.toArray(new String[0]); FilterSettings.BLACK_LISTED_IP_ADDRESSES.set(allHosts); } // Load the local whitelist, stripping out invalid entries IPList newGood = new IPList(); allHosts = FilterSettings.WHITE_LISTED_IP_ADDRESSES.get(); valid = new ArrayList<String>(allHosts.length); for (int i = 0; i < allHosts.length; i++) { if (newGood.add(allHosts[i])) valid.add(allHosts[i]); } if (valid.size() != allHosts.length) { allHosts = valid.toArray(new String[0]); FilterSettings.WHITE_LISTED_IP_ADDRESSES.set(allHosts); } // Load data from hostiles.txt (if it wasn't already loaded!)... if (shouldLoadHostiles) { shouldLoadHostiles = false; LOG.debug("loading hostiles"); File hostiles = new File(CommonUtils.getUserSettingsDir(), "hostiles.txt"); BufferedReader reader = null; try { reader = new BufferedReader(new FileReader(hostiles)); String read = null; while ((read = reader.readLine()) != null) { hostilesTXTHosts.add(read); } } catch (IOException ignored) { LOG.debug("iox loading hostiles", ignored); } finally { IOUtils.close(reader); } } badHosts = new MultiIPList(newBad, hostilesTXTHosts); goodHosts = newGood; }
@Override public void initOptions() { String[] bannedIps = FilterSettings.BLACK_LISTED_IP_ADDRESSES.get(); FilterModel model = new FilterModel(new ArrayList<String>(Arrays.asList(bannedIps))); filterTable.setModel(model); backListCheckBox.setSelected(FilterSettings.USE_NETWORK_FILTER.getValue()); }
@Override boolean applyOptions() { List<String> list = filterTable.getFilterModel().getModel(); FilterSettings.USE_NETWORK_FILTER.setValue(backListCheckBox.isSelected()); FilterSettings.BLACK_LISTED_IP_ADDRESSES.set(list.toArray(new String[list.size()])); spamManager.reloadIPFilter(); return false; }
@SuppressWarnings({"unused"}) private static void doSettings() throws Exception { String localIP = InetAddress.getLocalHost().getHostAddress(); FilterSettings.BLACK_LISTED_IP_ADDRESSES.set(new String[] {"*.*.*.*"}); FilterSettings.WHITE_LISTED_IP_ADDRESSES.set( new String[] {"127.*.*.*", "192.168.*.*", "10.254.*.*", localIP}); NetworkSettings.PORT.setValue(SERVER_PORT); ConnectionSettings.CONNECT_ON_STARTUP.setValue(false); UltrapeerSettings.EVER_ULTRAPEER_CAPABLE.setValue(false); UltrapeerSettings.DISABLE_ULTRAPEER_MODE.setValue(true); UltrapeerSettings.FORCE_ULTRAPEER_MODE.setValue(false); ConnectionSettings.NUM_CONNECTIONS.setValue(0); ConnectionSettings.LOCAL_IS_PRIVATE.setValue(false); ConnectionSettings.WATCHDOG_ACTIVE.setValue(false); SearchSettings.MINIMUM_SEARCH_QUALITY.setValue(-2); }
private void setSettings() throws Exception { FilterSettings.BLACK_LISTED_IP_ADDRESSES.set(new String[] {"*.*.*.*"}); // Set the local host to not be banned so pushes can go through String ip = InetAddress.getLocalHost().getHostAddress(); FilterSettings.WHITE_LISTED_IP_ADDRESSES.set(new String[] {ip, "127.*.*.*"}); NetworkSettings.PORT.setValue(TEST_PORT); ConnectionSettings.CONNECT_ON_STARTUP.setValue(false); ConnectionSettings.LOCAL_IS_PRIVATE.setValue(false); // reset the node capabilities settings UltrapeerSettings.FORCE_ULTRAPEER_MODE.setValue(false); UltrapeerSettings.EVER_ULTRAPEER_CAPABLE.setValue(false); UltrapeerSettings.NEED_MIN_CONNECT_TIME.setValue(true); UltrapeerSettings.DISABLE_ULTRAPEER_MODE.setValue(false); DHTSettings.DISABLE_DHT_USER.setValue(false); DHTSettings.DISABLE_DHT_NETWORK.setValue(false); DHTSettings.EXCLUDE_ULTRAPEERS.setValue(true); DHTSettings.FORCE_DHT_CONNECT.setValue(false); DHTSettings.ENABLE_PASSIVE_DHT_MODE.setValue(true); DHTSettings.ENABLE_PASSIVE_LEAF_DHT_MODE.setValue(true); }
@Override protected void setSettings() throws Exception { ConnectionSettings.NUM_CONNECTIONS.setValue(4); SearchSettings.GUESS_ENABLED.setValue(true); UltrapeerSettings.DISABLE_ULTRAPEER_MODE.setValue(false); UltrapeerSettings.EVER_ULTRAPEER_CAPABLE.setValue(true); UltrapeerSettings.FORCE_ULTRAPEER_MODE.setValue(true); ConnectionSettings.EVER_ACCEPTED_INCOMING.setValue(true); ConnectionSettings.CONNECT_ON_STARTUP.setValue(false); ConnectionSettings.LOCAL_IS_PRIVATE.setValue(false); FilterSettings.BLACK_LISTED_IP_ADDRESSES.set(new String[] {"*.*.*.*"}); FilterSettings.WHITE_LISTED_IP_ADDRESSES.set( new String[] {"127.*.*.*", InetAddress.getLocalHost().getHostAddress()}); ConnectionSettings.WATCHDOG_ACTIVE.setValue(false); ConnectionSettings.ALLOW_WHILE_DISCONNECTED.setValue(true); // ConnectionSettings.PORT.setValue(6332); UltrapeerSettings.NEED_MIN_CONNECT_TIME.setValue(false); }
@Override boolean hasChanged() { List model = Arrays.asList(FilterSettings.BLACK_LISTED_IP_ADDRESSES.get()); return backListCheckBox.isSelected() != FilterSettings.USE_NETWORK_FILTER.getValue() || !model.equals(filterTable.getFilterModel().getModel()); }