Back to Site
Loading...
Searching...
No Matches
port_mapping_service.h File Reference

Automatic NAT port forwarding (UPnP IGD + NAT-PMP) as a Subsystem. More...

#include "node/peer_network.h"
#include "nat/port_mapping.h"
#include <cstdint>
#include <memory>
#include <mutex>
#include <optional>
#include <string>
#include <utility>
Include dependency graph for port_mapping_service.h:

Go to the source code of this file.

Classes

class  librats::PortMappingService
 Maps the node's TCP listen port through the home router via UPnP and/or NAT-PMP. More...
 

Namespaces

namespace  librats
 

Detailed Description

Automatic NAT port forwarding (UPnP IGD + NAT-PMP) as a Subsystem.

Wraps the standalone UpnpClient (src/upnp.h) and NatPmpClient (src/natpmp.h) backends into the Node lifecycle. On start() it asks the home router to forward the node's TCP listen port so peers behind NAT can accept inbound connections; on stop() it removes the mapping. Both backends run in parallel on their own worker threads — whichever the router supports wins.

Threading: the backends invoke our result callback from their own worker threads, so all shared state is guarded by mutex_. stop() moves the clients out under the lock and stops them OUTSIDE it — stop() joins those workers, which take the lock from handle_result(), so holding it across stop() would deadlock.

Definition in file port_mapping_service.h.