Skip to content

Commit

Permalink
config: profile tests, docs
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
  • Loading branch information
magik6k committed Sep 12, 2017
1 parent 0d4919f commit 865f4fb
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
15 changes: 15 additions & 0 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
2 changes: 1 addition & 1 deletion repo/config/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
24 changes: 24 additions & 0 deletions test/sharness/t0021-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 865f4fb

Please sign in to comment.