v0.2.3 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Feb 27, 2015 License: MIT Imports: 16 Imported by: 0



package config implements the ipfs config file datastructures and utilities.



View Source
const (
	// DefaultPathRoot is the path to the default config dir location.
	DefaultPathRoot = "~/.go-ipfs"
	// DefaultConfigFile is the filename of the configuration file
	DefaultConfigFile = "config"
	// EnvDir is the environment variable used to change the path root.
	EnvDir = "IPFS_PATH"
View Source
const (
	// CheckError value for Version.Check to raise error and exit if version is obsolete
	CheckError = "error"

	// CheckWarn value for Version.Check to show warning message if version is obsolete
	CheckWarn = "warn"

	// CheckIgnore value for Version.Check to not perform update check
	CheckIgnore = "ignore"

supported Version.Check values

View Source
const CurrentVersionNumber = "0.2.3"

CurrentVersionNumber is the current application's version literal

View Source
const DefaultDataStoreDirectory = "datastore"

DefaultDataStoreDirectory is the directory to store all the local IPFS data.


View Source
var DefaultBootstrapAddresses = []string{

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.

View Source
var DefaultSNRServers = []string{
View Source
var ErrInvalidPeerAddr = errors.New("invalid peer address")

ErrInvalidPeerAddr signals an address is not a valid peer address.

View Source
var ErrUnknownAutoUpdateSetting = errors.New("unknown value for AutoUpdate")

ErrUnknownAutoUpdateSetting is returned when an unknown value is read from the config


func BootstrapPeerStrings

func BootstrapPeerStrings(bps []BootstrapPeer) []string

func DataStorePath

func DataStorePath(configroot string) (string, error)

DataStorePath returns the default data store path given a configuration root (set an empty string to have the default configuration root)

func Filename

func Filename(configroot string) (string, error)

Filename returns the configuration file path given a configuration root directory. If the configuration root directory is empty, use the default one

func HumanOutput

func HumanOutput(value interface{}) ([]byte, error)

HumanOutput gets a config value ready for printing

func Marshal

func Marshal(value interface{}) ([]byte, error)

Marshal configuration with JSON

func Path

func Path(configroot, extension string) (string, error)

Path returns the path `extension` relative to the configuration root. If an empty string is provided for `configroot`, the default root is used.

func PathRoot

func PathRoot() (string, error)

PathRoot returns the default configuration root directory

func ToMap

func ToMap(conf *Config) (map[string]interface{}, error)


type Addresses

type Addresses struct {
	Swarm   []string // addresses for the swarm 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 AutoUpdateSetting

type AutoUpdateSetting int

AutoUpdateSetting implements json.Unmarshaler to check values in config

const (
	AutoUpdateNever AutoUpdateSetting = iota // do not auto-update
	AutoUpdatePatch                          // only on new patch versions
	AutoUpdateMinor                          // on new minor or patch versions (Default)
	AutoUpdateMajor                          // on all, even Major, version changes

AutoUpdateSetting values

func (AutoUpdateSetting) MarshalJSON

func (s AutoUpdateSetting) MarshalJSON() ([]byte, error)

MarshalJSON converts the value back to JSON string

func (AutoUpdateSetting) String

func (s AutoUpdateSetting) String() string

String converts valye to human readable string

func (*AutoUpdateSetting) UnmarshalJSON

func (s *AutoUpdateSetting) UnmarshalJSON(in []byte) error

UnmarshalJSON checks the input against known strings

type BootstrapPeer

type BootstrapPeer iaddr.IPFSAddr

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
	Version          Version               // local node's version management
	Bootstrap        []string              // local nodes's bootstrap peer addresses
	Tour             Tour                  // local node's tour position
	Gateway          Gateway               // local node's gateway server options
	SupernodeRouting SupernodeClientConfig // local node's routing servers (if SupernodeRouting enabled)
	Log              Log

Config is used to load IPFS config files.

func FromMap

func FromMap(v map[string]interface{}) (*Config, error)

func Init

func Init(out io.Writer, nBitsForKeypair int) (*Config, error)

func (*Config) BootstrapPeers

func (c *Config) BootstrapPeers() ([]BootstrapPeer, error)

func (*Config) SetBootstrapPeers

func (c *Config) SetBootstrapPeers(bps []BootstrapPeer)

type Datastore

type Datastore struct {
	Type string
	Path string

Datastore tracks the configuration of the datastore.

type Gateway

type Gateway struct {
	RootRedirect string
	Writable     bool

Gateway contains options for the HTTP gateway server.

type Identity

type Identity struct {
	PeerID  string
	PrivKey string

Identity tracks the configuration of the local node's identity.

func (*Identity) DecodePrivateKey

func (i *Identity) DecodePrivateKey(passphrase string) (ic.PrivKey, error)

DecodePrivateKey is a helper to decode the users PrivateKey

type Log

type Log struct {
	MaxSizeMB  int
	MaxBackups int
	MaxAgeDays int

type Mounts

type Mounts struct {
	IPFS string
	IPNS string

Mounts stores the (string) mount points

type SupernodeClientConfig

type SupernodeClientConfig struct {
	Servers []string

TODO rename

func (*SupernodeClientConfig) ServerIPFSAddrs

func (gcr *SupernodeClientConfig) ServerIPFSAddrs() ([]ipfsaddr.IPFSAddr, error)

type Tour

type Tour struct {
	Last string // last tour topic read


Tour stores the ipfs tour read-list and resume point

type Version

type Version struct {
	// Current is the ipfs version for which config was generated
	Current string

	// Check signals how to react on updates:
	// - "ignore" for not checking
	// - "warn" for issuing a warning and proceeding
	// - "error" for exiting with an error
	Check string

	// CheckDate is a timestamp for the last time API endpoint was checked for updates
	CheckDate time.Time

	// CheckPeriod is the time duration over which the update check will not be performed
	// (Note: cannot use time.Duration because marshalling with json breaks it)
	CheckPeriod string

	// AutoUpdate is optional
	AutoUpdate AutoUpdateSetting

Version regulates checking if the most recent version is run

func VersionDefaultValue

func VersionDefaultValue() Version

VersionDefaultValue returns the default version config value (for init).

func (*Version) ShouldCheckForUpdate

func (v *Version) ShouldCheckForUpdate() bool

ShouldCheckForUpdate returns if update check API endpoint is needed for this specific runtime

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL