[Bitcoin-development] NATPMP and proxy support in libcoin
gronager at ceptacle.com
Wed Feb 29 13:09:26 UTC 2012
I just finished adding NATPMP, together with IDG UPnP, to libcoin. This enables libcoin/bitcoind to setup port mapping also on Apple routers (AirPort Extreme/Express/TimeMachine) and a few other that supports this protocol.
libcoin/bitcoind first tried to setup mapping using UPnP, if that fails it resorts to using PMP.
It chooses a lease time of (default) 20 minutes and renews this every 10 minutes. This also means that if you are running libcoin on your laptop it will, when e.g. moved to your work, just setup the mapping there and the mapping back home will silently expire.
To include portmapping in libcoin/bitcoind the only thing needed is to add the PortMapper class and start it:
PortMapper mapper(node.get_io_service(), port);
where "portmap" is the former "upnp" command line option.
Also note that I choose to include the relevant portions of miniupnpc and libnatpmp in the coinNAT library to make it easier to build.
I choose to make a rather aggressive setting for quitting searching for an IGD device (3 seconds). If I waited too long here the PMP port mapping would only kick in after the other clients had tried to connect to the new node and timed out.
If it is too small please notify me - I only have access to a UPnP router sporadicly.
And btw: Also added proxy capability to libcoin (have a look in coinChain/Proxy.h for implementation details).
More information about the bitcoin-dev