will js-ipfs support private network feature as go-ipfs did (via swarm.key) ?
gitGksgk opened this issue · comments
- 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?
ok i've figured it out. Yes it supports. just a little configuration will do. close the issue.
Mind sharing config?
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