Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd, p2p: filter peers by regex on name #2404

Merged
merged 1 commit into from
Apr 18, 2024

Conversation

weiihann
Copy link
Contributor

Description

This PR adds a new feature to filter peers by their names based on a set of customized regex patterns.

Rationale

Some outdated versions of nodes running on BSC may keep connecting to a healthy set of peers and only consume information, but not return any useful data. Such nodes should be filtered out to save network bandwidth.

Example

In the config file:

...
[Node.P2P]
PeerFilterPatterns = ["(?!)geth"]
...

An example of a false regexp pattern error message:

t=2024-04-18T06:02:10+0000 lvl=error msg="Failed to compile peer filter patterns" err="error parsing regexp: missing closing ): `abc(def`"

@weiihann weiihann requested a review from zzzckck as a code owner April 18, 2024 06:45
@zzzckck zzzckck merged commit 3b7f0e4 into bnb-chain:develop Apr 18, 2024
7 checks passed
@wellgamer789
Copy link

"may keep connecting to a healthy set of peers and only consume information, but not return any useful data."

I may be wrong, but i think what you are fighting are "fake nodes" and they can easily bypass this "check".

@zzzckck
Copy link
Collaborator

zzzckck commented May 11, 2024

"may keep connecting to a healthy set of peers and only consume information, but not return any useful data."

I may be wrong, but i think what you are fighting are "fake nodes" and they can easily bypass this "check".

yes, it is just optional feature, can not solve the case you mentioned. But could be useful in some cases.

@kaber2
Copy link

kaber2 commented May 13, 2024

Obsolete peers should be filtered based on the fork ID. This seems really useless.

@zzzckck
Copy link
Collaborator

zzzckck commented Jun 20, 2024

1.to filter out specified nodes that the name contains "alice"

[Node.P2P]
PeerFilterPatterns = ["^alice.*"]

This will reject connection from client with name "alice*"

2.to filter out specified nodes that the name contains either "alice" or "bob"

[Node.P2P]
PeerFilterPatterns = ["^alice.*|^bob.*"]

3.Some Examples

[Node.P2P]
PeerFilterPatterns = ["Geth/v1.3.*|Geth/v1.4.4.*|Geth/v1.4.5.*|Geth/v1.4.6.*"]

@setunapo
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants