Skip to content

Commit

Permalink
feat: support /quic-v1 (#294)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
lidel authored Dec 10, 2022
1 parent 2bf11ef commit 7d95ef8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/protocols-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
20 changes: 17 additions & 3 deletions test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7d95ef8

Please sign in to comment.