Skip to content

Commit 63d5853

Browse files
kwvgPastaPastaPasta
authored andcommitted
merge bitcoin#22648: improve i2p/tor docs and i2p reachable unit tests
1 parent f04ce8b commit 63d5853

File tree

3 files changed

+68
-37
lines changed

3 files changed

+68
-37
lines changed

doc/i2p.md

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,22 @@ started with I2P terminology.
1010
## Run Dash Core with an I2P router (proxy)
1111

1212
A running I2P router (proxy) with [SAM](https://geti2p.net/en/docs/api/samv3)
13-
enabled is required (there is an [official one](https://geti2p.net) and
14-
[a few alternatives](https://en.wikipedia.org/wiki/I2P#Routers)). Notice the IP
15-
address and port the SAM proxy is listening to; usually, it is
16-
`127.0.0.1:7656`. Once it is up and running with SAM enabled, use the following
17-
Dash Core options:
13+
enabled is required. Options include:
14+
15+
- [i2prouter (I2P Router)](https://geti2p.net), the official implementation in
16+
Java
17+
- [i2pd (I2P Daemon)](https://github.com/PurpleI2P/i2pd)
18+
([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)
21+
- [i2p-zero](https://github.com/i2p-zero/i2p-zero)
22+
- [other alternatives](https://en.wikipedia.org/wiki/I2P#Routers)
23+
24+
Note the IP address and port the SAM proxy is listening to; usually, it is
25+
`127.0.0.1:7656`.
26+
27+
Once an I2P router with SAM enabled is up and running, use the following Dash
28+
Core configuration options:
1829

1930
```
2031
-i2psam=<ip:port>
@@ -42,15 +53,30 @@ named `i2p_private_key` in the Dash Core data directory.
4253

4354
## Additional configuration options related to I2P
4455

45-
You may set the `debug=i2p` config logging option to have additional
46-
information in the debug log about your I2P configuration and connections. Run
47-
`dash-cli help logging` for more information.
56+
```
57+
-debug=i2p
58+
```
59+
60+
Set the `debug=i2p` config logging option to see additional information in the
61+
debug log about your I2P configuration and connections. Run `dash-cli help
62+
logging` for more information.
63+
64+
```
65+
-onlynet=i2p
66+
```
67+
68+
Make outgoing connections only to I2P addresses. Incoming connections are not
69+
affected by this option. It can be specified multiple times to allow multiple
70+
network types, e.g. onlynet=ipv4, onlynet=ipv6, onlynet=onion, onlynet=i2p.
71+
72+
Warning: if you use -onlynet with values other than onion, and the -onion or
73+
-proxy option is set, then outgoing onion connections will still be made; use
74+
-noonion or -onion=0 to disable outbound onion connections in this case.
4875

49-
It is possible to restrict outgoing connections in the usual way with
50-
`onlynet=i2p`. I2P support was added to Dash Core in version 20.0 (fall-2023)
51-
and there may be fewer I2P peers than Tor or IP ones. Therefore, using
52-
`onlynet=i2p` alone (without other `onlynet=`) may make a node more susceptible
53-
to [Sybil attacks](https://en.dash.it/wiki/Weaknesses#Sybil_attack). Use
76+
I2P support was added to Dash Core in version 20.0 and there may be fewer I2P
77+
peers than Tor or IP ones. Therefore, using I2P alone without other networks may
78+
make a node more susceptible to [Sybil
79+
attacks](https://en.bitcoin.it/wiki/Weaknesses#Sybil_attack). You can use
5480
`dash-cli -addrinfo` to see the number of I2P addresses known to your node.
5581

5682
Another consideration with `onlynet=i2p` is that the initial blocks download

doc/tor.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ outgoing connections, but more is possible.
5151
-onlynet=onion Make outgoing connections only to .onion addresses. Incoming
5252
connections are not affected by this option. This option can be
5353
specified multiple times to allow multiple network types, e.g.
54-
ipv4, ipv6 or onion. If you use this option with values other
55-
than onion you *cannot* disable onion connections; outgoing onion
56-
connections will be enabled when you use -proxy or -onion. Use
57-
-noonion or -onion=0 if you want to be sure there are no outbound
58-
onion connections over the default proxy or your defined -proxy.
54+
onlynet=ipv4, onlynet=ipv6, onlynet=onion, onlynet=i2p.
55+
Warning: if you use -onlynet with values other than onion, and
56+
the -onion or -proxy option is set, then outgoing onion
57+
connections will still be made; use -noonion or -onion=0 to
58+
disable outbound onion connections in this case.
5959

6060
An example how to start the client if the Tor proxy is running on local host on
6161
port 9050 and only allows .onion nodes to connect:

src/test/net_tests.cpp

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -761,37 +761,42 @@ BOOST_AUTO_TEST_CASE(ipv4_peer_with_ipv6_addrMe_test)
761761

762762
BOOST_AUTO_TEST_CASE(LimitedAndReachable_Network)
763763
{
764-
BOOST_CHECK_EQUAL(IsReachable(NET_IPV4), true);
765-
BOOST_CHECK_EQUAL(IsReachable(NET_IPV6), true);
766-
BOOST_CHECK_EQUAL(IsReachable(NET_ONION), true);
764+
BOOST_CHECK(IsReachable(NET_IPV4));
765+
BOOST_CHECK(IsReachable(NET_IPV6));
766+
BOOST_CHECK(IsReachable(NET_ONION));
767+
BOOST_CHECK(IsReachable(NET_I2P));
767768

768769
SetReachable(NET_IPV4, false);
769770
SetReachable(NET_IPV6, false);
770771
SetReachable(NET_ONION, false);
772+
SetReachable(NET_I2P, false);
771773

772-
BOOST_CHECK_EQUAL(IsReachable(NET_IPV4), false);
773-
BOOST_CHECK_EQUAL(IsReachable(NET_IPV6), false);
774-
BOOST_CHECK_EQUAL(IsReachable(NET_ONION), false);
774+
BOOST_CHECK(!IsReachable(NET_IPV4));
775+
BOOST_CHECK(!IsReachable(NET_IPV6));
776+
BOOST_CHECK(!IsReachable(NET_ONION));
777+
BOOST_CHECK(!IsReachable(NET_I2P));
775778

776779
SetReachable(NET_IPV4, true);
777780
SetReachable(NET_IPV6, true);
778781
SetReachable(NET_ONION, true);
782+
SetReachable(NET_I2P, true);
779783

780-
BOOST_CHECK_EQUAL(IsReachable(NET_IPV4), true);
781-
BOOST_CHECK_EQUAL(IsReachable(NET_IPV6), true);
782-
BOOST_CHECK_EQUAL(IsReachable(NET_ONION), true);
784+
BOOST_CHECK(IsReachable(NET_IPV4));
785+
BOOST_CHECK(IsReachable(NET_IPV6));
786+
BOOST_CHECK(IsReachable(NET_ONION));
787+
BOOST_CHECK(IsReachable(NET_I2P));
783788
}
784789

785790
BOOST_AUTO_TEST_CASE(LimitedAndReachable_NetworkCaseUnroutableAndInternal)
786791
{
787-
BOOST_CHECK_EQUAL(IsReachable(NET_UNROUTABLE), true);
788-
BOOST_CHECK_EQUAL(IsReachable(NET_INTERNAL), true);
792+
BOOST_CHECK(IsReachable(NET_UNROUTABLE));
793+
BOOST_CHECK(IsReachable(NET_INTERNAL));
789794

790795
SetReachable(NET_UNROUTABLE, false);
791796
SetReachable(NET_INTERNAL, false);
792797

793-
BOOST_CHECK_EQUAL(IsReachable(NET_UNROUTABLE), true); // Ignored for both networks
794-
BOOST_CHECK_EQUAL(IsReachable(NET_INTERNAL), true);
798+
BOOST_CHECK(IsReachable(NET_UNROUTABLE)); // Ignored for both networks
799+
BOOST_CHECK(IsReachable(NET_INTERNAL));
795800
}
796801

797802
CNetAddr UtilBuildAddress(unsigned char p1, unsigned char p2, unsigned char p3, unsigned char p4)
@@ -810,10 +815,10 @@ BOOST_AUTO_TEST_CASE(LimitedAndReachable_CNetAddr)
810815
CNetAddr addr = UtilBuildAddress(0x001, 0x001, 0x001, 0x001); // 1.1.1.1
811816

812817
SetReachable(NET_IPV4, true);
813-
BOOST_CHECK_EQUAL(IsReachable(addr), true);
818+
BOOST_CHECK(IsReachable(addr));
814819

815820
SetReachable(NET_IPV4, false);
816-
BOOST_CHECK_EQUAL(IsReachable(addr), false);
821+
BOOST_CHECK(!IsReachable(addr));
817822

818823
SetReachable(NET_IPV4, true); // have to reset this, because this is stateful.
819824
}
@@ -825,12 +830,12 @@ BOOST_AUTO_TEST_CASE(LocalAddress_BasicLifecycle)
825830

826831
SetReachable(NET_IPV4, true);
827832

828-
BOOST_CHECK_EQUAL(IsLocal(addr), false);
829-
BOOST_CHECK_EQUAL(AddLocal(addr, 1000), true);
830-
BOOST_CHECK_EQUAL(IsLocal(addr), true);
833+
BOOST_CHECK(!IsLocal(addr));
834+
BOOST_CHECK(AddLocal(addr, 1000));
835+
BOOST_CHECK(IsLocal(addr));
831836

832837
RemoveLocal(addr);
833-
BOOST_CHECK_EQUAL(IsLocal(addr), false);
838+
BOOST_CHECK(!IsLocal(addr));
834839
}
835840

836841
BOOST_AUTO_TEST_SUITE_END()

0 commit comments

Comments
 (0)