Skip to content

Commit eee97c7

Browse files
authored
fix: require autonat when not automatically confirming addresses (#2824)
The user will need autonat to confirm addresses if not doing it automatically.
1 parent 2feaedd commit eee97c7

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

packages/upnp-nat/src/upnp-nat.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { upnpNat } from '@achingbrain/nat-port-mapper'
22
import { isIPv4, isIPv6 } from '@chainsafe/is-ip'
3-
import { InvalidParametersError, serviceCapabilities, start, stop } from '@libp2p/interface'
3+
import { InvalidParametersError, serviceCapabilities, serviceDependencies, start, stop } from '@libp2p/interface'
44
import { debounce } from '@libp2p/utils/debounce'
55
import { isLoopback } from '@libp2p/utils/multiaddr/is-loopback'
66
import { isPrivate } from '@libp2p/utils/multiaddr/is-private'
@@ -87,6 +87,16 @@ export class UPnPNAT implements Startable, UPnPNATInterface {
8787
'@libp2p/nat-traversal'
8888
]
8989

90+
get [serviceDependencies] (): string[] {
91+
if (!this.autoConfirmAddress) {
92+
return [
93+
'@libp2p/autonat'
94+
]
95+
}
96+
97+
return []
98+
}
99+
90100
isStarted (): boolean {
91101
return this.started
92102
}

0 commit comments

Comments
 (0)