Skip to content
This repository has been archived by the owner on Aug 23, 2019. It is now read-only.

[WIP] Add secio & move to pull-streams #67

Merged
merged 9 commits into from
Sep 7, 2016
Merged

[WIP] Add secio & move to pull-streams #67

merged 9 commits into from
Sep 7, 2016

Conversation

dignifiedquire
Copy link
Member

Not finished yet

Closes #63

@dignifiedquire
Copy link
Member Author

dignifiedquire commented Jul 4, 2016

I'm pretty close to passing tests, there is just one issue left to fix. When initiating the secio protocol multistream-select seems to loose one message, which is very unfortunate.

-->  /multistream/1.0.0
<--  /multistream/1.0.0
<--  /secio/1.0.0
listener ready
handle: QmVg942ZGNuGw7AFpiQAPsdRxzCK4J9e15NZGEBaixowQV
  libp2p:secio 1. propose - start +0ms
  libp2p:secio 1. propse - writing proposal +1ms
writing:  <Buffer f3 02 0a 10 98 a4 3a fb f0 07 e4 74 09 8c 9c 14 28 43 b9 6a 12 ab 02 08 00 12 a6 02 30 82 01 22 30 0d 06 09 2a 86 48 86 f7 0d 01 01 01 05 00 03 82 01 ... >
  libp2p:secio 1. propose - proposal size 373 +8ms
I shall read: 373
-->  /secio/1.0.0
dial: QmRRTGZEykibGGAEpSDh3fK2UnL746x5zHeQzNzERc74uM
  libp2p:secio 1. propose - start +4ms
  libp2p:secio 1. propse - writing proposal +0ms
writing:  <Buffer f3 02 0a 10 1b c0 15 68 22 cd c6 e9 0d 99 7e ae 4e 64 d8 f3 12 ab 02 08 00 12 a6 02 30 82 01 22 30 0d 06 09 2a 86 48 86 f7 0d 01 01 01 05 00 03 82 01 ... >
  libp2p:secio 1. propose - proposal size 373 +6ms
I shall read: 373
reading <Buffer 0d 2f 73 65 63 69 6f 2f 31 2e 30 2e 30 0a f3 02 0a 10 98 a4 3a fb f0 07 e4 74 09 8c 9c 14 28 43 b9 6a 12 ab 02 08 00 12 a6 02 30 82 01 22 30 0d 06 09 ... >
reading msg <Buffer f3 02 0a 10 1b c0 15 68 22 cd c6 e9 0d 99 7e ae 4e 64 d8 f3 12 ab 02 08 00 12 a6 02 30 82 01 22 30 0d 06 09 2a 86 48 86 f7 0d 01 01 01 05 00 03 82 01 ... >
  libp2p:secio 1. propse - reading proposal +4ms <Buffer 0a 10 1b c0 15 68 22 cd c6 e9 0d 99 7e ae 4e 64 d8 f3 12 ab 02 08 00 12 a6 02 30 82 01 22 30 0d 06 09 2a 86 48 86 f7 0d 01 01 01 05 00 03 82 01 0f 00 ... >
  libp2p:secio 1.1 identify +1ms
  libp2p:secio 1.1 identify - QmVg942ZGNuGw7AFpiQAPsdRxzCK4J9e15NZGEBaixowQV - identified remote peer as QmRRTGZEykibGGAEpSDh3fK2UnL746x5zHeQzNzERc74uM +6ms
  libp2p:secio 1.2 selection +0ms
  libp2p:secio 1. propose - finish +1ms
  libp2p:secio 2. exchange - start +1ms
  libp2p:secio 2. exchange - writing exchange +0ms
writing:  <Buffer c6 02 0a 41 04 87 54 67 c3 15 ba f1 b6 ff b9 c3 0c 6f 8a e4 16 fc b6 7a 54 51 20 e6 ee 5d 63 c1 bd 89 f2 b0 59 15 4b dd 1b 4e 50 fc c2 81 24 42 79 96 ... >
I shall read: 328

# hangs..

The message that is lost is the first one with writing..

@dignifiedquire
Copy link
Member Author

