Direct Connection Upgrade through Relay (DCUtR) is a protocol that allows two
nodes to connect to each other who would otherwise be prevented doing so due
to being behind NATed connections or firewalls.
The protocol involves making a relayed connection between the two peers and
using the relay to synchronize connection timings so that they dial each other
at precisely the same moment.
// QmTarget is a peer that is behind a NAT, supports TCP and has a relay // reservation constma = multiaddr('/ip4/.../p2p/QmRelay/p2p-circuit/p2p/QmTarget') awaitnode.dial(ma)
// after a while the connection should automatically get upgraded to a // direct connection (e.g. non-limited) while (true) { constconnections = node.getConnections()
if (connections.find(conn=>conn.limits == null)) { console.info('have direct connection') break } else { console.info('have relayed connection')
// wait a few seconds to see if it's succeeded yet awaitnewPromise<void>((resolve) => { setTimeout(() =>resolve(), 5000) }) } }
Direct Connection Upgrade through Relay (DCUtR) is a protocol that allows two nodes to connect to each other who would otherwise be prevented doing so due to being behind NATed connections or firewalls.
The protocol involves making a relayed connection between the two peers and using the relay to synchronize connection timings so that they dial each other at precisely the same moment.
Example