diff --git a/docs/config.md b/docs/config.md index 6c129e44f..e1da0da9b 100644 --- a/docs/config.md +++ b/docs/config.md @@ -17,6 +17,7 @@ on a running daemon do not read the config file at runtime. - [`Mounts`](#mounts) - [`Reprovider`](#reprovider) - [`Swarm`](#swarm) +- [`Profiles`](#profiles) ## `Addresses` Contains information about various listener addresses to be used by this node. @@ -287,3 +288,17 @@ LowWater is the minimum number of connections to maintain. HighWater is the number of connections that, when exceeded, will trigger a connection GC operation. - `GracePeriod` GracePeriod is a time duration that new connections are immune from being closed by the connection manager. + +## Profiles +Configuration profiles allow to tweak configuration quickly. Profiles can be +applied with `--profile` flag to `ipfs init` or with `ipfs config profile apply` +command. + +- `server` profile +Recommended for nodes with public IPv4 address, disables host and content +discovery in local networks. + +- `test` profile +Reduces external interference, useful for running ipfs in test environments. +Note that with these settings node won't be able to talk to the rest of the +network without manual bootstrap. diff --git a/repo/config/profile.go b/repo/config/profile.go index a4160306a..7711d9e7c 100644 --- a/repo/config/profile.go +++ b/repo/config/profile.go @@ -7,7 +7,7 @@ type Profile struct { Unapply Transformer } -// Profiles is a map holding configuration transformers +// Profiles is a map holding configuration transformers. Docs are in docs/config.md var Profiles = map[string]*Profile{ "server": { Apply: func(c *Config) error { @@ -65,17 +65,17 @@ var Profiles = map[string]*Profile{ }, "badgerds": { Apply: 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 - }, + c.Datastore.Spec = map[string]interface{}{ + "type": "measure", + "prefix": "badger.datastore", + "child": map[string]interface{}{ + "type": "badgerds", + "path": "badgerds", + "syncWrites": true, + }, + } + return nil + }, Unapply: func(c *Config) error { c.Datastore.Spec = DefaultDatastoreConfig().Spec return nil diff --git a/test/sharness/t0021-config.sh b/test/sharness/t0021-config.sh index b7b985a89..be1ce8158 100755 --- a/test/sharness/t0021-config.sh +++ b/test/sharness/t0021-config.sh @@ -151,6 +151,30 @@ test_config_cmd() { echo "Error: setting private key with API is not supported" > replace_expected test_cmp replace_out replace_expected ' + + test_expect_success "'ipfs config Swarm.AddrFilters' looks good" ' + ipfs config Swarm.AddrFilters > actual_config && + test $(cat actual_config | wc -l) = 1 + ' + + test_expect_success "'ipfs config profile apply server' works" ' + ipfs config profile apply server + ' + + test_expect_success "'ipfs config Swarm.AddrFilters' looks good with server profile" ' + ipfs config Swarm.AddrFilters > actual_config && + test $(cat actual_config | wc -l) = 17 + ' + + test_expect_success "'ipfs config profile revert server' works" ' + ipfs config profile revert server + ' + + test_expect_success "'ipfs config Swarm.AddrFilters' looks good with reverted server profile" ' + ipfs config Swarm.AddrFilters > actual_config && + test $(cat actual_config | wc -l) = 1 + ' + } test_init_ipfs