Capability that lets a sibling module ask for a NAT hole punch by PeerId. More...
Go to the source code of this file.
Classes | |
| struct | librats::HolePunchService |
Namespaces | |
| namespace | librats |
Capability that lets a sibling module ask for a NAT hole punch by PeerId.
Published by HolePunch via ServiceRegistry (see service_registry.h). A discovery module knows who it failed to reach long before it knows why — PeerExchange, for instance, learns a peer's id together with an address that then refuses to dial — and this is the whole contract it needs to hand that id over: no addresses, no relay selection, no NAT reasoning, all of which are HolePunch's own business.
Resolving it returns nullptr when hole punching is not enabled, which is exactly what makes the fallback optional at the consumer's side:
if (auto* punch = ctx.services.get<HolePunchService>()) punch->punch(id);
The provider registers during attach(), so resolve it in start() (every attach() runs before any start()) rather than in your own attach(), where the provider may not have been attached yet. The pointer is NON-owning and valid while the node is.
Definition in file hole_punch_service.h.