1 major finding · 2 minor findings · 4 suggestions
Findings
[major] · Persistent I2P sessions disable I2P private broadcasting
With -privatebroadcast, -i2psam and incoming I2P enabled, every I2P private-broadcast connection fails before contacting SAM, leaving no private-broadcast route if Tor is unavailable.
Location: src/net.cpp:3415 (head).
Details and suggested fix
Incoming I2P defaults to enabled; -listen=0 soft-disables it unless explicitly overridden. In the affected configuration, Start() installs m_i2p_sam_session before starting the workers. PRIVATE_BROADCAST correctly avoids that persistent identity, but its transient branch now calls GetI2PTransientSession(), which returns nullptr whenever the persistent object exists. ConnectNode() therefore returns before Session::Connect(), whereas base constructed or reused a transient session here. PickNetwork() still selects reachable I2P, so retries cannot repair this: I2P-only private broadcasts cannot open a connection, while configurations with Tor lose the I2P route. This fails closed without revealing the persistent address. Restrict the persistent-session exclusion to speculative preparation. When an actual connection requires a transient session, retrieve the spare or construct one from *use_proxy, preserving the private-broadcast identity separation.
[minor] · The reachability gate blocks manual I2P connections excluded by -onlynet
With an I2P proxy configured and incoming I2P disabled, -onlynet excluding I2P now prevents explicit manual I2P connections, contrary to the documented exception.
Location: src/net.cpp:3414 (head).
Details and suggested fix
For example, configure -onlynet=ipv4, -i2psam and -i2pacceptincoming=0, then use -addnode or addnode add/onetry with a valid .b32.i2p destination. Initialization retains the I2P proxy, and OpenNetworkConnection() permits the manual request. The transient branch now reaches GetI2PTransientSession(), whose reachability check returns nullptr before any SAM connection or addrman Attempt. Base constructed the session from *use_proxy, and retries now encounter the same rejection. Incoming-enabled configurations bypass this helper through their persistent session and are unaffected. Keep the reachability gate on speculative preparation only; demanded transient acquisition should retrieve a cached session or create one using the selected proxy.
[minor] · An empty spare slot leaves I2P session creation coupled to its use
Successful serial I2P-only connections leave the spare empty, so the next attempt creates and consumes its own session without the intended independent preparation interval.
Location: src/net.cpp:442 (head).
Details and suggested fix
When an eligible I2P attempt reaches line 442 with an empty slot, it creates a session, saves it, then retrieves that same session in the connection branch. HELLO and NAMING LOOKUP still precede STREAM CONNECT, but preparation remains part of the consuming attempt, as at base. Success moves the session into CNode without refilling the spare. Consequently, serial successful connections with -onlynet=i2p -i2pacceptincoming=0 repeat this sequence; mixed-network operation can also encounter it at startup or after a successful I2P connection. An earlier non-I2P attempt, failure reuse, or another thread can provide a prepared session, so this is a conditional mitigation gap, not a new timing leak. Refill the bounded spare independently of the consuming attempt, with interruptible preparation, or explicitly document cold-start and I2P-only operation as outside the mitigation.
Optional improvements
[suggestion] · Speculative SAM preparation blocks unrelated connection attempts
With transient I2P enabled and an empty spare, IPv4, IPv6 and Tor connection attempts now wait for SAM session preparation before starting their own connection.
Location: src/net.cpp:442 (head).
Details and suggested fix
This occurs when I2P is reachable, its proxy is configured, no persistent session exists, and ConnectNode() reaches line 442 with an empty slot. Constructing Session synchronously connects to SAM and waits for HELLO and SESSION CREATE replies, each with an interruptible three-minute receive timeout. That work precedes target-network dispatch, coupling unrelated connections to the configured SAM service's responsiveness. The serial opencon loop and synchronous addnode onetry RPC can therefore wait on I2P preparation, unlike base. An occupied spare avoids the I/O; even a failed eager attempt leaves an object cached, so subsequent serial non-I2P attempts do not repeat it until consumption. Move speculative creation to a bounded, interruptible producer instead of blocking unrelated connection setup, while retaining on-demand acquisition for actual transient I2P connections.
[suggestion] · The transient constructor still promises lazy, I/O-free construction
The transient Session constructor now attempts blocking SAM communication, but its declaration still tells callers that construction performs no I/O.
Location: src/i2p.cpp:135 (head).
Details and suggested fix
The transient overload's comment in src/i2p.h:72-81 says the session will be created lazily when first used. Its changed body instead calls CreateIfNotCreatedAlready(), which performs HELLO and SESSION CREATE synchronously. It suppresses runtime_error and leaves Connect() to retry failed creation. Current cache callers construct outside the cache mutex, but the header no longer describes the timing and failure behavior callers must account for. Update this overload's comment to document eager best-effort creation, possible blocking until replies or timeouts, later retry, and the need to avoid holding locks across construction. Keep the lazy/no-I/O wording on the unchanged persistent overload.
[suggestion] · feature_proxy.py now contacts the SAM endpoint it says it never uses
Speculative preparation makes feature_proxy.py contact localhost:7656 and can create a real transient session if a developer's SAM service is listening there.
Location: src/net.cpp:442 (head).
Details and suggested fix
Node 1 configures -i2psam=127.0.0.1:7656 and -i2pacceptincoming=0 under the comment 'We will not try to connect to this.' It is eligible for transient preparation, so its first non-I2P ConnectNode() call now constructs a Session and connects directly to that endpoint, outside the test's SOCKS mocks. The inherited network setup already issues a localhost onetry from node 1, before the later external IPv4 proxy checks. If a working local SAM service responds, the test can create real I2P tunnels and wait on that service's response time. If nothing listens, creation fails and the cached object prevents repeated serial attempts. Use a test-owned SAM endpoint, such as a mock listener, and update the comment; the existing proxy-reporting assertions can remain.
[suggestion] · Concurrent preparation can destroy newly created sessions unused
Concurrent eligible callers can each create a SAM session for the same empty spare slot, then immediately discard one, adding avoidable router work.
Location: src/net.cpp:3436 (head).
Details and suggested fix
GetI2PTransientSession() releases the cache mutex before constructing Session, so two concurrent callers can both observe an empty slot and send SESSION CREATE. If both subsequently save their sessions, SaveI2PTransientSession() retains the first and destroys the second unused. Opencon and addcon already provide independent callers, so the single-threaded filling assumption does not hold. A session returned after a failed connection is also discarded if another caller has filled the slot, whereas base could retain multiple returned sessions. These are bounded conditional costs, not repeated creation by serial non-I2P attempts. Serialize speculative preparation with a creation-in-progress state or a dedicated interruptible producer, while allowing actual transient connection demand to acquire a session without waiting indefinitely.