Skip to content

Commit b44f608

Browse files
authoredMar 6, 2023
feat: Add SNI support (#312)
Adds the JS part of multiformats/multiaddr#138
1 parent 8e2f680 commit b44f608

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed
 

‎src/convert.ts

+2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export function convertToString (proto: number | string, buf: Uint8Array): strin
5252
case 55: // dns6
5353
case 56: // dnsaddr
5454
case 400: // unix
55+
case 449: // sni
5556
case 777: // memory
5657
return bytes2str(buf)
5758

@@ -89,6 +90,7 @@ export function convertToBytes (proto: string | number, str: string): Uint8Array
8990
case 55: // dns6
9091
case 56: // dnsaddr
9192
case 400: // unix
93+
case 449: // sni
9294
case 777: // memory
9395
return str2bytes(str)
9496

‎src/protocols-table.ts

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export const table: Array<[number, number, string, boolean?, boolean?]> = [
3737
[445, 296, 'onion3'],
3838
[446, V, 'garlic64'],
3939
[448, 0, 'tls'],
40+
[449, V, 'sni'],
4041
[460, 0, 'quic'],
4142
[461, 0, 'quic-v1'],
4243
[465, 0, 'webtransport'],

‎test/index.spec.ts

+7
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,13 @@ describe('variants', () => {
431431
expect(addr.toString()).to.equal(str)
432432
})
433433

434+
it('sni', () => {
435+
const str = '/ip4/127.0.0.1/tcp/9090/tls/sni/example.com/ws'
436+
const addr = multiaddr(str)
437+
expect(addr).to.have.property('bytes')
438+
expect(addr.toString()).to.equal(str)
439+
})
440+
434441
it('onion', () => {
435442
const str = '/onion/timaq4ygg2iegci7:1234'
436443
const addr = multiaddr(str)

0 commit comments

Comments
 (0)
Please sign in to comment.