/** * Two-letter upper case or "" * @return country in routerconsole.country property, else current locale * @since 0.9.10 */ public static String getCountry(I2PAppContext ctx) { // property may be empty so we don't have a non-default // language and a default country return ctx.getProperty(PROP_COUNTRY, _localeCountry); }
/** * Uses default m of 23, memory usage is 2 MB. * @param name just for logging / debugging / stats */ public DecayingBloomFilter(I2PAppContext context, int durationMs, int entryBytes, String name) { // this is instantiated in four different places, they may have different // requirements, but for now use this as a gross method of memory reduction. // m == 23 => 1MB each BloomSHA1 (4 pairs = 8MB total) this(context, durationMs, entryBytes, name, context.getProperty("router.decayingBloomFilterM", DEFAULT_M)); }
/** * @since 0.7.12 */ public boolean getBooleanPropertyDefaultTrue(String propName) { return getProperty(propName, true); }
/** @since 0.9.8 */ public boolean useLongElGamalExponent() { return _context.getProperty(PROP_LONG_EXPONENT, DEFAULT_USE_LONG_EXPONENT); }
public String getTheme() { String theme = _context.getProperty(PROP_THEME_NAME, DEFAULT_THEME); // remap deprecated themes if (theme.equals("midnight")) { if (_context.getProperty(PROP_DISABLE_OLD, DEFAULT_DISABLE_OLD)) theme = "dark"; } else if (theme.equals("classic")) { if (_context.getProperty(PROP_DISABLE_OLD, DEFAULT_DISABLE_OLD)) theme = "light"; } return "/themes/console/" + theme + "/"; }
/** * @param realm e.g. i2cp, routerconsole, etc. * @param user null or "" for no user, already trimmed * @return the pw or null */ public String getPlain(String realm, String user) { String pfx = realm; if (user != null && user.length() > 0) pfx += '.' + user; return _context.getProperty(pfx + PROP_PW); }
/** * Default false * @since 0.7.12 */ public boolean getBooleanProperty(String propName) { return Boolean.parseBoolean(getProperty(propName)); }
/** * Return a boolean with a boolean default * @since 0.7.12 */ public boolean getProperty(String propName, boolean defaultVal) { String val = getProperty(propName); if (val == null) return defaultVal; return Boolean.parseBoolean(val); }
/** * Two- or three-letter lower case * @return lang in routerconsole.lang property, else current locale */ public static String getLanguage(I2PAppContext ctx) { String lang = ctx.getProperty(PROP_LANG); if (lang == null || lang.length() <= 0) lang = _localeLang; return lang; }
/** * @param realm e.g. i2cp, routerconsole, etc. * @param user null or "" for no user, already trimmed * @param pw plain text, already trimmed * @return if pw verified */ public boolean checkPlain(String realm, String user, String pw) { String pfx = realm; if (user != null && user.length() > 0) pfx += '.' + user; return pw.equals(_context.getProperty(pfx + PROP_PW)); }
private List<String> getFilenames() { String list = _context.getProperty(PROP_HOSTS_FILE, DEFAULT_HOSTS_FILE); StringTokenizer tok = new StringTokenizer(list, ","); List<String> rv = new ArrayList<String>(tok.countTokens()); while (tok.hasMoreTokens()) rv.add(tok.nextToken()); return rv; }
private List<String> getURLs() { String list = _context.getProperty(PROP_EEPGET_LIST, DEFAULT_EEPGET_LIST); StringTokenizer tok = new StringTokenizer(list, ","); List<String> rv = new ArrayList<String>(tok.countTokens()); while (tok.hasMoreTokens()) rv.add(tok.nextToken()); return rv; }
public static File configFile(I2PAppContext ctx) { String clientConfigFile = ctx.getProperty(PROP_CLIENT_CONFIG_FILENAME, DEFAULT_CLIENT_CONFIG_FILENAME); File cfgFile = new File(clientConfigFile); if (!cfgFile.isAbsolute()) cfgFile = new File(ctx.getConfigDir(), clientConfigFile); return cfgFile; }
/** * Tie in the router's config as properties, as well as whatever the * I2PAppContext says. * */ @Override public String getProperty(String propName, String defaultVal) { if (_router != null) { String val = _router.getConfigSetting(propName); if (val != null) return val; } return super.getProperty(propName, defaultVal); }
/** * @param realm e.g. i2cp, routerconsole, etc. * @param user null or "" for no user, already trimmed * @return the decoded pw or null */ public String getB64(String realm, String user) { String pfx = realm; if (user != null && user.length() > 0) pfx += '.' + user; String b64 = _context.getProperty(pfx + PROP_B64); if (b64 == null) return null; return Base64.decodeToString(b64); }
/** * Tie in the router's config as properties, as well as whatever the * I2PAppContext says. * */ @Override public String getProperty(String propName) { if (_router != null) { String val = _router.getConfigSetting(propName); if (val != null) return val; } return super.getProperty(propName); } /**
private void initializeAESEngine() { synchronized (_lock7) { if (_AESEngine == null) { if ("off".equals(getProperty("i2p.encryption", "on"))) _AESEngine = new AESEngine(this); else _AESEngine = new CryptixAESEngine(this); } _AESEngineInitialized = true; } }
/** * @param realm e.g. i2cp, routerconsole, etc. * @param user null or "" for no user, already trimmed * @param pw plain text, already trimmed * @return if pw verified */ public boolean checkB64(String realm, String user, String pw) { String pfx = realm; if (user != null && user.length() > 0) pfx += '.' + user; String b64 = _context.getProperty(pfx + PROP_B64); if (b64 == null) return false; return b64.equals(Base64.encode(DataHelper.getUTF8(pw))); }
public AsyncFortunaStandalone(I2PAppContext context) { super(); _bufferCount = Math.max(context.getProperty("prng.buffers", DEFAULT_BUFFERS), 2); _bufferSize = Math.max(context.getProperty("prng.bufferSize", DEFAULT_BUFSIZE), 16*1024); _emptyBuffers = new LinkedBlockingQueue<AsyncBuffer>(_bufferCount); _fullBuffers = new LinkedBlockingQueue<AsyncBuffer>(_bufferCount); _context = context; context.statManager().createRequiredRateStat("prng.bufferWaitTime", "Delay for random number buffer (ms)", "Encryption", new long[] { 60*1000, 10*60*1000, 60*60*1000 } ); context.statManager().createRequiredRateStat("prng.bufferFillTime", "Time to fill random number buffer (ms)", "Encryption", new long[] { 60*1000, 10*60*1000, 60*60*1000 } ); _log = context.logManager().getLog(AsyncFortunaStandalone.class); }
private void updateInboundRate() { int in = _context.getProperty(PROP_INBOUND_BANDWIDTH, DEFAULT_INBOUND_BANDWIDTH); if (in != _inboundKBytesPerSecond) { // bandwidth was specified *and* changed if ( (in <= 0) || (in > MIN_INBOUND_BANDWIDTH) ) _inboundKBytesPerSecond = in; else _inboundKBytesPerSecond = MIN_INBOUND_BANDWIDTH; if (_log.shouldLog(Log.DEBUG)) _log.debug("Updating inbound rate to " + _inboundKBytesPerSecond); } if (_inboundKBytesPerSecond <= 0) _inboundKBytesPerSecond = DEFAULT_INBOUND_BANDWIDTH; }