Skip to content
This repository has been archived by the owner on Sep 6, 2022. It is now read-only.

Add canonical peer status logging with sampling #269

Merged
merged 3 commits into from
Jun 30, 2022

Conversation

MarcoPolo
Copy link
Contributor

These logs would normally be noisy, so we sample them. And randomly log 1 in N (N is configurable).

This means that most logs are pretty random, but patterns will emerge when there are a large number of similar events.

These logs can then be hooked up to fail2ban to automatically block abnormal peers for a bit.

Example:
A node starts a connection, sends a ping, and closes it. 100 times a second.
We log a connection established at a rate of 1 in 100 (1%).
This would log roughly once a second.
a fail2ban filter can ban a peer after 30 of these logs in a minute. (average of 50 conns/peer/second). And ban that peer for 60 minutes (not sure yet on the timing, but likely anything >10 min is good).

This solution can be applied to similar problems too. Basically anything that boils down to "this is fine/normal if it happens sparingly, but not great if it happens a ton".

Another benefit to this compared to similar solutions is that it's stateless in libp2p. Libp2p doesn't have to do anything besides maybe log a line.

@MarcoPolo MarcoPolo merged commit 7a9d494 into master Jun 30, 2022
@MarcoPolo MarcoPolo deleted the marco/canonical-peer-status branch June 30, 2022 18:18
@ajnavarro ajnavarro mentioned this pull request Aug 24, 2022
72 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants