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

getPeerId can return an unexpected peer id #319

Closed
achingbrain opened this issue Apr 14, 2023 · 1 comment · Fixed by #325
Closed

getPeerId can return an unexpected peer id #319

achingbrain opened this issue Apr 14, 2023 · 1 comment · Fixed by #325
Labels

Comments

@achingbrain
Copy link
Member

achingbrain commented Apr 14, 2023

.getPeerId() returns the peer id from a multiaddr if one is present but it may not be the one we expect.

If the mulitaddr is a relay address but doesn't have the relay client's peer id in the address, the peer id returned is that of the relay.

I believe the intention of .getPeerId is to return the peer id of the remote peer that can be dialled using the peer id, not just any peer id that happens to be in the multiaddr.

We could fix this by treating p2p-circuit as a special case and returning the value part of the p2p-circuit tuple if found, or more generally by only returning a peer id if it's in the final tuple?

Refs: libp2p/js-libp2p#1680

@achingbrain achingbrain changed the title getPeerId can return the wrong peer id getPeerId can return an unexpected peer id Apr 14, 2023
achingbrain added a commit that referenced this issue May 11, 2023
If a p2p-circuit address doesn't contain the `/p2p/QmFoo` tuple for
the target peer, `getPeerId` returns the peer id of the relay which
is not what you'd expect.

The fix here is for relay addresses, to return the peer id of the
target and never the relay.

Fixes #319
achingbrain added a commit that referenced this issue Jul 28, 2023
If a p2p-circuit address doesn't contain the `/p2p/QmFoo` tuple for
the target peer, `getPeerId` returns the peer id of the relay which
is not what you'd expect.

The fix here is for relay addresses, to return the peer id of the
target and never the relay.

Fixes #319
github-actions bot pushed a commit that referenced this issue Jul 28, 2023
## [12.1.5](v12.1.4...v12.1.5) (2023-07-28)

### Bug Fixes

* make getPeerId return the target peer id from relay addrs ([#325](#325)) ([2b0e353](2b0e353)), closes [#319](#319)
@github-actions
Copy link

🎉 This issue has been resolved in version 12.1.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant