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

p2p: support configuring NAT in TOML file #31041

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

fjl
Copy link
Contributor

@fjl fjl commented Jan 17, 2025

This is an alternative for #27407 with a solution based on gencodec. With the PR, one can now configure like this:

# config.toml
[Node.P2P]
NAT = "extip:33.33.33.33"
$ geth --config config.toml
...
INFO [01-17|16:37:31.436] Started P2P networking      self=enode://[email protected]:30303

@fjl fjl requested a review from zsfelfoldi as a code owner January 17, 2025 15:40
// protocol.
BootstrapNodesV5 []*enode.Node `toml:",omitempty"`

// Static nodes are used as pre-configured connections which are always
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Static nodes are used as pre-configured connections which are always
// StaticNodes are used as pre-configured connections which are always

// allowed to connect, even above the peer limit.
TrustedNodes []*enode.Node

// Connectivity can be restricted to certain IP networks.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Connectivity can be restricted to certain IP networks.
// NetRestrict is used to restrict connectivity to specific IP networks.

Comment on lines +95 to +96
// If ListenAddr is set to a non-nil address, the server
// will listen for incoming connections.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// If ListenAddr is set to a non-nil address, the server
// will listen for incoming connections.
// ListenAddr specifies the address on which the server will listen for incoming connections.
// If set to a non-empty value, the server will actively listen for connections on this address.

Comment on lines +103 to +104
// If DiscAddr is set to a non-nil value, the server will use ListenAddr
// for TCP and DiscAddr for the UDP discovery protocol.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// If DiscAddr is set to a non-nil value, the server will use ListenAddr
// for TCP and DiscAddr for the UDP discovery protocol.
// DiscAddr specifies the address to be used for the UDP discovery protocol.
// If set to a non-empty value, the server will use ListenAddr for TCP connections
// and DiscAddr for UDP-based discovery communication.

Comment on lines +107 to +109
// If set to a non-nil value, the given NAT port mapper
// is used to make the listening port available to the
// Internet.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// If set to a non-nil value, the given NAT port mapper
// is used to make the listening port available to the
// Internet.
// NAT specifies the NAT port mapping mechanism to use for making the listening port
// accessible from the Internet. If set to a non-nil value, the provided NAT interface
// will be used to map and expose the server's listening port.

Comment on lines +112 to +113
// If Dialer is set to a non-nil value, the given Dialer
// is used to dial outbound peer connections.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// If Dialer is set to a non-nil value, the given Dialer
// is used to dial outbound peer connections.
// Dialer specifies the dialer used to establish outbound peer connections.
// If set to a non-nil value, the provided dialer will be used to dial and connect
// to remote peers. If nil, a default dialing mechanism will be used.

// is used to dial outbound peer connections.
Dialer NodeDialer `toml:"-"`

// If NoDial is true, the server will not dial any peers.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// If NoDial is true, the server will not dial any peers.
// NoDial controls whether the server will initiate outbound connections to peers.
// If set to true, the server will not dial any peers and will only accept incoming connections.

Comment on lines +119 to +120
// If EnableMsgEvents is set then the server will emit PeerEvents
// whenever a message is sent to or received from a peer
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// If EnableMsgEvents is set then the server will emit PeerEvents
// whenever a message is sent to or received from a peer
// EnableMsgEvents enables the emission of PeerEvents for message activity.
// If set to true, the server will emit events whenever a message is sent to or received from a peer.


// Config holds Server options.
type Config struct {
// This field must be set to a valid secp256k1 private key.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// This field must be set to a valid secp256k1 private key.
// PrivateKey specifies the secp256k1 private key used for cryptographic operations.
// This field must be set to a valid ECDSA private key; otherwise, the server will not function properly.

// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.

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.

2 participants