Skip to content
Merged
Show file tree
Hide file tree
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 src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ export const TCP = fmt(and(_TCP, optional(peerId())))
*/
export const UDP = fmt(_UDP)

const _QUIC = and(_UDP, literal('quic'))
const _QUICV1 = and(_UDP, literal('quic-v1'))
const _QUIC = and(_UDP, literal('quic'), optional(peerId()))
const _QUICV1 = and(_UDP, literal('quic-v1'), optional(peerId()))

const QUIC_V0_OR_V1 = or(_QUIC, _QUICV1)

Expand Down
34 changes: 33 additions & 1 deletion test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ describe('multiaddr matcher', () => {

const exactQUIC = [
'/ip4/1.2.3.4/udp/1234/quic',
'/ip6/::/udp/1234/quic'
'/ip4/1.2.3.4/udp/1234/quic/p2p/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64',
'/ip6/::/udp/1234/quic',
'/ip6/::/udp/1234/quic/p2p/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64'
]

const goodQUIC = [
Expand All @@ -100,6 +102,30 @@ describe('multiaddr matcher', () => {
'/quic'
]

const exactQUICv1 = [
'/ip4/1.2.3.4/udp/1234/quic-v1',
'/ip4/1.2.3.4/udp/1234/quic-v1/p2p/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64',
'/ip6/::/udp/1234/quic-v1',
'/ip6/::/udp/1234/quic-v1/p2p/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64'
]

const goodQUICv1 = [
...exactQUICv1,
'/ip4/1.2.3.4/udp/1234/quic-v1/webtransport/certhash/uEiAeP0OEmBbGVTH5Bhnm3WopwRNSQ0et46xNkn2dIagnGw',
'/dns/google.com/udp/1234/quic-v1/p2p/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64'
]

const badQUICv1 = [
'/ip4/0.0.0.0/tcp/12345/quic-v1',
'/ip6/1.2.3.4/ip4/0.0.0.0/udp/1234/quic-v1',
'/quic-v1',
'/quic',
'/ip4/1.2.3.4/udp/1234/quic',
'/ip4/1.2.3.4/udp/1234/quic/p2p/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64',
'/ip6/::/udp/1234/quic',
'/ip6/::/udp/1234/quic/p2p/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64'
]

const exactWS = [
'/dnsaddr/ipfs.io/ws',
'/dns4/ipfs.io/ws',
Expand Down Expand Up @@ -382,6 +408,12 @@ describe('multiaddr matcher', () => {
assertMismatches(mafmt.QUIC, badQUIC)
})

it('QUICv1 addresses', () => {
assertMatches(mafmt.QUICV1, goodQUICv1)
assertExactMatches(mafmt.QUICV1, exactQUICv1)
assertMismatches(mafmt.QUICV1, badQUICv1)
})

it('WebSockets addresses', () => {
assertMatches(mafmt.WebSockets, goodWS)
assertExactMatches(mafmt.WebSockets, exactWS)
Expand Down
Loading