Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add TLS to protocols-table #306

Merged
merged 3 commits into from
Jan 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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?]> = [
[444, 96, 'onion'],
[445, 296, 'onion3'],
[446, V, 'garlic64'],
[448, 0, 'tls'],
[460, 0, 'quic'],
[461, 0, 'quic-v1'],
[465, 0, 'webtransport'],
Expand Down
14 changes: 14 additions & 0 deletions test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,13 @@ describe('variants', () => {
expect(addr.toString()).to.equal(str.replace('/ipfs/', '/p2p/'))
})

it('tls', () => {
const str = '/ip4/127.0.0.1/tcp/9090/tls/ws'
const addr = multiaddr(str)
expect(addr).to.have.property('bytes')
expect(addr.toString()).to.equal(str)
})

it('onion', () => {
const str = '/onion/timaq4ygg2iegci7:1234'
const addr = multiaddr(str)
Expand Down Expand Up @@ -1058,3 +1065,10 @@ describe('helpers', () => {
})
})
})

describe('unknown protocols', () => {
it('throws an error', () => {
const str = '/ip4/127.0.0.1/unknown'
expect(() => multiaddr(str)).to.throw('no protocol with name: unknown')
})
})