-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix missing profile docs #4846
Merged
Merged
Fix missing profile docs #4846
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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,123 @@ 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 | ||
c.Swarm.DisableNatPortMap = true | ||
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 | ||
c.Swarm.DisableNatPortMap = false | ||
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.`, | ||
|
||
c.Swarm.DisableNatPortMap = false | ||
c.Discovery.MDNS.Enabled = true | ||
return nil | ||
Transform: func(c *Config) error { | ||
c.Addresses = addressesConfig() | ||
|
||
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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we put a usage example of ipfs-ds-convert as well? Or maybe a link to the readme of ipfs-ds-convert is enough There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
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.`, | ||
|
||
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. | ||
For more on ipfs-ds-convert see | ||
$ ipfs-ds-convert --help | ||
and | ||
$ ipfs-ds-convert convert --help | ||
`, | ||
|
||
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 | ||
}, | ||
}, | ||
} | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is MDNS disabled? Isn't the problem that we spam nearby ip addresses, not that we announce mdns services?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC Some providers don't like use of multicast addresses.