From 865f4fb27d7adee0a69263775632ae4cf991704f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Wed, 6 Sep 2017 13:54:45 +0200 Subject: [PATCH] config: profile tests, docs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Ɓukasz Magiera --- docs/config.md | 15 +++++++++++++++ repo/config/profile.go | 2 +- test/sharness/t0021-config.sh | 24 ++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/docs/config.md b/docs/config.md index cd9e7a0168b..2f0cf8ad600 100644 --- a/docs/config.md +++ b/docs/config.md @@ -18,6 +18,7 @@ on a running daemon do not read the config file at runtime. - [`Reprovider`](#reprovider) - [`SupernodeRouting`](#supernoderouting) - [`Swarm`](#swarm) +- [`Profiles`](#profiles) ## `Addresses` Contains information about various listener addresses to be used by this node. @@ -267,3 +268,17 @@ Disables the p2p-circuit relay transport. - `EnableRelayHop` Enables HOP relay for the node. If this is enabled, the node will act as an intermediate (Hop Relay) node in relay circuits for connected peers. + +## 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 a4160306a8b..4010a6fb3d8 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 { diff --git a/test/sharness/t0021-config.sh b/test/sharness/t0021-config.sh index ccfc9c3e6a5..cc7010ba71b 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