Skip to content

Commit

Permalink
fix: require autonat when not automatically confirming addresses (#2824)
Browse files Browse the repository at this point in the history
The user will need autonat to confirm addresses if not doing it
automatically.
  • Loading branch information
achingbrain authored Nov 15, 2024
1 parent 2feaedd commit eee97c7
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/upnp-nat/src/upnp-nat.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit eee97c7

Please sign in to comment.