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

fix: decapsulate ipfs from dht find peer #11

Merged
merged 1 commit into from
Mar 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions src/daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,17 +369,7 @@ class Daemon {
enc.write(OkResponse({
identify: {
id: this.libp2p.peerInfo.id.toBytes(),
// temporary removal of "/ipfs/..." from multiaddrs
// this will be solved in: https://github.com/libp2p/js-libp2p/issues/323
addrs: this.libp2p.peerInfo.multiaddrs.toArray().map(m => {
let buffer
try {
buffer = m.decapsulate('ipfs').buffer
} catch (_) {
buffer = m.buffer
}
return buffer
})
addrs: this.libp2p.peerInfo.multiaddrs.toArray().map(m => m.buffer)
}
}))
break
Expand Down
14 changes: 14 additions & 0 deletions src/libp2p.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,20 @@ class DaemonLibp2p extends Libp2p {
this.peerInfo.multiaddrs.add(addr)
})
}

// temporary removal of "/ipfs/..." from multiaddrs
// this will be solved in: https://github.com/libp2p/js-libp2p/issues/323
this.peerInfo.multiaddrs.toArray().forEach(m => {
let ma
try {
ma = m.decapsulate('ipfs')
} catch (_) {
ma = m
}

this.peerInfo.multiaddrs.replace(m, ma)
})

resolve()
})
})
Expand Down
2 changes: 1 addition & 1 deletion test/daemon/core.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ describe('core features', () => {

expect(response.identify).to.eql({
id: daemon.libp2p.peerInfo.id.toBytes(),
addrs: daemon.libp2p.peerInfo.multiaddrs.toArray().map(m => m.decapsulate('ipfs').buffer)
addrs: daemon.libp2p.peerInfo.multiaddrs.toArray().map(m => m.buffer)
})
stream.end()
})
Expand Down