Skip to content

Commit 7d95ef8

Browse files
authored
feat: support /quic-v1 (#294)
This PR adds support for `/quic-v1` which will be enabled by default in Kubo 0.18 (ipfs/kubo#9417, ipfs/kubo#9410). @achingbrain @TinyTb FYSA an important caveat is that WebTransport addrs will be `/quic-v1/webtransport` (as noted in ipfs/kubo#9410). Ref. - ipfs/kubo#9410 - multiformats/multiaddr#145 Signed-off-by: Marcin Rataj <[email protected]>
1 parent 2bf11ef commit 7d95ef8

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

src/protocols-table.ts

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export const table: Array<[number, number, string, boolean?, boolean?]> = [
3535
[445, 296, 'onion3'],
3636
[446, V, 'garlic64'],
3737
[460, 0, 'quic'],
38+
[461, 0, 'quic-v1'],
3839
[465, 0, 'webtransport'],
3940
[466, V, 'certhash'],
4041
[477, 0, 'ws'],

test/index.spec.ts

+17-3
Original file line numberDiff line numberDiff line change
@@ -347,22 +347,36 @@ describe('variants', () => {
347347
expect(addr.toString()).to.equal(str)
348348
})
349349

350+
it('ip6 + udp + quic-v1 + ipfs', () => {
351+
const str = '/ip6/2001:8a0:7ac5:4201:3ac9:86ff:fe31:7095/udp/4001/quic-v1/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC'
352+
const addr = multiaddr(str)
353+
expect(addr).to.have.property('bytes')
354+
expect(addr.toString()).to.equal(str.replace('/ipfs/', '/p2p/'))
355+
})
356+
357+
it('ip6 + udp + quic-v1 + p2p', () => {
358+
const str = '/ip6/2001:8a0:7ac5:4201:3ac9:86ff:fe31:7095/udp/4001/quic-v1/p2p/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC'
359+
const addr = multiaddr(str)
360+
expect(addr).to.have.property('bytes')
361+
expect(addr.toString()).to.equal(str)
362+
})
363+
350364
it('ip6 webtransport', () => {
351-
const str = '/ip6/2001:8a0:7ac5:4201:3ac9:86ff:fe31:7095/udp/4001/quic/webtransport'
365+
const str = '/ip6/2001:8a0:7ac5:4201:3ac9:86ff:fe31:7095/udp/4001/quic-v1/webtransport'
352366
const addr = multiaddr(str)
353367
expect(addr).to.have.property('bytes')
354368
expect(addr.toString()).to.equal(str)
355369
})
356370

357371
it('ip4 webtransport', () => {
358-
const str = '/ip4/1.2.3.4/udp/4001/quic/webtransport'
372+
const str = '/ip4/1.2.3.4/udp/4001/quic-v1/webtransport'
359373
const addr = multiaddr(str)
360374
expect(addr).to.have.property('bytes')
361375
expect(addr.toString()).to.equal(str)
362376
})
363377

364378
it('webtransport with certhash', () => {
365-
const str = '/ip4/1.2.3.4/udp/4001/quic/webtransport/certhash/uEiAkH5a4DPGKUuOBjYw0CgwjvcJCJMD2K_1aluKR_tpevQ/certhash/uEiAfbgiymPP2_nX7Dgir8B4QkksjHp2lVuJZz0F79Be9JA/p2p/12D3KooWBdmLJjhpgJ9KZgLM3f894ff9xyBfPvPjFNn7MKJpyrC2'
379+
const str = '/ip4/1.2.3.4/udp/4001/quic-v1/webtransport/certhash/uEiAkH5a4DPGKUuOBjYw0CgwjvcJCJMD2K_1aluKR_tpevQ/certhash/uEiAfbgiymPP2_nX7Dgir8B4QkksjHp2lVuJZz0F79Be9JA/p2p/12D3KooWBdmLJjhpgJ9KZgLM3f894ff9xyBfPvPjFNn7MKJpyrC2'
366380
const addr = multiaddr(str)
367381
expect(addr).to.have.property('bytes')
368382
expect(addr.toString()).to.equal(str)

0 commit comments

Comments
 (0)