Documentation ¶
Overview ¶
package config implements the ipfs config file datastructures and utilities.
Index ¶
- Constants
- Variables
- func BootstrapPeerStrings(bps []BootstrapPeer) []string
- func DataStorePath(configroot string) (string, error)
- func Filename(configroot string) (string, error)
- func HumanOutput(value interface{}) ([]byte, error)
- func Marshal(value interface{}) ([]byte, error)
- func Path(configroot, extension string) (string, error)
- func PathRoot() (string, error)
- func ToMap(conf *Config) (map[string]interface{}, error)
- type API
- type Addresses
- type BootstrapPeer
- type Config
- type ConnMgr
- type Datastore
- type Discovery
- type Experiments
- type Gateway
- type Identity
- type Ipns
- type MDNS
- type Mounts
- type Reprovider
- type SwarmConfig
Constants ¶
const ( // DefaultPathName is the default config dir name DefaultPathName = ".ipfs" // DefaultPathRoot is the path to the default config dir location. DefaultPathRoot = "~/" + DefaultPathName // DefaultConfigFile is the filename of the configuration file DefaultConfigFile = "config" // EnvDir is the environment variable used to change the path root. EnvDir = "IPFS_PATH" )
const ApiVersion = "/go-ipfs/" + CurrentVersionNumber + "/"
const CurrentVersionNumber = "0.4.13-rc1"
CurrentVersionNumber is the current application's version literal
const DefaultConnMgrGracePeriod = time.Second * 20
DefaultConnMgrGracePeriod is the default value for the connection managers grace period
const DefaultConnMgrHighWater = 900
DefaultConnMgrHighWater is the default value for the connection managers 'high water' mark
const DefaultConnMgrLowWater = 600
DefaultConnMgrLowWater is the default value for the connection managers 'low water' mark
const DefaultDataStoreDirectory = "datastore"
DefaultDataStoreDirectory is the directory to store all the local IPFS data.
const IdentityTag = "Identity"
const PrivKeySelector = IdentityTag + "." + PrivKeyTag
const PrivKeyTag = "PrivKey"
Variables ¶
var ConfigProfiles = map[string]func(*Config) error{ "server": func(c *Config) error { defaultServerFilters := []string{ "/ip4/10.0.0.0/ipcidr/8", "/ip4/100.64.0.0/ipcidr/10", "/ip4/169.254.0.0/ipcidr/16", "/ip4/172.16.0.0/ipcidr/12", "/ip4/192.0.0.0/ipcidr/24", "/ip4/192.0.0.0/ipcidr/29", "/ip4/192.0.0.8/ipcidr/32", "/ip4/192.0.0.170/ipcidr/32", "/ip4/192.0.0.171/ipcidr/32", "/ip4/192.0.2.0/ipcidr/24", "/ip4/192.168.0.0/ipcidr/16", "/ip4/198.18.0.0/ipcidr/15", "/ip4/198.51.100.0/ipcidr/24", "/ip4/203.0.113.0/ipcidr/24", "/ip4/240.0.0.0/ipcidr/4", } c.Swarm.AddrFilters = append(c.Swarm.AddrFilters, defaultServerFilters...) c.Discovery.MDNS.Enabled = 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.Swarm.DisableNatPortMap = true c.Addresses.Swarm = []string{ "/ip4/127.0.0.1/tcp/0", } c.Bootstrap = []string{} c.Discovery.MDNS.Enabled = false 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 }, }
ConfigProfiles is a map holding configuration transformers
var CurrentCommit string
CurrentCommit is the current git commit, this is set as a ldflag in the Makefile
var DefaultBootstrapAddresses = []string{
"/dnsaddr/bootstrap.libp2p.io/ipfs/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN",
"/dnsaddr/bootstrap.libp2p.io/ipfs/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa",
"/dnsaddr/bootstrap.libp2p.io/ipfs/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb",
"/dnsaddr/bootstrap.libp2p.io/ipfs/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt",
"/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
"/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM",
"/ip4/128.199.219.111/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu",
"/ip4/104.236.76.40/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64",
"/ip4/178.62.158.247/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd",
"/ip6/2604:a880:1:20::203:d001/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM",
"/ip6/2400:6180:0:d0::151:6001/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu",
"/ip6/2604:a880:800:10::4a:5001/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64",
"/ip6/2a03:b0c0:0:1010::23:1001/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd",
}
DefaultBootstrapAddresses are the hardcoded bootstrap addresses for IPFS. they are nodes run by the IPFS team. docs on these later. As with all p2p networks, bootstrap is an important security concern.
NOTE: This is here -- and not inside cmd/ipfs/init.go -- because of an import dependency issue. TODO: move this into a config/default/ package.
var ErrInvalidPeerAddr = errors.New("invalid peer address")
ErrInvalidPeerAddr signals an address is not a valid peer address.
Functions ¶
func BootstrapPeerStrings ¶
func BootstrapPeerStrings(bps []BootstrapPeer) []string
func DataStorePath ¶
DataStorePath returns the default data store path given a configuration root (set an empty string to have the default configuration root)
func Filename ¶
Filename returns the configuration file path given a configuration root directory. If the configuration root directory is empty, use the default one
func HumanOutput ¶
HumanOutput gets a config value ready for printing
func Path ¶
Path returns the path `extension` relative to the configuration root. If an empty string is provided for `configroot`, the default root is used.
Types ¶
type Addresses ¶
type Addresses struct { Swarm []string // addresses for the swarm to listen on Announce []string // swarm addresses to announce to the network NoAnnounce []string // swarm addresses not to announce to the network API string // address for the local API (RPC) Gateway string // address to listen on for IPFS HTTP object gateway }
Addresses stores the (string) multiaddr addresses for the node.
type BootstrapPeer ¶
BootstrapPeer is a peer used to bootstrap the network.
func DefaultBootstrapPeers ¶
func DefaultBootstrapPeers() ([]BootstrapPeer, error)
DefaultBootstrapPeers returns the (parsed) set of default bootstrap peers. if it fails, it returns a meaningful error for the user. This is here (and not inside cmd/ipfs/init) because of module dependency problems.
func ParseBootstrapPeer ¶
func ParseBootstrapPeer(addr string) (BootstrapPeer, error)
func ParseBootstrapPeers ¶
func ParseBootstrapPeers(addrs []string) ([]BootstrapPeer, error)
type Config ¶
type Config struct { Identity Identity // local node's peer identity Datastore Datastore // local node's storage Addresses Addresses // local node's addresses Mounts Mounts // local node's mount points Discovery Discovery // local node's discovery mechanisms Ipns Ipns // Ipns settings Bootstrap []string // local nodes's bootstrap peer addresses Gateway Gateway // local node's gateway server options API API // local node's API settings Swarm SwarmConfig Reprovider Reprovider Experimental Experiments }
Config is used to load ipfs config files.
func (*Config) BootstrapPeers ¶
func (c *Config) BootstrapPeers() ([]BootstrapPeer, error)
func (*Config) SetBootstrapPeers ¶
func (c *Config) SetBootstrapPeers(bps []BootstrapPeer)
type ConnMgr ¶ added in v0.4.12
ConnMgr defines configuration options for the libp2p connection manager
type Datastore ¶
type Datastore struct { StorageMax string // in B, kB, kiB, MB, ... StorageGCWatermark int64 // in percentage to multiply on StorageMax GCPeriod string // in ns, us, ms, s, m, h // deprecated fields, use Spec Type string `json:",omitempty"` Path string `json:",omitempty"` NoSync bool `json:",omitempty"` Params *json.RawMessage `json:",omitempty"` Spec map[string]interface{} HashOnRead bool BloomFilterSize int }
Datastore tracks the configuration of the datastore.
func DefaultDatastoreConfig ¶ added in v0.4.11
func DefaultDatastoreConfig() Datastore
DefaultDatastoreConfig is an internal function exported to aid in testing.
type Experiments ¶ added in v0.4.7
type Gateway ¶
type Gateway struct { HTTPHeaders map[string][]string // HTTP headers to return with the gateway RootRedirect string Writable bool PathPrefixes []string }
Gateway contains options for the HTTP gateway server.