multiformats / js-multiaddr

JavaScript implementation of multiaddr
http://multiformats.github.io/js-multiaddr
Other
109 stars 64 forks source link

getPeerId can return an unexpected peer id #319

Closed achingbrain closed 1 year ago

achingbrain commented 1 year ago

.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: https://github.com/libp2p/js-libp2p/pull/1680

github-actions[bot] commented 1 year ago

:tada: This issue has been resolved in version 12.1.5 :tada:

The release is available on:

Your semantic-release bot :package::rocket: