-
Notifications
You must be signed in to change notification settings - Fork 22
[WIP] Refactor to use pull streams #8
Conversation
dignifiedquire
commented
Jun 13, 2016
•
edited
Loading
edited
- Fix tests
- Fix error handling
- Test in libp2p-swarm
- Cleanup state management
- Fix and publish Uncaught TypeError: stream.destroy is not a function pull-stream/stream-to-pull-stream#9
- Fix and publish fix: move pull-pair to dependencies pull-stream/pull-handshake#3
the two "fix and publish" tasks are done now. |
thanks @dominictarr :) just on my flight back from holidays so will hopefully be able to finish this in the next days |
btw, I quite like how you have used run-series to separate the parts of the handshake. my plan is to refactor |
@dominictarr I'm getting close to working :) but I have this nasty issue when I started using You can run it yourself with |
the problem is here: you are trying to read to the same stream in from two different places. that isn't allowed. you need to take the stream, and put the mac into the start, and intercept it coming out. var shake = Handshake()
pull(
stream,
etm.createUnboxStream(proto.local.cipher, proto.local.mac),
shake,
etm.createBoxStream(proto.remote.cipher, proto.remote.mac),
stream
)
shake.write(state.proposal.in.rand)
shake.read(state.proposal.in.rand.length, function (err, buf) {
if(deepEqual(buf, state.proposal.in.rand)) //SUCCESS
state.secure.resolve(shake.rest())
else
state.secure.resolve(pull.error(new Error('fail')))
}) it seems silly to use two handshake phases, but since it sends a fixed value to confirm the session, part of the handshake is in the body, so that is kinda just how this protocol works. |
@dominictarr thank you so much! I finally have passing tests again 😂 |
I believe you have successfully tested this in libp2p-swarm, right? |
Yes the secio branch in libp2p-swarm adds tests using secio which passed with the current version of this branch |
This probably still needs some cleanup, need to go through it once more before merging |
@@ -2,7 +2,7 @@ | |||
"name": "libp2p-secio", | |||
"version": "0.3.1", | |||
"description": "Secio implementation in JavaScript", | |||
"main": "lib/index.js", | |||
"main": "src/index.js", |
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.
- change before merge
Last things to do before merge:
|
Extra, required for js and go interop #4 (comment) |
This should be simple with this: dignifiedquire/pull-length-prefixed#5 |