Prevent connecting to peers not in allowed peer list (#1102)

We needed to add some additional logic to ensure we didn't connect to
peers not in the allowlist.
This commit is contained in:
Shane da Silva
2023-07-10 22:13:37 -07:00
committed by GitHub
parent 1d07446152
commit d5d65bdc62
2 changed files with 11 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
---
"@farcaster/hubble": patch
---
Prevent connecting to peers not in allowed peer list

View File

@@ -946,6 +946,12 @@ export class Hub implements HubInterface {
}
async isValidPeer(ourPeerId: PeerId, message: ContactInfoContent) {
const peerId = ourPeerId.toString();
if (MAINNET_ALLOWED_PEERS?.length && !MAINNET_ALLOWED_PEERS.includes(peerId)) {
log.warn(`Peer ${ourPeerId.toString()} is not in the allowed peers list`);
return false;
}
const theirVersion = message.hubVersion;
const theirNetwork = message.network;