From 17b7dcef6fe15a08e40ce4142a601483017cf92b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 27 Aug 2021 19:14:29 +0200 Subject: [PATCH 1/2] config for disabling NAT port mapping --- node/builder.go | 3 ++- node/config/doc_gen.go | 9 +++++++++ node/config/types.go | 6 ++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/node/builder.go b/node/builder.go index 887f9046fe9..5810910a7b4 100644 --- a/node/builder.go +++ b/node/builder.go @@ -195,7 +195,6 @@ var LibP2P = Options( Override(new(routing.Routing), lp2p.Routing), // Services - Override(NatPortMapKey, lp2p.NatPortMap), Override(BandwidthReporterKey, lp2p.BandwidthCounter), Override(AutoNATSvcKey, lp2p.AutoNATService), @@ -277,6 +276,8 @@ func ConfigCommon(cfg *config.Common, enableLibp2pNode bool) Option { Override(AddrsFactoryKey, lp2p.AddrsFactory( cfg.Libp2p.AnnounceAddresses, cfg.Libp2p.NoAnnounceAddresses)), + + If(!cfg.Libp2p.DisableNatPortMap, Override(NatPortMapKey, lp2p.NatPortMap)), ), Override(new(dtypes.MetadataDS), modules.Datastore(cfg.Backup.DisableMetadataLog)), ) diff --git a/node/config/doc_gen.go b/node/config/doc_gen.go index 9efe4e03c38..2228393e45c 100644 --- a/node/config/doc_gen.go +++ b/node/config/doc_gen.go @@ -348,6 +348,15 @@ Format: multiaddress`, Comment: ``, }, + { + Name: "DisableNatPortMap", + Type: "bool", + + Comment: `When not disabled (default), lotus asks NAT devices (e.g., routers), to +open up an external port and forward it to the port lotus is running on. +When this works (i.e., when your router supports NAT port forwarding), +it makes the local lotus node accessible from the public internet`, + }, { Name: "ConnMgrLow", Type: "uint", diff --git a/node/config/types.go b/node/config/types.go index 1576169e66a..499912d4043 100644 --- a/node/config/types.go +++ b/node/config/types.go @@ -292,6 +292,12 @@ type Libp2p struct { BootstrapPeers []string ProtectedPeers []string + // When not disabled (default), lotus asks NAT devices (e.g., routers), to + // open up an external port and forward it to the port lotus is running on. + // When this works (i.e., when your router supports NAT port forwarding), + // it makes the local lotus node accessible from the public internet + DisableNatPortMap bool + ConnMgrLow uint ConnMgrHigh uint ConnMgrGrace Duration From 3708a7ac30fb36d4fe7c9eaa1dff854179cef347 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 27 Aug 2021 19:16:50 +0200 Subject: [PATCH 2/2] config: Port some docstrings from go-ipfs --- node/config/doc_gen.go | 10 +++++++--- node/config/types.go | 11 +++++++++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/node/config/doc_gen.go b/node/config/doc_gen.go index 2228393e45c..dd6dda50df5 100644 --- a/node/config/doc_gen.go +++ b/node/config/doc_gen.go @@ -361,19 +361,23 @@ it makes the local lotus node accessible from the public internet`, Name: "ConnMgrLow", Type: "uint", - Comment: ``, + Comment: `ConnMgrLow is the number of connections that the basic connection manager +will trim down to.`, }, { Name: "ConnMgrHigh", Type: "uint", - Comment: ``, + Comment: `ConnMgrHigh is the number of connections that, when exceeded, will trigger +a connection GC operation. Note: protected/recently formed connections don't +count towards this limit.`, }, { Name: "ConnMgrGrace", Type: "Duration", - Comment: ``, + Comment: `ConnMgrGrace is a time duration that new connections are immune from being +closed by the connection manager.`, }, }, "MinerAddressConfig": []DocField{ diff --git a/node/config/types.go b/node/config/types.go index 499912d4043..97b0812d7c8 100644 --- a/node/config/types.go +++ b/node/config/types.go @@ -298,8 +298,15 @@ type Libp2p struct { // it makes the local lotus node accessible from the public internet DisableNatPortMap bool - ConnMgrLow uint - ConnMgrHigh uint + // ConnMgrLow is the number of connections that the basic connection manager + // will trim down to. + ConnMgrLow uint + // ConnMgrHigh is the number of connections that, when exceeded, will trigger + // a connection GC operation. Note: protected/recently formed connections don't + // count towards this limit. + ConnMgrHigh uint + // ConnMgrGrace is a time duration that new connections are immune from being + // closed by the connection manager. ConnMgrGrace Duration }