Commit c33eb23
committed
Merge bitcoin/bitcoin#30043: net: Replace libnatpmp with built-in PCP+NATPMP implementation
5c7cacf ci: Remove natpmp build option and libnatpmp dependency (laanwj)
7e7ec98 doc: Remove mention of natpmp build options (laanwj)
061c3e3 depends: Drop natpmp and associated option from depends (laanwj)
20a18bf build: Drop libnatpmp from build system (laanwj)
7b04709 qt: Changes for built-in PCP+NAT-PMP (laanwj)
52f8ef6 net: Replace libnatpmp with built-in NATPMP+PCP implementation in mapport (laanwj)
97c9717 net: Add PCP and NATPMP implementation (laanwj)
d72df63 net: Use GetLocalAddresses in Discover (laanwj)
e020304 net: Add netif utility (laanwj)
754e425 crypto: Add missing WriteBE16 function (laanwj)
Pull request description:
Continues #30005. Closes #17012..
This PR adds PCP (Port Control Protocol) from [RFC6887](https://datatracker.ietf.org/doc/html/rfc6887). This adds, in addition to the existing IPv4 port mapping (which now uses PCP, with fallback to NAT-PMP), support for IPv6 pinholing-that is, opening a port on the firewall to make it reachable.
PCP, like NAT-PMP is a simple UDP-based protocol, and the implementation is self-contained, so this gets rid of lthe libnatpnp dependency without adding a new one. It should otherwise be a drop-in replacement. NAT-PMP fallback is implemented so this will not make router support worse.
For now it is disabled by default, though in the future (not in this PR) we could consider enable it by default to increase the number of connectable nodes without adding significant attack surface.
To test:
```bash
bitcoind -regtest -natpmp=1 -debug=net
```
(most of the changes in this PR are, ironically, removing the libnatpmp dependency and associated build system and build docs)
## TODO
- [x] Default gateway discovery on Linux / FreeBSD
- [x] Default gateway discovery on Windows
- [x] Default gateway discovery on MacOS
- [x] Either solve FreeBSD compile issue (probably upstream issue) or remove FreeBSD support
## Things to consider for follow-up PRs
- bitcoin/bitcoin#30043 (comment) avoid unreachable nets (not given to -onlynet=)
- bitcoin/bitcoin#30043 (comment) could announce an addr:port where we do not listen (no -bind)
- bitcoin/bitcoin#30043 (comment) could announce the wrong port because it uses GetListenPort()
- bitcoin/bitcoin#30043 (comment) if we requested one port but another was assigned, then which one to use in the renewal?
- bitcoin/bitcoin#30043 (comment) Use `GetAdapterAddresses` to discover local addresses for Windows
ACKs for top commit:
Sjors:
ACK 5c7cacf
achow101:
ACK 5c7cacf
vasild:
ACK 5c7cacf
Tree-SHA512: e35b69e56d5f5449a3d48a799f9b7b65107c65eeb3e245c2c1e9d42221e469ca5ead90afae423160601cd664dd553a51c859e04f4492f335b064aae3bf23e3bcFile tree
38 files changed
+1049
-283
lines changed- .github/workflows
- ci/test
- cmake/module
- depends
- packages
- doc
- src
- crypto
- interfaces
- node
- qt
- forms
- test/fuzz
- util
38 files changed
+1049
-283
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
| 70 | + | |
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
| 75 | + | |
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
108 | | - | |
| 108 | + | |
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | 124 | | |
130 | 125 | | |
131 | 126 | | |
| |||
239 | 234 | | |
240 | 235 | | |
241 | 236 | | |
242 | | - | |
243 | 237 | | |
244 | 238 | | |
245 | 239 | | |
| |||
621 | 615 | | |
622 | 616 | | |
623 | 617 | | |
624 | | - | |
625 | | - | |
626 | | - | |
| 618 | + | |
627 | 619 | | |
628 | 620 | | |
629 | 621 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | | - | |
90 | 89 | | |
91 | 90 | | |
92 | 91 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
46 | 45 | | |
47 | 46 | | |
48 | 47 | | |
| |||
159 | 158 | | |
160 | 159 | | |
161 | 160 | | |
162 | | - | |
163 | 161 | | |
164 | 162 | | |
165 | 163 | | |
166 | 164 | | |
167 | 165 | | |
168 | | - | |
| 166 | + | |
169 | 167 | | |
170 | 168 | | |
171 | 169 | | |
| |||
233 | 231 | | |
234 | 232 | | |
235 | 233 | | |
236 | | - | |
237 | 234 | | |
238 | 235 | | |
239 | 236 | | |
| |||
0 commit comments