refactor: crypto and pnet (#469)

* feat: add initial plaintext 2 module

* refactor: initial refactor of pnet

* chore: fix lint

* fix: update plaintext api usage

* test: use plaintext for test crypto

* chore: update deps

test: update dialer suite scope

* feat: add connection protection to the upgrader

* refactor: cleanup and lint fix

* chore: remove unncessary transforms

* chore: temporarily disable bundlesize

* chore: add missing dep

* fix: use it-handshake to prevent overreading

* chore(fix): PR feedback updates

* chore: apply suggestions from code review

Co-Authored-By: Vasco Santos <vasco.santos@moxy.studio>
This commit is contained in:
Jacob Heun
2019-11-04 14:05:58 +01:00
parent af364b070b
commit 138bb0bbae
19 changed files with 577 additions and 309 deletions

View File

@ -90,7 +90,7 @@ class Libp2p extends EventEmitter {
if (this._modules.connEncryption) {
const cryptos = this._modules.connEncryption
cryptos.forEach((crypto) => {
this.upgrader.cryptos.set(crypto.tag, crypto)
this.upgrader.cryptos.set(crypto.protocol, crypto)
})
}
@ -108,7 +108,7 @@ class Libp2p extends EventEmitter {
// Attach private network protector
if (this._modules.connProtector) {
this._switch.protector = this._modules.connProtector
this.upgrader.protector = this._modules.connProtector
} else if (process.env.LIBP2P_FORCE_PNET) {
throw new Error('Private network is enforced, but no protector was provided')
}
@ -229,6 +229,7 @@ class Libp2p extends EventEmitter {
try {
await this.transportManager.close()
await this._switch.stop()
} catch (err) {
if (err) {
log.error(err)