From 15ca5df7e53b105dc88667604e3fe6fd0e11178c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 20 Mar 2018 17:50:37 +0100 Subject: [PATCH 1/2] go-ipfs-config: Fix missing profile docs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera --- config/profile.go | 157 +++++++++++++++++++++++++++++++--------------- 1 file changed, 107 insertions(+), 50 deletions(-) diff --git a/config/profile.go b/config/profile.go index b20382ef4ed8..6d2d2b3a5c3d 100644 --- a/config/profile.go +++ b/config/profile.go @@ -5,6 +5,15 @@ import "time" // Transformer is a function which takes configuration and applies some filter to it type Transformer func(c *Config) error +// Profile contains the profile transformer the description of the profile +type Profile struct { + // Description briefly describes the functionality of the profile + Description string + + // Transform takes ipfs configuration and applies the profile to it + Transform Transformer +} + // defaultServerFilters has a list of non-routable IPv4 prefixes // according to http://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml var defaultServerFilters = []string{ @@ -26,63 +35,111 @@ var defaultServerFilters = []string{ } // Profiles is a map holding configuration transformers. Docs are in docs/config.md -var Profiles = map[string]Transformer{ - "server": func(c *Config) error { - c.Addresses.NoAnnounce = appendSingle(c.Addresses.NoAnnounce, defaultServerFilters) - c.Swarm.AddrFilters = appendSingle(c.Swarm.AddrFilters, defaultServerFilters) - c.Discovery.MDNS.Enabled = false - return nil +var Profiles = map[string]Profile{ + "server": { + Description: `Disables local host discovery, recommended when +running IPFS on machines with public IPv4 addresses.`, + + Transform: func(c *Config) error { + c.Addresses.NoAnnounce = appendSingle(c.Addresses.NoAnnounce, defaultServerFilters) + c.Swarm.AddrFilters = appendSingle(c.Swarm.AddrFilters, defaultServerFilters) + c.Discovery.MDNS.Enabled = false + return nil + }, }, - "local-discovery": func(c *Config) error { - c.Addresses.NoAnnounce = deleteEntries(c.Addresses.NoAnnounce, defaultServerFilters) - c.Swarm.AddrFilters = deleteEntries(c.Swarm.AddrFilters, defaultServerFilters) - c.Discovery.MDNS.Enabled = true - return nil + + "local-discovery": { + Description: `Sets default values to fields affected by the server +profile, enables discovery in local networks.`, + + Transform: func(c *Config) error { + c.Addresses.NoAnnounce = deleteEntries(c.Addresses.NoAnnounce, defaultServerFilters) + c.Swarm.AddrFilters = deleteEntries(c.Swarm.AddrFilters, defaultServerFilters) + c.Discovery.MDNS.Enabled = true + return nil + }, }, - "test": func(c *Config) error { - c.Addresses.API = "/ip4/127.0.0.1/tcp/0" - c.Addresses.Gateway = "/ip4/127.0.0.1/tcp/0" - c.Addresses.Swarm = []string{ - "/ip4/127.0.0.1/tcp/0", - } - - c.Swarm.DisableNatPortMap = true - - c.Bootstrap = []string{} - c.Discovery.MDNS.Enabled = false - return nil + "test": { + Description: `Reduces external interference of IPFS daemon, this +is useful when using the daemon in test environments.`, + + Transform: func(c *Config) error { + c.Addresses.API = "/ip4/127.0.0.1/tcp/0" + c.Addresses.Gateway = "/ip4/127.0.0.1/tcp/0" + c.Addresses.Swarm = []string{ + "/ip4/127.0.0.1/tcp/0", + } + + c.Swarm.DisableNatPortMap = true + + c.Bootstrap = []string{} + c.Discovery.MDNS.Enabled = false + return nil + }, }, - "default-networking": func(c *Config) error { - c.Addresses = addressesConfig() + "default-networking": { + Description: `Restores default network settings. +Inverse profile of the test profile.`, + + Transform: func(c *Config) error { + c.Addresses = addressesConfig() - c.Swarm.DisableNatPortMap = false - c.Discovery.MDNS.Enabled = true - return nil + c.Swarm.DisableNatPortMap = false + c.Discovery.MDNS.Enabled = true + return nil + }, }, - "badgerds": func(c *Config) error { - c.Datastore.Spec = map[string]interface{}{ - "type": "measure", - "prefix": "badger.datastore", - "child": map[string]interface{}{ - "type": "badgerds", - "path": "badgerds", - "syncWrites": true, - }, - } - return nil + "badgerds": { + Description: `Replaces default datastore configuration with experimental +badger datastore. + +If you apply this profile after ipfs init, you will need +to convert your datastore to the new configuration. +You can do this using ipfs-ds-convert. + +WARNING: badger datastore is experimental. +Make sure to backup your data frequently.`, + + Transform: func(c *Config) error { + c.Datastore.Spec = map[string]interface{}{ + "type": "measure", + "prefix": "badger.datastore", + "child": map[string]interface{}{ + "type": "badgerds", + "path": "badgerds", + "syncWrites": true, + }, + } + return nil + }, }, - "default-datastore": func(c *Config) error { - c.Datastore.Spec = DefaultDatastoreConfig().Spec - return nil + "default-datastore": { + Description: `Restores default datastore configuration. + +If you apply this profile after ipfs init, you will need +to convert your datastore to the new configuration. +You can do this using ipfs-ds-convert. +`, + + Transform: func(c *Config) error { + c.Datastore.Spec = DefaultDatastoreConfig().Spec + return nil + }, }, - "lowpower": func(c *Config) error { - c.Routing.Type = "dhtclient" - c.Reprovider.Interval = "0" - - c.Swarm.ConnMgr.LowWater = 20 - c.Swarm.ConnMgr.HighWater = 40 - c.Swarm.ConnMgr.GracePeriod = time.Minute.String() - return nil + "lowpower": { + Description: `Reduces daemon overhead on the system. May affect node +functionality - performance of content discovery and data +fetching may be degraded. +`, + Transform: func(c *Config) error { + c.Routing.Type = "dhtclient" + c.Reprovider.Interval = "0" + + c.Swarm.ConnMgr.LowWater = 20 + c.Swarm.ConnMgr.HighWater = 40 + c.Swarm.ConnMgr.GracePeriod = time.Minute.String() + return nil + }, }, } From 371c3146118ecf1c0cc8628b4aa2e4b043b7037e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Mon, 26 Mar 2018 19:32:15 +0200 Subject: [PATCH 2/2] go-ipfs-config: config/profile: disable UPnP/NAT in server profile, docs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera --- config/profile.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/config/profile.go b/config/profile.go index 6d2d2b3a5c3d..a7d4f1fe318a 100644 --- a/config/profile.go +++ b/config/profile.go @@ -44,6 +44,7 @@ running IPFS on machines with public IPv4 addresses.`, c.Addresses.NoAnnounce = appendSingle(c.Addresses.NoAnnounce, defaultServerFilters) c.Swarm.AddrFilters = appendSingle(c.Swarm.AddrFilters, defaultServerFilters) c.Discovery.MDNS.Enabled = false + c.Swarm.DisableNatPortMap = true return nil }, }, @@ -56,6 +57,7 @@ profile, enables discovery in local networks.`, c.Addresses.NoAnnounce = deleteEntries(c.Addresses.NoAnnounce, defaultServerFilters) c.Swarm.AddrFilters = deleteEntries(c.Swarm.AddrFilters, defaultServerFilters) c.Discovery.MDNS.Enabled = true + c.Swarm.DisableNatPortMap = false return nil }, }, @@ -97,6 +99,11 @@ If you apply this profile after ipfs init, you will need to convert your datastore to the new configuration. You can do this using ipfs-ds-convert. +For more on ipfs-ds-convert see +$ ipfs-ds-convert --help +and +$ ipfs-ds-convert convert --help + WARNING: badger datastore is experimental. Make sure to backup your data frequently.`, @@ -119,6 +126,11 @@ Make sure to backup your data frequently.`, If you apply this profile after ipfs init, you will need to convert your datastore to the new configuration. You can do this using ipfs-ds-convert. + +For more on ipfs-ds-convert see +$ ipfs-ds-convert --help +and +$ ipfs-ds-convert convert --help `, Transform: func(c *Config) error {