Adds minimal support for NATPMP (and removes dependency on external UPnP library). Reference implementation in miniupnp/libnatpmp.
WIP but aims to fix #11902 .
I assume libnatpmp should be subtree'd or we should still use the version linked-against in miniupnpc?
On January 28, 2018 8:15:18 PM UTC, Annanay Agarwal notifications@github.com wrote:
Adds minimal support for NATPMP (and removes dependency on external UPnP library). Reference implementation in
miniupnp/libnatpmp.WIP but aims to fix #11902 . You can view, comment on, or merge this pull request online at:
-- Commit Summary --
- Add basic NATPMP support, get gateway by file parsing, getpublicaddress, map public-private port
-- File Changes --
A src/getgateway.c (570) A src/getgateway.h (47) A src/natpmp.c (354) A src/natpmp.h (182) M src/net.cpp (187) A src/wingettimeofday.c (60) A src/wingettimeofday.h (36)
-- Patch Links --
https://github.com/bitcoin/bitcoin/pull/12288.patch https://github.com/bitcoin/bitcoin/pull/12288.diff
-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/bitcoin/bitcoin/pull/12288
This PR just copies 6 files from libnatpmp into the repository. Perhaps this is a sufficiently low amount of code that we want to do this (like with tinyformat), but if so, putting them in a subdirectory together may be better.
I haven't checked how much changes were necessary to them, but if it was 0, perhaps we can subtree but still build them directly from our build system (as opposed to building as a library and linking statically).
There are minor changes to the copied files, some including changing the WIN32 macro, and others according to the coding guidelines like changing NULL to nullptr, etc.
libnatpmp seems to have been virtually unmaintained a while (last commit was Mar 15, 2016), so I think it doesn't matter whether we use 'subtree'. It might be easier to just include the (small) implementation files into our build system and see if we can maintain it ourselves, cutting out parts we don't need.
At least now we don't have to carry the .javas.
putting them in a subdirectory together may be better.
I agree with that - whatever you do, please don't put them in src/ root.
This is failing the travis build - did you perhaps forget to add natpmp.h to the makefile, so that it's not included in make dist?
Making check in src
make[1]: Entering directory `/home/travis/build/bitcoin/bitcoin/build/bitcoin-i686-w64-mingw32/src'
make[2]: Entering directory `/home/travis/build/bitcoin/bitcoin/build/bitcoin-i686-w64-mingw32/src'
CXX libbitcoin_server_a-net.o
CXX libbitcoin_server_a-noui.o
CXX libbitcoin_server_a-pow.o
CXX libbitcoin_server_a-rest.o
net.cpp:31:20: fatal error: natpmp.h: No such file or directory
#include <natpmp.h>
^
compilation terminated.
make[2]: *** [libbitcoin_server_a-net.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory `/home/travis/build/bitcoin/bitcoin/build/bitcoin-i686-w64-mingw32/src'
make[1]: *** [check-recursive] Error 1
make[1]: Leaving directory `/home/travis/build/bitcoin/bitcoin/build/bitcoin-i686-w64-mingw32/src'
make: *** [check-recursive] Error 1
Merge branch 'natpmp-support' of https://github.com/annanay25/bitcoin into natpmp-support
Merge branch 'master' into natpmp-support
@laanwj ;
I'm a little confused with the name mangling happening here. The src/natpmp/*.c files have extern "C" in the function prototypes, which confirms no name mangling (confirmed this with nm src/natpmp/libbitcoin_server_a-natpmp.o | grep initnatpmp), but C++ object files are looking for mangled function names?
but C++ object files are looking for mangled function names?
You need the extern "C" in the header, not in the implementation files.
<!--5d09a71f8925f3f132321140b44b946d-->The last travis run for this pull request was 101 days ago and is thus outdated. To trigger a fresh travis build, this pull request should be closed and re-opened.
Libraries should not be copied or subtree'd. There's arguably an excuse for consensus-critical libraries, but NATPMP is not that. Link to the system library if present, and if not, just don't build support for it.
124 | +extern "C" { 125 | +#endif 126 | + 127 | +/* initnatpmp() 128 | + * initialize a natpmp_t object 129 | + * With forcegw=1 the gateway is not detected automaticaly.
Typo found by codespell: automaticaly
1609 | - LogPrintf("No valid UPnP IGDs found\n"); 1610 | - freeUPNPDevlist(devlist); devlist = nullptr; 1611 | - if (r != 0) 1612 | - FreeUPNPUrls(&urls); 1613 | + LogPrintf("Mapped public port %hu protocol %s to local port %hu " 1614 | + "liftime %u\n",
Typo found by codespell: liftime
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--174a7506f384e20aa4161008e828411d-->
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
@annanay25 It seems like the work on this PR has stalled somewhat. Do you have time to continue working on this PR? :-)
Is this PR still relevant? I'm not sure if I will be able to continue working on it. @practicalswift
I think it's still relevant, but closing if you're not able to work on it anymore. Will add "up for grabs" tag.
Can someone please re-assign #11902 to me? I would like to take this PR forward.