mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-03-31 06:41:08 +00:00
Port of https://github.com/libp2p/go-libp2p-core/blob/master/connmgr/gater.go Adds a new configuration key `connectionGater` which allows denying the dialing of certain peers, individual multiaddrs and the creation of connections at certain points in the connection flow. Fixes: https://github.com/libp2p/js-libp2p/issues/175 Refs: https://github.com/libp2p/js-libp2p/issues/744 Refs: https://github.com/libp2p/js-libp2p/issues/769 Co-authored-by: mzdws <8580712+mzdws@user.noreply.gitee.com>
20 lines
699 B
JavaScript
20 lines
699 B
JavaScript
'use strict'
|
|
|
|
function mockConnectionGater () {
|
|
return {
|
|
denyDialPeer: async () => Promise.resolve(false),
|
|
denyDialMultiaddr: async () => Promise.resolve(false),
|
|
denyInboundConnection: async () => Promise.resolve(false),
|
|
denyOutboundConnection: async () => Promise.resolve(false),
|
|
denyInboundEncryptedConnection: async () => Promise.resolve(false),
|
|
denyOutboundEncryptedConnection: async () => Promise.resolve(false),
|
|
denyInboundUpgradedConnection: async () => Promise.resolve(false),
|
|
denyOutboundUpgradedConnection: async () => Promise.resolve(false),
|
|
filterMultiaddrForPeer: async () => Promise.resolve(true)
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
mockConnectionGater
|
|
}
|