Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions config/localTemplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,10 @@ type Local struct {
// EnableDHT will turn on the hash table for use with capabilities advertisement
EnableDHTProviders bool `version[34]:"false"`

// DisableP2PRelayTransport disables the relay transport for the P2P network. Relay transport is
// enabled by default when EnableP2P or EnableP2PHybridMode is set to true.
DisableP2PRelayTransport bool `version[34]:"false"`

// P2PPersistPeerID will write the private key used for the node's PeerID to the P2PPrivateKeyLocation.
// This is only used when P2PEnable is true. If P2PPrivateKey is not specified, it uses the default location.
P2PPersistPeerID bool `version[29]:"false"`
Expand Down
1 change: 1 addition & 0 deletions config/local_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ var defaultLocal = Local{
DisableLocalhostConnectionRateLimit: true,
DisableNetworking: false,
DisableOutgoingConnectionThrottling: false,
DisableP2PRelayTransport: false,
EnableAccountUpdatesStats: false,
EnableAgreementReporting: false,
EnableAgreementTimeMetrics: false,
Expand Down
1 change: 1 addition & 0 deletions installer/config.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"DisableLocalhostConnectionRateLimit": true,
"DisableNetworking": false,
"DisableOutgoingConnectionThrottling": false,
"DisableP2PRelayTransport": false,
"EnableAccountUpdatesStats": false,
"EnableAgreementReporting": false,
"EnableAgreementTimeMetrics": false,
Expand Down
11 changes: 8 additions & 3 deletions network/p2p/p2p.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,14 @@ func MakeHost(cfg config.Local, datadir string, pstore *pstore.PeerStore) (host.
listenAddr = "/ip4/0.0.0.0/tcp/0"
}

// the libp2p.NoListenAddrs builtin disables relays but this one does not
var noListenAddrs = func(cfg *libp2p.Config) error {
cfg.ListenAddrs = []multiaddr.Multiaddr{}
// the libp2p.NoListenAddrs builtin disables relays but this one only does if
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is technically right but I think two separate opts noListenAddrNoRelay := libp2p.NoListenAddrs(p2pCfg) and noListenAddrs := func... p2pCfg.ListenAddrs = []multiaddr.Multiaddr{} could be more clear?

// DisableP2PRelayTransport is set to true
var noListenAddrs = func(p2pCfg *libp2p.Config) error {
if cfg.DisableP2PRelayTransport {
return libp2p.NoListenAddrs(p2pCfg)
}

p2pCfg.ListenAddrs = []multiaddr.Multiaddr{}
return nil
}

Expand Down
1 change: 1 addition & 0 deletions test/testdata/configs/config-v34.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"DisableLocalhostConnectionRateLimit": true,
"DisableNetworking": false,
"DisableOutgoingConnectionThrottling": false,
"DisableP2PRelayTransport": false,
"EnableAccountUpdatesStats": false,
"EnableAgreementReporting": false,
"EnableAgreementTimeMetrics": false,
Expand Down