Skip to content

Commit 50bb433

Browse files
authored
feat: add TLS to protocols-table (#306)
This allows the construction of `/tls/ws` which is identical and preferred to `/wss`. Similar with `/http`
1 parent 4a7c850 commit 50bb433

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
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
[444, 96, 'onion'],
3636
[445, 296, 'onion3'],
3737
[446, V, 'garlic64'],
38+
[448, 0, 'tls'],
3839
[460, 0, 'quic'],
3940
[461, 0, 'quic-v1'],
4041
[465, 0, 'webtransport'],

test/index.spec.ts

+14
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,13 @@ describe('variants', () => {
424424
expect(addr.toString()).to.equal(str.replace('/ipfs/', '/p2p/'))
425425
})
426426

427+
it('tls', () => {
428+
const str = '/ip4/127.0.0.1/tcp/9090/tls/ws'
429+
const addr = multiaddr(str)
430+
expect(addr).to.have.property('bytes')
431+
expect(addr.toString()).to.equal(str)
432+
})
433+
427434
it('onion', () => {
428435
const str = '/onion/timaq4ygg2iegci7:1234'
429436
const addr = multiaddr(str)
@@ -1058,3 +1065,10 @@ describe('helpers', () => {
10581065
})
10591066
})
10601067
})
1068+
1069+
describe('unknown protocols', () => {
1070+
it('throws an error', () => {
1071+
const str = '/ip4/127.0.0.1/unknown'
1072+
expect(() => multiaddr(str)).to.throw('no protocol with name: unknown')
1073+
})
1074+
})

0 commit comments

Comments
 (0)