package net.i2p.util
General utility classes shared across the core libraries and the router.
- Logging (Log, LogManager, LogWriter outputs)
- HTTP fetches through the proxy (EepGet)
- String and encoding helpers (see also
DataHelper) - Collection and map helpers
- File and I/O helpers
- Thread and executor helpers
- Network address utilities
- Random sources (RandomSource, FortunaRandomSource)
- Native BigInteger support via the jbigi library
- System version and memory checks
Classes here may be changed or moved without notice.
See also: RFC 2617 (HTTP authentication) • RFC 4941 (temporary IPv6 addresses) • RFC 5952 (IPv6 text format) • RFC 7578 (multipart form data) • RFC 7858 (DNS over TLS) • RFC 8484 (DNS over HTTPS).
- ClassDescriptionMethods to get the local addresses, and other IP utilities.Cached IPv6 address with its scope.Enumeration of supported address types.ArraySet<E>A small, fast Set with a maximum size, backed by a fixed-size array.Exception thrown when attempting to add an element to a full ArraySet.A Westwood bandwidth estimator.OutputStream to InputStream adapter.Cache the objects frequently used to reduce memory churn.Factory for cached byte arrays.Global cleanup task that iterates over all caches.Alternate location for determining the time which takes into account an offset.Listener for clock offset changes.Simple command line access to various utilities.Implement on top of a ConcurrentHashMap with a dummy value.Convert any kind of destination String to a hash Supported: Base64 dest Base64 dest.i2p Base64 Hash Base64 Hash.i2p Base32 Hash Base32 desthash.b32.i2p example.i2p.Simple implementation of DNS over HTTPS.One resolved IP with its expiry time.DNS query type for IPv4/IPv6 preference.EepGet [-p 127.0.0.1:4444] [-n #retries] [-o outputFile] [-m markSize lineLen] url.Authentication mode enumeration.Parsed Content-Range header value.Callback interface for monitoring EepGet transfer progress.This is a quick hack to get a working EepHead, primarily for the following usage:Extends EepGet for POST.Event dispatching interface.An implementation of the EventDispatcher interface.File-based log writer thread that pulls log records from the LogManager, writes them to the current logfile, and rotates the logs as necessary.Gzips a rotated log file in the background.A FileFilter that accepts regular files with a suffix and optionally a prefix, case-insensitive.General helper methods for messing with filesWrapper around GNU-Crypto's Fortuna PRNG.Hexdump class (well, it's actually a namespace with some functions, but let's stick with java terminology :-).Like
I2PThreadbut with per-thread OOM listeners, rather than a static router-wide listener list, so that an OOM in an app won't call the router listener to shutdown the whole router.This class contains a number of properties ((key,value)-pairs).Callback interface for property change notifications.Loads trusted ASCII certs from ~/.i2p/certificates/ and $I2P/certificates/.Preferred overThreadfor all router uses.Listener for out-of-memory events.A simple in-JVM ServerSocket using Piped Streams.A simple in-JVM Socket using Piped Streams.Thread-safe mapping from router hashes to session keys.LHMCache<K,V> A LinkedHashMap with a maximum size, for use as an LRU cache.Wrapper class for whatever logging system I2P uses.One named logging scope and its settings.Offer a glimpse into the last few console messages generated.Defines the log limit for a particular set of logs.Manages the logging system, loading (and reloading) the configuration file, coordinating the log limits, and storing the set of log records pending.Keep track of a log entry, unformatted.Render a log record according to the log manager's settings.Collapses repeated occurrences of the same log message.What the caller should do with one occurrence.Per-key bookkeeping.Log writer thread that pulls log records from the LogManager and writes them to the log.Simple lookahead buffer to keep the last K bytes in reserve, configured to easily be reused.BigInteger that takes advantage of the jbigi library for the modPow operation, which accounts for a massive segment of the processing cost of asymmetric crypto.Thread-safe counter for tracking occurrences of objects.Non-thread-safe counter for tracking occurrences of objects.Modifiable integer.Properties map that has its keySet ordered consistently (via the key's lexicographical ordering).Orders entries by key so the written file is stable.Fetch exactly the first 'size' bytes into a stream Anything less or more will throw an IOException Retries may be given; zero for no retries.Manage both plaintext and salted/hashed password storage inrouter.config.Map services to internal or external application ports for this context.Singleton for whatever PRNG i2p uses.Thread to prevent hanging on init, presumably due to /dev/random blocking, which is common in VMs.GZIP implementation per RFC 1952, reusing java's standard CRC32 and Inflater and InflaterInputStream implementations.Essentially a SequenceInputStream(in, new ByteArrayInputStream(new byte[1])), except that this is resettable.GZIP implementation per RFC 1952, reusing java's standard CRC32 and Deflater implementations.Provide a cache of reusable GZIP unzipper streams.Provide a cache of reusable GZIP streams, each handling up to 40 KB output without expansion.Moved from NewsFetcher.Same as File but sets the file mode afterSecureDirectory.mkdir()so it can be read and written by the owner only (i.e.Same as SecureDirectory but sets the file mode afterSecureFile.createNewFile()andSecureFile.createTempFile(String, String)also.Same as FileOutputStream but sets the file mode so it can only be read and written by the owner only (i.e.Passes a command to the OS shell for execution and manages the input and output.Holds the result of a shell command.Consumes stream data.Like ByteCache but works directly with byte arrays, not ByteArrays.Factory for cached byte arrays.Global cleanup task that iterates over all caches.A set ofSimpleByteCache, keyed by array size.Replaced wholesale on growth, so a reader always sees a complete one.Scheduled event executor backed byScheduledThreadPoolExecutor.Executor that rejects work after shutdown.Base class for timer events.State of a given TimedEvent.What a single saturation-watchdog sample means.Thread factory for the saturation watchdog.Wrapper around SipHashInline with constant per-JVM keys.Implements one or two timers; one for inactivity, that is reset bySocketTimeout.resetTimer(), and optionally, a total time since instantiation, that is configured bySocketTimeout.setTotalTimeoutPeriod(long).HTTPS only, no retries, no min and max size options, no timeout option As of 0.9.45, supports redirect to https (redirect to http will still fail).Not all may be supported.From http://blogs.sun.com/andreas/resource/InstallCert.java This just saves the certificate chain for later inspection.An opaque class for the caller to pass to repeated instantiations of SSLEepGet.Records which destinations had a streaming stall, so the router can prefer a different outbound tunnel when sending to them again.A "synthetic" queue that does not store data but estimates the average queue size assuming a fixed output bandwidth, and applies the Random Early Detection (RED) algorithm to decide probabilistically whether to accept or drop packets.Methods to find out what system we are running on.Prevent systemd from deleting our temp dir or any dirs or files in it.Helper for TimeoutPipedInputStream.Translate strings efficiently.Filters a reader, replacing the gettext-style tags described below as they are read.The states of the parser, all of which may transition to START.Hook writing the tags out as a properties file.Callback handling each translated string.TryCache<T>A thread-safe, lock-free-ish object cache that reuses objects to reduce allocation overhead.Factory interface for creating new objects in TryCache.A queue of messages, where each has an ID number.Represents a single UI message with a unique identifier.Efficient implementation of a SortedSet stored in a fixed-size array.Compares versions.