/** * */ public SU3File(File file) { this(I2PAppContext.getGlobalContext(), file); }
/** * Constructs a new <code>TrustedUpdate</code> with the default global * context. */ public TrustedUpdate() { this(I2PAppContext.getGlobalContext()); }
/** * Create a new public/private value pair for the DH exchange. * Only for internal use and unit tests. * Others should get instances from PrecalcRunner.getBuilder() */ DHSessionKeyBuilder() { this(I2PAppContext.getGlobalContext()); }
/** * Translate */ private static String _t(String s) { return Translate.getString(s, I2PAppContext.getGlobalContext(), BUNDLE_NAME); }
/** * Is the certificate revoked? * This loads the CRLs from disk. * For efficiency, call loadCRLs() and then pass to isRevoked(). * * @since 0.9.25 */ public static boolean isRevoked(Certificate cert) { return isRevoked(I2PAppContext.getGlobalContext(), cert); }
/** * Create a new session (though do not connect it yet) * */ public I2PSession createSession(InputStream destKeyStream, Properties options) throws I2PSessionException { return createSession(I2PAppContext.getGlobalContext(), options); }
/** * @deprecated Don't use this to prestart threads, this is no longer a static instance * @return a new instance as of 0.9 */ @Deprecated public static final RetransmissionTimer getInstance() { return new RetransmissionTimer(I2PAppContext.getGlobalContext(), "RetransmissionTimer"); }
public static final void writeSeed(byte buf[]) { File f = new File(I2PAppContext.getGlobalContext().getConfigDir(), SEEDFILE); FileOutputStream fos = null; try { fos = new SecureFileOutputStream(f); fos.write(buf); } catch (IOException ioe) { // ignore } finally { if (fos != null) try { fos.close(); } catch (IOException ioe) {} } }
/** @return the configured NamingService, or the root NamingService */ private static NamingService getNamingService(String srch) { NamingService root = I2PAppContext.getGlobalContext().namingService(); NamingService rv = searchNamingService(root, srch); return rv != null ? rv : root; }
/** * Warning - not recommended. * Use I2PAppContext.getGlobalContext().logManager().getLog(cls) */ public Log(Class<?> cls) { this(I2PAppContext.getGlobalContext().logManager(), cls, null); _manager.addLog(this); }
/** @since 0.9.7 */ private static Log getLog() { return I2PAppContext.getGlobalContext().logManager().getLog(I2PSocketManagerFactory.class); } }
/** * If PROP_PREFER_HTTPS is true or unset, * return https URL unless console is http only. Default https://127.0.0.1:7667/ * If PROP_PREFER_HTTPS is set to false, * return http URL unless console is https only. Default http://127.0.0.1:7657/ * * @since 0.9.33 consolidated from i2ptunnel and desktopgui */ public String getConsoleURL() { return getConsoleURL(I2PAppContext.getGlobalContext().getBooleanPropertyDefaultTrue(PROP_PREFER_HTTPS)); }
/** * Resolved the specified hostname. * * @param name Hostname to be resolved * * @return the Destination for the specified hostname, or null if not found */ private static Destination lookupHost(String name) { NamingService ns = I2PAppContext.getGlobalContext().namingService(); Destination dest = ns.lookup(name); return dest; }
private static void info(String s) { if(_doLog) System.err.println("INFO: " + s); I2PAppContext.getGlobalContext().logManager().getLog(NativeBigInteger.class).info(s); _loadStatus = s; }
private static void error(String s) { I2PAppContext ctx = I2PAppContext.getGlobalContext(); Log log = ctx.logManager().getLog(ConnectionOptions.class); log.error(s); }
/** 48 char b32 string (30 bytes of entropy) */ public static String randomString() { I2PAppContext ctx = I2PAppContext.getGlobalContext(); // make a random 48 character password (30 * 8 / 5) byte[] rand = new byte[30]; ctx.random().nextBytes(rand); return Base32.encode(rand); }
@Override protected void afterExecute(Runnable r, Throwable t) { super.afterExecute(r, t); if (t != null) { // shoudn't happen, caught in RunnableEvent.run() Log log = I2PAppContext.getGlobalContext().logManager().getLog(SimpleTimer2.class); log.log(Log.CRIT, "event borked: " + r, t); } } }
/** * @throws IllegalStateException if not in RouterContext */ public boolean validateRoutingKey() { I2PAppContext ctx = I2PAppContext.getGlobalContext(); if (!ctx.isRouterContext()) throw new IllegalStateException("Not in router context"); RoutingKeyGenerator gen = ctx.routingKeyGenerator(); Hash destKey = getHash(); Hash rk = gen.getRoutingKey(destKey); return rk.equals(getRoutingKey()); }
public void fetchFrom(String url, boolean shouldSucceed) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); I2PSocketEepGet eep = new I2PSocketEepGet(I2PAppContext.getGlobalContext(), mgr, 0, -1, -1, null, baos, url); if (shouldSucceed) { assertTrue(eep.fetch()); assertThat(baos.toString(), is(equalTo(FETCH_RESULT))); } else { assertFalse(eep.fetch()); assertThat(baos.toString().length(), is(0)); } }
private ByteCache(int maxCachedEntries, int entrySize) { super(new ByteArrayFactory(entrySize), maxCachedEntries); _entrySize = entrySize; int stagger = SystemVersion.isAndroid() ? 0 : (entrySize % 777); SimpleTimer2.getInstance().addPeriodicEvent(new Cleanup(), CLEANUP_FREQUENCY + stagger); I2PAppContext.getGlobalContext().statManager().createRateStat("byteCache.memory." + entrySize, "Memory usage (B)", "Router", new long[] { 10*60*1000 }); }