-
Notifications
You must be signed in to change notification settings - Fork 46
[WIP] feat: dns support for WS #47
Changes from 1 commit
569eab1
7ea8841
ee32dab
3e113be
029c917
9a48319
63a9fe7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,4 +59,4 @@ | |
"Greenkeeper <[email protected]>", | ||
"Richard Littauer <[email protected]>" | ||
] | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,22 +26,25 @@ describe('listen', () => { | |
}) | ||
|
||
it('listen, check for callback', (done) => { | ||
const listener = ws.createListener((conn) => {}) | ||
const listener = ws.createListener((conn) => { | ||
}) | ||
listener.listen(ma, () => { | ||
listener.close(done) | ||
}) | ||
}) | ||
|
||
it('listen, check for listening event', (done) => { | ||
const listener = ws.createListener((conn) => {}) | ||
const listener = ws.createListener((conn) => { | ||
}) | ||
listener.on('listening', () => { | ||
listener.close(done) | ||
}) | ||
listener.listen(ma) | ||
}) | ||
|
||
it('listen, check for the close event', (done) => { | ||
const listener = ws.createListener((conn) => {}) | ||
const listener = ws.createListener((conn) => { | ||
}) | ||
listener.on('listening', () => { | ||
listener.on('close', done) | ||
listener.close() | ||
|
@@ -51,7 +54,8 @@ describe('listen', () => { | |
|
||
it('listen on addr with /ipfs/QmHASH', (done) => { | ||
const ma = multiaddr('/ip4/127.0.0.1/tcp/9090/ws/ipfs/Qmb6owHp6eaWArVbcJJbQSyifyJBttMMjYV76N2hMbf5Vw') | ||
const listener = ws.createListener((conn) => {}) | ||
const listener = ws.createListener((conn) => { | ||
}) | ||
listener.listen(ma, () => { | ||
listener.close(done) | ||
}) | ||
|
@@ -74,7 +78,8 @@ describe('listen', () => { | |
}) | ||
|
||
it('getAddrs', (done) => { | ||
const listener = ws.createListener((conn) => {}) | ||
const listener = ws.createListener((conn) => { | ||
}) | ||
listener.listen(ma, () => { | ||
listener.getAddrs((err, addrs) => { | ||
expect(err).to.not.exist | ||
|
@@ -100,7 +105,8 @@ describe('listen', () => { | |
it('getAddrs preserves IPFS Id', (done) => { | ||
const ma = multiaddr('/ip4/127.0.0.1/tcp/9090/ws/ipfs/Qmb6owHp6eaWArVbcJJbQSyifyJBttMMjYV76N2hMbf5Vw') | ||
|
||
const listener = ws.createListener((conn) => {}) | ||
const listener = ws.createListener((conn) => { | ||
}) | ||
listener.listen(ma, () => { | ||
listener.getAddrs((err, addrs) => { | ||
expect(err).to.not.exist | ||
|
@@ -179,11 +185,15 @@ describe('filter addrs', () => { | |
const mh2 = multiaddr('/ip4/127.0.0.1/udp/9090') | ||
const mh3 = multiaddr('/ip4/127.0.0.1/tcp/9090/ws') | ||
const mh4 = multiaddr('/ip4/127.0.0.1/tcp/9090/ws/ipfs/Qmb6owHp6eaWArVbcJJbQSyifyJBttMMjYV76N2hMbf5Vw') | ||
const mh5 = multiaddr('/dns/ipfs.io/ws') | ||
const mh6 = multiaddr('/dns/ipfs.io/ws/ipfs/Qmb6owHp6eaWArVbcJJbQSyifyJBttMMjYV76N2hMbf5Vw') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need to also account for addresses like
otherwise you can't specify the port There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes these need /tcp/80/wss or /tcp/443/wss, and it needs to be /dns4 or /dns6 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah :) I'll add those. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, actually, default for just @dryajov still up to finish this? It would be sweet for the 0.23 release! :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @diasdavid yep, I'll get this in. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. awesome @dryajov :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Turns out that we apparently don't support ports in DNS address in js-mafmt, here is a PR that addresses it - multiformats/js-mafmt#15. I'm not entirely sure its the right approach here, but it seems to work. With this PR in mafmt, I have most of the tests passing here, I should be able to get them all passing soon. I'll push as soon as I have everything working. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dryajov published mafmt for you :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! |
||
|
||
const valid = ws.filter([mh1, mh2, mh3, mh4]) | ||
expect(valid.length).to.equal(2) | ||
const valid = ws.filter([mh1, mh2, mh3, mh4, mh5, mh6]) | ||
expect(valid.length).to.equal(4) | ||
expect(valid[0]).to.deep.equal(mh3) | ||
expect(valid[1]).to.deep.equal(mh4) | ||
expect(valid[2]).to.deep.equal(mh5) | ||
expect(valid[3]).to.deep.equal(mh6) | ||
done() | ||
}) | ||
|
||
|
@@ -311,6 +321,8 @@ describe('valid Connection', () => { | |
}) | ||
|
||
describe.skip('turbolence', () => { | ||
it('dialer - emits error on the other end is terminated abruptly', (done) => {}) | ||
it('listener - emits error on the other end is terminated abruptly', (done) => {}) | ||
it('dialer - emits error on the other end is terminated abruptly', (done) => { | ||
}) | ||
it('listener - emits error on the other end is terminated abruptly', (done) => { | ||
}) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will fail as these hosts don't exist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, those should fail... They are being intentionally filtered out, according to the test.
Not the clearest test case, some refactoring might make sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything should be passing right now. I also refactored the existing tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re: compliance addresses, you are right, i was talking about something else. I'll make those point to existing hosts.