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

Adds allowed-peers Flag #688

Merged
merged 21 commits into from
Apr 29, 2024
Merged

Adds allowed-peers Flag #688

merged 21 commits into from
Apr 29, 2024

Conversation

otherview
Copy link
Member

@otherview otherview commented Apr 1, 2024

Description

Adds a new flag that limits the connections of a node.
This features help and allows for a few features like bootstrapping to be limited to a single node (good for metrics), DMZ's and traffic-shapping in general is now easier.

Flags accept a list of enodes :

--allowed-peers enode://797fdd968592ca3b59a143f1aa2f152913499d4bb469f2bd5b62dfb1257707b4cb0686563fe144ee2088b1cc4f174bd72df51dbeb7ec1c5b6a8d8599c756f38b@107.150.112.22:55555 enode://3eae6740af6180bb015309f7a07ff7405d6f1f9f1e5a9f2fabbd36b0c00b862521e63ff23573ffdb9035f2237c26513cb9f02454f9ada993e60b99ffc187bb54@107.150.112.21:55555

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • Log testing, making sure that no other peer had connected

@otherview otherview requested a review from a team as a code owner April 1, 2024 11:24
@codecov-commenter
Copy link

codecov-commenter commented Apr 1, 2024

Codecov Report

Attention: Patch coverage is 5.26316% with 36 lines in your changes are missing coverage. Please review.

Project coverage is 61.35%. Comparing base (2441238) to head (12816f0).

Files Patch % Lines
cmd/thor/utils.go 0.00% 34 Missing ⚠️
cmd/thor/main.go 0.00% 1 Missing ⚠️
p2psrv/server.go 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #688      +/-   ##
==========================================
+ Coverage   61.24%   61.35%   +0.11%     
==========================================
  Files         194      194              
  Lines       18207    18221      +14     
==========================================
+ Hits        11150    11179      +29     
+ Misses       5975     5960      -15     
  Partials     1082     1082              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@claytonneal
Copy link
Member

heya, do we need up update any README or docs.vechain.org for this?

p2psrv/server.go Outdated Show resolved Hide resolved
leszek-vechain
leszek-vechain previously approved these changes Apr 5, 2024
@libotony
Copy link
Member

libotony commented Apr 10, 2024

We already have a --bootnode flag that does part of the feature but does not limit other connections. I would consider adding a new flag --no-discovery that disables the discovery feature.

As the --bootnode flag indicates bootstrapping/discovery node, might not be ideal to indicate that it's the nodes that used to be connecting via peer-to-peer network, a new flag can be added for the designated feature.

And for the --no-discovery option, I think it's better to be a hidden flag, as it won't be a general usage and shouldn't be used in general cases.

@otherview otherview changed the title Adds connect-only-nodes Flag Adds allow-peers-only Flag Apr 12, 2024
@otherview otherview requested a review from libotony April 22, 2024 14:50
@otherview
Copy link
Member Author

otherview commented Apr 22, 2024

Myself and @libotony did a pair-prog on this, due to flag behaviours we ended up agreeing on allow-peers-only as a flag that only allows connectivity to certain peers.

The TLDR is that --no-discovery + --bootnodes in certain cases can still allow connections to other nodes.

darrenvechain
darrenvechain previously approved these changes Apr 22, 2024
Copy link
Member

@darrenvechain darrenvechain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking thoughts around the flag, but looks good

cmd/thor/flags.go Outdated Show resolved Hide resolved
@otherview otherview changed the title Adds allow-peers-only Flag Adds allowed-peers Flag Apr 22, 2024
p2psrv/server.go Outdated Show resolved Hide resolved
cmd/thor/utils.go Outdated Show resolved Hide resolved
@paologalligit
Copy link
Member

Myself and @libotony did a pair-prog on this, due to flag behaviours we ended up agreeing on allow-peers-only as a flag that only allows connectivity to certain peers.

The TLDR is that --no-discovery + --bootnodes in certain cases can still allow connections to other nodes.

About the last line, is it because this is only an outgoing connection restricted list and so it doesn't imply that another node could start an incoming connection with the node (even if not in the allow-peers flag)?

cmd/thor/utils.go Outdated Show resolved Hide resolved
cmd/thor/flags.go Outdated Show resolved Hide resolved
cmd/thor/utils.go Outdated Show resolved Hide resolved
p2psrv/options.go Outdated Show resolved Hide resolved
p2psrv/server.go Outdated Show resolved Hide resolved
@otherview otherview merged commit 88baecd into master Apr 29, 2024
13 checks passed
@otherview otherview deleted the pedro/connect_only_nodes_flag branch April 29, 2024 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants