mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-06-21 13:01:33 +00:00
feat: add check for protector and enforced pnet
fix: update protector config and tests docs: add private network info to the readme test: fix an issue with config
This commit is contained in:
@ -13,6 +13,9 @@ const OptionsSchema = Joi.object({
|
||||
transport: Joi.array().items(ModuleSchema).min(1).required(),
|
||||
streamMuxer: Joi.array().items(ModuleSchema).allow(null),
|
||||
connEncryption: Joi.array().items(ModuleSchema).allow(null),
|
||||
connProtector: Joi.object().keys({
|
||||
protect: Joi.func().required()
|
||||
}).unknown(),
|
||||
peerDiscovery: Joi.array().items(ModuleSchema).allow(null),
|
||||
dht: ModuleSchema.allow(null)
|
||||
}).required(),
|
||||
|
@ -75,6 +75,13 @@ class Node extends EventEmitter {
|
||||
})
|
||||
}
|
||||
|
||||
// Attach private network protector
|
||||
if (this._modules.connProtector) {
|
||||
this._switch.protector = this._modules.connProtector
|
||||
} else if (process.env.LIBP2P_FORCE_PNET) {
|
||||
throw new Error('Private network is enforced, but no protector was provided')
|
||||
}
|
||||
|
||||
// dht provided components (peerRouting, contentRouting, dht)
|
||||
if (this._config.EXPERIMENTAL.dht) {
|
||||
const DHT = this._modules.dht
|
||||
|
Reference in New Issue
Block a user