From eee97c7d4ced5763f6620e535f3c9a5619abf046 Mon Sep 17 00:00:00 2001 From: Alex Potsides Date: Fri, 15 Nov 2024 15:37:16 +0000 Subject: [PATCH] fix: require autonat when not automatically confirming addresses (#2824) The user will need autonat to confirm addresses if not doing it automatically. --- packages/upnp-nat/src/upnp-nat.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/upnp-nat/src/upnp-nat.ts b/packages/upnp-nat/src/upnp-nat.ts index 1cd480141b..78e7b55dbf 100644 --- a/packages/upnp-nat/src/upnp-nat.ts +++ b/packages/upnp-nat/src/upnp-nat.ts @@ -1,6 +1,6 @@ import { upnpNat } from '@achingbrain/nat-port-mapper' import { isIPv4, isIPv6 } from '@chainsafe/is-ip' -import { InvalidParametersError, serviceCapabilities, start, stop } from '@libp2p/interface' +import { InvalidParametersError, serviceCapabilities, serviceDependencies, start, stop } from '@libp2p/interface' import { debounce } from '@libp2p/utils/debounce' import { isLoopback } from '@libp2p/utils/multiaddr/is-loopback' import { isPrivate } from '@libp2p/utils/multiaddr/is-private' @@ -87,6 +87,16 @@ export class UPnPNAT implements Startable, UPnPNATInterface { '@libp2p/nat-traversal' ] + get [serviceDependencies] (): string[] { + if (!this.autoConfirmAddress) { + return [ + '@libp2p/autonat' + ] + } + + return [] + } + isStarted (): boolean { return this.started }