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

Initial development #1

Merged
merged 1 commit into from
Jul 18, 2018
Merged

Initial development #1

merged 1 commit into from
Jul 18, 2018

Conversation

jacobheun
Copy link
Collaborator

@jacobheun jacobheun commented May 30, 2018

This adds functionality to create private libp2p connections. A demo is also included demonstrating the interop between go and js working. I've created a WIP PR of interop tests, ipfs/interop#24. The failing tests in the PR are due to pubsub. Viewing the details you can see the private tests are functioning properly.

There is currently an issue with bad private network connections timing out instead of erroring. This is related to dominictarr/pull-reader#5. What happens is that since the private network is invalid, the stream of data coming in is still encrypted. When pull-length-prefixed attempts to determine the byte size of the incoming stream by parsing a varint, the varint is determined from encrypted data so it's wrong. When the incorrect stream size is larger than what's actually available in the buffer, it times out attempting to read what's not there.

I will continue looking into fixing the issue, but wanted to get the private network released, as it functions properly in a correct private network and the current issue doesn't pose a security risk.

Implements: https://github.com/libp2p/specs/blob/b1365bedcd46442074fbf96610f66b0663be088a/pnet/Private-Networks-PSK-V1.md

@jacobheun jacobheun changed the title [WIP] Initial development Initial development Jun 18, 2018
chore: add more documentation and comments
feat: protector now takes a key file buffer instead of the key
refactor: clean up decoder
fix: use xor streaming for encryption
fix: up handshake timeout to 60 seconds for default
refactor: clean up unneeded data and update readme
Copy link
Member

@daviddias daviddias left a comment

Choose a reason for hiding this comment

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

This looks pretty good! Are there interop tests that we can rely on?

@Kubuxu wanna give your review as well? It's the implementation of your idea in JS :)

@jacobheun
Copy link
Collaborator Author

jacobheun commented Jul 5, 2018

@diasdavid I've got an updated suite of interop tests at ipfs/interop#24 that are passing. There are a couple of go tests that are skipped in there right now due to a similar issue I was having with js pull-reader.

I have the interop tests using a temporary fork of pull-reader that I have a PR in for to try and resolve the overreading problem that crops up with crypto reads to prevent timeouts from occurring during invalid private network connection attempts.

Here's the output of the tests for easy reference. Valid connections will exchange 1024 bytes in each direction.

  Private network
    js <-> js on the same private network
      ✓ should be able to fetch data from js via js (431ms)
    go <-> js on the same private network
      ✓ should be able to fetch data from go via js (275ms)
      ✓ should be able to fetch data from js via go (198ms)
    go <-> go on the same private network
      ✓ should be able to fetch data from go via go
    go <-> js on different private networks
      ✓ should NOT be able to connect go <-> js
    js <-> js on different private networks
      ✓ should NOT be able to connect js <-> js (68ms)
    go <-> go on different private networks
      - should NOT be able to connect go <-> go
    js private network <-> go public network
      ✓ should NOT be able to connect js <-> go
    js private network <-> js public network
      ✓ should NOT be able to connect js <-> js (43ms)
    go private network <-> go public network
      - should NOT be able to connect go <-> go

@Kubuxu Kubuxu closed this Jul 9, 2018
@Kubuxu Kubuxu reopened this Jul 9, 2018
@ghost ghost assigned Kubuxu Jul 9, 2018
@ghost ghost added the in progress label Jul 9, 2018
@Kubuxu
Copy link
Member

Kubuxu commented Jul 9, 2018

Seems good to me.

@jacobheun jacobheun merged commit 9f5038d into master Jul 18, 2018
@ghost ghost removed the in progress label Jul 18, 2018
@jacobheun jacobheun deleted the feat/initial branch July 18, 2018 19:24
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