Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

will js-ipfs support private network feature as go-ipfs did (via swarm.key) ? #1630

Closed
gitGksgk opened this issue Oct 12, 2018 · 3 comments
Closed

Comments

@gitGksgk
Copy link

gitGksgk commented Oct 12, 2018

  • Version: 0.32.3
  • Platform: windows
  • Subsystem: unkown

Type: Feature

Severity:

Medium

Description:

js-ipfs private net feature not implemented

Steps to reproduce the error:

Set up a private network via putting a swarm.key in go-ipfs config file ( .ipfs/ ). get address1
Set up another go-ipfs node(node2) with the same swarm.key. In node2 use ipfs swarm connect address1. success.
Use the latest version of js-ipfs (currently 0.32.3) . put the same swarm.key in .jsipfs/ . node src\cli\bin.js daemon. it won't print the same message as go-ipfs do

> Swarm is limited to private network of peers with the swarm key
> Swarm key fingerprint: blablabla

node src\cli\bin.js swarm connect address1, failed.

js-ipfs\src\cli\commands\swarm\connect.js:20
        throw err
        ^

Error: Error: stream ended with:43 but wanted:75
    at parseError (\js-ipfs\node_modules\ipfs-api\src\utils\send-request.js:17:17)
    at ClientRequest.<anonymous> (\js-ipfs\node_modules\ipfs-api\src\utils\send-request.js:47:14)
    at Object.onceWrapper (events.js:315:30)
    at emitOne (events.js:116:13)
    at ClientRequest.emit (events.js:211:7)
    at HTTPParser.parserOnIncomingClient (_http_client.js:543:21)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:112:17)
    at Socket.socketOnData (_http_client.js:440:20)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)

Since js-libp2p has supported private network, will js-ipfs implement private network feature as go-ipfs did?

@gitGksgk gitGksgk changed the title js-ipfs won't support private network feature as go-ipfs did (via swarm.key) will js-ipfs support private network feature as go-ipfs did (via swarm.key) ? Oct 13, 2018
@gitGksgk
Copy link
Author

gitGksgk commented Oct 15, 2018

ok i've figured it out. Yes it supports. just a little configuration will do. close the issue.

@yonderblue
Copy link

yonderblue commented Jan 26, 2019

Mind sharing config?

@Duske
Copy link

Duske commented Mar 31, 2019

Hey @Gaillard , I figured it out.

The swarm.key gets ignored at the moment, so one has to do it manually.

const fs = require('fs');
const IPFS = require('ipfs');
const Protector = require('libp2p-pnet')
// your path to the key file
const swarmKeyPath = './repo/swarm.key';
const node = new IPFS({ 
    libp2p: {
      modules: {
        connProtector: new Protector(fs.readFileSync(swarmKeyPath))
      }
    }
})

Just as the config, you can define some settings for libp2p.
Take a look at the following issues: #1857 and https://github.com/libp2p/js-libp2p-pnet/issues/3

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

No branches or pull requests

3 participants