Dialing a specific endpoint over a specific wire — the capability a NAT-traversal module needs and the ordinary connect() cannot express. More...
Go to the source code of this file.
Classes | |
| class | librats::DialService |
Namespaces | |
| namespace | librats |
Dialing a specific endpoint over a specific wire — the capability a NAT-traversal module needs and the ordinary connect() cannot express.
PeerNetwork::connect(Address) is deliberately opinionated: it hands the target to the Dialer, which picks a transport, races the other one in after the fallback delay, and remembers what it learned for next time (see node/dialer.h). That is exactly right for "connect me to this peer" and exactly wrong for a hole punch, which needs three things the race cannot give:
So this is the narrow escape hatch, published by the Node in its ServiceRegistry and resolved by whoever needs it:
if (auto* dial = ctx.services.get<DialService>())
dial->dial_direct(addr, TransportKind::Udp, DialProfile::punch());
It is deliberately not on PeerNetwork: every subsystem sees that interface, and "dial exactly this, exactly this way" is a capability one module needs rather than a contract all of them should have. Everything else about the resulting connection is ordinary — the same handshake, the same identify, the same duplicate resolution in PeerTable if the peer dialed us back at the same moment.
Definition in file dial_service.h.