Skip to content

Conversation

SgtPooki
Copy link
Contributor

@SgtPooki SgtPooki commented Oct 1, 2024

fixes #36

I'm not sure if it's intentional that relayed webrtc multiaddrs are not passing Circuit.matches tests

@SgtPooki SgtPooki self-assigned this Oct 1, 2024
const _Circuit = and(_P2P, literal('p2p-circuit'), peerId())
const _Circuit = or(
and(_P2P, literal('p2p-circuit'), peerId()),
and(_P2P, literal('p2p-circuit'), literal('webrtc'), optional(peerId())) // webrtc relay
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This module has two types of matching - .matches and .exactMatch

An address that .matches can have additional path components that might make it .matches other address types. .exactMatch means the address is unequivocally of that type.

E.g.:

const address = multiaddr('/dns/example.com/tcp/80/ws')

TCP.matches(address) // true, starts with a TCP address
TCP.exactMatch(address) // false is a WebSocket address

By adding the literal('webrtc') component, it will make Circuit.exactMatch return true for WebRTC addresses which would be a bug.

What you could do is make the peerId() optional:

const _Circuit = and(_P2P, literal('p2p-circuit'), optional(peerId()))

...but then you wouldn't actually have a valid circuit relay address since you need the final peer id to tell the relay which peer you're trying to reach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: webrtc circuit relay addresses not passing Circuit matcher

2 participants