From 66a90560259726643e5060428b155cf16d294674 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Sat, 10 Dec 2022 00:54:47 +0100 Subject: [PATCH] feat: support /quic-v1 https://github.com/multiformats/multiaddr/issues/145 https://github.com/ipfs/kubo/issues/9410 License: MIT Signed-off-by: Marcin Rataj --- src/protocols-table.ts | 1 + test/index.spec.ts | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/protocols-table.ts b/src/protocols-table.ts index d88294be..b00e6a0b 100644 --- a/src/protocols-table.ts +++ b/src/protocols-table.ts @@ -35,6 +35,7 @@ export const table: Array<[number, number, string, boolean?, boolean?]> = [ [445, 296, 'onion3'], [446, V, 'garlic64'], [460, 0, 'quic'], + [461, 0, 'quic-v1'], [465, 0, 'webtransport'], [466, V, 'certhash'], [477, 0, 'ws'], diff --git a/test/index.spec.ts b/test/index.spec.ts index fb753ece..08b92306 100644 --- a/test/index.spec.ts +++ b/test/index.spec.ts @@ -347,22 +347,36 @@ describe('variants', () => { expect(addr.toString()).to.equal(str) }) + it('ip6 + udp + quic-v1 + ipfs', () => { + const str = '/ip6/2001:8a0:7ac5:4201:3ac9:86ff:fe31:7095/udp/4001/quic-v1/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC' + const addr = multiaddr(str) + expect(addr).to.have.property('bytes') + expect(addr.toString()).to.equal(str.replace('/ipfs/', '/p2p/')) + }) + + it('ip6 + udp + quic-v1 + p2p', () => { + const str = '/ip6/2001:8a0:7ac5:4201:3ac9:86ff:fe31:7095/udp/4001/quic-v1/p2p/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC' + const addr = multiaddr(str) + expect(addr).to.have.property('bytes') + expect(addr.toString()).to.equal(str) + }) + it('ip6 webtransport', () => { - const str = '/ip6/2001:8a0:7ac5:4201:3ac9:86ff:fe31:7095/udp/4001/quic/webtransport' + const str = '/ip6/2001:8a0:7ac5:4201:3ac9:86ff:fe31:7095/udp/4001/quic-v1/webtransport' const addr = multiaddr(str) expect(addr).to.have.property('bytes') expect(addr.toString()).to.equal(str) }) it('ip4 webtransport', () => { - const str = '/ip4/1.2.3.4/udp/4001/quic/webtransport' + const str = '/ip4/1.2.3.4/udp/4001/quic-v1/webtransport' const addr = multiaddr(str) expect(addr).to.have.property('bytes') expect(addr.toString()).to.equal(str) }) it('webtransport with certhash', () => { - const str = '/ip4/1.2.3.4/udp/4001/quic/webtransport/certhash/uEiAkH5a4DPGKUuOBjYw0CgwjvcJCJMD2K_1aluKR_tpevQ/certhash/uEiAfbgiymPP2_nX7Dgir8B4QkksjHp2lVuJZz0F79Be9JA/p2p/12D3KooWBdmLJjhpgJ9KZgLM3f894ff9xyBfPvPjFNn7MKJpyrC2' + const str = '/ip4/1.2.3.4/udp/4001/quic-v1/webtransport/certhash/uEiAkH5a4DPGKUuOBjYw0CgwjvcJCJMD2K_1aluKR_tpevQ/certhash/uEiAfbgiymPP2_nX7Dgir8B4QkksjHp2lVuJZz0F79Be9JA/p2p/12D3KooWBdmLJjhpgJ9KZgLM3f894ff9xyBfPvPjFNn7MKJpyrC2' const addr = multiaddr(str) expect(addr).to.have.property('bytes') expect(addr.toString()).to.equal(str)