Skip to content

Commit 1dc50d0

Browse files
kwvgPastaPastaPasta
authored andcommitted
merge bitcoin#26838: I2P documentation updates
1 parent 5058519 commit 1dc50d0

File tree

3 files changed

+57
-47
lines changed

3 files changed

+57
-47
lines changed

doc/i2p.md

Lines changed: 50 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ enabled is required. Options include:
1616
Java
1717
- [i2pd (I2P Daemon)](https://github.com/PurpleI2P/i2pd)
1818
([documentation](https://i2pd.readthedocs.io/en/latest)), a lighter
19-
alternative in C++ (successfully tested with version 2.23 and up; version 2.36
20-
or later recommended)
19+
alternative in C++
2120
- [i2p-zero](https://github.com/i2p-zero/i2p-zero)
2221
- [other alternatives](https://en.wikipedia.org/wiki/I2P#Routers)
2322

@@ -33,12 +32,10 @@ Core configuration options:
3332
none)
3433
3534
-i2pacceptincoming
36-
If set and -i2psam is also set then incoming I2P connections are
37-
accepted via the SAM proxy. If this is not set but -i2psam is set
38-
then only outgoing connections will be made to the I2P network.
39-
Ignored if -i2psam is not set. Listening for incoming I2P
40-
connections is done through the SAM proxy, not by binding to a
41-
local address and port (default: 1)
35+
Whether to accept inbound I2P connections (default: 1). Ignored if
36+
-i2psam is not set. Listening for inbound I2P connections is
37+
done through the SAM proxy, not by binding to a local address and
38+
port.
4239
```
4340

4441
In a typical situation, this suffices:
@@ -47,27 +44,6 @@ In a typical situation, this suffices:
4744
dashd -i2psam=127.0.0.1:7656
4845
```
4946

50-
The first time Dash Core connects to the I2P router, if
51-
`-i2pacceptincoming=1`, then it will automatically generate a persistent I2P
52-
address and its corresponding private key. The private key will be saved in a
53-
file named `i2p_private_key` in the Dash Core data directory. The persistent
54-
I2P address is used for accepting incoming connections and for making outgoing
55-
connections if `-i2pacceptincoming=1`. If `-i2pacceptincoming=0` then only
56-
outbound I2P connections are made and a different transient I2P address is used
57-
for each connection to improve privacy.
58-
59-
## Persistent vs transient I2P addresses
60-
61-
In I2P connections, the connection receiver sees the I2P address of the
62-
connection initiator. This is unlike the Tor network where the recipient does
63-
not know who is connecting to them and can't tell if two connections are from
64-
the same peer or not.
65-
66-
If an I2P node is not accepting incoming connections, then Dash Core uses
67-
random, one-time, transient I2P addresses for itself for outbound connections
68-
to make it harder to discriminate, fingerprint or analyze it based on its I2P
69-
address.
70-
7147
## Additional configuration options related to I2P
7248

7349
```
@@ -104,7 +80,29 @@ In general, a node can be run with both onion and I2P hidden services (or
10480
any/all of IPv4/IPv6/onion/I2P), which can provide a potential fallback if one
10581
of the networks has issues.
10682

107-
## I2P-related information in Dash Core
83+
## Persistent vs transient I2P addresses
84+
85+
The first time Dash Core connects to the I2P router, it automatically
86+
generates a persistent I2P address and its corresponding private key by default
87+
or if `-i2pacceptincoming=1` is set. The private key is saved in a file named
88+
`i2p_private_key` in the Dash Core data directory. The persistent I2P
89+
address is used for making outbound connections and accepting inbound
90+
connections.
91+
92+
In the I2P network, the receiver of an inbound connection sees the address of
93+
the initiator. This is unlike the Tor network, where the recipient does not
94+
know who is connecting to it.
95+
96+
If your node is configured by setting `-i2pacceptincoming=0` to not accept
97+
inbound I2P connections, then it will use a random transient I2P address for
98+
itself on each outbound connection to make it harder to discriminate,
99+
fingerprint or analyze it based on its I2P address.
100+
101+
I2P addresses are designed to be long-lived. Waiting for tunnels to be built
102+
for every peer connection adds delay to connection setup time. Therefore, I2P
103+
listening should only be turned off if really needed.
104+
105+
## Fetching I2P-related information from Dash Core
108106

109107
There are several ways to see your I2P address in Dash Core if accepting
110108
incoming I2P connections (`-i2pacceptincoming`):
@@ -140,14 +138,19 @@ port (`TO_PORT`) is always set to 0 and is not in the control of Dash Core.
140138

141139
## Bandwidth
142140

143-
I2P routers may route a large amount of general network traffic with their
144-
default settings. Check your router's configuration to limit the amount of this
145-
traffic relayed, if desired.
141+
By default, your node shares bandwidth and transit tunnels with the I2P network
142+
in order to increase your anonymity with cover traffic, help the I2P router used
143+
by your node integrate optimally with the network, and give back to the network.
144+
It's important that the nodes of a popular application like Dash contribute
145+
as much to the I2P network as they consume.
146146

147-
With `i2pd`, the amount of bandwidth being shared with the wider network can be
148-
adjusted with the `bandwidth`, `share` and `transittunnels` options in your
149-
`i2pd.conf` file. For example, to limit total I2P traffic to 256KB/s and share
150-
50% of this limit for a maximum of 20 transit tunnels:
147+
It is possible, though strongly discouraged, to change your I2P router
148+
configuration to limit the amount of I2P traffic relayed by your node.
149+
150+
With `i2pd`, this can be done by adjusting the `bandwidth`, `share` and
151+
`transittunnels` options in your `i2pd.conf` file. For example, to limit total
152+
I2P traffic to 256KB/s and share 50% of this limit for a maximum of 20 transit
153+
tunnels:
151154

152155
```
153156
bandwidth = 256
@@ -157,9 +160,15 @@ share = 50
157160
transittunnels = 20
158161
```
159162

160-
If you prefer not to relay any public I2P traffic and only permit I2P traffic
161-
from programs which are connecting via the SAM proxy, e.g. Dash Core, you
162-
can set the `notransit` option to `true`.
163-
164163
Similar bandwidth configuration options for the Java I2P router can be found in
165164
`http://127.0.0.1:7657/config` under the "Bandwidth" tab.
165+
166+
Before doing this, please see the "Participating Traffic Considerations" section
167+
in [Embedding I2P in your Application](https://geti2p.net/en/docs/applications/embedding).
168+
169+
In most cases, the default router settings should work fine.
170+
171+
## Bundling I2P in a Dash application
172+
173+
Please see the "General Guidance for Developers" section in https://geti2p.net/en/docs/api/samv3
174+
if you are developing a downstream application that may be bundling I2P with Dash.

src/init.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,9 @@
131131
#include <zmq/zmqrpc.h>
132132
#endif
133133

134-
static const bool DEFAULT_PROXYRANDOMIZE = true;
135-
static const bool DEFAULT_REST_ENABLE = false;
134+
static constexpr bool DEFAULT_PROXYRANDOMIZE{true};
135+
static constexpr bool DEFAULT_REST_ENABLE{false};
136+
static constexpr bool DEFAULT_I2P_ACCEPT_INCOMING{true};
136137

137138
static CDSNotificationInterface* pdsNotificationInterface = nullptr;
138139

@@ -581,7 +582,7 @@ void SetupServerArgs(NodeContext& node)
581582
argsman.AddArg("-maxuploadtarget=<n>", strprintf("Tries to keep outbound traffic under the given target (in MiB per 24h). Limit does not apply to peers with 'download' permission. 0 = no limit (default: %d)", DEFAULT_MAX_UPLOAD_TARGET), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
582583
argsman.AddArg("-onion=<ip:port>", "Use separate SOCKS5 proxy to reach peers via Tor onion services, set -noonion to disable (default: -proxy)", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
583584
argsman.AddArg("-i2psam=<ip:port>", "I2P SAM proxy to reach I2P peers and accept I2P connections (default: none)", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
584-
argsman.AddArg("-i2pacceptincoming", "If set and -i2psam is also set then incoming I2P connections are accepted via the SAM proxy. If this is not set but -i2psam is set then only outgoing connections will be made to the I2P network. Ignored if -i2psam is not set. Listening for incoming I2P connections is done through the SAM proxy, not by binding to a local address and port (default: 1)", ArgsManager::ALLOW_BOOL, OptionsCategory::CONNECTION);
585+
argsman.AddArg("-i2pacceptincoming", strprintf("Whether to accept inbound I2P connections (default: %i). Ignored if -i2psam is not set. Listening for inbound I2P connections is done through the SAM proxy, not by binding to a local address and port.", DEFAULT_I2P_ACCEPT_INCOMING), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
585586
argsman.AddArg("-onlynet=<net>", "Make outgoing connections only through network <net> (" + Join(GetNetworkNames(), ", ") + "). Incoming connections are not affected by this option. This option can be specified multiple times to allow multiple networks. Warning: if it is used with non-onion networks and the -onion or -proxy option is set, then outbound onion connections will still be made; use -noonion or -onion=0 to disable outbound onion connections in this case.", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
586587
argsman.AddArg("-peerblockfilters", strprintf("Serve compact block filters to peers per BIP 157 (default: %u)", DEFAULT_PEERBLOCKFILTERS), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
587588
argsman.AddArg("-peerbloomfilters", strprintf("Support filtering of blocks and transaction with bloom filters (default: %u)", DEFAULT_PEERBLOOMFILTERS), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
@@ -2534,7 +2535,7 @@ bool AppInitMain(const CoreContext& context, NodeContext& node, interfaces::Bloc
25342535
SetReachable(NET_I2P, false);
25352536
}
25362537

2537-
connOptions.m_i2p_accept_incoming = args.GetBoolArg("-i2pacceptincoming", true);
2538+
connOptions.m_i2p_accept_incoming = args.GetBoolArg("-i2pacceptincoming", DEFAULT_I2P_ACCEPT_INCOMING);
25382539

25392540
if (!node.connman->Start(*node.dmnman, *node.mn_metaman, *node.mn_sync, *node.scheduler, connOptions)) {
25402541
return false;

test/functional/p2p_i2p_sessions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ def run_test(self):
2323

2424
self.log.info("Ensure we create a persistent session when -i2pacceptincoming=1")
2525
node0 = self.nodes[0]
26-
with node0.assert_debug_log(expected_msgs=[f"Creating persistent SAM session"]):
26+
with node0.assert_debug_log(expected_msgs=["Creating persistent SAM session"]):
2727
node0.addnode(node=addr, command="onetry")
2828

2929
self.log.info("Ensure we create a transient session when -i2pacceptincoming=0")
3030
node1 = self.nodes[1]
31-
with node1.assert_debug_log(expected_msgs=[f"Creating transient SAM session"]):
31+
with node1.assert_debug_log(expected_msgs=["Creating transient SAM session"]):
3232
node1.addnode(node=addr, command="onetry")
3333

3434

0 commit comments

Comments
 (0)