Adding the below snippet to https://github.com/diasdavid/js-multistream/blob/master/src/listener.js#L62

      if (handlers[msg]) {
        // Protocol supported, ACK back
        encode.write(new Buffer(msg + '\n'));

        if (conn.cork) {
          conn.cork()

          setTimeout(() => {
            conn.uncork()
          }, 100)
        }
        console.log('listener ready')
        return handlers[msg](conn);

fixes the issue.

@dignifiedquire dignifiedquire changed the title [WIP] Add secio [WIP] Add secio & move to pull-streams Aug 9, 2016
@daviddias
Copy link
Member

@dignifiedquire just to confirm, this just depends on merges and releases, all the rest is 👌 ?

@daviddias
Copy link
Member

daviddias commented Aug 18, 2016

What was the magic to not need node-forge anymore? libp2p-crypto? It doesn't require to be injected every single time anymore? @haadcode will be happy :)

@@ -35,7 +38,7 @@ module.exports = function connection (swarm) {
ms.select(identify.multicodec, (err, conn) => {
if (err) { return cb(err) }

identify.exec(conn, (err, peerInfo, observedAddrs) => {
identify.listen(conn, (err, peerInfo, observedAddrs) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: This will change to 'dialer', once identify CR is applied

@dignifiedquire
Copy link
Member Author

@dignifiedquire just to confirm, this just depends on merges and releases, all the rest is 👌 ?

Secio yes, but some of the other tests do not yet pass with all the new pull-stream things. Especially webrtc as that isn't migrated yet, and I'm having some issues with websockets, probably due to the halfOpen issue.

@dignifiedquire
Copy link
Member Author

What was the magic to not need node-forge anymore? libp2p-crypto? It doesn't require to be injected every single time anymore? @haadcode will be happy :)

This: https://github.com/libp2p/js-libp2p-swarm/blob/56e558ea86c1eb5b5355ade8cda9652d1589c408/.aegir.js#L9-L12

@daviddias
Copy link
Member

@dignifiedquire
Copy link
Member Author

@dignifiedquire
Copy link
Member Author

Started doing some fixes for the websocket problems in

@daviddias
Copy link
Member

daviddias commented Sep 2, 2016

@dignifiedquire having an hard time getting the stream muxing tests to pass: nvm, got it to pass, it was the circular npm linking

    stream muxing with spdy (on TCP)
      ✓ add
      3) handle + dial on protocol
      4) dial to warm conn
      5) dial on protocol, reuse warmed conn
      6) enable identify to reuse incomming muxed conn
      7) with Identify, do getPeerInfo
      - make sure it does not blow up when the socket is closed
      - blow up a socket, with WebSockets
      ✓ close one end, make sure the other does not blow (1006ms)

@daviddias
Copy link
Member

daviddias commented Sep 2, 2016

Last things before merge


const id = swarm._peerInfo.id
if (id.privKey == null || swarm.encrypt === false) {
return ms.select(tags.plaintex, cb)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this typo is what was causing my issue in libp2p-ipfs

@dignifiedquire
Copy link
Member Author

make the encrypted channel be a option set by a func just like connection.reuse

This is done, needs the new secio api: libp2p/js-libp2p-secio#17

@dignifiedquire
Copy link
Member Author

All tests pass locally when using the above mentioned secio branch plus libp2p/js-libp2p-webrtc-star#19

@coveralls
Copy link

coveralls commented Sep 7, 2016

Coverage Status

Changes Unknown when pulling 6091e94 on secio into * on master*.

@coveralls
Copy link

coveralls commented Sep 7, 2016

Coverage Status

Changes Unknown when pulling 6091e94 on secio into * on master*.

@daviddias
Copy link
Member

@dignifiedquire why do we have coveralls badges all over again?

@daviddias daviddias merged commit 546c9bc into master Sep 7, 2016
@coveralls
Copy link

coveralls commented Sep 7, 2016

Coverage Status

Changes Unknown when pulling 6091e94 on secio into * on master*.

@daviddias daviddias deleted the secio branch September 7, 2016 14:12
@dignifiedquire
Copy link
Member Author

@dignifiedquire why do we have coveralls badges all over again?

trying to disable them one at a time, but they are enabled by default :(

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants