fix: do upnp hole punch after startup (#1217)

The transport manager configures it's addresses during the `start`
phase so access them during `afterStart` so they'll be ready for use.
This commit is contained in:
Alex Potsides
2022-05-18 13:19:31 +01:00
committed by GitHub
parent 1f5d5c2de1
commit d5386df684
3 changed files with 17 additions and 12 deletions

View File

@ -94,10 +94,14 @@ export class NatManager implements Startable {
return this.started
}
start () {}
/**
* Starts the NAT manager
* Attempt to use uPnP to configure port mapping using the current gateway.
*
* Run after start to ensure the transport manager has all addresses configured.
*/
start () {
afterStart () {
if (isBrowser || !this.enabled || this.started) {
return
}
@ -105,7 +109,7 @@ export class NatManager implements Startable {
this.started = true
// done async to not slow down startup
this._start().catch((err) => {
void this._start().catch((err) => {
// hole punching errors are non-fatal
log.error(err)
})