-
Notifications
You must be signed in to change notification settings - Fork 446
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(libp2p): filter out dnsaddrs for different peers #1954
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -309,8 +309,22 @@ export class DialQueue { | |||||||||||||||||
)) | ||||||||||||||||||
.flat() | ||||||||||||||||||
|
||||||||||||||||||
// filter out any multiaddrs that we do not have transports for | ||||||||||||||||||
const filteredAddrs = resolvedAddresses.filter(addr => Boolean(this.transportManager.transportForMultiaddr(addr.multiaddr))) | ||||||||||||||||||
const filteredAddrs = resolvedAddresses.filter(addr => { | ||||||||||||||||||
// filter out any multiaddrs that we do not have transports for | ||||||||||||||||||
if (this.transportManager.transportForMultiaddr(addr.multiaddr) == null) { | ||||||||||||||||||
return false | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
// if the resolved multiaddr has a PeerID but it's the wrong one, ignore it | ||||||||||||||||||
// - this can happen with addresses like bootstrap.libp2p.io that resolve | ||||||||||||||||||
// to multiple different peers | ||||||||||||||||||
const addrPeerId = addr.multiaddr.getPeerId() | ||||||||||||||||||
if (peerId != null && addrPeerId != null) { | ||||||||||||||||||
return peerId.equals(addrPeerId) | ||||||||||||||||||
} | ||||||||||||||||||
Comment on lines
+321
to
+324
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. one of the null checks look redundant. Also can the equality check be the other way? just for the sake of convention
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You have to null guard on |
||||||||||||||||||
|
||||||||||||||||||
return true | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should the default be true? Can this be restructured such that it's only true when all conditions are met and defaults to false otherwise? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it makes sense to fallback to true and filter out the false on the way |
||||||||||||||||||
}) | ||||||||||||||||||
|
||||||||||||||||||
// deduplicate addresses | ||||||||||||||||||
const dedupedAddrs = new Map<string, Address>() | ||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If its p2p-circuit addrPeerId will likely be null always
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
related: #1961