Skip to content

Commit 2c182d2

Browse files
authored
fix: use isPrivate to detect private multiaddrs (#2868)
To prevent throwing when non-thin waist addresses are encountered, use `isPrivate` instead of converting the multiaddr to a node address.
1 parent 99f5f27 commit 2c182d2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/protocol-identify/src/identify.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { publicKeyFromProtobuf, publicKeyToProtobuf } from '@libp2p/crypto/keys'
44
import { InvalidMessageError, UnsupportedProtocolError, serviceCapabilities, setMaxListeners } from '@libp2p/interface'
55
import { peerIdFromCID } from '@libp2p/peer-id'
66
import { RecordEnvelope, PeerRecord } from '@libp2p/peer-record'
7-
import { isPrivateIp } from '@libp2p/utils/private-ip'
7+
import { isPrivate } from '@libp2p/utils/multiaddr/is-private'
88
import { protocols } from '@multiformats/multiaddr'
99
import { IP_OR_DOMAIN } from '@multiformats/multiaddr-matcher'
1010
import { pbStream } from 'it-protobuf-stream'
@@ -112,7 +112,7 @@ export class Identify extends AbstractIdentify implements Startable, IdentifyInt
112112
if (cleanObservedAddr != null) {
113113
this.log('our observed address was %a', cleanObservedAddr)
114114

115-
if (isPrivateIp(cleanObservedAddr?.nodeAddress().address) === true) {
115+
if (isPrivate(cleanObservedAddr)) {
116116
this.log('our observed address was private')
117117
} else if (this.addressManager.getObservedAddrs().length < (this.maxObservedAddresses ?? Infinity)) {
118118
this.log('storing our observed address')

0 commit comments

Comments
 (0)