Continues #30005. Closes #17012..
This PR adds PCP (Port Control Protocol) from 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:
0bitcoind -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
- Default gateway discovery on Linux / FreeBSD
- Default gateway discovery on Windows
- Default gateway discovery on MacOS
- Either solve FreeBSD compile issue (probably upstream issue) or remove FreeBSD support
- (maybe) split src/util/netif.h off into a separate PR #30043#pullrequestreview-2047432934