feat: custom address filter (#116)

* feat: custom address filter

BREAKING CHANGE: Only DNS+WSS addresses are now returned on filter by default in the browser. This can be overritten by the filter option and filters are provided in the module.
This commit is contained in:
Vasco Santos
2020-11-24 10:14:01 +01:00
committed by GitHub
parent 662d04128c
commit 711c721b03
8 changed files with 257 additions and 61 deletions

View File

@ -34,6 +34,16 @@ describe('libp2p-websockets', () => {
expect(results).to.eql([message])
})
it('should filter out no DNS websocket addresses', function () {
const ma1 = multiaddr('/ip4/127.0.0.1/tcp/80/ws')
const ma2 = multiaddr('/ip4/127.0.0.1/tcp/443/wss')
const ma3 = multiaddr('/ip6/::1/tcp/80/ws')
const ma4 = multiaddr('/ip6/::1/tcp/443/wss')
const valid = ws.filter([ma1, ma2, ma3, ma4])
expect(valid.length).to.equal(0)
})
describe('stress', () => {
it('one big write', async () => {
const rawMessage = new Uint8Array(1000000).fill('a')