Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use isPrivate to detect private multiaddrs #2868

Merged
merged 1 commit into from
Nov 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/protocol-identify/src/identify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { InvalidMessageError, UnsupportedProtocolError, serviceCapabilities, setMaxListeners } from '@libp2p/interface'
import { peerIdFromCID } from '@libp2p/peer-id'
import { RecordEnvelope, PeerRecord } from '@libp2p/peer-record'
import { isPrivateIp } from '@libp2p/utils/private-ip'
import { isPrivate } from '@libp2p/utils/multiaddr/is-private'
import { protocols } from '@multiformats/multiaddr'
import { IP_OR_DOMAIN } from '@multiformats/multiaddr-matcher'
import { pbStream } from 'it-protobuf-stream'
Expand Down Expand Up @@ -112,7 +112,7 @@
if (cleanObservedAddr != null) {
this.log('our observed address was %a', cleanObservedAddr)

if (isPrivateIp(cleanObservedAddr?.nodeAddress().address) === true) {
if (isPrivate(cleanObservedAddr)) {

Check warning on line 115 in packages/protocol-identify/src/identify.ts

View check run for this annotation

Codecov / codecov/patch

packages/protocol-identify/src/identify.ts#L115

Added line #L115 was not covered by tests
this.log('our observed address was private')
} else if (this.addressManager.getObservedAddrs().length < (this.maxObservedAddresses ?? Infinity)) {
this.log('storing our observed address')
Expand Down
Loading