From 99929de0506ca78419163476d3506fc47698afd2 Mon Sep 17 00:00:00 2001 From: Brian Tiger Chow Date: Mon, 12 Jan 2015 11:01:15 -0800 Subject: [PATCH 001/262] go-ipfs-config: refactor(repo/config) move config under repo --- config/config.go | 219 +++++++++++++++++++++++++++++++++++++++++ config/config_test.go | 24 +++++ config/serialize.go | 144 +++++++++++++++++++++++++++ config/version_test.go | 36 +++++++ 4 files changed, 423 insertions(+) create mode 100644 config/config.go create mode 100644 config/config_test.go create mode 100644 config/serialize.go create mode 100644 config/version_test.go diff --git a/config/config.go b/config/config.go new file mode 100644 index 00000000000..d33e4d36de0 --- /dev/null +++ b/config/config.go @@ -0,0 +1,219 @@ +// package config implements the ipfs config file datastructures and utilities. +package config + +import ( + "encoding/base64" + "errors" + "os" + "path/filepath" + "strings" + + ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" + mh "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash" + + ic "github.com/jbenet/go-ipfs/p2p/crypto" + u "github.com/jbenet/go-ipfs/util" + "github.com/jbenet/go-ipfs/util/debugerror" +) + +var log = u.Logger("config") + +// Identity tracks the configuration of the local node's identity. +type Identity struct { + PeerID string + PrivKey string +} + +// Logs tracks the configuration of the event logger +type Logs struct { + Filename string + MaxSizeMB uint64 + MaxBackups uint64 + MaxAgeDays uint64 +} + +// Datastore tracks the configuration of the datastore. +type Datastore struct { + Type string + Path string +} + +// Addresses stores the (string) multiaddr addresses for the node. +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 +} + +// Mounts stores the (string) mount points +type Mounts struct { + IPFS string + IPNS string +} + +// BootstrapPeer is a peer used to bootstrap the network. +type BootstrapPeer struct { + Address string + PeerID string // until multiaddr supports ipfs, use another field. +} + +func (bp *BootstrapPeer) String() string { + return bp.Address + "/" + bp.PeerID +} + +func ParseBootstrapPeer(addr string) (BootstrapPeer, error) { + // to be replaced with just multiaddr parsing, once ptp is a multiaddr protocol + idx := strings.LastIndex(addr, "/") + if idx == -1 { + return BootstrapPeer{}, errors.New("invalid address") + } + addrS := addr[:idx] + peeridS := addr[idx+1:] + + // make sure addrS parses as a multiaddr. + if len(addrS) > 0 { + maddr, err := ma.NewMultiaddr(addrS) + if err != nil { + return BootstrapPeer{}, err + } + + addrS = maddr.String() + } + + // make sure idS parses as a peer.ID + _, err := mh.FromB58String(peeridS) + if err != nil { + return BootstrapPeer{}, err + } + + return BootstrapPeer{ + Address: addrS, + PeerID: peeridS, + }, nil +} + +func ParseBootstrapPeers(addrs []string) ([]BootstrapPeer, error) { + peers := make([]BootstrapPeer, len(addrs)) + var err error + for i, addr := range addrs { + peers[i], err = ParseBootstrapPeer(addr) + if err != nil { + return nil, err + } + } + return peers, nil +} + +// Tour stores the ipfs tour read-list and resume point +type Tour struct { + Last string // last tour topic read + // Done []string // all topics done so far +} + +// Config is used to load IPFS config files. +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 []BootstrapPeer // local nodes's bootstrap peers + Tour Tour // local node's tour position + Logs Logs // local node's event log configuration +} + +// DefaultPathRoot is the path to the default config dir location. +const DefaultPathRoot = "~/.go-ipfs" + +// DefaultConfigFile is the filename of the configuration file +const DefaultConfigFile = "config" + +// DefaultDataStoreDirectory is the directory to store all the local IPFS data. +const DefaultDataStoreDirectory = "datastore" + +// EnvDir is the environment variable used to change the path root. +const EnvDir = "IPFS_DIR" + +// LogsDefaultDirectory is the directory to store all IPFS event logs. +var LogsDefaultDirectory = "logs" + +// PathRoot returns the default configuration root directory +func PathRoot() (string, error) { + dir := os.Getenv(EnvDir) + var err error + if len(dir) == 0 { + dir, err = u.TildeExpansion(DefaultPathRoot) + } + return dir, err +} + +// Path returns the path `extension` relative to the configuration root. If an +// empty string is provided for `configroot`, the default root is used. +func Path(configroot, extension string) (string, error) { + if len(configroot) == 0 { + dir, err := PathRoot() + if err != nil { + return "", err + } + return filepath.Join(dir, extension), nil + + } + return filepath.Join(configroot, extension), nil +} + +// DataStorePath returns the default data store path given a configuration root +// (set an empty string to have the default configuration root) +func DataStorePath(configroot string) (string, error) { + return Path(configroot, DefaultDataStoreDirectory) +} + +// LogsPath returns the default path for event logs given a configuration root +// (set an empty string to have the default configuration root) +func LogsPath(configroot string) (string, error) { + return Path(configroot, LogsDefaultDirectory) +} + +// Filename returns the configuration file path given a configuration root +// directory. If the configuration root directory is empty, use the default one +func Filename(configroot string) (string, error) { + return Path(configroot, DefaultConfigFile) +} + +// DecodePrivateKey is a helper to decode the users PrivateKey +func (i *Identity) DecodePrivateKey(passphrase string) (ic.PrivKey, error) { + pkb, err := base64.StdEncoding.DecodeString(i.PrivKey) + if err != nil { + return nil, err + } + + // currently storing key unencrypted. in the future we need to encrypt it. + // TODO(security) + return ic.UnmarshalPrivateKey(pkb) +} + +// Load reads given file and returns the read config, or error. +func Load(filename string) (*Config, error) { + // if nothing is there, fail. User must run 'ipfs init' + if !u.FileExists(filename) { + return nil, debugerror.New("ipfs not initialized, please run 'ipfs init'") + } + + var cfg Config + err := ReadConfigFile(filename, &cfg) + if err != nil { + return nil, err + } + + // tilde expansion on datastore path + cfg.Datastore.Path, err = u.TildeExpansion(cfg.Datastore.Path) + if err != nil { + return nil, err + } + + return &cfg, err +} + +// Set sets the value of a particular config key +func Set(filename, key, value string) error { + return WriteConfigKey(filename, key, value) +} diff --git a/config/config_test.go b/config/config_test.go new file mode 100644 index 00000000000..c891d6c514b --- /dev/null +++ b/config/config_test.go @@ -0,0 +1,24 @@ +package config + +import ( + "testing" +) + +func TestConfig(t *testing.T) { + const filename = ".ipfsconfig" + const dsPath = "/path/to/datastore" + cfgWritten := new(Config) + cfgWritten.Datastore.Path = dsPath + err := WriteConfigFile(filename, cfgWritten) + if err != nil { + t.Error(err) + } + cfgRead, err := Load(filename) + if err != nil { + t.Error(err) + return + } + if cfgWritten.Datastore.Path != cfgRead.Datastore.Path { + t.Fail() + } +} diff --git a/config/serialize.go b/config/serialize.go new file mode 100644 index 00000000000..b71d945b0bb --- /dev/null +++ b/config/serialize.go @@ -0,0 +1,144 @@ +package config + +import ( + "encoding/json" + "fmt" + "io" + "os" + "path/filepath" + "strings" +) + +// ReadConfigFile reads the config from `filename` into `cfg`. +func ReadConfigFile(filename string, cfg interface{}) error { + f, err := os.Open(filename) + if err != nil { + return err + } + defer f.Close() + + if err := Decode(f, cfg); err != nil { + return fmt.Errorf("Failure to decode config: %s", err) + } + return nil +} + +// WriteConfigFile writes the config from `cfg` into `filename`. +func WriteConfigFile(filename string, cfg interface{}) error { + err := os.MkdirAll(filepath.Dir(filename), 0775) + if err != nil { + return err + } + + f, err := os.Create(filename) + if err != nil { + return err + } + defer f.Close() + + return Encode(f, cfg) +} + +// WriteFile writes the buffer at filename +func WriteFile(filename string, buf []byte) error { + err := os.MkdirAll(filepath.Dir(filename), 0775) + if err != nil { + return err + } + + f, err := os.Create(filename) + if err != nil { + return err + } + defer f.Close() + + _, err = f.Write(buf) + return err +} + +// HumanOutput gets a config value ready for printing +func HumanOutput(value interface{}) ([]byte, error) { + s, ok := value.(string) + if ok { + return []byte(strings.Trim(s, "\n")), nil + } + return Marshal(value) +} + +// Marshal configuration with JSON +func Marshal(value interface{}) ([]byte, error) { + // need to prettyprint, hence MarshalIndent, instead of Encoder + return json.MarshalIndent(value, "", " ") +} + +// Encode configuration with JSON +func Encode(w io.Writer, value interface{}) error { + // need to prettyprint, hence MarshalIndent, instead of Encoder + buf, err := Marshal(value) + if err != nil { + return err + } + + _, err = w.Write(buf) + return err +} + +// Decode configuration with JSON +func Decode(r io.Reader, value interface{}) error { + return json.NewDecoder(r).Decode(value) +} + +// ReadConfigKey retrieves only the value of a particular key +func ReadConfigKey(filename, key string) (interface{}, error) { + var cfg interface{} + if err := ReadConfigFile(filename, &cfg); err != nil { + return nil, err + } + + var ok bool + cursor := cfg + parts := strings.Split(key, ".") + for i, part := range parts { + cursor, ok = cursor.(map[string]interface{})[part] + if !ok { + sofar := strings.Join(parts[:i], ".") + return nil, fmt.Errorf("%s key has no attributes", sofar) + } + } + return cursor, nil +} + +// WriteConfigKey writes the value of a particular key +func WriteConfigKey(filename, key string, value interface{}) error { + var cfg interface{} + if err := ReadConfigFile(filename, &cfg); err != nil { + return err + } + + var ok bool + var mcursor map[string]interface{} + cursor := cfg + + parts := strings.Split(key, ".") + for i, part := range parts { + mcursor, ok = cursor.(map[string]interface{}) + if !ok { + sofar := strings.Join(parts[:i], ".") + return fmt.Errorf("%s key is not a map", sofar) + } + + // last part? set here + if i == (len(parts) - 1) { + mcursor[part] = value + break + } + + cursor, ok = mcursor[part] + if !ok { // create map if this is empty + mcursor[part] = map[string]interface{}{} + cursor = mcursor[part] + } + } + + return WriteConfigFile(filename, cfg) +} diff --git a/config/version_test.go b/config/version_test.go new file mode 100644 index 00000000000..37160c47896 --- /dev/null +++ b/config/version_test.go @@ -0,0 +1,36 @@ +package config + +import ( + "strings" + "testing" +) + +func TestAutoUpdateValues(t *testing.T) { + var tval struct { + AutoUpdate AutoUpdateSetting + } + tests := []struct { + input string + val AutoUpdateSetting + err error + }{ + {`{"hello":123}`, AutoUpdateNever, nil}, // zero value + {`{"AutoUpdate": "never"}`, AutoUpdateNever, nil}, + {`{"AutoUpdate": "patch"}`, AutoUpdatePatch, nil}, + {`{"AutoUpdate": "minor"}`, AutoUpdateMinor, nil}, + {`{"AutoUpdate": "major"}`, AutoUpdateMajor, nil}, + {`{"AutoUpdate": "blarg"}`, AutoUpdateMinor, ErrUnknownAutoUpdateSetting}, + } + + for i, tc := range tests { + err := Decode(strings.NewReader(tc.input), &tval) + if err != tc.err { + t.Fatalf("%d failed - got err %q wanted %v", i, err, tc.err) + } + + if tval.AutoUpdate != tc.val { + t.Fatalf("%d failed - got val %q where we wanted %q", i, tval.AutoUpdate, tc.val) + } + } + +} From 20cc7a451b66054dca1e5e17f5ae54ac73b5c298 Mon Sep 17 00:00:00 2001 From: Brian Tiger Chow Date: Mon, 12 Jan 2015 15:00:03 -0800 Subject: [PATCH 002/262] go-ipfs-config: refactor(config, repo): all writes go through FSRepo. next: privatize these --- config/config.go | 34 ++++------ config/config_test.go | 24 ------- config/serialize.go | 144 ----------------------------------------- config/version_test.go | 5 +- 4 files changed, 13 insertions(+), 194 deletions(-) delete mode 100644 config/config_test.go delete mode 100644 config/serialize.go diff --git a/config/config.go b/config/config.go index d33e4d36de0..939c4564c44 100644 --- a/config/config.go +++ b/config/config.go @@ -3,6 +3,7 @@ package config import ( "encoding/base64" + "encoding/json" "errors" "os" "path/filepath" @@ -13,7 +14,6 @@ import ( ic "github.com/jbenet/go-ipfs/p2p/crypto" u "github.com/jbenet/go-ipfs/util" - "github.com/jbenet/go-ipfs/util/debugerror" ) var log = u.Logger("config") @@ -191,29 +191,17 @@ func (i *Identity) DecodePrivateKey(passphrase string) (ic.PrivKey, error) { return ic.UnmarshalPrivateKey(pkb) } -// Load reads given file and returns the read config, or error. -func Load(filename string) (*Config, error) { - // if nothing is there, fail. User must run 'ipfs init' - if !u.FileExists(filename) { - return nil, debugerror.New("ipfs not initialized, please run 'ipfs init'") +// HumanOutput gets a config value ready for printing +func HumanOutput(value interface{}) ([]byte, error) { + s, ok := value.(string) + if ok { + return []byte(strings.Trim(s, "\n")), nil } - - var cfg Config - err := ReadConfigFile(filename, &cfg) - if err != nil { - return nil, err - } - - // tilde expansion on datastore path - cfg.Datastore.Path, err = u.TildeExpansion(cfg.Datastore.Path) - if err != nil { - return nil, err - } - - return &cfg, err + return Marshal(value) } -// Set sets the value of a particular config key -func Set(filename, key, value string) error { - return WriteConfigKey(filename, key, value) +// Marshal configuration with JSON +func Marshal(value interface{}) ([]byte, error) { + // need to prettyprint, hence MarshalIndent, instead of Encoder + return json.MarshalIndent(value, "", " ") } diff --git a/config/config_test.go b/config/config_test.go deleted file mode 100644 index c891d6c514b..00000000000 --- a/config/config_test.go +++ /dev/null @@ -1,24 +0,0 @@ -package config - -import ( - "testing" -) - -func TestConfig(t *testing.T) { - const filename = ".ipfsconfig" - const dsPath = "/path/to/datastore" - cfgWritten := new(Config) - cfgWritten.Datastore.Path = dsPath - err := WriteConfigFile(filename, cfgWritten) - if err != nil { - t.Error(err) - } - cfgRead, err := Load(filename) - if err != nil { - t.Error(err) - return - } - if cfgWritten.Datastore.Path != cfgRead.Datastore.Path { - t.Fail() - } -} diff --git a/config/serialize.go b/config/serialize.go deleted file mode 100644 index b71d945b0bb..00000000000 --- a/config/serialize.go +++ /dev/null @@ -1,144 +0,0 @@ -package config - -import ( - "encoding/json" - "fmt" - "io" - "os" - "path/filepath" - "strings" -) - -// ReadConfigFile reads the config from `filename` into `cfg`. -func ReadConfigFile(filename string, cfg interface{}) error { - f, err := os.Open(filename) - if err != nil { - return err - } - defer f.Close() - - if err := Decode(f, cfg); err != nil { - return fmt.Errorf("Failure to decode config: %s", err) - } - return nil -} - -// WriteConfigFile writes the config from `cfg` into `filename`. -func WriteConfigFile(filename string, cfg interface{}) error { - err := os.MkdirAll(filepath.Dir(filename), 0775) - if err != nil { - return err - } - - f, err := os.Create(filename) - if err != nil { - return err - } - defer f.Close() - - return Encode(f, cfg) -} - -// WriteFile writes the buffer at filename -func WriteFile(filename string, buf []byte) error { - err := os.MkdirAll(filepath.Dir(filename), 0775) - if err != nil { - return err - } - - f, err := os.Create(filename) - if err != nil { - return err - } - defer f.Close() - - _, err = f.Write(buf) - return err -} - -// HumanOutput gets a config value ready for printing -func HumanOutput(value interface{}) ([]byte, error) { - s, ok := value.(string) - if ok { - return []byte(strings.Trim(s, "\n")), nil - } - return Marshal(value) -} - -// Marshal configuration with JSON -func Marshal(value interface{}) ([]byte, error) { - // need to prettyprint, hence MarshalIndent, instead of Encoder - return json.MarshalIndent(value, "", " ") -} - -// Encode configuration with JSON -func Encode(w io.Writer, value interface{}) error { - // need to prettyprint, hence MarshalIndent, instead of Encoder - buf, err := Marshal(value) - if err != nil { - return err - } - - _, err = w.Write(buf) - return err -} - -// Decode configuration with JSON -func Decode(r io.Reader, value interface{}) error { - return json.NewDecoder(r).Decode(value) -} - -// ReadConfigKey retrieves only the value of a particular key -func ReadConfigKey(filename, key string) (interface{}, error) { - var cfg interface{} - if err := ReadConfigFile(filename, &cfg); err != nil { - return nil, err - } - - var ok bool - cursor := cfg - parts := strings.Split(key, ".") - for i, part := range parts { - cursor, ok = cursor.(map[string]interface{})[part] - if !ok { - sofar := strings.Join(parts[:i], ".") - return nil, fmt.Errorf("%s key has no attributes", sofar) - } - } - return cursor, nil -} - -// WriteConfigKey writes the value of a particular key -func WriteConfigKey(filename, key string, value interface{}) error { - var cfg interface{} - if err := ReadConfigFile(filename, &cfg); err != nil { - return err - } - - var ok bool - var mcursor map[string]interface{} - cursor := cfg - - parts := strings.Split(key, ".") - for i, part := range parts { - mcursor, ok = cursor.(map[string]interface{}) - if !ok { - sofar := strings.Join(parts[:i], ".") - return fmt.Errorf("%s key is not a map", sofar) - } - - // last part? set here - if i == (len(parts) - 1) { - mcursor[part] = value - break - } - - cursor, ok = mcursor[part] - if !ok { // create map if this is empty - mcursor[part] = map[string]interface{}{} - cursor = mcursor[part] - } - } - - return WriteConfigFile(filename, cfg) -} diff --git a/config/version_test.go b/config/version_test.go index 37160c47896..c4b8aeb5ac2 100644 --- a/config/version_test.go +++ b/config/version_test.go @@ -1,6 +1,7 @@ package config import ( + "encoding/json" "strings" "testing" ) @@ -23,8 +24,7 @@ func TestAutoUpdateValues(t *testing.T) { } for i, tc := range tests { - err := Decode(strings.NewReader(tc.input), &tval) - if err != tc.err { + if err := json.NewDecoder(strings.NewReader(tc.input)).Decode(&tval); err != tc.err { t.Fatalf("%d failed - got err %q wanted %v", i, err, tc.err) } @@ -32,5 +32,4 @@ func TestAutoUpdateValues(t *testing.T) { t.Fatalf("%d failed - got val %q where we wanted %q", i, tval.AutoUpdate, tc.val) } } - } From ea5243400c1e391cfd5c32c135568dcc4bb6874a Mon Sep 17 00:00:00 2001 From: Brian Tiger Chow Date: Mon, 12 Jan 2015 18:23:29 -0800 Subject: [PATCH 003/262] go-ipfs-config: move utility method --- config/config.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/config/config.go b/config/config.go index 939c4564c44..a0a79eebadb 100644 --- a/config/config.go +++ b/config/config.go @@ -2,9 +2,11 @@ package config import ( + "bytes" "encoding/base64" "encoding/json" "errors" + "fmt" "os" "path/filepath" "strings" @@ -205,3 +207,15 @@ func Marshal(value interface{}) ([]byte, error) { // need to prettyprint, hence MarshalIndent, instead of Encoder return json.MarshalIndent(value, "", " ") } + +func FromMap(v map[string]interface{}) (*Config, error) { + var buf bytes.Buffer + if err := json.NewEncoder(&buf).Encode(v); err != nil { + return nil, err + } + var conf Config + if err := json.NewDecoder(&buf).Decode(&conf); err != nil { + return nil, fmt.Errorf("Failure to decode config: %s", err) + } + return &conf, nil +} From 058c999ba03fd06efe56d001130848ff22f047ab Mon Sep 17 00:00:00 2001 From: Brian Tiger Chow Date: Mon, 12 Jan 2015 18:31:42 -0800 Subject: [PATCH 004/262] go-ipfs-config: fix(config): avoid clobbering user-provided key value pairs let me know if this looks off @whyrusleeping @jbenet --- config/config.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/config/config.go b/config/config.go index a0a79eebadb..1230cd29b79 100644 --- a/config/config.go +++ b/config/config.go @@ -219,3 +219,15 @@ func FromMap(v map[string]interface{}) (*Config, error) { } return &conf, nil } + +func ToMap(conf *Config) (map[string]interface{}, error) { + var buf bytes.Buffer + if err := json.NewEncoder(&buf).Encode(conf); err != nil { + return nil, err + } + var m map[string]interface{} + if err := json.NewDecoder(&buf).Decode(&m); err != nil { + return nil, fmt.Errorf("Failure to decode config: %s", err) + } + return m, nil +} From 7882aa98f5b221992e4821081c9cd239fe57c7da Mon Sep 17 00:00:00 2001 From: Brian Tiger Chow Date: Mon, 12 Jan 2015 19:09:10 -0800 Subject: [PATCH 005/262] go-ipfs-config: refactor(config): break it apart --- config/addresses.go | 8 +++ config/bootstrap_peers.go | 62 ++++++++++++++++ config/config.go | 144 +++----------------------------------- config/datastore.go | 16 +++++ config/identity.go | 24 +++++++ config/logs.go | 18 +++++ config/mounts.go | 7 ++ config/tour.go | 7 ++ 8 files changed, 150 insertions(+), 136 deletions(-) create mode 100644 config/addresses.go create mode 100644 config/bootstrap_peers.go create mode 100644 config/datastore.go create mode 100644 config/identity.go create mode 100644 config/logs.go create mode 100644 config/mounts.go create mode 100644 config/tour.go diff --git a/config/addresses.go b/config/addresses.go new file mode 100644 index 00000000000..ba891526196 --- /dev/null +++ b/config/addresses.go @@ -0,0 +1,8 @@ +package config + +// Addresses stores the (string) multiaddr addresses for the node. +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 +} diff --git a/config/bootstrap_peers.go b/config/bootstrap_peers.go new file mode 100644 index 00000000000..db59f975f96 --- /dev/null +++ b/config/bootstrap_peers.go @@ -0,0 +1,62 @@ +package config + +import ( + "errors" + "strings" + + ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" + mh "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash" +) + +// BootstrapPeer is a peer used to bootstrap the network. +type BootstrapPeer struct { + Address string + PeerID string // until multiaddr supports ipfs, use another field. +} + +func (bp *BootstrapPeer) String() string { + return bp.Address + "/" + bp.PeerID +} + +func ParseBootstrapPeer(addr string) (BootstrapPeer, error) { + // to be replaced with just multiaddr parsing, once ptp is a multiaddr protocol + idx := strings.LastIndex(addr, "/") + if idx == -1 { + return BootstrapPeer{}, errors.New("invalid address") + } + addrS := addr[:idx] + peeridS := addr[idx+1:] + + // make sure addrS parses as a multiaddr. + if len(addrS) > 0 { + maddr, err := ma.NewMultiaddr(addrS) + if err != nil { + return BootstrapPeer{}, err + } + + addrS = maddr.String() + } + + // make sure idS parses as a peer.ID + _, err := mh.FromB58String(peeridS) + if err != nil { + return BootstrapPeer{}, err + } + + return BootstrapPeer{ + Address: addrS, + PeerID: peeridS, + }, nil +} + +func ParseBootstrapPeers(addrs []string) ([]BootstrapPeer, error) { + peers := make([]BootstrapPeer, len(addrs)) + var err error + for i, addr := range addrs { + peers[i], err = ParseBootstrapPeer(addr) + if err != nil { + return nil, err + } + } + return peers, nil +} diff --git a/config/config.go b/config/config.go index 1230cd29b79..4c1086e8bcc 100644 --- a/config/config.go +++ b/config/config.go @@ -3,115 +3,17 @@ package config import ( "bytes" - "encoding/base64" "encoding/json" - "errors" "fmt" "os" "path/filepath" "strings" - ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" - mh "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash" - - ic "github.com/jbenet/go-ipfs/p2p/crypto" u "github.com/jbenet/go-ipfs/util" ) var log = u.Logger("config") -// Identity tracks the configuration of the local node's identity. -type Identity struct { - PeerID string - PrivKey string -} - -// Logs tracks the configuration of the event logger -type Logs struct { - Filename string - MaxSizeMB uint64 - MaxBackups uint64 - MaxAgeDays uint64 -} - -// Datastore tracks the configuration of the datastore. -type Datastore struct { - Type string - Path string -} - -// Addresses stores the (string) multiaddr addresses for the node. -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 -} - -// Mounts stores the (string) mount points -type Mounts struct { - IPFS string - IPNS string -} - -// BootstrapPeer is a peer used to bootstrap the network. -type BootstrapPeer struct { - Address string - PeerID string // until multiaddr supports ipfs, use another field. -} - -func (bp *BootstrapPeer) String() string { - return bp.Address + "/" + bp.PeerID -} - -func ParseBootstrapPeer(addr string) (BootstrapPeer, error) { - // to be replaced with just multiaddr parsing, once ptp is a multiaddr protocol - idx := strings.LastIndex(addr, "/") - if idx == -1 { - return BootstrapPeer{}, errors.New("invalid address") - } - addrS := addr[:idx] - peeridS := addr[idx+1:] - - // make sure addrS parses as a multiaddr. - if len(addrS) > 0 { - maddr, err := ma.NewMultiaddr(addrS) - if err != nil { - return BootstrapPeer{}, err - } - - addrS = maddr.String() - } - - // make sure idS parses as a peer.ID - _, err := mh.FromB58String(peeridS) - if err != nil { - return BootstrapPeer{}, err - } - - return BootstrapPeer{ - Address: addrS, - PeerID: peeridS, - }, nil -} - -func ParseBootstrapPeers(addrs []string) ([]BootstrapPeer, error) { - peers := make([]BootstrapPeer, len(addrs)) - var err error - for i, addr := range addrs { - peers[i], err = ParseBootstrapPeer(addr) - if err != nil { - return nil, err - } - } - return peers, nil -} - -// Tour stores the ipfs tour read-list and resume point -type Tour struct { - Last string // last tour topic read - // Done []string // all topics done so far -} - // Config is used to load IPFS config files. type Config struct { Identity Identity // local node's peer identity @@ -124,20 +26,14 @@ type Config struct { Logs Logs // local node's event log configuration } -// DefaultPathRoot is the path to the default config dir location. -const DefaultPathRoot = "~/.go-ipfs" - -// DefaultConfigFile is the filename of the configuration file -const DefaultConfigFile = "config" - -// DefaultDataStoreDirectory is the directory to store all the local IPFS data. -const DefaultDataStoreDirectory = "datastore" - -// EnvDir is the environment variable used to change the path root. -const EnvDir = "IPFS_DIR" - -// LogsDefaultDirectory is the directory to store all IPFS event logs. -var LogsDefaultDirectory = "logs" +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_DIR" +) // PathRoot returns the default configuration root directory func PathRoot() (string, error) { @@ -163,36 +59,12 @@ func Path(configroot, extension string) (string, error) { return filepath.Join(configroot, extension), nil } -// DataStorePath returns the default data store path given a configuration root -// (set an empty string to have the default configuration root) -func DataStorePath(configroot string) (string, error) { - return Path(configroot, DefaultDataStoreDirectory) -} - -// LogsPath returns the default path for event logs given a configuration root -// (set an empty string to have the default configuration root) -func LogsPath(configroot string) (string, error) { - return Path(configroot, LogsDefaultDirectory) -} - // Filename returns the configuration file path given a configuration root // directory. If the configuration root directory is empty, use the default one func Filename(configroot string) (string, error) { return Path(configroot, DefaultConfigFile) } -// DecodePrivateKey is a helper to decode the users PrivateKey -func (i *Identity) DecodePrivateKey(passphrase string) (ic.PrivKey, error) { - pkb, err := base64.StdEncoding.DecodeString(i.PrivKey) - if err != nil { - return nil, err - } - - // currently storing key unencrypted. in the future we need to encrypt it. - // TODO(security) - return ic.UnmarshalPrivateKey(pkb) -} - // HumanOutput gets a config value ready for printing func HumanOutput(value interface{}) ([]byte, error) { s, ok := value.(string) diff --git a/config/datastore.go b/config/datastore.go new file mode 100644 index 00000000000..b615c650f25 --- /dev/null +++ b/config/datastore.go @@ -0,0 +1,16 @@ +package config + +// DefaultDataStoreDirectory is the directory to store all the local IPFS data. +const DefaultDataStoreDirectory = "datastore" + +// Datastore tracks the configuration of the datastore. +type Datastore struct { + Type string + Path string +} + +// DataStorePath returns the default data store path given a configuration root +// (set an empty string to have the default configuration root) +func DataStorePath(configroot string) (string, error) { + return Path(configroot, DefaultDataStoreDirectory) +} diff --git a/config/identity.go b/config/identity.go new file mode 100644 index 00000000000..2097e51886d --- /dev/null +++ b/config/identity.go @@ -0,0 +1,24 @@ +package config + +import ( + "encoding/base64" + ic "github.com/jbenet/go-ipfs/p2p/crypto" +) + +// Identity tracks the configuration of the local node's identity. +type Identity struct { + PeerID string + PrivKey string +} + +// DecodePrivateKey is a helper to decode the users PrivateKey +func (i *Identity) DecodePrivateKey(passphrase string) (ic.PrivKey, error) { + pkb, err := base64.StdEncoding.DecodeString(i.PrivKey) + if err != nil { + return nil, err + } + + // currently storing key unencrypted. in the future we need to encrypt it. + // TODO(security) + return ic.UnmarshalPrivateKey(pkb) +} diff --git a/config/logs.go b/config/logs.go new file mode 100644 index 00000000000..687f0832f71 --- /dev/null +++ b/config/logs.go @@ -0,0 +1,18 @@ +package config + +// LogsDefaultDirectory is the directory to store all IPFS event logs. +var LogsDefaultDirectory = "logs" + +// Logs tracks the configuration of the event logger +type Logs struct { + Filename string + MaxSizeMB uint64 + MaxBackups uint64 + MaxAgeDays uint64 +} + +// LogsPath returns the default path for event logs given a configuration root +// (set an empty string to have the default configuration root) +func LogsPath(configroot string) (string, error) { + return Path(configroot, LogsDefaultDirectory) +} diff --git a/config/mounts.go b/config/mounts.go new file mode 100644 index 00000000000..a0f42005943 --- /dev/null +++ b/config/mounts.go @@ -0,0 +1,7 @@ +package config + +// Mounts stores the (string) mount points +type Mounts struct { + IPFS string + IPNS string +} diff --git a/config/tour.go b/config/tour.go new file mode 100644 index 00000000000..cf9aef35502 --- /dev/null +++ b/config/tour.go @@ -0,0 +1,7 @@ +package config + +// Tour stores the ipfs tour read-list and resume point +type Tour struct { + Last string // last tour topic read + // Done []string // all topics done so far +} From 13ffe4fbb8db4ffcb53b38434562b5e06a75c5ab Mon Sep 17 00:00:00 2001 From: Brian Tiger Chow Date: Mon, 19 Jan 2015 00:02:43 -0800 Subject: [PATCH 006/262] go-ipfs-config: refactor: rename IPFS_DIR -> IPFS_PATH closes #394 https://github.com/jbenet/go-ipfs/issues/394 --- config/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index 4c1086e8bcc..16b6a789644 100644 --- a/config/config.go +++ b/config/config.go @@ -32,7 +32,7 @@ const ( // DefaultConfigFile is the filename of the configuration file DefaultConfigFile = "config" // EnvDir is the environment variable used to change the path root. - EnvDir = "IPFS_DIR" + EnvDir = "IPFS_PATH" ) // PathRoot returns the default configuration root directory From 843cc85edec6135f40f02f91caf4285f0c1c3c49 Mon Sep 17 00:00:00 2001 From: Brian Tiger Chow Date: Sat, 24 Jan 2015 01:20:31 -0800 Subject: [PATCH 007/262] go-ipfs-config: refactor(eventlog) integrate into fsrepo now, eventlogger works wherever the fsrepo is used --- config/config.go | 1 - config/logs.go | 17 ----------------- 2 files changed, 18 deletions(-) diff --git a/config/config.go b/config/config.go index 16b6a789644..816ffcef57a 100644 --- a/config/config.go +++ b/config/config.go @@ -23,7 +23,6 @@ type Config struct { Version Version // local node's version management Bootstrap []BootstrapPeer // local nodes's bootstrap peers Tour Tour // local node's tour position - Logs Logs // local node's event log configuration } const ( diff --git a/config/logs.go b/config/logs.go index 687f0832f71..d912156bec0 100644 --- a/config/logs.go +++ b/config/logs.go @@ -1,18 +1 @@ package config - -// LogsDefaultDirectory is the directory to store all IPFS event logs. -var LogsDefaultDirectory = "logs" - -// Logs tracks the configuration of the event logger -type Logs struct { - Filename string - MaxSizeMB uint64 - MaxBackups uint64 - MaxAgeDays uint64 -} - -// LogsPath returns the default path for event logs given a configuration root -// (set an empty string to have the default configuration root) -func LogsPath(configroot string) (string, error) { - return Path(configroot, LogsDefaultDirectory) -} From 69d7848d2ed23a5491ee7c0f396650c429457f0d Mon Sep 17 00:00:00 2001 From: Brian Tiger Chow Date: Sat, 24 Jan 2015 02:50:53 -0800 Subject: [PATCH 008/262] go-ipfs-config: move config.Init into config package --- config/bootstrap_peers.go | 33 ++++++++++++- config/init.go | 99 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 config/init.go diff --git a/config/bootstrap_peers.go b/config/bootstrap_peers.go index db59f975f96..2b437d185c5 100644 --- a/config/bootstrap_peers.go +++ b/config/bootstrap_peers.go @@ -1,19 +1,50 @@ package config import ( - "errors" "strings" ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" mh "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash" + + errors "github.com/jbenet/go-ipfs/util/debugerror" ) +// 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 DefaultBootstrapAddresses = []string{ + "/ip4/104.131.131.82/tcp/4001/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ", // mars.i.ipfs.io + "/ip4/104.236.176.52/tcp/4001/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z", // neptune (to be neptune.i.ipfs.io) + "/ip4/104.236.179.241/tcp/4001/QmSoLpPVmHKQ4XTPdz8tjDFgdeRFkpV8JgYq8JVJ69RrZm", // pluto (to be pluto.i.ipfs.io) + "/ip4/162.243.248.213/tcp/4001/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm", // uranus (to be uranus.i.ipfs.io) + "/ip4/128.199.219.111/tcp/4001/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu", // saturn (to be saturn.i.ipfs.io) + "/ip4/104.236.76.40/tcp/4001/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64", // venus (to be venus.i.ipfs.io) + "/ip4/178.62.158.247/tcp/4001/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd", // earth (to be earth.i.ipfs.io) + "/ip4/178.62.61.185/tcp/4001/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3", // mercury (to be mercury.i.ipfs.io) + "/ip4/104.236.151.122/tcp/4001/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx", // jupiter (to be jupiter.i.ipfs.io) +} + // BootstrapPeer is a peer used to bootstrap the network. type BootstrapPeer struct { Address string PeerID string // until multiaddr supports ipfs, use another field. } +// 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 DefaultBootstrapPeers() ([]BootstrapPeer, error) { + ps, err := ParseBootstrapPeers(DefaultBootstrapAddresses) + if err != nil { + return nil, errors.Errorf(`failed to parse hardcoded bootstrap peers: %s +This is a problem with the ipfs codebase. Please report it to the dev team.`, err) + } + return ps, nil +} + func (bp *BootstrapPeer) String() string { return bp.Address + "/" + bp.PeerID } diff --git a/config/init.go b/config/init.go new file mode 100644 index 00000000000..dade155bc94 --- /dev/null +++ b/config/init.go @@ -0,0 +1,99 @@ +package config + +import ( + "encoding/base64" + "fmt" + + ci "github.com/jbenet/go-ipfs/p2p/crypto" + peer "github.com/jbenet/go-ipfs/p2p/peer" + errors "github.com/jbenet/go-ipfs/util/debugerror" +) + +func Init(nBitsForKeypair int) (*Config, error) { + ds, err := datastoreConfig() + if err != nil { + return nil, err + } + + identity, err := identityConfig(nBitsForKeypair) + if err != nil { + return nil, err + } + + bootstrapPeers, err := DefaultBootstrapPeers() + if err != nil { + return nil, err + } + + conf := &Config{ + + // setup the node's default addresses. + // Note: two swarm listen addrs, one tcp, one utp. + Addresses: Addresses{ + Swarm: []string{ + "/ip4/0.0.0.0/tcp/4001", + // "/ip4/0.0.0.0/udp/4002/utp", // disabled for now. + }, + API: "/ip4/127.0.0.1/tcp/5001", + }, + + Bootstrap: bootstrapPeers, + Datastore: *ds, + Identity: identity, + + // setup the node mount points. + Mounts: Mounts{ + IPFS: "/ipfs", + IPNS: "/ipns", + }, + + // tracking ipfs version used to generate the init folder and adding + // update checker default setting. + Version: VersionDefaultValue(), + } + + return conf, nil +} + +func datastoreConfig() (*Datastore, error) { + dspath, err := DataStorePath("") + if err != nil { + return nil, err + } + return &Datastore{ + Path: dspath, + Type: "leveldb", + }, nil +} + +// identityConfig initializes a new identity. +func identityConfig(nbits int) (Identity, error) { + // TODO guard higher up + ident := Identity{} + if nbits < 1024 { + return ident, errors.New("Bitsize less than 1024 is considered unsafe.") + } + + fmt.Printf("generating %v-bit RSA keypair...", nbits) + sk, pk, err := ci.GenerateKeyPair(ci.RSA, nbits) + if err != nil { + return ident, err + } + fmt.Printf("done\n") + + // currently storing key unencrypted. in the future we need to encrypt it. + // TODO(security) + skbytes, err := sk.Bytes() + if err != nil { + return ident, err + } + ident.PrivKey = base64.StdEncoding.EncodeToString(skbytes) + + id, err := peer.IDFromPublicKey(pk) + if err != nil { + return ident, err + } + ident.PeerID = id.Pretty() + fmt.Printf("peer identity: %s\n", ident.PeerID) + return ident, nil +} From 2217c97632f4d20e32c72f337e1e62d268b8ff1b Mon Sep 17 00:00:00 2001 From: Matt Bell Date: Mon, 26 Jan 2015 23:17:58 -0800 Subject: [PATCH 009/262] go-ipfs-config: repo/config: Added Gateway options to config --- config/config.go | 1 + config/gateway.go | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 config/gateway.go diff --git a/config/config.go b/config/config.go index 816ffcef57a..9159223f7cf 100644 --- a/config/config.go +++ b/config/config.go @@ -23,6 +23,7 @@ type Config struct { Version Version // local node's version management Bootstrap []BootstrapPeer // local nodes's bootstrap peers Tour Tour // local node's tour position + Gateway Gateway // local node's gateway server options } const ( diff --git a/config/gateway.go b/config/gateway.go new file mode 100644 index 00000000000..7bc3eb02044 --- /dev/null +++ b/config/gateway.go @@ -0,0 +1,6 @@ +package config + +// Gateway contains options for the HTTP gateway server. +type Gateway struct { + RootRedirect string +} From 6579236d398f38e6bd0cfd94dfc8e4ebcfe4ec72 Mon Sep 17 00:00:00 2001 From: Matt Bell Date: Mon, 26 Jan 2015 23:28:21 -0800 Subject: [PATCH 010/262] go-ipfs-config: cmd/ipfs: Add empty gateway object when initting config --- config/init.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config/init.go b/config/init.go index dade155bc94..402139e41ee 100644 --- a/config/init.go +++ b/config/init.go @@ -50,6 +50,10 @@ func Init(nBitsForKeypair int) (*Config, error) { // tracking ipfs version used to generate the init folder and adding // update checker default setting. Version: VersionDefaultValue(), + + Gateway: Gateway{ + RootRedirect: "", + }, } return conf, nil From 075ae67fdd24f889513849910cdcecf3016d4284 Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Mon, 19 Jan 2015 17:26:58 -0800 Subject: [PATCH 011/262] go-ipfs-config: init docs: go generated welcome dir + files updated sharness hashes --- config/init.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/config/init.go b/config/init.go index 402139e41ee..aef5624ec72 100644 --- a/config/init.go +++ b/config/init.go @@ -3,19 +3,20 @@ package config import ( "encoding/base64" "fmt" + "io" ci "github.com/jbenet/go-ipfs/p2p/crypto" peer "github.com/jbenet/go-ipfs/p2p/peer" errors "github.com/jbenet/go-ipfs/util/debugerror" ) -func Init(nBitsForKeypair int) (*Config, error) { +func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { ds, err := datastoreConfig() if err != nil { return nil, err } - identity, err := identityConfig(nBitsForKeypair) + identity, err := identityConfig(out, nBitsForKeypair) if err != nil { return nil, err } @@ -71,19 +72,19 @@ func datastoreConfig() (*Datastore, error) { } // identityConfig initializes a new identity. -func identityConfig(nbits int) (Identity, error) { +func identityConfig(out io.Writer, nbits int) (Identity, error) { // TODO guard higher up ident := Identity{} if nbits < 1024 { return ident, errors.New("Bitsize less than 1024 is considered unsafe.") } - fmt.Printf("generating %v-bit RSA keypair...", nbits) + out.Write([]byte(fmt.Sprintf("generating %v-bit RSA keypair...", nbits))) sk, pk, err := ci.GenerateKeyPair(ci.RSA, nbits) if err != nil { return ident, err } - fmt.Printf("done\n") + out.Write([]byte(fmt.Sprintf("done\n"))) // currently storing key unencrypted. in the future we need to encrypt it. // TODO(security) From cf854f9a2074b5ce88999b852bb46e277defb27a Mon Sep 17 00:00:00 2001 From: Mildred Ki'Lya Date: Wed, 28 Jan 2015 12:57:09 +0100 Subject: [PATCH 012/262] go-ipfs-config: Make gateway read-only by default and add option to make it writable --- config/gateway.go | 1 + config/init.go | 1 + 2 files changed, 2 insertions(+) diff --git a/config/gateway.go b/config/gateway.go index 7bc3eb02044..c0885778d57 100644 --- a/config/gateway.go +++ b/config/gateway.go @@ -3,4 +3,5 @@ package config // Gateway contains options for the HTTP gateway server. type Gateway struct { RootRedirect string + Writable bool } diff --git a/config/init.go b/config/init.go index aef5624ec72..976d266883e 100644 --- a/config/init.go +++ b/config/init.go @@ -54,6 +54,7 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { Gateway: Gateway{ RootRedirect: "", + Writable: false, }, } From 9adf5bc2bfb69820ef42fb4f824678aa84af0e35 Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Tue, 20 Jan 2015 16:05:48 -0800 Subject: [PATCH 013/262] go-ipfs-config: bootstrap: use ipfsaddr for boostrap peers :warning: :warning: this commit makes your current configs unusable, as the default bootstrap peers. You may need to edit your config. Go from: ```js Bootstrap: [ { "Address": "/ip4/104.131.131.82/tcp/4001", "PeerID": "QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ" } ] ``` To: ```js Bootstrap: [ "/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ" ] ``` --- config/bootstrap_peers.go | 76 ++++++++++++++++----------------------- config/config.go | 16 ++++----- config/init.go | 2 +- 3 files changed, 40 insertions(+), 54 deletions(-) diff --git a/config/bootstrap_peers.go b/config/bootstrap_peers.go index 2b437d185c5..de4935d7856 100644 --- a/config/bootstrap_peers.go +++ b/config/bootstrap_peers.go @@ -1,12 +1,9 @@ package config import ( - "strings" - - ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" - mh "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash" - errors "github.com/jbenet/go-ipfs/util/debugerror" + + iaddr "github.com/jbenet/go-ipfs/util/ipfsaddr" ) // DefaultBootstrapAddresses are the hardcoded bootstrap addresses @@ -16,21 +13,25 @@ import ( // 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 DefaultBootstrapAddresses = []string{ - "/ip4/104.131.131.82/tcp/4001/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ", // mars.i.ipfs.io - "/ip4/104.236.176.52/tcp/4001/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z", // neptune (to be neptune.i.ipfs.io) - "/ip4/104.236.179.241/tcp/4001/QmSoLpPVmHKQ4XTPdz8tjDFgdeRFkpV8JgYq8JVJ69RrZm", // pluto (to be pluto.i.ipfs.io) - "/ip4/162.243.248.213/tcp/4001/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm", // uranus (to be uranus.i.ipfs.io) - "/ip4/128.199.219.111/tcp/4001/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu", // saturn (to be saturn.i.ipfs.io) - "/ip4/104.236.76.40/tcp/4001/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64", // venus (to be venus.i.ipfs.io) - "/ip4/178.62.158.247/tcp/4001/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd", // earth (to be earth.i.ipfs.io) - "/ip4/178.62.61.185/tcp/4001/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3", // mercury (to be mercury.i.ipfs.io) - "/ip4/104.236.151.122/tcp/4001/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx", // jupiter (to be jupiter.i.ipfs.io) + "/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ", // mars.i.ipfs.io + "/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z", // neptune (to be neptune.i.ipfs.io) + "/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLpPVmHKQ4XTPdz8tjDFgdeRFkpV8JgYq8JVJ69RrZm", // pluto (to be pluto.i.ipfs.io) + "/ip4/162.243.248.213/tcp/4001/ipfs/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm", // uranus (to be uranus.i.ipfs.io) + "/ip4/128.199.219.111/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu", // saturn (to be saturn.i.ipfs.io) + "/ip4/104.236.76.40/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64", // venus (to be venus.i.ipfs.io) + "/ip4/178.62.158.247/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd", // earth (to be earth.i.ipfs.io) + "/ip4/178.62.61.185/tcp/4001/ipfs/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3", // mercury (to be mercury.i.ipfs.io) + "/ip4/104.236.151.122/tcp/4001/ipfs/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx", // jupiter (to be jupiter.i.ipfs.io) } // BootstrapPeer is a peer used to bootstrap the network. -type BootstrapPeer struct { - Address string - PeerID string // until multiaddr supports ipfs, use another field. +type BootstrapPeer iaddr.IPFSAddr + +// ErrInvalidPeerAddr signals an address is not a valid peer address. +var ErrInvalidPeerAddr = errors.New("invalid peer address") + +func (c *Config) BootstrapPeers() ([]BootstrapPeer, error) { + return ParseBootstrapPeers(c.Bootstrap) } // DefaultBootstrapPeers returns the (parsed) set of default bootstrap peers. @@ -45,39 +46,16 @@ This is a problem with the ipfs codebase. Please report it to the dev team.`, er return ps, nil } -func (bp *BootstrapPeer) String() string { - return bp.Address + "/" + bp.PeerID +func (c *Config) SetBootstrapPeers(bps []BootstrapPeer) { + c.Bootstrap = BootstrapPeerStrings(bps) } func ParseBootstrapPeer(addr string) (BootstrapPeer, error) { - // to be replaced with just multiaddr parsing, once ptp is a multiaddr protocol - idx := strings.LastIndex(addr, "/") - if idx == -1 { - return BootstrapPeer{}, errors.New("invalid address") - } - addrS := addr[:idx] - peeridS := addr[idx+1:] - - // make sure addrS parses as a multiaddr. - if len(addrS) > 0 { - maddr, err := ma.NewMultiaddr(addrS) - if err != nil { - return BootstrapPeer{}, err - } - - addrS = maddr.String() - } - - // make sure idS parses as a peer.ID - _, err := mh.FromB58String(peeridS) + ia, err := iaddr.ParseString(addr) if err != nil { - return BootstrapPeer{}, err + return nil, err } - - return BootstrapPeer{ - Address: addrS, - PeerID: peeridS, - }, nil + return BootstrapPeer(ia), err } func ParseBootstrapPeers(addrs []string) ([]BootstrapPeer, error) { @@ -91,3 +69,11 @@ func ParseBootstrapPeers(addrs []string) ([]BootstrapPeer, error) { } return peers, nil } + +func BootstrapPeerStrings(bps []BootstrapPeer) []string { + bpss := make([]string, len(bps)) + for i, p := range bps { + bpss[i] = p.String() + } + return bpss +} diff --git a/config/config.go b/config/config.go index 9159223f7cf..e912429cd89 100644 --- a/config/config.go +++ b/config/config.go @@ -16,14 +16,14 @@ var log = u.Logger("config") // Config is used to load IPFS config files. 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 []BootstrapPeer // local nodes's bootstrap peers - Tour Tour // local node's tour position - Gateway Gateway // local node's gateway server options + 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 } const ( diff --git a/config/init.go b/config/init.go index 976d266883e..6d1c529e7ef 100644 --- a/config/init.go +++ b/config/init.go @@ -38,7 +38,7 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { API: "/ip4/127.0.0.1/tcp/5001", }, - Bootstrap: bootstrapPeers, + Bootstrap: BootstrapPeerStrings(bootstrapPeers), Datastore: *ds, Identity: identity, From 2cca094aa8b73f0f4e48deeefa0145dc361904c0 Mon Sep 17 00:00:00 2001 From: Brian Tiger Chow Date: Mon, 2 Feb 2015 17:42:54 -0800 Subject: [PATCH 014/262] go-ipfs-config: feat(fsrepo) add eventlog config to repo/config struct --- config/config.go | 1 + config/log.go | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 config/log.go diff --git a/config/config.go b/config/config.go index e912429cd89..f214b513b58 100644 --- a/config/config.go +++ b/config/config.go @@ -24,6 +24,7 @@ type Config struct { Bootstrap []string // local nodes's bootstrap peer addresses Tour Tour // local node's tour position Gateway Gateway // local node's gateway server options + Log Log } const ( diff --git a/config/log.go b/config/log.go new file mode 100644 index 00000000000..50e7243d45b --- /dev/null +++ b/config/log.go @@ -0,0 +1,8 @@ +package config + + +type Log struct { + MaxSizeMB uint64 + MaxBackups uint64 + MaxAgeDays uint64 +} From 4309541e87f6786d0fa2c4d8f33696c56e555c21 Mon Sep 17 00:00:00 2001 From: Brian Tiger Chow Date: Mon, 2 Feb 2015 18:26:47 -0800 Subject: [PATCH 015/262] go-ipfs-config: feat(config) default Log.MaxSizeMB = 500 --- config/init.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/config/init.go b/config/init.go index 6d1c529e7ef..76a70cdd65a 100644 --- a/config/init.go +++ b/config/init.go @@ -41,6 +41,9 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { Bootstrap: BootstrapPeerStrings(bootstrapPeers), Datastore: *ds, Identity: identity, + Log: Log{ + MaxSizeMB: 500, + }, // setup the node mount points. Mounts: Mounts{ @@ -54,7 +57,7 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { Gateway: Gateway{ RootRedirect: "", - Writable: false, + Writable: false, }, } From b8d85948012f464f77de5a5f58af9c910ece1cc3 Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Tue, 3 Feb 2015 02:27:24 -0800 Subject: [PATCH 016/262] go-ipfs-config: fsrepo: fix output to writer --- config/init.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/init.go b/config/init.go index 76a70cdd65a..737f174f2f5 100644 --- a/config/init.go +++ b/config/init.go @@ -83,12 +83,12 @@ func identityConfig(out io.Writer, nbits int) (Identity, error) { return ident, errors.New("Bitsize less than 1024 is considered unsafe.") } - out.Write([]byte(fmt.Sprintf("generating %v-bit RSA keypair...", nbits))) + fmt.Fprintf(out, "generating %v-bit RSA keypair...", nbits) sk, pk, err := ci.GenerateKeyPair(ci.RSA, nbits) if err != nil { return ident, err } - out.Write([]byte(fmt.Sprintf("done\n"))) + fmt.Fprintf(out, "done\n") // currently storing key unencrypted. in the future we need to encrypt it. // TODO(security) @@ -103,6 +103,6 @@ func identityConfig(out io.Writer, nbits int) (Identity, error) { return ident, err } ident.PeerID = id.Pretty() - fmt.Printf("peer identity: %s\n", ident.PeerID) + fmt.Fprintf(out, "peer identity: %s\n", ident.PeerID) return ident, nil } From 8c84f214f68da2fe768c484e0051b5291cadc84e Mon Sep 17 00:00:00 2001 From: Brian Tiger Chow Date: Tue, 3 Feb 2015 17:19:05 -0800 Subject: [PATCH 017/262] go-ipfs-config: fix(config, eventlog) use int. it plays nicely with everyone else --- config/log.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/log.go b/config/log.go index 50e7243d45b..abaa5c7cbd9 100644 --- a/config/log.go +++ b/config/log.go @@ -2,7 +2,7 @@ package config type Log struct { - MaxSizeMB uint64 - MaxBackups uint64 - MaxAgeDays uint64 + MaxSizeMB int + MaxBackups int + MaxAgeDays int } From 58445c282471d61486a5169d9ca45c5586d51987 Mon Sep 17 00:00:00 2001 From: Brian Tiger Chow Date: Tue, 3 Feb 2015 17:13:58 -0800 Subject: [PATCH 018/262] go-ipfs-config: fix(config) use max backups to limit number of backups --- config/init.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/init.go b/config/init.go index 737f174f2f5..0efcf629ab9 100644 --- a/config/init.go +++ b/config/init.go @@ -42,7 +42,8 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { Datastore: *ds, Identity: identity, Log: Log{ - MaxSizeMB: 500, + MaxSizeMB: 250, + MaxBackups: 1, }, // setup the node mount points. From 57814a36bfcc20204c6c6c5182c44100c8977c4b Mon Sep 17 00:00:00 2001 From: Matt Bell Date: Mon, 2 Feb 2015 17:45:16 -0800 Subject: [PATCH 019/262] go-ipfs-config: repo/config: Added default gateway address to initial config --- config/init.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/init.go b/config/init.go index 0efcf629ab9..49d80c78156 100644 --- a/config/init.go +++ b/config/init.go @@ -35,7 +35,8 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { "/ip4/0.0.0.0/tcp/4001", // "/ip4/0.0.0.0/udp/4002/utp", // disabled for now. }, - API: "/ip4/127.0.0.1/tcp/5001", + API: "/ip4/127.0.0.1/tcp/5001", + Gateway: "/ip4/127.0.0.1/tcp/8080", }, Bootstrap: BootstrapPeerStrings(bootstrapPeers), From df1e24d846a3ac8a32a646b1856698a6d0f725dd Mon Sep 17 00:00:00 2001 From: Brian Tiger Chow Date: Mon, 2 Feb 2015 01:39:03 -0800 Subject: [PATCH 020/262] go-ipfs-config: feat(config) add GCR config section --- config/config.go | 1 + config/gcr_servers.go | 33 +++++++++++++++++++++++++++++++++ config/init.go | 6 ++++++ 3 files changed, 40 insertions(+) create mode 100644 config/gcr_servers.go diff --git a/config/config.go b/config/config.go index f214b513b58..54473df1075 100644 --- a/config/config.go +++ b/config/config.go @@ -24,6 +24,7 @@ type Config struct { Bootstrap []string // local nodes's bootstrap peer addresses Tour Tour // local node's tour position Gateway Gateway // local node's gateway server options + GCR GCR // local node's routing servers (if GCR enabled) Log Log } diff --git a/config/gcr_servers.go b/config/gcr_servers.go new file mode 100644 index 00000000000..0f9ae962875 --- /dev/null +++ b/config/gcr_servers.go @@ -0,0 +1,33 @@ +package config + +import "github.com/jbenet/go-ipfs/util/ipfsaddr" + +// TODO replace with final servers before merge + +type GCR struct { + Servers []string +} + +var DefaultGCRServers = []string{ + "/ip4/104.236.70.34/tcp/4001/QmaWJw5mcWkCThPtC7hVq28e3WbwLHnWF8HbMNJrRDybE4", + "/ip4/128.199.72.111/tcp/4001/Qmd2cSiZUt7vhiuTmqBB7XWbkuFR8KMLiEuQssjyNXyaZT", +} + +func initGCR() (*GCR, error) { + // TODO perform validation + return &GCR{ + Servers: DefaultGCRServers, + }, nil +} + +func (gcr *GCR) ServerIPFSAddrs() ([]ipfsaddr.IPFSAddr, error) { + var addrs []ipfsaddr.IPFSAddr + for _, server := range gcr.Servers { + addr, err := ipfsaddr.ParseString(server) + if err != nil { + return nil, err + } + addrs = append(addrs, addr) + } + return addrs, nil +} diff --git a/config/init.go b/config/init.go index 49d80c78156..bbd82c44864 100644 --- a/config/init.go +++ b/config/init.go @@ -26,6 +26,11 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { return nil, err } + gcr, err := initGCR() + if err != nil { + return nil, err + } + conf := &Config{ // setup the node's default addresses. @@ -40,6 +45,7 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { }, Bootstrap: BootstrapPeerStrings(bootstrapPeers), + GCR: *gcr, Datastore: *ds, Identity: identity, Log: Log{ From 67f8655f18c581fc4629b084111a444a1e2c0e89 Mon Sep 17 00:00:00 2001 From: Brian Tiger Chow Date: Mon, 2 Feb 2015 05:47:36 -0800 Subject: [PATCH 021/262] go-ipfs-config: fix(config/gcr) include protocol --- config/gcr_servers.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/gcr_servers.go b/config/gcr_servers.go index 0f9ae962875..40f217e1db8 100644 --- a/config/gcr_servers.go +++ b/config/gcr_servers.go @@ -9,8 +9,8 @@ type GCR struct { } var DefaultGCRServers = []string{ - "/ip4/104.236.70.34/tcp/4001/QmaWJw5mcWkCThPtC7hVq28e3WbwLHnWF8HbMNJrRDybE4", - "/ip4/128.199.72.111/tcp/4001/Qmd2cSiZUt7vhiuTmqBB7XWbkuFR8KMLiEuQssjyNXyaZT", + "/ip4/104.236.70.34/tcp/4001/ipfs/QmaWJw5mcWkCThPtC7hVq28e3WbwLHnWF8HbMNJrRDybE4", + "/ip4/128.199.72.111/tcp/4001/ipfs/Qmd2cSiZUt7vhiuTmqBB7XWbkuFR8KMLiEuQssjyNXyaZT", } func initGCR() (*GCR, error) { From b4bc6482c89a560d3d39897502290f5b40ea6d09 Mon Sep 17 00:00:00 2001 From: Brian Tiger Chow Date: Fri, 6 Feb 2015 10:44:54 -0700 Subject: [PATCH 022/262] go-ipfs-config: fix(routingd) update port and servers --- config/gcr_servers.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/gcr_servers.go b/config/gcr_servers.go index 40f217e1db8..e1faa25d6a1 100644 --- a/config/gcr_servers.go +++ b/config/gcr_servers.go @@ -9,8 +9,8 @@ type GCR struct { } var DefaultGCRServers = []string{ - "/ip4/104.236.70.34/tcp/4001/ipfs/QmaWJw5mcWkCThPtC7hVq28e3WbwLHnWF8HbMNJrRDybE4", - "/ip4/128.199.72.111/tcp/4001/ipfs/Qmd2cSiZUt7vhiuTmqBB7XWbkuFR8KMLiEuQssjyNXyaZT", + "/ip4/107.170.212.195/tcp/4001/ipfs/QmVy5xh7sYKyQxHG4ZatHj9cCu1H5PR1LySKeTfLdJxp1b", + "/ip4/107.170.215.87/tcp/4001/ipfs/QmZDYP9GBjkAmZrS5usSzPnLf41haq6jJhJDmWgnSM4zvW", } func initGCR() (*GCR, error) { From 4b98e19165db0935ca38ac6403bacb20fefebb4f Mon Sep 17 00:00:00 2001 From: Brian Tiger Chow Date: Fri, 6 Feb 2015 11:08:11 -0700 Subject: [PATCH 023/262] go-ipfs-config: fix(repo/config) Update gcr_servers.go TODO rename --- config/gcr_servers.go | 1 + 1 file changed, 1 insertion(+) diff --git a/config/gcr_servers.go b/config/gcr_servers.go index e1faa25d6a1..a6aae090ab1 100644 --- a/config/gcr_servers.go +++ b/config/gcr_servers.go @@ -4,6 +4,7 @@ import "github.com/jbenet/go-ipfs/util/ipfsaddr" // TODO replace with final servers before merge +// TODO rename type GCR struct { Servers []string } From fd2fcf0879c97cec0eee162b935842c5fe4b543a Mon Sep 17 00:00:00 2001 From: Brian Tiger Chow Date: Fri, 6 Feb 2015 13:49:48 -0700 Subject: [PATCH 024/262] go-ipfs-config: fix(corerouting) pass transport addr --- config/config.go | 20 ++++++++++---------- config/init.go | 4 ++-- config/{gcr_servers.go => supernode.go} | 8 ++++---- 3 files changed, 16 insertions(+), 16 deletions(-) rename config/{gcr_servers.go => supernode.go} (75%) diff --git a/config/config.go b/config/config.go index 54473df1075..eec25d8cd85 100644 --- a/config/config.go +++ b/config/config.go @@ -16,16 +16,16 @@ var log = u.Logger("config") // Config is used to load IPFS config files. 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 - GCR GCR // local node's routing servers (if GCR enabled) - Log Log + 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 } const ( diff --git a/config/init.go b/config/init.go index bbd82c44864..34ebcebef4a 100644 --- a/config/init.go +++ b/config/init.go @@ -26,7 +26,7 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { return nil, err } - gcr, err := initGCR() + snr, err := initSNRConfig() if err != nil { return nil, err } @@ -45,7 +45,7 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { }, Bootstrap: BootstrapPeerStrings(bootstrapPeers), - GCR: *gcr, + SupernodeRouting: *snr, Datastore: *ds, Identity: identity, Log: Log{ diff --git a/config/gcr_servers.go b/config/supernode.go similarity index 75% rename from config/gcr_servers.go rename to config/supernode.go index a6aae090ab1..a812b7a5e07 100644 --- a/config/gcr_servers.go +++ b/config/supernode.go @@ -5,7 +5,7 @@ import "github.com/jbenet/go-ipfs/util/ipfsaddr" // TODO replace with final servers before merge // TODO rename -type GCR struct { +type SupernodeClientConfig struct { Servers []string } @@ -14,14 +14,14 @@ var DefaultGCRServers = []string{ "/ip4/107.170.215.87/tcp/4001/ipfs/QmZDYP9GBjkAmZrS5usSzPnLf41haq6jJhJDmWgnSM4zvW", } -func initGCR() (*GCR, error) { +func initSNRConfig() (*SupernodeClientConfig, error) { // TODO perform validation - return &GCR{ + return &SupernodeClientConfig{ Servers: DefaultGCRServers, }, nil } -func (gcr *GCR) ServerIPFSAddrs() ([]ipfsaddr.IPFSAddr, error) { +func (gcr *SupernodeClientConfig) ServerIPFSAddrs() ([]ipfsaddr.IPFSAddr, error) { var addrs []ipfsaddr.IPFSAddr for _, server := range gcr.Servers { addr, err := ipfsaddr.ParseString(server) From 46a4b1a4087e0380e224e069151b8079f1f5686c Mon Sep 17 00:00:00 2001 From: Brian Tiger Chow Date: Fri, 6 Feb 2015 14:02:34 -0700 Subject: [PATCH 025/262] go-ipfs-config: feat(config/supernode) add 5 supernodes --- config/supernode.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/config/supernode.go b/config/supernode.go index a812b7a5e07..dbad8c11dcc 100644 --- a/config/supernode.go +++ b/config/supernode.go @@ -10,8 +10,11 @@ type SupernodeClientConfig struct { } var DefaultGCRServers = []string{ - "/ip4/107.170.212.195/tcp/4001/ipfs/QmVy5xh7sYKyQxHG4ZatHj9cCu1H5PR1LySKeTfLdJxp1b", - "/ip4/107.170.215.87/tcp/4001/ipfs/QmZDYP9GBjkAmZrS5usSzPnLf41haq6jJhJDmWgnSM4zvW", + "/ip4/104.236.176.52/tcp/4002/ipfs/QmXdb7tWTxdFEQEFgWBqkuYSrZd3mXrC7HxkD4krGNYx2U", + "/ip4/104.236.179.241/tcp/4002/ipfs/QmVRqViDByUxjUMoPnjurjKvZhaEMFDtK35FJXHAM4Lkj6", + "/ip4/104.236.151.122/tcp/4002/ipfs/QmSZwGx8Tn8tmcM4PtDJaMeUQNRhNFdBLVGPzRiNaRJtFH", + "/ip4/162.243.248.213/tcp/4002/ipfs/QmbHVEEepCi7rn7VL7Exxpd2Ci9NNB6ifvqwhsrbRMgQFP", + "/ip4/128.199.219.111/tcp/4002/ipfs/Qmb3brdCYmKG1ycwqCbo6LUwWxTuo3FisnJV2yir7oN92R", } func initSNRConfig() (*SupernodeClientConfig, error) { From 0ca9469bf37cdfcc457502233ac0f47d94fa27d2 Mon Sep 17 00:00:00 2001 From: Brian Tiger Chow Date: Thu, 12 Feb 2015 14:37:22 -0800 Subject: [PATCH 026/262] go-ipfs-config: add three more supernode routers --- config/supernode.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config/supernode.go b/config/supernode.go index dbad8c11dcc..6d301dc1528 100644 --- a/config/supernode.go +++ b/config/supernode.go @@ -15,6 +15,9 @@ var DefaultGCRServers = []string{ "/ip4/104.236.151.122/tcp/4002/ipfs/QmSZwGx8Tn8tmcM4PtDJaMeUQNRhNFdBLVGPzRiNaRJtFH", "/ip4/162.243.248.213/tcp/4002/ipfs/QmbHVEEepCi7rn7VL7Exxpd2Ci9NNB6ifvqwhsrbRMgQFP", "/ip4/128.199.219.111/tcp/4002/ipfs/Qmb3brdCYmKG1ycwqCbo6LUwWxTuo3FisnJV2yir7oN92R", + "/ip4/104.236.76.40/tcp/4002/ipfs/QmdRBCV8Cz2dGhoKLkD3YjPwVFECmqADQkx5ZteF2c6Fy4", + "/ip4/178.62.158.247/tcp/4002/ipfs/QmUdiMPci7YoEUBkyFZAh2pAbjqcPr7LezyiPD2artLw3v", + "/ip4/178.62.61.185/tcp/4002/ipfs/QmVw6fGNqBixZE4bewRLT2VXX7fAHUHs8JyidDiJ1P7RUN", } func initSNRConfig() (*SupernodeClientConfig, error) { From 44ef2bab38d01a9b43616014cbcc0c584197e14c Mon Sep 17 00:00:00 2001 From: Brian Tiger Chow Date: Sun, 15 Feb 2015 06:28:03 -0800 Subject: [PATCH 027/262] go-ipfs-config: fix(config) rename variable GCR -> SNR --- config/supernode.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/supernode.go b/config/supernode.go index 6d301dc1528..ccc5be3dd0f 100644 --- a/config/supernode.go +++ b/config/supernode.go @@ -9,7 +9,7 @@ type SupernodeClientConfig struct { Servers []string } -var DefaultGCRServers = []string{ +var DefaultSNRServers = []string{ "/ip4/104.236.176.52/tcp/4002/ipfs/QmXdb7tWTxdFEQEFgWBqkuYSrZd3mXrC7HxkD4krGNYx2U", "/ip4/104.236.179.241/tcp/4002/ipfs/QmVRqViDByUxjUMoPnjurjKvZhaEMFDtK35FJXHAM4Lkj6", "/ip4/104.236.151.122/tcp/4002/ipfs/QmSZwGx8Tn8tmcM4PtDJaMeUQNRhNFdBLVGPzRiNaRJtFH", @@ -23,7 +23,7 @@ var DefaultGCRServers = []string{ func initSNRConfig() (*SupernodeClientConfig, error) { // TODO perform validation return &SupernodeClientConfig{ - Servers: DefaultGCRServers, + Servers: DefaultSNRServers, }, nil } From 25c4d28de9a55615eb276a57016e220d6449b0ea Mon Sep 17 00:00:00 2001 From: Ho-Sheng Hsiao Date: Mon, 30 Mar 2015 20:04:32 -0700 Subject: [PATCH 028/262] go-ipfs-config: Reorged imports from jbenet/go-ipfs to ipfs/go-ipfs - Modified Godeps/Godeps.json by hand - [TEST] Updated welcome docs hash to sharness - [TEST] Updated contact doc - [TEST] disabled breaking test (t0080-repo refs local) --- config/bootstrap_peers.go | 4 ++-- config/config.go | 2 +- config/identity.go | 2 +- config/init.go | 6 +++--- config/supernode.go | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/config/bootstrap_peers.go b/config/bootstrap_peers.go index de4935d7856..af18ab17baf 100644 --- a/config/bootstrap_peers.go +++ b/config/bootstrap_peers.go @@ -1,9 +1,9 @@ package config import ( - errors "github.com/jbenet/go-ipfs/util/debugerror" + errors "github.com/ipfs/go-ipfs/util/debugerror" - iaddr "github.com/jbenet/go-ipfs/util/ipfsaddr" + iaddr "github.com/ipfs/go-ipfs/util/ipfsaddr" ) // DefaultBootstrapAddresses are the hardcoded bootstrap addresses diff --git a/config/config.go b/config/config.go index eec25d8cd85..6876f9603f5 100644 --- a/config/config.go +++ b/config/config.go @@ -9,7 +9,7 @@ import ( "path/filepath" "strings" - u "github.com/jbenet/go-ipfs/util" + u "github.com/ipfs/go-ipfs/util" ) var log = u.Logger("config") diff --git a/config/identity.go b/config/identity.go index 2097e51886d..d2298fbcd86 100644 --- a/config/identity.go +++ b/config/identity.go @@ -2,7 +2,7 @@ package config import ( "encoding/base64" - ic "github.com/jbenet/go-ipfs/p2p/crypto" + ic "github.com/ipfs/go-ipfs/p2p/crypto" ) // Identity tracks the configuration of the local node's identity. diff --git a/config/init.go b/config/init.go index 34ebcebef4a..8f456f690c9 100644 --- a/config/init.go +++ b/config/init.go @@ -5,9 +5,9 @@ import ( "fmt" "io" - ci "github.com/jbenet/go-ipfs/p2p/crypto" - peer "github.com/jbenet/go-ipfs/p2p/peer" - errors "github.com/jbenet/go-ipfs/util/debugerror" + ci "github.com/ipfs/go-ipfs/p2p/crypto" + peer "github.com/ipfs/go-ipfs/p2p/peer" + errors "github.com/ipfs/go-ipfs/util/debugerror" ) func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { diff --git a/config/supernode.go b/config/supernode.go index ccc5be3dd0f..30ee6f22e55 100644 --- a/config/supernode.go +++ b/config/supernode.go @@ -1,6 +1,6 @@ package config -import "github.com/jbenet/go-ipfs/util/ipfsaddr" +import "github.com/ipfs/go-ipfs/util/ipfsaddr" // TODO replace with final servers before merge From 154216d34d48d00a4af1c70ea6f6d0ce5550225d Mon Sep 17 00:00:00 2001 From: Ho-Sheng Hsiao Date: Tue, 31 Mar 2015 17:13:28 -0700 Subject: [PATCH 029/262] go-ipfs-config: Added fuse allow_other option ipfs config Mounts.FuseAllowOther --bool true ipfs daemon --mount --- config/mounts.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/config/mounts.go b/config/mounts.go index a0f42005943..b23d30b2ef3 100644 --- a/config/mounts.go +++ b/config/mounts.go @@ -2,6 +2,7 @@ package config // Mounts stores the (string) mount points type Mounts struct { - IPFS string - IPNS string + IPFS string + IPNS string + FuseAllowOther bool } From ffacc10342daa4778ebe90a3d64df06173c578c3 Mon Sep 17 00:00:00 2001 From: Baptiste Jonglez Date: Tue, 14 Apr 2015 14:26:51 +0200 Subject: [PATCH 030/262] go-ipfs-config: Default config: listen on IPv6 for the swarm address --- config/init.go | 1 + 1 file changed, 1 insertion(+) diff --git a/config/init.go b/config/init.go index 8f456f690c9..05e6eb107b8 100644 --- a/config/init.go +++ b/config/init.go @@ -39,6 +39,7 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { Swarm: []string{ "/ip4/0.0.0.0/tcp/4001", // "/ip4/0.0.0.0/udp/4002/utp", // disabled for now. + "/ip6/::/tcp/4001", }, API: "/ip4/127.0.0.1/tcp/5001", Gateway: "/ip4/127.0.0.1/tcp/8080", From 6457cc5ab8ec020f24c7b4cc883ebf4254a0124d Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Mon, 20 Apr 2015 00:15:34 -0700 Subject: [PATCH 031/262] go-ipfs-config: remove debugerrors We now consider debugerrors harmful: we've run into cases where debugerror.Wrap() hid valuable error information (err == io.EOF?). I've removed them from the main code, but left them in some tests. Go errors are lacking, but unfortunately, this isn't the solution. It is possible that debugerros.New or debugerrors.Errorf should remain still (i.e. only remove debugerrors.Wrap) but we don't use these errors often enough to keep. --- config/bootstrap_peers.go | 5 +++-- config/gateway.go | 2 +- config/init.go | 10 +++++----- config/log.go | 1 - 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/config/bootstrap_peers.go b/config/bootstrap_peers.go index af18ab17baf..5fefae92f36 100644 --- a/config/bootstrap_peers.go +++ b/config/bootstrap_peers.go @@ -1,7 +1,8 @@ package config import ( - errors "github.com/ipfs/go-ipfs/util/debugerror" + "errors" + "fmt" iaddr "github.com/ipfs/go-ipfs/util/ipfsaddr" ) @@ -40,7 +41,7 @@ func (c *Config) BootstrapPeers() ([]BootstrapPeer, error) { func DefaultBootstrapPeers() ([]BootstrapPeer, error) { ps, err := ParseBootstrapPeers(DefaultBootstrapAddresses) if err != nil { - return nil, errors.Errorf(`failed to parse hardcoded bootstrap peers: %s + return nil, fmt.Errorf(`failed to parse hardcoded bootstrap peers: %s This is a problem with the ipfs codebase. Please report it to the dev team.`, err) } return ps, nil diff --git a/config/gateway.go b/config/gateway.go index c0885778d57..dfb72880c60 100644 --- a/config/gateway.go +++ b/config/gateway.go @@ -3,5 +3,5 @@ package config // Gateway contains options for the HTTP gateway server. type Gateway struct { RootRedirect string - Writable bool + Writable bool } diff --git a/config/init.go b/config/init.go index 8f456f690c9..2b4bf2a0880 100644 --- a/config/init.go +++ b/config/init.go @@ -2,12 +2,12 @@ package config import ( "encoding/base64" + "errors" "fmt" "io" ci "github.com/ipfs/go-ipfs/p2p/crypto" peer "github.com/ipfs/go-ipfs/p2p/peer" - errors "github.com/ipfs/go-ipfs/util/debugerror" ) func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { @@ -44,10 +44,10 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { Gateway: "/ip4/127.0.0.1/tcp/8080", }, - Bootstrap: BootstrapPeerStrings(bootstrapPeers), - SupernodeRouting: *snr, - Datastore: *ds, - Identity: identity, + Bootstrap: BootstrapPeerStrings(bootstrapPeers), + SupernodeRouting: *snr, + Datastore: *ds, + Identity: identity, Log: Log{ MaxSizeMB: 250, MaxBackups: 1, diff --git a/config/log.go b/config/log.go index abaa5c7cbd9..81aebf05979 100644 --- a/config/log.go +++ b/config/log.go @@ -1,6 +1,5 @@ package config - type Log struct { MaxSizeMB int MaxBackups int From c685f571eab02b397b76a528b55472fc6a2222b8 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Sun, 29 Mar 2015 13:25:01 +0200 Subject: [PATCH 032/262] go-ipfs-config: config: change default config dir name to .ipfs This changes .go-ipfs to .ipfs everywhere. And by the way this defines a DefaultPathName const for this name. License: MIT Signed-off-by: Christian Couder --- config/config.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index 6876f9603f5..83cd2abb9db 100644 --- a/config/config.go +++ b/config/config.go @@ -29,8 +29,10 @@ type Config struct { } const ( + // DefaultPathName is the default config dir name + DefaultPathName = ".ipfs" // DefaultPathRoot is the path to the default config dir location. - DefaultPathRoot = "~/.go-ipfs" + DefaultPathRoot = "~/" + DefaultPathName // DefaultConfigFile is the filename of the configuration file DefaultConfigFile = "config" // EnvDir is the environment variable used to change the path root. From d5503594e3cb1388a822d4a5d836ed4c6e266930 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Wed, 22 Apr 2015 00:55:31 -0700 Subject: [PATCH 033/262] go-ipfs-config: implement a config option for mdns --- config/config.go | 1 + config/discovery.go | 12 ++++++++++++ config/init.go | 4 ++++ 3 files changed, 17 insertions(+) create mode 100644 config/discovery.go diff --git a/config/config.go b/config/config.go index 83cd2abb9db..1d2fa87ad7c 100644 --- a/config/config.go +++ b/config/config.go @@ -21,6 +21,7 @@ type Config struct { Addresses Addresses // local node's addresses Mounts Mounts // local node's mount points Version Version // local node's version management + Discovery Discovery // local node's discovery mechanisms Bootstrap []string // local nodes's bootstrap peer addresses Tour Tour // local node's tour position Gateway Gateway // local node's gateway server options diff --git a/config/discovery.go b/config/discovery.go new file mode 100644 index 00000000000..4fb8508f00a --- /dev/null +++ b/config/discovery.go @@ -0,0 +1,12 @@ +package config + +type Discovery struct { + MDNS MDNS +} + +type MDNS struct { + Enabled bool + + // Time in seconds between discovery rounds + Interval int +} diff --git a/config/init.go b/config/init.go index 2b4bf2a0880..76ee1fdc144 100644 --- a/config/init.go +++ b/config/init.go @@ -48,6 +48,10 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { SupernodeRouting: *snr, Datastore: *ds, Identity: identity, + Discovery: Discovery{MDNS{ + Enabled: true, + Interval: 10, + }}, Log: Log{ MaxSizeMB: 250, MaxBackups: 1, From 316b2d1de9a60888c479871a40c92c538c567c6e Mon Sep 17 00:00:00 2001 From: rht Date: Tue, 26 May 2015 23:18:04 +0700 Subject: [PATCH 034/262] go-ipfs-config: Replace 'var * bytes.Buffer' with '\1 := new(bytes.Buffer)' --- config/config.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/config/config.go b/config/config.go index 1d2fa87ad7c..c9a8aabec68 100644 --- a/config/config.go +++ b/config/config.go @@ -86,24 +86,24 @@ func Marshal(value interface{}) ([]byte, error) { } func FromMap(v map[string]interface{}) (*Config, error) { - var buf bytes.Buffer - if err := json.NewEncoder(&buf).Encode(v); err != nil { + buf := new(bytes.Buffer) + if err := json.NewEncoder(buf).Encode(v); err != nil { return nil, err } var conf Config - if err := json.NewDecoder(&buf).Decode(&conf); err != nil { + if err := json.NewDecoder(buf).Decode(&conf); err != nil { return nil, fmt.Errorf("Failure to decode config: %s", err) } return &conf, nil } func ToMap(conf *Config) (map[string]interface{}, error) { - var buf bytes.Buffer - if err := json.NewEncoder(&buf).Encode(conf); err != nil { + buf := new(bytes.Buffer) + if err := json.NewEncoder(buf).Encode(conf); err != nil { return nil, err } var m map[string]interface{} - if err := json.NewDecoder(&buf).Decode(&m); err != nil { + if err := json.NewDecoder(buf).Decode(&m); err != nil { return nil, fmt.Errorf("Failure to decode config: %s", err) } return m, nil From eb6a0a5d89c5a5ff4ce1d15cf03cb74e88962f9a Mon Sep 17 00:00:00 2001 From: Jeromy Date: Tue, 16 Jun 2015 11:06:04 -0700 Subject: [PATCH 035/262] go-ipfs-config: add in basic address dial filtering License: MIT Signed-off-by: Jeromy --- config/config.go | 1 + 1 file changed, 1 insertion(+) diff --git a/config/config.go b/config/config.go index c9a8aabec68..e7474cf7e09 100644 --- a/config/config.go +++ b/config/config.go @@ -26,6 +26,7 @@ type Config struct { 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) + DialBlocklist []string Log Log } From 3861ff304e1d52060ed165b842bb5845827b63cd Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Thu, 2 Jul 2015 16:11:46 -0700 Subject: [PATCH 036/262] go-ipfs-config: config: DialBlocklist -> Swarm.AddrFilters This commit changes the DialBlocklist key to be under the key Swarm.AddrFilters instead. License: MIT Signed-off-by: Juan Batiz-Benet --- config/config.go | 2 +- config/swarm.go | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 config/swarm.go diff --git a/config/config.go b/config/config.go index e7474cf7e09..ad493a18995 100644 --- a/config/config.go +++ b/config/config.go @@ -26,7 +26,7 @@ type Config struct { 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) - DialBlocklist []string + Swarm SwarmConfig Log Log } diff --git a/config/swarm.go b/config/swarm.go new file mode 100644 index 00000000000..d398b3d80af --- /dev/null +++ b/config/swarm.go @@ -0,0 +1,5 @@ +package config + +type SwarmConfig struct { + AddrFilters []string +} From b73f2d531d1d0159fd4790c562b71cd16578d993 Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Thu, 23 Jul 2015 18:44:46 -0700 Subject: [PATCH 037/262] go-ipfs-config: Added API + Gateway support for arbitrary HTTP headers This commit fixes + improves CORS support License: MIT Signed-off-by: Juan Batiz-Benet --- config/api.go | 5 +++++ config/config.go | 1 + config/gateway.go | 1 + 3 files changed, 7 insertions(+) create mode 100644 config/api.go diff --git a/config/api.go b/config/api.go new file mode 100644 index 00000000000..b36b1080304 --- /dev/null +++ b/config/api.go @@ -0,0 +1,5 @@ +package config + +type API struct { + HTTPHeaders map[string][]string // HTTP headers to return with the API. +} diff --git a/config/config.go b/config/config.go index ad493a18995..42b56550c9e 100644 --- a/config/config.go +++ b/config/config.go @@ -26,6 +26,7 @@ type Config struct { 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) + API API // local node's API settings Swarm SwarmConfig Log Log } diff --git a/config/gateway.go b/config/gateway.go index dfb72880c60..07bc9aad2cb 100644 --- a/config/gateway.go +++ b/config/gateway.go @@ -2,6 +2,7 @@ package config // Gateway contains options for the HTTP gateway server. type Gateway struct { + HTTPHeaders map[string][]string // HTTP headers to return with the gateway RootRedirect string Writable bool } From 809269399ecd49cc509d86c40144a84bc1ebbc3c Mon Sep 17 00:00:00 2001 From: Jeromy Date: Mon, 14 Sep 2015 17:33:03 -0700 Subject: [PATCH 038/262] go-ipfs-config: extract logging License: MIT Signed-off-by: Jeromy --- config/config.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index 42b56550c9e..77573e9145d 100644 --- a/config/config.go +++ b/config/config.go @@ -10,9 +10,10 @@ import ( "strings" u "github.com/ipfs/go-ipfs/util" + logging "github.com/ipfs/go-ipfs/vendor/go-log-v1.0.0" ) -var log = u.Logger("config") +var log = logging.Logger("config") // Config is used to load IPFS config files. type Config struct { From 4f6eb40056dd948423b449952c31a67157dd950b Mon Sep 17 00:00:00 2001 From: Jeromy Date: Mon, 21 Sep 2015 16:35:33 -0700 Subject: [PATCH 039/262] go-ipfs-config: Implement ipns republisher This commit adds a very basic process that will periodically go through a list of given ids and republish the values for their ipns entries. License: MIT Signed-off-by: Jeromy --- config/config.go | 1 + config/ipns.go | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 config/ipns.go diff --git a/config/config.go b/config/config.go index 77573e9145d..3430bb1b129 100644 --- a/config/config.go +++ b/config/config.go @@ -23,6 +23,7 @@ type Config struct { Mounts Mounts // local node's mount points Version Version // local node's version management Discovery Discovery // local node's discovery mechanisms + Ipns Ipns // Ipns settings Bootstrap []string // local nodes's bootstrap peer addresses Tour Tour // local node's tour position Gateway Gateway // local node's gateway server options diff --git a/config/ipns.go b/config/ipns.go new file mode 100644 index 00000000000..feb77be10ba --- /dev/null +++ b/config/ipns.go @@ -0,0 +1,5 @@ +package config + +type Ipns struct { + RepublishPeriod string +} From a28d610d804be028408d027163d717efd8977bf3 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Wed, 30 Sep 2015 11:03:44 -0700 Subject: [PATCH 040/262] go-ipfs-config: make publish more configurable and add test for repub License: MIT Signed-off-by: Jeromy --- config/ipns.go | 1 + 1 file changed, 1 insertion(+) diff --git a/config/ipns.go b/config/ipns.go index feb77be10ba..feab6f044f7 100644 --- a/config/ipns.go +++ b/config/ipns.go @@ -2,4 +2,5 @@ package config type Ipns struct { RepublishPeriod string + RecordLifetime string } From f6c74ee68bf8fe74cc2c05200a5a8f96f9344601 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Thu, 1 Oct 2015 11:22:28 -0700 Subject: [PATCH 041/262] go-ipfs-config: replace imports with absolute path instead of using symlink License: MIT Signed-off-by: Jeromy --- config/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index 3430bb1b129..09c11d31428 100644 --- a/config/config.go +++ b/config/config.go @@ -10,7 +10,7 @@ import ( "strings" u "github.com/ipfs/go-ipfs/util" - logging "github.com/ipfs/go-ipfs/vendor/go-log-v1.0.0" + logging "github.com/ipfs/go-ipfs/vendor/QmXJkcEXB6C9h6Ytb6rrUTFU56Ro62zxgrbxTT3dgjQGA8/go-log" ) var log = logging.Logger("config") From bdee8cb3ad2f562f17274d93ea3f7e228727aaeb Mon Sep 17 00:00:00 2001 From: Lars Gierth Date: Thu, 24 Sep 2015 22:11:12 +0200 Subject: [PATCH 042/262] go-ipfs-config: config: update bootstrap list hostname License: MIT Signed-off-by: Lars Gierth --- config/bootstrap_peers.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/config/bootstrap_peers.go b/config/bootstrap_peers.go index 5fefae92f36..25153f7f373 100644 --- a/config/bootstrap_peers.go +++ b/config/bootstrap_peers.go @@ -15,14 +15,14 @@ import ( // import dependency issue. TODO: move this into a config/default/ package. var DefaultBootstrapAddresses = []string{ "/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ", // mars.i.ipfs.io - "/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z", // neptune (to be neptune.i.ipfs.io) - "/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLpPVmHKQ4XTPdz8tjDFgdeRFkpV8JgYq8JVJ69RrZm", // pluto (to be pluto.i.ipfs.io) - "/ip4/162.243.248.213/tcp/4001/ipfs/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm", // uranus (to be uranus.i.ipfs.io) - "/ip4/128.199.219.111/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu", // saturn (to be saturn.i.ipfs.io) - "/ip4/104.236.76.40/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64", // venus (to be venus.i.ipfs.io) - "/ip4/178.62.158.247/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd", // earth (to be earth.i.ipfs.io) - "/ip4/178.62.61.185/tcp/4001/ipfs/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3", // mercury (to be mercury.i.ipfs.io) - "/ip4/104.236.151.122/tcp/4001/ipfs/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx", // jupiter (to be jupiter.i.ipfs.io) + "/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z", // neptune.i.ipfs.io + "/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLpPVmHKQ4XTPdz8tjDFgdeRFkpV8JgYq8JVJ69RrZm", // pluto.i.ipfs.io + "/ip4/162.243.248.213/tcp/4001/ipfs/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm", // uranus.i.ipfs.io + "/ip4/128.199.219.111/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu", // saturn.i.ipfs.io + "/ip4/104.236.76.40/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64", // venus.i.ipfs.io + "/ip4/178.62.158.247/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd", // earth.i.ipfs.io + "/ip4/178.62.61.185/tcp/4001/ipfs/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3", // mercury.i.ipfs.io + "/ip4/104.236.151.122/tcp/4001/ipfs/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx", // jupiter.i.ipfs.io } // BootstrapPeer is a peer used to bootstrap the network. From bf8e4ab52c7944f9c305765be266bffc2097ca89 Mon Sep 17 00:00:00 2001 From: Lars Gierth Date: Sun, 4 Oct 2015 23:16:35 +0200 Subject: [PATCH 043/262] go-ipfs-config: config: update pluto's peerID We lost its private key a while ago... License: MIT Signed-off-by: Lars Gierth --- config/bootstrap_peers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/bootstrap_peers.go b/config/bootstrap_peers.go index 25153f7f373..fa607c84252 100644 --- a/config/bootstrap_peers.go +++ b/config/bootstrap_peers.go @@ -16,7 +16,7 @@ import ( var DefaultBootstrapAddresses = []string{ "/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ", // mars.i.ipfs.io "/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z", // neptune.i.ipfs.io - "/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLpPVmHKQ4XTPdz8tjDFgdeRFkpV8JgYq8JVJ69RrZm", // pluto.i.ipfs.io + "/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM", // pluto.i.ipfs.io "/ip4/162.243.248.213/tcp/4001/ipfs/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm", // uranus.i.ipfs.io "/ip4/128.199.219.111/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu", // saturn.i.ipfs.io "/ip4/104.236.76.40/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64", // venus.i.ipfs.io From b6d1a3f6ee43aececb8e7a051b965f32ff49389b Mon Sep 17 00:00:00 2001 From: Jeromy Date: Tue, 27 Oct 2015 10:47:32 -0700 Subject: [PATCH 044/262] go-ipfs-config: update code to use new logging changes License: MIT Signed-off-by: Jeromy --- config/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index 09c11d31428..ce96f594ebf 100644 --- a/config/config.go +++ b/config/config.go @@ -10,7 +10,7 @@ import ( "strings" u "github.com/ipfs/go-ipfs/util" - logging "github.com/ipfs/go-ipfs/vendor/QmXJkcEXB6C9h6Ytb6rrUTFU56Ro62zxgrbxTT3dgjQGA8/go-log" + logging "github.com/ipfs/go-ipfs/vendor/QmTBXYb6y2ZcJmoXVKk3pf9rzSEjbCg7tQaJW7RSuH14nv/go-log" ) var log = logging.Logger("config") From d84895e0d953e40493b13413cc217b97ae9f3f54 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Thu, 22 Oct 2015 16:27:31 -0700 Subject: [PATCH 045/262] go-ipfs-config: cache ipns entries to speed things up a little License: MIT Signed-off-by: Jeromy --- config/init.go | 4 ++++ config/ipns.go | 2 ++ 2 files changed, 6 insertions(+) diff --git a/config/init.go b/config/init.go index 49d0a1ecb08..970597a65cd 100644 --- a/config/init.go +++ b/config/init.go @@ -64,6 +64,10 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { IPNS: "/ipns", }, + Ipns: Ipns{ + ResolveCacheSize: 128, + }, + // tracking ipfs version used to generate the init folder and adding // update checker default setting. Version: VersionDefaultValue(), diff --git a/config/ipns.go b/config/ipns.go index feab6f044f7..44a95b0990c 100644 --- a/config/ipns.go +++ b/config/ipns.go @@ -3,4 +3,6 @@ package config type Ipns struct { RepublishPeriod string RecordLifetime string + + ResolveCacheSize int } From 1e4bd881172a8d523f00b45fe6af34c67e77e2e7 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Thu, 29 Oct 2015 21:22:53 -0700 Subject: [PATCH 046/262] go-ipfs-config: vendor logging lib update License: MIT Signed-off-by: Jeromy --- config/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index ce96f594ebf..0b8b721ee0d 100644 --- a/config/config.go +++ b/config/config.go @@ -10,7 +10,7 @@ import ( "strings" u "github.com/ipfs/go-ipfs/util" - logging "github.com/ipfs/go-ipfs/vendor/QmTBXYb6y2ZcJmoXVKk3pf9rzSEjbCg7tQaJW7RSuH14nv/go-log" + logging "github.com/ipfs/go-ipfs/vendor/QmQg1J6vikuXF9oDvm4wpdeAUvvkVEKW1EYDw9HhTMnP2b/go-log" ) var log = logging.Logger("config") From 14cf564b3a1a7d7956677c60448b724c45a3b2f7 Mon Sep 17 00:00:00 2001 From: rht Date: Tue, 20 Oct 2015 10:56:41 +0700 Subject: [PATCH 047/262] go-ipfs-config: Add fixed period repo GC + test License: MIT Signed-off-by: rht --- config/datastore.go | 7 +++++-- config/init.go | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/config/datastore.go b/config/datastore.go index b615c650f25..6749a4c39a0 100644 --- a/config/datastore.go +++ b/config/datastore.go @@ -5,8 +5,11 @@ const DefaultDataStoreDirectory = "datastore" // Datastore tracks the configuration of the datastore. type Datastore struct { - Type string - Path string + Type string + Path string + StorageMax string // in B, kB, kiB, MB, ... + StorageGCWatermark int64 // in percentage to multiply on StorageMax + GCPeriod string // in ns, us, ms, s, m, h } // DataStorePath returns the default data store path given a configuration root diff --git a/config/init.go b/config/init.go index 970597a65cd..4d50ac6611f 100644 --- a/config/init.go +++ b/config/init.go @@ -87,8 +87,11 @@ func datastoreConfig() (*Datastore, error) { return nil, err } return &Datastore{ - Path: dspath, - Type: "leveldb", + Path: dspath, + Type: "leveldb", + StorageMax: "10GB", + StorageGCWatermark: 90, // 90% + GCPeriod: "1h", }, nil } From 5ed0af64381f1983874997f21221136d62ff861e Mon Sep 17 00:00:00 2001 From: Lars Gierth Date: Wed, 11 Nov 2015 18:32:24 +0100 Subject: [PATCH 048/262] go-ipfs-config: repo: remove Log config We stopped logging to files in a676b5a8ac2848a57318283f4b2b52d7d8686323 and this config section was missed. License: MIT Signed-off-by: Lars Gierth --- config/config.go | 1 - config/init.go | 4 ---- config/log.go | 7 ------- config/logs.go | 1 - 4 files changed, 13 deletions(-) delete mode 100644 config/log.go delete mode 100644 config/logs.go diff --git a/config/config.go b/config/config.go index ce96f594ebf..e40d0d7dca9 100644 --- a/config/config.go +++ b/config/config.go @@ -30,7 +30,6 @@ type Config struct { SupernodeRouting SupernodeClientConfig // local node's routing servers (if SupernodeRouting enabled) API API // local node's API settings Swarm SwarmConfig - Log Log } const ( diff --git a/config/init.go b/config/init.go index 970597a65cd..ab1cea0e8d1 100644 --- a/config/init.go +++ b/config/init.go @@ -53,10 +53,6 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { Enabled: true, Interval: 10, }}, - Log: Log{ - MaxSizeMB: 250, - MaxBackups: 1, - }, // setup the node mount points. Mounts: Mounts{ diff --git a/config/log.go b/config/log.go deleted file mode 100644 index 81aebf05979..00000000000 --- a/config/log.go +++ /dev/null @@ -1,7 +0,0 @@ -package config - -type Log struct { - MaxSizeMB int - MaxBackups int - MaxAgeDays int -} diff --git a/config/logs.go b/config/logs.go deleted file mode 100644 index d912156bec0..00000000000 --- a/config/logs.go +++ /dev/null @@ -1 +0,0 @@ -package config From e7989f12148dad4799c6afe33e7d4344e21871c6 Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Fri, 20 Nov 2015 00:28:07 +0100 Subject: [PATCH 049/262] go-ipfs-config: Add correct access control headers to the default api config License: MIT Signed-off-by: Friedel Ziegelmayer --- config/init.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/config/init.go b/config/init.go index eaa23d28528..0119d734d3f 100644 --- a/config/init.go +++ b/config/init.go @@ -44,6 +44,16 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { API: "/ip4/127.0.0.1/tcp/5001", Gateway: "/ip4/127.0.0.1/tcp/8080", }, + API: API{ + HTTPHeaders: map[string][]string{ + "Access-Control-Allow-Headers": []string{ + "X-Stream-Output, X-Chunked-Output", + }, + "Access-Control-Expose-Headers": []string{ + "X-Stream-Output, X-Chunked-Output", + }, + }, + }, Bootstrap: BootstrapPeerStrings(bootstrapPeers), SupernodeRouting: *snr, From 511fb7e96e33f52fac94274240ce65bce2612343 Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Fri, 20 Nov 2015 20:25:25 +0100 Subject: [PATCH 050/262] go-ipfs-config: Add access-control-headers to gateway config License: MIT Signed-off-by: Friedel Ziegelmayer --- config/init.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/config/init.go b/config/init.go index 0119d734d3f..a59423b4c08 100644 --- a/config/init.go +++ b/config/init.go @@ -81,6 +81,14 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { Gateway: Gateway{ RootRedirect: "", Writable: false, + HTTPHeaders: map[string][]string{ + "Access-Control-Allow-Headers": []string{ + "X-Stream-Output, X-Chunked-Output", + }, + "Access-Control-Expose-Headers": []string{ + "X-Stream-Output, X-Chunked-Output", + }, + }, }, } From 8c25058225ff72b5fc88728cd5c091af11a603aa Mon Sep 17 00:00:00 2001 From: Jeromy Date: Mon, 30 Nov 2015 14:43:37 -0800 Subject: [PATCH 051/262] go-ipfs-config: hard code things License: MIT Signed-off-by: Jeromy --- config/init.go | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/config/init.go b/config/init.go index a59423b4c08..eaa23d28528 100644 --- a/config/init.go +++ b/config/init.go @@ -44,16 +44,6 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { API: "/ip4/127.0.0.1/tcp/5001", Gateway: "/ip4/127.0.0.1/tcp/8080", }, - API: API{ - HTTPHeaders: map[string][]string{ - "Access-Control-Allow-Headers": []string{ - "X-Stream-Output, X-Chunked-Output", - }, - "Access-Control-Expose-Headers": []string{ - "X-Stream-Output, X-Chunked-Output", - }, - }, - }, Bootstrap: BootstrapPeerStrings(bootstrapPeers), SupernodeRouting: *snr, @@ -81,14 +71,6 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { Gateway: Gateway{ RootRedirect: "", Writable: false, - HTTPHeaders: map[string][]string{ - "Access-Control-Allow-Headers": []string{ - "X-Stream-Output, X-Chunked-Output", - }, - "Access-Control-Expose-Headers": []string{ - "X-Stream-Output, X-Chunked-Output", - }, - }, }, } From 1f3ad375416edbda4ab255e3b2a373bf62a25853 Mon Sep 17 00:00:00 2001 From: Tommi Virtanen Date: Tue, 19 May 2015 15:32:41 -0700 Subject: [PATCH 052/262] go-ipfs-config: Remove Config file section "Datastore", it's not used This gives us a clean slate for the new code, avoiding leftovers. License: MIT Signed-off-by: Tommi Virtanen --- config/config.go | 3 ++- config/init.go | 6 ------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/config/config.go b/config/config.go index d8f5720e58d..8c834b4158b 100644 --- a/config/config.go +++ b/config/config.go @@ -18,7 +18,6 @@ var log = logging.Logger("config") // Config is used to load IPFS config files. 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 @@ -30,6 +29,8 @@ type Config struct { SupernodeRouting SupernodeClientConfig // local node's routing servers (if SupernodeRouting enabled) API API // local node's API settings Swarm SwarmConfig + + Datastore Datastore } const ( diff --git a/config/init.go b/config/init.go index eaa23d28528..1835833c568 100644 --- a/config/init.go +++ b/config/init.go @@ -11,11 +11,6 @@ import ( ) func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { - ds, err := datastoreConfig() - if err != nil { - return nil, err - } - identity, err := identityConfig(out, nBitsForKeypair) if err != nil { return nil, err @@ -47,7 +42,6 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { Bootstrap: BootstrapPeerStrings(bootstrapPeers), SupernodeRouting: *snr, - Datastore: *ds, Identity: identity, Discovery: Discovery{MDNS{ Enabled: true, From 3f419cc59902eaafd6bf650ca4971e61b14866d4 Mon Sep 17 00:00:00 2001 From: Tommi Virtanen Date: Wed, 20 May 2015 10:17:38 -0700 Subject: [PATCH 053/262] go-ipfs-config: Implement pluggable Datastore types, with nothing implemented yet License: MIT Signed-off-by: Tommi Virtanen --- config/config.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/config/config.go b/config/config.go index 8c834b4158b..d8f5720e58d 100644 --- a/config/config.go +++ b/config/config.go @@ -18,6 +18,7 @@ var log = logging.Logger("config") // Config is used to load IPFS config files. 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 @@ -29,8 +30,6 @@ type Config struct { SupernodeRouting SupernodeClientConfig // local node's routing servers (if SupernodeRouting enabled) API API // local node's API settings Swarm SwarmConfig - - Datastore Datastore } const ( From 45deffe50ea5823bd59c1d3ef412a4aac7c93402 Mon Sep 17 00:00:00 2001 From: Tommi Virtanen Date: Wed, 20 May 2015 14:32:23 -0700 Subject: [PATCH 054/262] go-ipfs-config: S3 datastore support To test it, set up an S3 bucket (in an AWS region that is not US Standard, for read-after-write consistency), run `ipfs init`, then edit `~/.ipfs/config` to say "Datastore": { "Type": "s3", "Region": "us-west-1", "Bucket": "mahbukkit", "ACL": "private" }, with the right values. Set `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` in the environment and you should be able to run `ipfs add` and `ipfs cat` and see the bucket be populated. No automated tests exist, unfortunately. S3 is thorny to simulate. License: MIT Signed-off-by: Tommi Virtanen --- config/datastore.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/config/datastore.go b/config/datastore.go index 6749a4c39a0..89ded36f1a2 100644 --- a/config/datastore.go +++ b/config/datastore.go @@ -1,5 +1,9 @@ package config +import ( + "encoding/json" +) + // DefaultDataStoreDirectory is the directory to store all the local IPFS data. const DefaultDataStoreDirectory = "datastore" @@ -10,6 +14,22 @@ 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 + + Params *json.RawMessage +} + +func (d *Datastore) ParamData() []byte { + if d.Params == nil { + return nil + } + + return []byte(*d.Params) +} + +type S3Datastore struct { + Region string `json:"region"` + Bucket string `json:"bucket"` + ACL string `json:"acl"` } // DataStorePath returns the default data store path given a configuration root From b94954635fcfa56766afa2e7e223b6db96f0fcfb Mon Sep 17 00:00:00 2001 From: rht Date: Thu, 12 Nov 2015 22:28:04 +0700 Subject: [PATCH 055/262] go-ipfs-config: Add config option for flatfs no-sync License: MIT Signed-off-by: rht --- config/datastore.go | 1 + 1 file changed, 1 insertion(+) diff --git a/config/datastore.go b/config/datastore.go index 89ded36f1a2..52582bd5cb5 100644 --- a/config/datastore.go +++ b/config/datastore.go @@ -16,6 +16,7 @@ type Datastore struct { GCPeriod string // in ns, us, ms, s, m, h Params *json.RawMessage + NoSync bool } func (d *Datastore) ParamData() []byte { From ac586580bac16082f5cfaa4e33b783977f963097 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Wed, 27 Jan 2016 14:28:34 -0800 Subject: [PATCH 056/262] go-ipfs-config: initial vendoring of libp2p outside of the repo with gx License: MIT Signed-off-by: Jeromy --- config/config.go | 2 +- config/identity.go | 2 +- config/init.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config/config.go b/config/config.go index d8f5720e58d..8ea2dbd28a9 100644 --- a/config/config.go +++ b/config/config.go @@ -10,7 +10,7 @@ import ( "strings" u "github.com/ipfs/go-ipfs/util" - logging "github.com/ipfs/go-ipfs/vendor/QmQg1J6vikuXF9oDvm4wpdeAUvvkVEKW1EYDw9HhTMnP2b/go-log" + logging "gx/ipfs/QmaPaGNE2GqnfJjRRpQuQuFHuJn4FZvsrGxdik4kgxCkBi/go-log" ) var log = logging.Logger("config") diff --git a/config/identity.go b/config/identity.go index d2298fbcd86..f938efc3346 100644 --- a/config/identity.go +++ b/config/identity.go @@ -2,7 +2,7 @@ package config import ( "encoding/base64" - ic "github.com/ipfs/go-ipfs/p2p/crypto" + ic "gx/ipfs/QmY3NAw959vbE1oJooP9HchcRdBsbxhgQsEZTRhKgvoSuC/go-libp2p/p2p/crypto" ) // Identity tracks the configuration of the local node's identity. diff --git a/config/init.go b/config/init.go index 1835833c568..74ff3ec6916 100644 --- a/config/init.go +++ b/config/init.go @@ -6,8 +6,8 @@ import ( "fmt" "io" - ci "github.com/ipfs/go-ipfs/p2p/crypto" - peer "github.com/ipfs/go-ipfs/p2p/peer" + ci "gx/ipfs/QmY3NAw959vbE1oJooP9HchcRdBsbxhgQsEZTRhKgvoSuC/go-libp2p/p2p/crypto" + peer "gx/ipfs/QmY3NAw959vbE1oJooP9HchcRdBsbxhgQsEZTRhKgvoSuC/go-libp2p/p2p/peer" ) func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { From 8ff4f93d942e0a7619acea377b2b8f9d7c587303 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Thu, 28 Jan 2016 09:43:06 -0800 Subject: [PATCH 057/262] go-ipfs-config: go-keyspace dep from libp2p added License: MIT Signed-off-by: Jeromy --- config/identity.go | 2 +- config/init.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/identity.go b/config/identity.go index f938efc3346..a1b944de7ac 100644 --- a/config/identity.go +++ b/config/identity.go @@ -2,7 +2,7 @@ package config import ( "encoding/base64" - ic "gx/ipfs/QmY3NAw959vbE1oJooP9HchcRdBsbxhgQsEZTRhKgvoSuC/go-libp2p/p2p/crypto" + ic "gx/ipfs/QmZxtCsPRgCnCXwVPUjcBiFckkG5NMYM4Pthwe6X4C8uQq/go-libp2p/p2p/crypto" ) // Identity tracks the configuration of the local node's identity. diff --git a/config/init.go b/config/init.go index 74ff3ec6916..e667067986f 100644 --- a/config/init.go +++ b/config/init.go @@ -6,8 +6,8 @@ import ( "fmt" "io" - ci "gx/ipfs/QmY3NAw959vbE1oJooP9HchcRdBsbxhgQsEZTRhKgvoSuC/go-libp2p/p2p/crypto" - peer "gx/ipfs/QmY3NAw959vbE1oJooP9HchcRdBsbxhgQsEZTRhKgvoSuC/go-libp2p/p2p/peer" + ci "gx/ipfs/QmZxtCsPRgCnCXwVPUjcBiFckkG5NMYM4Pthwe6X4C8uQq/go-libp2p/p2p/crypto" + peer "gx/ipfs/QmZxtCsPRgCnCXwVPUjcBiFckkG5NMYM4Pthwe6X4C8uQq/go-libp2p/p2p/peer" ) func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { From 389545c7508b308856223751b31e4653c729a355 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Thu, 28 Jan 2016 10:07:26 -0800 Subject: [PATCH 058/262] go-ipfs-config: correct go-log dep License: MIT Signed-off-by: Jeromy --- config/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index 8ea2dbd28a9..76280256164 100644 --- a/config/config.go +++ b/config/config.go @@ -10,7 +10,7 @@ import ( "strings" u "github.com/ipfs/go-ipfs/util" - logging "gx/ipfs/QmaPaGNE2GqnfJjRRpQuQuFHuJn4FZvsrGxdik4kgxCkBi/go-log" + logging "gx/ipfs/Qmazh5oNUVsDZTs2g59rq8aYQqwpss8tcUWQzor5sCCEuH/go-log" ) var log = logging.Logger("config") From 5bad15f8ee76a02b470d95640d851fb6eae4d408 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Sun, 31 Jan 2016 10:19:50 -0800 Subject: [PATCH 059/262] go-ipfs-config: update libp2p dep License: MIT Signed-off-by: Jeromy --- config/identity.go | 2 +- config/init.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/identity.go b/config/identity.go index a1b944de7ac..6e75abadb1e 100644 --- a/config/identity.go +++ b/config/identity.go @@ -2,7 +2,7 @@ package config import ( "encoding/base64" - ic "gx/ipfs/QmZxtCsPRgCnCXwVPUjcBiFckkG5NMYM4Pthwe6X4C8uQq/go-libp2p/p2p/crypto" + ic "gx/ipfs/QmQQCBoWhMZtStYuAAo2uDNNLit9n7yX5ANBecfjKq4XBn/go-libp2p/p2p/crypto" ) // Identity tracks the configuration of the local node's identity. diff --git a/config/init.go b/config/init.go index e667067986f..7c9c593e5cb 100644 --- a/config/init.go +++ b/config/init.go @@ -6,8 +6,8 @@ import ( "fmt" "io" - ci "gx/ipfs/QmZxtCsPRgCnCXwVPUjcBiFckkG5NMYM4Pthwe6X4C8uQq/go-libp2p/p2p/crypto" - peer "gx/ipfs/QmZxtCsPRgCnCXwVPUjcBiFckkG5NMYM4Pthwe6X4C8uQq/go-libp2p/p2p/peer" + ci "gx/ipfs/QmQQCBoWhMZtStYuAAo2uDNNLit9n7yX5ANBecfjKq4XBn/go-libp2p/p2p/crypto" + peer "gx/ipfs/QmQQCBoWhMZtStYuAAo2uDNNLit9n7yX5ANBecfjKq4XBn/go-libp2p/p2p/peer" ) func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { From 8a262c832aa41855c1424314d8e80bed6ced6626 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Sun, 31 Jan 2016 15:37:39 -0800 Subject: [PATCH 060/262] go-ipfs-config: do that last thing again License: MIT Signed-off-by: Jeromy --- config/identity.go | 2 +- config/init.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/identity.go b/config/identity.go index 6e75abadb1e..e09bedcdf80 100644 --- a/config/identity.go +++ b/config/identity.go @@ -2,7 +2,7 @@ package config import ( "encoding/base64" - ic "gx/ipfs/QmQQCBoWhMZtStYuAAo2uDNNLit9n7yX5ANBecfjKq4XBn/go-libp2p/p2p/crypto" + ic "gx/ipfs/QmUBogf4nUefBjmYjn6jfsfPJRkmDGSeMhNj4usRKq69f4/go-libp2p/p2p/crypto" ) // Identity tracks the configuration of the local node's identity. diff --git a/config/init.go b/config/init.go index 7c9c593e5cb..9bb7b4e0556 100644 --- a/config/init.go +++ b/config/init.go @@ -6,8 +6,8 @@ import ( "fmt" "io" - ci "gx/ipfs/QmQQCBoWhMZtStYuAAo2uDNNLit9n7yX5ANBecfjKq4XBn/go-libp2p/p2p/crypto" - peer "gx/ipfs/QmQQCBoWhMZtStYuAAo2uDNNLit9n7yX5ANBecfjKq4XBn/go-libp2p/p2p/peer" + ci "gx/ipfs/QmUBogf4nUefBjmYjn6jfsfPJRkmDGSeMhNj4usRKq69f4/go-libp2p/p2p/crypto" + peer "gx/ipfs/QmUBogf4nUefBjmYjn6jfsfPJRkmDGSeMhNj4usRKq69f4/go-libp2p/p2p/peer" ) func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { From a7c4694354fd5d71f715a5fb36731e0f53cb112f Mon Sep 17 00:00:00 2001 From: Jeromy Date: Tue, 9 Feb 2016 10:56:19 -0800 Subject: [PATCH 061/262] go-ipfs-config: Use gx vendored go-ipfs-utils where possible For the rest of the packages in util, move them to thirdparty and update the references. util is gone! License: MIT Signed-off-by: Jeromy --- config/bootstrap_peers.go | 2 +- config/config.go | 4 ++-- config/supernode.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config/bootstrap_peers.go b/config/bootstrap_peers.go index fa607c84252..c880913a170 100644 --- a/config/bootstrap_peers.go +++ b/config/bootstrap_peers.go @@ -4,7 +4,7 @@ import ( "errors" "fmt" - iaddr "github.com/ipfs/go-ipfs/util/ipfsaddr" + iaddr "github.com/ipfs/go-ipfs/thirdparty/ipfsaddr" ) // DefaultBootstrapAddresses are the hardcoded bootstrap addresses diff --git a/config/config.go b/config/config.go index 76280256164..bfe9be1de64 100644 --- a/config/config.go +++ b/config/config.go @@ -9,7 +9,7 @@ import ( "path/filepath" "strings" - u "github.com/ipfs/go-ipfs/util" + "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/mitchellh/go-homedir" logging "gx/ipfs/Qmazh5oNUVsDZTs2g59rq8aYQqwpss8tcUWQzor5sCCEuH/go-log" ) @@ -48,7 +48,7 @@ func PathRoot() (string, error) { dir := os.Getenv(EnvDir) var err error if len(dir) == 0 { - dir, err = u.TildeExpansion(DefaultPathRoot) + dir, err = homedir.Expand(DefaultPathRoot) } return dir, err } diff --git a/config/supernode.go b/config/supernode.go index 30ee6f22e55..de403fadd7d 100644 --- a/config/supernode.go +++ b/config/supernode.go @@ -1,6 +1,6 @@ package config -import "github.com/ipfs/go-ipfs/util/ipfsaddr" +import "github.com/ipfs/go-ipfs/thirdparty/ipfsaddr" // TODO replace with final servers before merge From 37118595eec54eb184c036f0b2976c622a509d42 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Wed, 9 Mar 2016 09:53:19 -0800 Subject: [PATCH 062/262] go-ipfs-config: update libp2p dep License: MIT Signed-off-by: Jeromy --- config/identity.go | 2 +- config/init.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/identity.go b/config/identity.go index e09bedcdf80..f54586ad3d5 100644 --- a/config/identity.go +++ b/config/identity.go @@ -2,7 +2,7 @@ package config import ( "encoding/base64" - ic "gx/ipfs/QmUBogf4nUefBjmYjn6jfsfPJRkmDGSeMhNj4usRKq69f4/go-libp2p/p2p/crypto" + ic "gx/ipfs/QmNefBbWHR9JEiP3KDVqZsBLQVRmH3GBG2D2Ke24SsFqfW/go-libp2p/p2p/crypto" ) // Identity tracks the configuration of the local node's identity. diff --git a/config/init.go b/config/init.go index 9bb7b4e0556..50ebbfa3a0b 100644 --- a/config/init.go +++ b/config/init.go @@ -6,8 +6,8 @@ import ( "fmt" "io" - ci "gx/ipfs/QmUBogf4nUefBjmYjn6jfsfPJRkmDGSeMhNj4usRKq69f4/go-libp2p/p2p/crypto" - peer "gx/ipfs/QmUBogf4nUefBjmYjn6jfsfPJRkmDGSeMhNj4usRKq69f4/go-libp2p/p2p/peer" + ci "gx/ipfs/QmNefBbWHR9JEiP3KDVqZsBLQVRmH3GBG2D2Ke24SsFqfW/go-libp2p/p2p/crypto" + peer "gx/ipfs/QmNefBbWHR9JEiP3KDVqZsBLQVRmH3GBG2D2Ke24SsFqfW/go-libp2p/p2p/peer" ) func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { From 7beb8be675148bfe9a2c0619fda44b8924050c8e Mon Sep 17 00:00:00 2001 From: Jeromy Date: Tue, 29 Mar 2016 19:18:14 -0700 Subject: [PATCH 063/262] go-ipfs-config: update utp and cleanup more godeps along the way License: MIT Signed-off-by: Jeromy --- config/identity.go | 2 +- config/init.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/identity.go b/config/identity.go index f54586ad3d5..f70b6fe03c8 100644 --- a/config/identity.go +++ b/config/identity.go @@ -2,7 +2,7 @@ package config import ( "encoding/base64" - ic "gx/ipfs/QmNefBbWHR9JEiP3KDVqZsBLQVRmH3GBG2D2Ke24SsFqfW/go-libp2p/p2p/crypto" + ic "gx/ipfs/QmSN2ELGRp4T9kjqiSsSNJRUeR9JKXzQEgwe1HH3tdSGbC/go-libp2p/p2p/crypto" ) // Identity tracks the configuration of the local node's identity. diff --git a/config/init.go b/config/init.go index 50ebbfa3a0b..1cbc9f4956a 100644 --- a/config/init.go +++ b/config/init.go @@ -6,8 +6,8 @@ import ( "fmt" "io" - ci "gx/ipfs/QmNefBbWHR9JEiP3KDVqZsBLQVRmH3GBG2D2Ke24SsFqfW/go-libp2p/p2p/crypto" - peer "gx/ipfs/QmNefBbWHR9JEiP3KDVqZsBLQVRmH3GBG2D2Ke24SsFqfW/go-libp2p/p2p/peer" + ci "gx/ipfs/QmSN2ELGRp4T9kjqiSsSNJRUeR9JKXzQEgwe1HH3tdSGbC/go-libp2p/p2p/crypto" + peer "gx/ipfs/QmSN2ELGRp4T9kjqiSsSNJRUeR9JKXzQEgwe1HH3tdSGbC/go-libp2p/p2p/peer" ) func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { From 0747b9cecdc6b498fa7ef7f70c6e58e3e0546d2c Mon Sep 17 00:00:00 2001 From: Lars Gierth Date: Mon, 28 Mar 2016 19:21:48 -0400 Subject: [PATCH 064/262] go-ipfs-config: gateway: enforce allowlist for path prefixes The gateway accepts an X-Ipfs-Path-Prefix header, and assumes that it is mounted in a reverse proxy like nginx, at this path. Links in directory listings, as well as trailing-slash redirects need to be rewritten with that prefix in mind. We don't want a potential attacker to be able to pass in arbitrary path prefixes, which would end up in redirects and directory listings, which is why every prefix has to be explicitly allowed in the config. Previously, we'd accept *any* X-Ipfs-Path-Prefix header. Example: We mount blog.ipfs.io (a dnslink page) at ipfs.io/blog. nginx_ipfs.conf: location /blog/ { rewrite "^/blog(/.*)$" $1 break; proxy_set_header Host blog.ipfs.io; proxy_set_header X-Ipfs-Gateway-Prefix /blog; proxy_pass http://127.0.0.1:8080; } .ipfs/config: "Gateway": { "PathPrefixes": ["/blog"], // ... }, dnslink: > dig TXT _dnslink.blog.ipfs.io dnslink=/ipfs/QmWcBjXPAEdhXDATV4ghUpkAonNBbiyFx1VmmHcQe9HEGd License: MIT Signed-off-by: Lars Gierth --- config/gateway.go | 1 + config/init.go | 1 + 2 files changed, 2 insertions(+) diff --git a/config/gateway.go b/config/gateway.go index 07bc9aad2cb..a8ba7059071 100644 --- a/config/gateway.go +++ b/config/gateway.go @@ -5,4 +5,5 @@ type Gateway struct { HTTPHeaders map[string][]string // HTTP headers to return with the gateway RootRedirect string Writable bool + PathPrefixes []string } diff --git a/config/init.go b/config/init.go index 1cbc9f4956a..3dbc1b3f522 100644 --- a/config/init.go +++ b/config/init.go @@ -65,6 +65,7 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { Gateway: Gateway{ RootRedirect: "", Writable: false, + PathPrefixes: []string{}, }, } From 1868295693e225f4b2884d80a83e568a0aeab2ea Mon Sep 17 00:00:00 2001 From: Jeromy Date: Wed, 6 Apr 2016 15:42:06 -0700 Subject: [PATCH 065/262] go-ipfs-config: switch to new libp2p with mss crypto License: MIT Signed-off-by: Jeromy --- config/identity.go | 2 +- config/init.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/identity.go b/config/identity.go index f70b6fe03c8..3a2f39d40c4 100644 --- a/config/identity.go +++ b/config/identity.go @@ -2,7 +2,7 @@ package config import ( "encoding/base64" - ic "gx/ipfs/QmSN2ELGRp4T9kjqiSsSNJRUeR9JKXzQEgwe1HH3tdSGbC/go-libp2p/p2p/crypto" + ic "gx/ipfs/QmZMehXD2w81qeVJP6r1mmocxwsD7kqAvuzGm2QWDw1H88/go-libp2p/p2p/crypto" ) // Identity tracks the configuration of the local node's identity. diff --git a/config/init.go b/config/init.go index 3dbc1b3f522..810cc99982c 100644 --- a/config/init.go +++ b/config/init.go @@ -6,8 +6,8 @@ import ( "fmt" "io" - ci "gx/ipfs/QmSN2ELGRp4T9kjqiSsSNJRUeR9JKXzQEgwe1HH3tdSGbC/go-libp2p/p2p/crypto" - peer "gx/ipfs/QmSN2ELGRp4T9kjqiSsSNJRUeR9JKXzQEgwe1HH3tdSGbC/go-libp2p/p2p/peer" + ci "gx/ipfs/QmZMehXD2w81qeVJP6r1mmocxwsD7kqAvuzGm2QWDw1H88/go-libp2p/p2p/crypto" + peer "gx/ipfs/QmZMehXD2w81qeVJP6r1mmocxwsD7kqAvuzGm2QWDw1H88/go-libp2p/p2p/peer" ) func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { From 46e32373f0647b956c3122fc7c1467b2249ac066 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Fri, 8 Apr 2016 13:11:30 -0700 Subject: [PATCH 066/262] go-ipfs-config: clean up dead code and config fields License: MIT Signed-off-by: Jeromy --- config/config.go | 1 - config/init.go | 14 ++------------ 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/config/config.go b/config/config.go index bfe9be1de64..8c8d2ec1ebf 100644 --- a/config/config.go +++ b/config/config.go @@ -21,7 +21,6 @@ type Config struct { 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 Discovery Discovery // local node's discovery mechanisms Ipns Ipns // Ipns settings Bootstrap []string // local nodes's bootstrap peer addresses diff --git a/config/init.go b/config/init.go index 810cc99982c..886aaac7567 100644 --- a/config/init.go +++ b/config/init.go @@ -21,11 +21,6 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { return nil, err } - snr, err := initSNRConfig() - if err != nil { - return nil, err - } - conf := &Config{ // setup the node's default addresses. @@ -40,9 +35,8 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { Gateway: "/ip4/127.0.0.1/tcp/8080", }, - Bootstrap: BootstrapPeerStrings(bootstrapPeers), - SupernodeRouting: *snr, - Identity: identity, + Bootstrap: BootstrapPeerStrings(bootstrapPeers), + Identity: identity, Discovery: Discovery{MDNS{ Enabled: true, Interval: 10, @@ -58,10 +52,6 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { ResolveCacheSize: 128, }, - // tracking ipfs version used to generate the init folder and adding - // update checker default setting. - Version: VersionDefaultValue(), - Gateway: Gateway{ RootRedirect: "", Writable: false, From 0d2853dbaa4d87ffed3d5611524ff7c400a2f396 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Fri, 8 Apr 2016 13:54:12 -0700 Subject: [PATCH 067/262] go-ipfs-config: remove test for removed dead config version fields License: MIT Signed-off-by: Jeromy --- config/version_test.go | 35 ----------------------------------- 1 file changed, 35 deletions(-) delete mode 100644 config/version_test.go diff --git a/config/version_test.go b/config/version_test.go deleted file mode 100644 index c4b8aeb5ac2..00000000000 --- a/config/version_test.go +++ /dev/null @@ -1,35 +0,0 @@ -package config - -import ( - "encoding/json" - "strings" - "testing" -) - -func TestAutoUpdateValues(t *testing.T) { - var tval struct { - AutoUpdate AutoUpdateSetting - } - tests := []struct { - input string - val AutoUpdateSetting - err error - }{ - {`{"hello":123}`, AutoUpdateNever, nil}, // zero value - {`{"AutoUpdate": "never"}`, AutoUpdateNever, nil}, - {`{"AutoUpdate": "patch"}`, AutoUpdatePatch, nil}, - {`{"AutoUpdate": "minor"}`, AutoUpdateMinor, nil}, - {`{"AutoUpdate": "major"}`, AutoUpdateMajor, nil}, - {`{"AutoUpdate": "blarg"}`, AutoUpdateMinor, ErrUnknownAutoUpdateSetting}, - } - - for i, tc := range tests { - if err := json.NewDecoder(strings.NewReader(tc.input)).Decode(&tval); err != tc.err { - t.Fatalf("%d failed - got err %q wanted %v", i, err, tc.err) - } - - if tval.AutoUpdate != tc.val { - t.Fatalf("%d failed - got val %q where we wanted %q", i, tval.AutoUpdate, tc.val) - } - } -} From 713fe1cdbd157f744cc4695cf29461bd313fac55 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Mon, 11 Apr 2016 12:52:54 -0700 Subject: [PATCH 068/262] go-ipfs-config: update libp2p dep to fix hanging listeners problem License: MIT Signed-off-by: Jeromy --- config/identity.go | 2 +- config/init.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/identity.go b/config/identity.go index 3a2f39d40c4..b09bb0317c9 100644 --- a/config/identity.go +++ b/config/identity.go @@ -2,7 +2,7 @@ package config import ( "encoding/base64" - ic "gx/ipfs/QmZMehXD2w81qeVJP6r1mmocxwsD7kqAvuzGm2QWDw1H88/go-libp2p/p2p/crypto" + ic "gx/ipfs/QmccGfZs3rzku8Bv6sTPH3bMUKD1EVod8srgRjt5csdmva/go-libp2p/p2p/crypto" ) // Identity tracks the configuration of the local node's identity. diff --git a/config/init.go b/config/init.go index 886aaac7567..6d1f185fd46 100644 --- a/config/init.go +++ b/config/init.go @@ -6,8 +6,8 @@ import ( "fmt" "io" - ci "gx/ipfs/QmZMehXD2w81qeVJP6r1mmocxwsD7kqAvuzGm2QWDw1H88/go-libp2p/p2p/crypto" - peer "gx/ipfs/QmZMehXD2w81qeVJP6r1mmocxwsD7kqAvuzGm2QWDw1H88/go-libp2p/p2p/peer" + ci "gx/ipfs/QmccGfZs3rzku8Bv6sTPH3bMUKD1EVod8srgRjt5csdmva/go-libp2p/p2p/crypto" + peer "gx/ipfs/QmccGfZs3rzku8Bv6sTPH3bMUKD1EVod8srgRjt5csdmva/go-libp2p/p2p/peer" ) func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { From 21887fac8bb04ae0f0ad34daf0cac2ad3c37e40a Mon Sep 17 00:00:00 2001 From: Lars Gierth Date: Thu, 7 Apr 2016 17:01:23 -0400 Subject: [PATCH 069/262] go-ipfs-config: repo: properly init Datastore config, and leave it be We didn't previously initialize the Datastore config section. The respective function exists, but was dead code up until now. This lead to weird decisions like the GC code deciding on defaults, and writing these to the config file. Don't want GC to touch the config. License: MIT Signed-off-by: Lars Gierth --- config/init.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/config/init.go b/config/init.go index 6d1f185fd46..01a360bd94c 100644 --- a/config/init.go +++ b/config/init.go @@ -21,6 +21,11 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { return nil, err } + datastore, err := datastoreConfig() + if err != nil { + return nil, err + } + conf := &Config{ // setup the node's default addresses. @@ -35,6 +40,7 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { Gateway: "/ip4/127.0.0.1/tcp/8080", }, + Datastore: datastore, Bootstrap: BootstrapPeerStrings(bootstrapPeers), Identity: identity, Discovery: Discovery{MDNS{ @@ -62,12 +68,12 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { return conf, nil } -func datastoreConfig() (*Datastore, error) { +func datastoreConfig() (Datastore, error) { dspath, err := DataStorePath("") if err != nil { - return nil, err + return Datastore{}, err } - return &Datastore{ + return Datastore{ Path: dspath, Type: "leveldb", StorageMax: "10GB", From 1244da163c9e47bdaa17afe170616d4f6e695460 Mon Sep 17 00:00:00 2001 From: Lars Gierth Date: Sat, 16 Apr 2016 21:23:47 -0700 Subject: [PATCH 070/262] go-ipfs-config: Update go-libp2p License: MIT Signed-off-by: Lars Gierth --- config/identity.go | 2 +- config/init.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/identity.go b/config/identity.go index b09bb0317c9..74d5c681bf4 100644 --- a/config/identity.go +++ b/config/identity.go @@ -2,7 +2,7 @@ package config import ( "encoding/base64" - ic "gx/ipfs/QmccGfZs3rzku8Bv6sTPH3bMUKD1EVod8srgRjt5csdmva/go-libp2p/p2p/crypto" + ic "gx/ipfs/QmYgaiNVVL7f2nydijAwpDRunRkmxfu3PoK87Y3pH84uAW/go-libp2p/p2p/crypto" ) // Identity tracks the configuration of the local node's identity. diff --git a/config/init.go b/config/init.go index 01a360bd94c..f3887178242 100644 --- a/config/init.go +++ b/config/init.go @@ -6,8 +6,8 @@ import ( "fmt" "io" - ci "gx/ipfs/QmccGfZs3rzku8Bv6sTPH3bMUKD1EVod8srgRjt5csdmva/go-libp2p/p2p/crypto" - peer "gx/ipfs/QmccGfZs3rzku8Bv6sTPH3bMUKD1EVod8srgRjt5csdmva/go-libp2p/p2p/peer" + ci "gx/ipfs/QmYgaiNVVL7f2nydijAwpDRunRkmxfu3PoK87Y3pH84uAW/go-libp2p/p2p/crypto" + peer "gx/ipfs/QmYgaiNVVL7f2nydijAwpDRunRkmxfu3PoK87Y3pH84uAW/go-libp2p/p2p/peer" ) func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { From 7c3d8a108f4a9bba312f762eb3897d7b17795963 Mon Sep 17 00:00:00 2001 From: Lars Gierth Date: Sat, 16 Apr 2016 21:38:22 -0700 Subject: [PATCH 071/262] go-ipfs-config: Use extracted go-libp2p-crypto, -secio, -peer packages License: MIT Signed-off-by: Lars Gierth --- config/identity.go | 2 +- config/init.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/identity.go b/config/identity.go index 74d5c681bf4..05a44dc4860 100644 --- a/config/identity.go +++ b/config/identity.go @@ -2,7 +2,7 @@ package config import ( "encoding/base64" - ic "gx/ipfs/QmYgaiNVVL7f2nydijAwpDRunRkmxfu3PoK87Y3pH84uAW/go-libp2p/p2p/crypto" + ic "gx/ipfs/QmUEUu1CM8bxBJxc3ZLojAi8evhTr4byQogWstABet79oY/go-libp2p-crypto" ) // Identity tracks the configuration of the local node's identity. diff --git a/config/init.go b/config/init.go index f3887178242..22bf8e26c44 100644 --- a/config/init.go +++ b/config/init.go @@ -6,8 +6,8 @@ import ( "fmt" "io" - ci "gx/ipfs/QmYgaiNVVL7f2nydijAwpDRunRkmxfu3PoK87Y3pH84uAW/go-libp2p/p2p/crypto" - peer "gx/ipfs/QmYgaiNVVL7f2nydijAwpDRunRkmxfu3PoK87Y3pH84uAW/go-libp2p/p2p/peer" + ci "gx/ipfs/QmUEUu1CM8bxBJxc3ZLojAi8evhTr4byQogWstABet79oY/go-libp2p-crypto" + peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer" ) func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { From ef1a5c04a852cf3b0e5fa031ac3514059985e1da Mon Sep 17 00:00:00 2001 From: Richard Littauer Date: Fri, 29 Apr 2016 16:57:19 -0400 Subject: [PATCH 072/262] go-ipfs-config: Capitalized `NOTE`, first letter of following word License: MIT Signed-off-by: Richard Littauer --- config/bootstrap_peers.go | 2 +- config/init.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/bootstrap_peers.go b/config/bootstrap_peers.go index c880913a170..db6bad2e662 100644 --- a/config/bootstrap_peers.go +++ b/config/bootstrap_peers.go @@ -11,7 +11,7 @@ import ( // 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 +// 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 DefaultBootstrapAddresses = []string{ "/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ", // mars.i.ipfs.io diff --git a/config/init.go b/config/init.go index 22bf8e26c44..79751994771 100644 --- a/config/init.go +++ b/config/init.go @@ -29,7 +29,7 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { conf := &Config{ // setup the node's default addresses. - // Note: two swarm listen addrs, one tcp, one utp. + // NOTE: two swarm listen addrs, one tcp, one utp. Addresses: Addresses{ Swarm: []string{ "/ip4/0.0.0.0/tcp/4001", From 641003089befac001dd3deb4b134fae6c68883e2 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Wed, 4 May 2016 22:56:39 +0200 Subject: [PATCH 073/262] go-ipfs-config: Update go-log to 1.1.0 and fix calls to go-log.Uuid License: MIT Signed-off-by: Hector Sanjuan --- config/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index 8c8d2ec1ebf..d910ccf65cd 100644 --- a/config/config.go +++ b/config/config.go @@ -10,7 +10,7 @@ import ( "strings" "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/mitchellh/go-homedir" - logging "gx/ipfs/Qmazh5oNUVsDZTs2g59rq8aYQqwpss8tcUWQzor5sCCEuH/go-log" + logging "gx/ipfs/QmaDNZ4QMdBdku1YZWBysufYyoQt1negQGNav6PLYarbY8/go-log" ) var log = logging.Logger("config") From b5c55cf2a1019707bd2e528e9c061030ecefd0fc Mon Sep 17 00:00:00 2001 From: Jeromy Date: Tue, 10 May 2016 16:06:28 -0700 Subject: [PATCH 074/262] go-ipfs-config: update libp2p with go-multiaddr and go-stream-muxer updates License: MIT Signed-off-by: Jeromy --- config/init.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/init.go b/config/init.go index 79751994771..67179d2e091 100644 --- a/config/init.go +++ b/config/init.go @@ -7,7 +7,7 @@ import ( "io" ci "gx/ipfs/QmUEUu1CM8bxBJxc3ZLojAi8evhTr4byQogWstABet79oY/go-libp2p-crypto" - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer" + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer" ) func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { From e36dc46a632e9ecd8821499ae6a6cdc423e41d6c Mon Sep 17 00:00:00 2001 From: Jeromy Date: Tue, 17 May 2016 10:23:10 -0700 Subject: [PATCH 075/262] go-ipfs-config: update go-libp2p 3.2.2, nil maddr fixes License: MIT Signed-off-by: Jeromy --- config/init.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/init.go b/config/init.go index 67179d2e091..f8f4a4890ea 100644 --- a/config/init.go +++ b/config/init.go @@ -7,7 +7,7 @@ import ( "io" ci "gx/ipfs/QmUEUu1CM8bxBJxc3ZLojAi8evhTr4byQogWstABet79oY/go-libp2p-crypto" - peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer" + peer "gx/ipfs/QmbyvM8zRFDkbFdYyt1MnevUMJ62SiSGbfDFZ3Z8nkrzr4/go-libp2p-peer" ) func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { From 705652ea637081daf7118227fc80e78d8ba0aac7 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Tue, 17 May 2016 20:42:35 +0200 Subject: [PATCH 076/262] go-ipfs-config: Add CORS headers to Read Only Gateway Default config License: MIT Signed-off-by: Jakub Sztandera --- config/init.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/config/init.go b/config/init.go index f8f4a4890ea..35ccda36b55 100644 --- a/config/init.go +++ b/config/init.go @@ -62,6 +62,11 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { RootRedirect: "", Writable: false, PathPrefixes: []string{}, + HTTPHeaders: map[string][]string{ + "Access-Control-Allow-Origin": []string{"*"}, + "Access-Control-Allow-Methods": []string{"GET"}, + "Access-Control-Allow-Headers": []string{"X-Requested-With"}, + }, }, } From f48cecdd37cf35cb6e5698b7190d774e38f8b80b Mon Sep 17 00:00:00 2001 From: Jeromy Date: Wed, 1 Jun 2016 15:51:39 -0700 Subject: [PATCH 077/262] go-ipfs-config: update libp2p to v3.3.1 License: MIT Signed-off-by: Jeromy --- config/init.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/init.go b/config/init.go index f8f4a4890ea..de467fe084c 100644 --- a/config/init.go +++ b/config/init.go @@ -6,8 +6,8 @@ import ( "fmt" "io" + peer "gx/ipfs/QmQGwpJy9P4yXZySmqkZEXCmbBpJUb8xntCv8Ca4taZwDC/go-libp2p-peer" ci "gx/ipfs/QmUEUu1CM8bxBJxc3ZLojAi8evhTr4byQogWstABet79oY/go-libp2p-crypto" - peer "gx/ipfs/QmbyvM8zRFDkbFdYyt1MnevUMJ62SiSGbfDFZ3Z8nkrzr4/go-libp2p-peer" ) func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { From c82b5816501c10dece6159656c7dfb454b94bedf Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Thu, 9 Jun 2016 22:12:52 +0200 Subject: [PATCH 078/262] go-ipfs-config: Update go-log https://github.com/ipfs/go-log/pull/3 License: MIT Signed-off-by: Jakub Sztandera --- config/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index d910ccf65cd..b2f1fae4e62 100644 --- a/config/config.go +++ b/config/config.go @@ -10,7 +10,7 @@ import ( "strings" "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/mitchellh/go-homedir" - logging "gx/ipfs/QmaDNZ4QMdBdku1YZWBysufYyoQt1negQGNav6PLYarbY8/go-log" + logging "gx/ipfs/QmYtB7Qge8cJpXc4irsEp8zRqfnZMBeB7aTrMEkPk67DRv/go-log" ) var log = logging.Logger("config") From c36294a933e693ec2297ee6558670033a01e9139 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Fri, 24 Jun 2016 18:38:07 +0200 Subject: [PATCH 079/262] go-ipfs-config: Update go-log in whole dependency tree (#2898) * Update golog in go-ipfs License: MIT Signed-off-by: Jakub Sztandera * Update go-libp2p for go-log License: MIT Signed-off-by: Jakub Sztandera * Update go-libp2p-secio for go-log License: MIT Signed-off-by: Jakub Sztandera * Update go-libp2p-crypto for go-log License: MIT Signed-off-by: Jakub Sztandera * Update go-libp2p-peer for go-log License: MIT Signed-off-by: Jakub Sztandera * Import peersore, it wasn't imported License: MIT Signed-off-by: Jakub Sztandera * Update peerstore License: MIT Signed-off-by: Jakub Sztandera * Update peer License: MIT Signed-off-by: Jakub Sztandera * Update secio License: MIT Signed-off-by: Jakub Sztandera * Update go-libp2p License: MIT Signed-off-by: Jakub Sztandera --- config/config.go | 2 +- config/identity.go | 2 +- config/init.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config/config.go b/config/config.go index b2f1fae4e62..4488bba083d 100644 --- a/config/config.go +++ b/config/config.go @@ -10,7 +10,7 @@ import ( "strings" "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/mitchellh/go-homedir" - logging "gx/ipfs/QmYtB7Qge8cJpXc4irsEp8zRqfnZMBeB7aTrMEkPk67DRv/go-log" + logging "gx/ipfs/QmNQynaz7qfriSUJkiEZUrm2Wen1u3Kj9goZzWtrPyu7XR/go-log" ) var log = logging.Logger("config") diff --git a/config/identity.go b/config/identity.go index 05a44dc4860..fe88a34b0d7 100644 --- a/config/identity.go +++ b/config/identity.go @@ -2,7 +2,7 @@ package config import ( "encoding/base64" - ic "gx/ipfs/QmUEUu1CM8bxBJxc3ZLojAi8evhTr4byQogWstABet79oY/go-libp2p-crypto" + ic "gx/ipfs/QmUWER4r4qMvaCnX5zREcfyiWN7cXN9g3a7fkRqNz8qWPP/go-libp2p-crypto" ) // Identity tracks the configuration of the local node's identity. diff --git a/config/init.go b/config/init.go index 8e248c12902..ae5c813b7a3 100644 --- a/config/init.go +++ b/config/init.go @@ -6,8 +6,8 @@ import ( "fmt" "io" - peer "gx/ipfs/QmQGwpJy9P4yXZySmqkZEXCmbBpJUb8xntCv8Ca4taZwDC/go-libp2p-peer" - ci "gx/ipfs/QmUEUu1CM8bxBJxc3ZLojAi8evhTr4byQogWstABet79oY/go-libp2p-crypto" + peer "gx/ipfs/QmRBqJF7hb8ZSpRcMwUt8hNhydWcxGEhtk81HKq6oUwKvs/go-libp2p-peer" + ci "gx/ipfs/QmUWER4r4qMvaCnX5zREcfyiWN7cXN9g3a7fkRqNz8qWPP/go-libp2p-crypto" ) func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { From 6135edf075f54b019b6cf04b79d84d6200a81e4a Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Fri, 24 Jun 2016 22:10:31 +0200 Subject: [PATCH 080/262] go-ipfs-config: core: Add config option for datastore read rehashing License: MIT Signed-off-by: Jakub Sztandera --- config/datastore.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/config/datastore.go b/config/datastore.go index 52582bd5cb5..2b9bf600df2 100644 --- a/config/datastore.go +++ b/config/datastore.go @@ -15,8 +15,9 @@ type Datastore struct { StorageGCWatermark int64 // in percentage to multiply on StorageMax GCPeriod string // in ns, us, ms, s, m, h - Params *json.RawMessage - NoSync bool + Params *json.RawMessage + NoSync bool + HashOnRead bool } func (d *Datastore) ParamData() []byte { From 35108597dd505719e2f85c150bb942fa4f88ecee Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Fri, 24 Jun 2016 22:22:38 +0200 Subject: [PATCH 081/262] go-ipfs-config: config: Add explicit default value for HashOnRead License: MIT Signed-off-by: Jakub Sztandera --- config/init.go | 1 + 1 file changed, 1 insertion(+) diff --git a/config/init.go b/config/init.go index ae5c813b7a3..8a6c72222ce 100644 --- a/config/init.go +++ b/config/init.go @@ -84,6 +84,7 @@ func datastoreConfig() (Datastore, error) { StorageMax: "10GB", StorageGCWatermark: 90, // 90% GCPeriod: "1h", + HashOnRead: false, }, nil } From e8912c13ea2a5ee95b422cf1b18b00ec38d3e7ea Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Fri, 8 Jul 2016 23:21:08 +0200 Subject: [PATCH 082/262] go-ipfs-config: core/commands: do not show PrivKey in config if it is null License: MIT Signed-off-by: Jakub Sztandera --- config/identity.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/identity.go b/config/identity.go index fe88a34b0d7..d997bc2b632 100644 --- a/config/identity.go +++ b/config/identity.go @@ -8,7 +8,7 @@ import ( // Identity tracks the configuration of the local node's identity. type Identity struct { PeerID string - PrivKey string + PrivKey string `json:",omitempty"` } // DecodePrivateKey is a helper to decode the users PrivateKey From 30b5a1f28c2aae0169ca052d203583a81e15a548 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Fri, 15 Jul 2016 21:38:46 +0100 Subject: [PATCH 083/262] go-ipfs-config: config: add config option for bloom filter License: MIT Signed-off-by: Jakub Sztandera --- config/datastore.go | 7 ++++--- config/init.go | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/config/datastore.go b/config/datastore.go index 2b9bf600df2..2b861a113cf 100644 --- a/config/datastore.go +++ b/config/datastore.go @@ -15,9 +15,10 @@ type Datastore struct { StorageGCWatermark int64 // in percentage to multiply on StorageMax GCPeriod string // in ns, us, ms, s, m, h - Params *json.RawMessage - NoSync bool - HashOnRead bool + Params *json.RawMessage + NoSync bool + HashOnRead bool + BloomFilterSize int } func (d *Datastore) ParamData() []byte { diff --git a/config/init.go b/config/init.go index 8a6c72222ce..5123e39e9e4 100644 --- a/config/init.go +++ b/config/init.go @@ -85,6 +85,7 @@ func datastoreConfig() (Datastore, error) { StorageGCWatermark: 90, // 90% GCPeriod: "1h", HashOnRead: false, + BloomFilterSize: 0, }, nil } From f5e4f1861c83b2e24a421b877b7f7c84d5b22a99 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Fri, 19 Aug 2016 16:47:29 -0700 Subject: [PATCH 084/262] go-ipfs-config: reprovider: add config option to set reprovide interval License: MIT Signed-off-by: Jeromy --- config/config.go | 2 ++ config/init.go | 3 +++ config/reprovider.go | 5 +++++ 3 files changed, 10 insertions(+) create mode 100644 config/reprovider.go diff --git a/config/config.go b/config/config.go index 4488bba083d..4a3995a9993 100644 --- a/config/config.go +++ b/config/config.go @@ -29,6 +29,8 @@ type Config struct { SupernodeRouting SupernodeClientConfig // local node's routing servers (if SupernodeRouting enabled) API API // local node's API settings Swarm SwarmConfig + + Reprovider Reprovider } const ( diff --git a/config/init.go b/config/init.go index 5123e39e9e4..ac0c8f23bb3 100644 --- a/config/init.go +++ b/config/init.go @@ -68,6 +68,9 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { "Access-Control-Allow-Headers": []string{"X-Requested-With"}, }, }, + Reprovider: Reprovider{ + Interval: "12h", + }, } return conf, nil diff --git a/config/reprovider.go b/config/reprovider.go new file mode 100644 index 00000000000..53cf293ab61 --- /dev/null +++ b/config/reprovider.go @@ -0,0 +1,5 @@ +package config + +type Reprovider struct { + Interval string // Time period to reprovide locally stored objects to the network +} From 16dd9472bdbcdec945e05bf8ba9a66ba5715b6b1 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Mon, 22 Aug 2016 22:29:25 -0700 Subject: [PATCH 085/262] go-ipfs-config: update deps for libp2p 3.4.0 License: MIT Signed-off-by: Jeromy --- config/config.go | 2 +- config/identity.go | 2 +- config/init.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config/config.go b/config/config.go index 4a3995a9993..d367ac30421 100644 --- a/config/config.go +++ b/config/config.go @@ -10,7 +10,7 @@ import ( "strings" "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/mitchellh/go-homedir" - logging "gx/ipfs/QmNQynaz7qfriSUJkiEZUrm2Wen1u3Kj9goZzWtrPyu7XR/go-log" + logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log" ) var log = logging.Logger("config") diff --git a/config/identity.go b/config/identity.go index d997bc2b632..edac9298338 100644 --- a/config/identity.go +++ b/config/identity.go @@ -2,7 +2,7 @@ package config import ( "encoding/base64" - ic "gx/ipfs/QmUWER4r4qMvaCnX5zREcfyiWN7cXN9g3a7fkRqNz8qWPP/go-libp2p-crypto" + ic "gx/ipfs/QmVoi5es8D5fNHZDqoW6DgDAEPEV5hQp8GBz161vZXiwpQ/go-libp2p-crypto" ) // Identity tracks the configuration of the local node's identity. diff --git a/config/init.go b/config/init.go index ac0c8f23bb3..d640b1b9c31 100644 --- a/config/init.go +++ b/config/init.go @@ -6,8 +6,8 @@ import ( "fmt" "io" - peer "gx/ipfs/QmRBqJF7hb8ZSpRcMwUt8hNhydWcxGEhtk81HKq6oUwKvs/go-libp2p-peer" - ci "gx/ipfs/QmUWER4r4qMvaCnX5zREcfyiWN7cXN9g3a7fkRqNz8qWPP/go-libp2p-crypto" + ci "gx/ipfs/QmVoi5es8D5fNHZDqoW6DgDAEPEV5hQp8GBz161vZXiwpQ/go-libp2p-crypto" + peer "gx/ipfs/QmWtbQU15LaB5B1JC2F7TV9P4K88vD3PpA4AJrwfCjhML8/go-libp2p-peer" ) func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { From b4fd445e0e35ed6d2285c7d887f92d85ef69fb2c Mon Sep 17 00:00:00 2001 From: Jeromy Date: Mon, 29 Aug 2016 14:56:55 -0700 Subject: [PATCH 086/262] go-ipfs-config: config: guard against privkey being overwritten in fsrepo setConfig License: MIT Signed-off-by: Jeromy --- config/identity.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config/identity.go b/config/identity.go index d997bc2b632..55fc11e70e0 100644 --- a/config/identity.go +++ b/config/identity.go @@ -5,6 +5,10 @@ import ( ic "gx/ipfs/QmUWER4r4qMvaCnX5zREcfyiWN7cXN9g3a7fkRqNz8qWPP/go-libp2p-crypto" ) +const IdentityTag = "Identity" +const PrivKeyTag = "PrivKey" +const PrivKeySelector = IdentityTag + "." + PrivKeyTag + // Identity tracks the configuration of the local node's identity. type Identity struct { PeerID string From d22951764f27daea79c61ebd80226155456f61e1 Mon Sep 17 00:00:00 2001 From: George Antoniadis Date: Sat, 10 Sep 2016 23:22:17 +0100 Subject: [PATCH 087/262] go-ipfs-config: Extract peerset, update peer, peerset, secio, libp2p License: MIT Signed-off-by: George Antoniadis --- config/init.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/init.go b/config/init.go index d640b1b9c31..7e17faa0513 100644 --- a/config/init.go +++ b/config/init.go @@ -7,7 +7,7 @@ import ( "io" ci "gx/ipfs/QmVoi5es8D5fNHZDqoW6DgDAEPEV5hQp8GBz161vZXiwpQ/go-libp2p-crypto" - peer "gx/ipfs/QmWtbQU15LaB5B1JC2F7TV9P4K88vD3PpA4AJrwfCjhML8/go-libp2p-peer" + peer "gx/ipfs/QmWXjJo15p4pzT7cayEwZi2sWgJqLnGDof6ZGMh9xBgU1p/go-libp2p-peer" ) func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { From 3e6db54da249a0c99a20c14bc2f4ef2439697500 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Wed, 5 Oct 2016 15:49:08 -0700 Subject: [PATCH 088/262] go-ipfs-config: update to libp2p 4.0.1 and propogate other changes License: MIT Signed-off-by: Jeromy --- config/identity.go | 2 +- config/init.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/identity.go b/config/identity.go index 61e11cf5b29..ca89ae72f3d 100644 --- a/config/identity.go +++ b/config/identity.go @@ -2,7 +2,7 @@ package config import ( "encoding/base64" - ic "gx/ipfs/QmVoi5es8D5fNHZDqoW6DgDAEPEV5hQp8GBz161vZXiwpQ/go-libp2p-crypto" + ic "gx/ipfs/QmfWDLQjGjVe4fr5CoztYW2DYYjRysMJrFe1RCsXLPTf46/go-libp2p-crypto" ) const IdentityTag = "Identity" diff --git a/config/init.go b/config/init.go index 7e17faa0513..edb5408b2f3 100644 --- a/config/init.go +++ b/config/init.go @@ -6,8 +6,8 @@ import ( "fmt" "io" - ci "gx/ipfs/QmVoi5es8D5fNHZDqoW6DgDAEPEV5hQp8GBz161vZXiwpQ/go-libp2p-crypto" - peer "gx/ipfs/QmWXjJo15p4pzT7cayEwZi2sWgJqLnGDof6ZGMh9xBgU1p/go-libp2p-peer" + peer "gx/ipfs/QmfMmLGoKzCHDN7cGgk64PJr4iipzidDRME8HABSJqvmhC/go-libp2p-peer" + ci "gx/ipfs/QmfWDLQjGjVe4fr5CoztYW2DYYjRysMJrFe1RCsXLPTf46/go-libp2p-crypto" ) func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { From ed67b7bf9a76ef829fa6327ec9e89ffcbdfc0191 Mon Sep 17 00:00:00 2001 From: Richard Littauer Date: Fri, 1 Jul 2016 18:36:55 +0100 Subject: [PATCH 089/262] go-ipfs-config: Changed so only explicit ipfs cli commands are lowercased License: MIT Signed-off-by: Richard Littauer --- config/bootstrap_peers.go | 2 +- config/config.go | 2 +- config/tour.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/bootstrap_peers.go b/config/bootstrap_peers.go index db6bad2e662..788112ec0aa 100644 --- a/config/bootstrap_peers.go +++ b/config/bootstrap_peers.go @@ -8,7 +8,7 @@ import ( ) // DefaultBootstrapAddresses are the hardcoded bootstrap addresses -// for ipfs. they are nodes run by the ipfs team. docs on these later. +// 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 diff --git a/config/config.go b/config/config.go index d367ac30421..898cf56a472 100644 --- a/config/config.go +++ b/config/config.go @@ -15,7 +15,7 @@ import ( var log = logging.Logger("config") -// Config is used to load IPFS config files. +// Config is used to load ipfs config files. type Config struct { Identity Identity // local node's peer identity Datastore Datastore // local node's storage diff --git a/config/tour.go b/config/tour.go index cf9aef35502..e22d8453f51 100644 --- a/config/tour.go +++ b/config/tour.go @@ -1,6 +1,6 @@ package config -// Tour stores the ipfs tour read-list and resume point +// Tour stores the 'ipfs tour' read-list and resume point type Tour struct { Last string // last tour topic read // Done []string // all topics done so far From 07559a265a32f44a36871f63da81c071b3e61a76 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Fri, 11 Nov 2016 10:31:24 -0800 Subject: [PATCH 090/262] go-ipfs-config: add config option to disable bandwidth metrics License: MIT Signed-off-by: Jeromy --- config/swarm.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/swarm.go b/config/swarm.go index d398b3d80af..7d074d996d2 100644 --- a/config/swarm.go +++ b/config/swarm.go @@ -1,5 +1,6 @@ package config type SwarmConfig struct { - AddrFilters []string + AddrFilters []string + DisableBandwidthMetrics bool } From 608f6f378cfc6d2c4288249328ebedb10735dab7 Mon Sep 17 00:00:00 2001 From: Lars Gierth Date: Sun, 18 Dec 2016 05:52:56 +0100 Subject: [PATCH 091/262] go-ipfs-config: bootstrap: add a few /ip6 nodes License: MIT Signed-off-by: Lars Gierth --- config/bootstrap_peers.go | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/config/bootstrap_peers.go b/config/bootstrap_peers.go index 788112ec0aa..ef9a5222e00 100644 --- a/config/bootstrap_peers.go +++ b/config/bootstrap_peers.go @@ -14,15 +14,23 @@ import ( // 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 DefaultBootstrapAddresses = []string{ - "/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ", // mars.i.ipfs.io - "/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z", // neptune.i.ipfs.io - "/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM", // pluto.i.ipfs.io - "/ip4/162.243.248.213/tcp/4001/ipfs/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm", // uranus.i.ipfs.io - "/ip4/128.199.219.111/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu", // saturn.i.ipfs.io - "/ip4/104.236.76.40/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64", // venus.i.ipfs.io - "/ip4/178.62.158.247/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd", // earth.i.ipfs.io - "/ip4/178.62.61.185/tcp/4001/ipfs/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3", // mercury.i.ipfs.io - "/ip4/104.236.151.122/tcp/4001/ipfs/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx", // jupiter.i.ipfs.io + "/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ", // mars.i.ipfs.io + "/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z", // neptune.i.ipfs.io + "/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM", // pluto.i.ipfs.io + "/ip4/162.243.248.213/tcp/4001/ipfs/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm", // uranus.i.ipfs.io + "/ip4/128.199.219.111/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu", // saturn.i.ipfs.io + "/ip4/104.236.76.40/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64", // venus.i.ipfs.io + "/ip4/178.62.158.247/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd", // earth.i.ipfs.io + "/ip4/178.62.61.185/tcp/4001/ipfs/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3", // mercury.i.ipfs.io + "/ip4/104.236.151.122/tcp/4001/ipfs/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx", // jupiter.i.ipfs.io + "/ip6/2604:a880:1:20::1f9:9001/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z", // neptune.i.ipfs.io + "/ip6/2604:a880:1:20::203:d001/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM", // pluto.i.ipfs.io + "/ip6/2604:a880:0:1010::23:d001/tcp/4001/ipfs/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm", // uranus.i.ipfs.io + "/ip6/2400:6180:0:d0::151:6001/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu", // saturn.i.ipfs.io + "/ip6/2604:a880:800:10::4a:5001/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64", // venus.i.ipfs.io + "/ip6/2a03:b0c0:0:1010::23:1001/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd", // earth.i.ipfs.io + "/ip6/2a03:b0c0:1:d0::e7:1/tcp/4001/ipfs/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3", // mercury.i.ipfs.io + "/ip6/2604:a880:1:20::1d9:6001/tcp/4001/ipfs/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx", // jupiter.i.ipfs.io } // BootstrapPeer is a peer used to bootstrap the network. From 90644b31309f7d98775a875dbb912ddf0bd8cc7f Mon Sep 17 00:00:00 2001 From: Jeromy Date: Thu, 2 Feb 2017 20:09:02 -0800 Subject: [PATCH 092/262] go-ipfs-config: update go-multihash and bubble up deps License: MIT Signed-off-by: Jeromy --- config/identity.go | 2 +- config/init.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/identity.go b/config/identity.go index ca89ae72f3d..d8420cc54ec 100644 --- a/config/identity.go +++ b/config/identity.go @@ -2,7 +2,7 @@ package config import ( "encoding/base64" - ic "gx/ipfs/QmfWDLQjGjVe4fr5CoztYW2DYYjRysMJrFe1RCsXLPTf46/go-libp2p-crypto" + ic "gx/ipfs/QmNiCwBNA8MWDADTFVq1BonUEJbS2SvjAoNkZZrhEwcuUi/go-libp2p-crypto" ) const IdentityTag = "Identity" diff --git a/config/init.go b/config/init.go index edb5408b2f3..28782c8f335 100644 --- a/config/init.go +++ b/config/init.go @@ -6,8 +6,8 @@ import ( "fmt" "io" - peer "gx/ipfs/QmfMmLGoKzCHDN7cGgk64PJr4iipzidDRME8HABSJqvmhC/go-libp2p-peer" - ci "gx/ipfs/QmfWDLQjGjVe4fr5CoztYW2DYYjRysMJrFe1RCsXLPTf46/go-libp2p-crypto" + ci "gx/ipfs/QmNiCwBNA8MWDADTFVq1BonUEJbS2SvjAoNkZZrhEwcuUi/go-libp2p-crypto" + peer "gx/ipfs/QmZcUPvPhD1Xvk6mwijYF8AfR3mG31S1YsEfHG4khrFPRr/go-libp2p-peer" ) func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { From 4b5929d47f1681615c407007c214a93aa75ae10d Mon Sep 17 00:00:00 2001 From: Jeromy Date: Sun, 5 Mar 2017 23:06:04 -0800 Subject: [PATCH 093/262] go-ipfs-config: update go-libp2p-kad-dht with getclosestpeers fix License: MIT Signed-off-by: Jeromy --- config/identity.go | 2 +- config/init.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/identity.go b/config/identity.go index d8420cc54ec..28ca64c3cb4 100644 --- a/config/identity.go +++ b/config/identity.go @@ -2,7 +2,7 @@ package config import ( "encoding/base64" - ic "gx/ipfs/QmNiCwBNA8MWDADTFVq1BonUEJbS2SvjAoNkZZrhEwcuUi/go-libp2p-crypto" + ic "gx/ipfs/QmPGxZ1DP2w45WcogpW1h43BvseXbfke9N91qotpoQcUeS/go-libp2p-crypto" ) const IdentityTag = "Identity" diff --git a/config/init.go b/config/init.go index 28782c8f335..55131f6457f 100644 --- a/config/init.go +++ b/config/init.go @@ -6,8 +6,8 @@ import ( "fmt" "io" - ci "gx/ipfs/QmNiCwBNA8MWDADTFVq1BonUEJbS2SvjAoNkZZrhEwcuUi/go-libp2p-crypto" - peer "gx/ipfs/QmZcUPvPhD1Xvk6mwijYF8AfR3mG31S1YsEfHG4khrFPRr/go-libp2p-peer" + ci "gx/ipfs/QmPGxZ1DP2w45WcogpW1h43BvseXbfke9N91qotpoQcUeS/go-libp2p-crypto" + peer "gx/ipfs/QmWUswjn261LSyVxWAEpMVtPdy8zmKBJJfBpG3Qdpa8ZsE/go-libp2p-peer" ) func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { From f1cb6feeb5e4b2199338429489eaac1032d15375 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Fri, 20 Jan 2017 10:48:23 -0800 Subject: [PATCH 094/262] go-ipfs-config: Implement basic filestore 'no-copy' functionality License: MIT Signed-off-by: Jeromy --- config/config.go | 3 ++- config/experiments.go | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 config/experiments.go diff --git a/config/config.go b/config/config.go index 898cf56a472..fa94d1e3f07 100644 --- a/config/config.go +++ b/config/config.go @@ -30,7 +30,8 @@ type Config struct { API API // local node's API settings Swarm SwarmConfig - Reprovider Reprovider + Reprovider Reprovider + Experimental Experiments } const ( diff --git a/config/experiments.go b/config/experiments.go new file mode 100644 index 00000000000..4757d15a362 --- /dev/null +++ b/config/experiments.go @@ -0,0 +1,5 @@ +package config + +type Experiments struct { + FilestoreEnabled bool +} From 0d70e835d722a93612e6d8611d78fb6776ea46ab Mon Sep 17 00:00:00 2001 From: Kevin Atkinson Date: Sat, 18 Mar 2017 18:50:10 -0400 Subject: [PATCH 095/262] go-ipfs-config: Add DisableNatPortMap option. License: MIT Signed-off-by: Kevin Atkinson --- config/swarm.go | 1 + 1 file changed, 1 insertion(+) diff --git a/config/swarm.go b/config/swarm.go index 7d074d996d2..d61c0a2e51b 100644 --- a/config/swarm.go +++ b/config/swarm.go @@ -3,4 +3,5 @@ package config type SwarmConfig struct { AddrFilters []string DisableBandwidthMetrics bool + DisableNatPortMap bool } From 4d73fe8b4296f094f4785fc43dd064c8fd614eb6 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Wed, 22 Mar 2017 16:09:34 -0700 Subject: [PATCH 096/262] go-ipfs-config: add global config switch for sharding License: MIT Signed-off-by: Jeromy --- config/experiments.go | 1 + 1 file changed, 1 insertion(+) diff --git a/config/experiments.go b/config/experiments.go index 4757d15a362..8eb942b3989 100644 --- a/config/experiments.go +++ b/config/experiments.go @@ -2,4 +2,5 @@ package config type Experiments struct { FilestoreEnabled bool + ShardingEnabled bool } From 413034b740938a2c630323be08541edc090d72ce Mon Sep 17 00:00:00 2001 From: Jeromy Date: Fri, 24 Mar 2017 23:51:18 -0700 Subject: [PATCH 097/262] go-ipfs-config: bubble up updates from go-multihash changes License: MIT Signed-off-by: Jeromy --- config/identity.go | 2 +- config/init.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/identity.go b/config/identity.go index 28ca64c3cb4..c471bb4f6c6 100644 --- a/config/identity.go +++ b/config/identity.go @@ -2,7 +2,7 @@ package config import ( "encoding/base64" - ic "gx/ipfs/QmPGxZ1DP2w45WcogpW1h43BvseXbfke9N91qotpoQcUeS/go-libp2p-crypto" + ic "gx/ipfs/QmP1DfoUjiWH2ZBo1PBH6FupdBucbDepx3HpWmEY6JMUpY/go-libp2p-crypto" ) const IdentityTag = "Identity" diff --git a/config/init.go b/config/init.go index 55131f6457f..0538826f667 100644 --- a/config/init.go +++ b/config/init.go @@ -6,8 +6,8 @@ import ( "fmt" "io" - ci "gx/ipfs/QmPGxZ1DP2w45WcogpW1h43BvseXbfke9N91qotpoQcUeS/go-libp2p-crypto" - peer "gx/ipfs/QmWUswjn261LSyVxWAEpMVtPdy8zmKBJJfBpG3Qdpa8ZsE/go-libp2p-peer" + ci "gx/ipfs/QmP1DfoUjiWH2ZBo1PBH6FupdBucbDepx3HpWmEY6JMUpY/go-libp2p-crypto" + peer "gx/ipfs/QmdS9KpbDyPrieswibZhkod1oXqRwZJrUPzxCofAMWpFGq/go-libp2p-peer" ) func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { From 53ceee47a91fefdc67bf1e630b1a2f29387aa767 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Sun, 28 May 2017 23:36:37 +0200 Subject: [PATCH 098/262] go-ipfs-config: Corenet API: Apply suggestions, cleanups MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera --- config/experiments.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/config/experiments.go b/config/experiments.go index 8eb942b3989..f76572ee2af 100644 --- a/config/experiments.go +++ b/config/experiments.go @@ -1,6 +1,7 @@ package config type Experiments struct { - FilestoreEnabled bool - ShardingEnabled bool + FilestoreEnabled bool + ShardingEnabled bool + Libp2pStreamMounting bool } From 9e050b1526f9ba5689e3525be8a167618916de76 Mon Sep 17 00:00:00 2001 From: zramsay Date: Wed, 31 May 2017 16:56:11 -0400 Subject: [PATCH 099/262] go-ipfs-config: apply the megacheck tool to improve code quality License: MIT Signed-off-by: Zach Ramsay --- config/config.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/config/config.go b/config/config.go index fa94d1e3f07..411cecc681f 100644 --- a/config/config.go +++ b/config/config.go @@ -10,11 +10,8 @@ import ( "strings" "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/mitchellh/go-homedir" - logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log" ) -var log = logging.Logger("config") - // Config is used to load ipfs config files. type Config struct { Identity Identity // local node's peer identity From 11f5cc698bf87bbc254e333d8324f84e6be82778 Mon Sep 17 00:00:00 2001 From: zramsay Date: Wed, 31 May 2017 23:41:26 -0400 Subject: [PATCH 100/262] go-ipfs-config: address PR comments; remove commented/dead code License: MIT Signed-off-by: Zach Ramsay --- config/supernode.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/config/supernode.go b/config/supernode.go index de403fadd7d..a985040b26f 100644 --- a/config/supernode.go +++ b/config/supernode.go @@ -20,13 +20,6 @@ var DefaultSNRServers = []string{ "/ip4/178.62.61.185/tcp/4002/ipfs/QmVw6fGNqBixZE4bewRLT2VXX7fAHUHs8JyidDiJ1P7RUN", } -func initSNRConfig() (*SupernodeClientConfig, error) { - // TODO perform validation - return &SupernodeClientConfig{ - Servers: DefaultSNRServers, - }, nil -} - func (gcr *SupernodeClientConfig) ServerIPFSAddrs() ([]ipfsaddr.IPFSAddr, error) { var addrs []ipfsaddr.IPFSAddr for _, server := range gcr.Servers { From 08255bcd915fcdee98ac4cc5f729d5c48d49f261 Mon Sep 17 00:00:00 2001 From: Ivan Date: Sat, 10 Jun 2017 05:56:56 +0300 Subject: [PATCH 101/262] go-ipfs-config: Allow the use of the Range header in WebTorrent (#3929) * Allow the use of the Range header in WebTorrent License: MIT Signed-off-by: Ivan386 * Allow the use of the Range header in WebTorrent License: MIT Signed-off-by: Ivan --- config/init.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/init.go b/config/init.go index 0538826f667..5b17011dabe 100644 --- a/config/init.go +++ b/config/init.go @@ -65,7 +65,7 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { HTTPHeaders: map[string][]string{ "Access-Control-Allow-Origin": []string{"*"}, "Access-Control-Allow-Methods": []string{"GET"}, - "Access-Control-Allow-Headers": []string{"X-Requested-With"}, + "Access-Control-Allow-Headers": []string{"X-Requested-With", "Range"}, }, }, Reprovider: Reprovider{ From c475d31c6163b21cbc9da4add93fe74f4a3b2406 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Wed, 21 Jun 2017 20:37:07 +0200 Subject: [PATCH 102/262] go-ipfs-config: Disable MDNS in server profile, move it out from init.go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera --- config/profile.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 config/profile.go diff --git a/config/profile.go b/config/profile.go new file mode 100644 index 00000000000..2f754617c37 --- /dev/null +++ b/config/profile.go @@ -0,0 +1,31 @@ +package config + +// ConfigProfiles is a map holding configuration transformers +var ConfigProfiles = map[string]func(*Config) error{ + "server": func(c *Config) error { + + // 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 + 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 + }, +} From af57db772588f78081d73b588747adc2fff2e97d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Thu, 6 Jul 2017 21:42:17 +0200 Subject: [PATCH 103/262] go-ipfs-config: Add test init profile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera --- config/profile.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/config/profile.go b/config/profile.go index 2f754617c37..359aa313a58 100644 --- a/config/profile.go +++ b/config/profile.go @@ -28,4 +28,17 @@ var ConfigProfiles = map[string]func(*Config) error{ 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 + }, } From 87d7ddbb9bf400b51c9c81ad30d8824c907a8bdc Mon Sep 17 00:00:00 2001 From: Jeromy Date: Tue, 11 Jul 2017 19:17:51 -0700 Subject: [PATCH 104/262] go-ipfs-config: update go-multihash and bubble up changes License: MIT Signed-off-by: Jeromy --- config/identity.go | 2 +- config/init.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/identity.go b/config/identity.go index c471bb4f6c6..077383c9346 100644 --- a/config/identity.go +++ b/config/identity.go @@ -2,7 +2,7 @@ package config import ( "encoding/base64" - ic "gx/ipfs/QmP1DfoUjiWH2ZBo1PBH6FupdBucbDepx3HpWmEY6JMUpY/go-libp2p-crypto" + ic "gx/ipfs/QmaPbCnUMBohSGo3KnxEa2bHqyJVVeEEcwtqJAYxerieBo/go-libp2p-crypto" ) const IdentityTag = "Identity" diff --git a/config/init.go b/config/init.go index 5b17011dabe..1f8ee434be1 100644 --- a/config/init.go +++ b/config/init.go @@ -6,8 +6,8 @@ import ( "fmt" "io" - ci "gx/ipfs/QmP1DfoUjiWH2ZBo1PBH6FupdBucbDepx3HpWmEY6JMUpY/go-libp2p-crypto" - peer "gx/ipfs/QmdS9KpbDyPrieswibZhkod1oXqRwZJrUPzxCofAMWpFGq/go-libp2p-peer" + peer "gx/ipfs/QmXYjuNuxVzXKJCfWasQk1RqkhVLDM9jtUKhqc2WPQmFSB/go-libp2p-peer" + ci "gx/ipfs/QmaPbCnUMBohSGo3KnxEa2bHqyJVVeEEcwtqJAYxerieBo/go-libp2p-crypto" ) func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { From c875a44a8d6a71009f37da22a29e75175dae1742 Mon Sep 17 00:00:00 2001 From: Lars Gierth Date: Wed, 31 May 2017 02:49:14 +0200 Subject: [PATCH 105/262] go-ipfs-config: core: make announced swarm addresses configurable License: MIT Signed-off-by: Lars Gierth --- config/addresses.go | 8 +++++--- config/init.go | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/config/addresses.go b/config/addresses.go index ba891526196..22c530655b2 100644 --- a/config/addresses.go +++ b/config/addresses.go @@ -2,7 +2,9 @@ package config // Addresses stores the (string) multiaddr addresses for the node. 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 + 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 } diff --git a/config/init.go b/config/init.go index 1f8ee434be1..aa129d97e12 100644 --- a/config/init.go +++ b/config/init.go @@ -36,8 +36,10 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { // "/ip4/0.0.0.0/udp/4002/utp", // disabled for now. "/ip6/::/tcp/4001", }, - API: "/ip4/127.0.0.1/tcp/5001", - Gateway: "/ip4/127.0.0.1/tcp/8080", + Announce: []string{}, + NoAnnounce: []string{}, + API: "/ip4/127.0.0.1/tcp/5001", + Gateway: "/ip4/127.0.0.1/tcp/8080", }, Datastore: datastore, From 2f2b1fbcd71c8693376d2cb7551f57707f3a653e Mon Sep 17 00:00:00 2001 From: Sherod Taylor Date: Sat, 5 Aug 2017 22:55:50 -0500 Subject: [PATCH 106/262] go-ipfs-config: Removed tour command and fix test License: MIT Signed-off-by: Sherod Taylor --- config/config.go | 1 - config/tour.go | 7 ------- 2 files changed, 8 deletions(-) delete mode 100644 config/tour.go diff --git a/config/config.go b/config/config.go index 411cecc681f..3e3c891683d 100644 --- a/config/config.go +++ b/config/config.go @@ -21,7 +21,6 @@ type Config struct { Discovery Discovery // local node's discovery mechanisms Ipns Ipns // Ipns settings 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) API API // local node's API settings diff --git a/config/tour.go b/config/tour.go deleted file mode 100644 index e22d8453f51..00000000000 --- a/config/tour.go +++ /dev/null @@ -1,7 +0,0 @@ -package config - -// Tour stores the 'ipfs tour' read-list and resume point -type Tour struct { - Last string // last tour topic read - // Done []string // all topics done so far -} From 92d7259c688d31a608a0a075d5f22cbe9bfda8ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 1 Aug 2017 02:57:21 +0200 Subject: [PATCH 107/262] go-ipfs-config: Reprovider strategies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera --- config/init.go | 1 + config/reprovider.go | 1 + 2 files changed, 2 insertions(+) diff --git a/config/init.go b/config/init.go index aa129d97e12..f31edd42b33 100644 --- a/config/init.go +++ b/config/init.go @@ -72,6 +72,7 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { }, Reprovider: Reprovider{ Interval: "12h", + Strategy: "all", }, } diff --git a/config/reprovider.go b/config/reprovider.go index 53cf293ab61..fa029c2fc21 100644 --- a/config/reprovider.go +++ b/config/reprovider.go @@ -2,4 +2,5 @@ package config type Reprovider struct { Interval string // Time period to reprovide locally stored objects to the network + Strategy string // Which keys to announce } From b4973a585d317ed1620bea06f99a98503cef885d Mon Sep 17 00:00:00 2001 From: vyzo Date: Wed, 26 Jul 2017 14:13:59 +0300 Subject: [PATCH 108/262] go-ipfs-config: integrate circuit-relay transport - enabled by default, so that we can dial/receive dials - /p2p-circuit/QmId address is not announced; filtered at host with AddrsFactory - use case is manual swarm connect with relay address License: MIT Signed-off-by: vyzo --- config/swarm.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/swarm.go b/config/swarm.go index d61c0a2e51b..25c35d58521 100644 --- a/config/swarm.go +++ b/config/swarm.go @@ -4,4 +4,6 @@ type SwarmConfig struct { AddrFilters []string DisableBandwidthMetrics bool DisableNatPortMap bool + DisableRelay bool + EnableRelayHop bool } From f65d6e4d8a4b1306f28a705ea275573bb9f4b0c8 Mon Sep 17 00:00:00 2001 From: Lars Gierth Date: Mon, 7 Aug 2017 08:53:31 +0200 Subject: [PATCH 109/262] go-ipfs-config: bootstrap: add /dnsaddr nodes, remove half of /ip4,/ip6 nodes License: MIT Signed-off-by: Lars Gierth --- config/bootstrap_peers.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/config/bootstrap_peers.go b/config/bootstrap_peers.go index ef9a5222e00..2b166ff1985 100644 --- a/config/bootstrap_peers.go +++ b/config/bootstrap_peers.go @@ -14,23 +14,19 @@ import ( // 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 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", // mars.i.ipfs.io - "/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z", // neptune.i.ipfs.io "/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM", // pluto.i.ipfs.io - "/ip4/162.243.248.213/tcp/4001/ipfs/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm", // uranus.i.ipfs.io "/ip4/128.199.219.111/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu", // saturn.i.ipfs.io "/ip4/104.236.76.40/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64", // venus.i.ipfs.io "/ip4/178.62.158.247/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd", // earth.i.ipfs.io - "/ip4/178.62.61.185/tcp/4001/ipfs/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3", // mercury.i.ipfs.io - "/ip4/104.236.151.122/tcp/4001/ipfs/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx", // jupiter.i.ipfs.io - "/ip6/2604:a880:1:20::1f9:9001/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z", // neptune.i.ipfs.io "/ip6/2604:a880:1:20::203:d001/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM", // pluto.i.ipfs.io - "/ip6/2604:a880:0:1010::23:d001/tcp/4001/ipfs/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm", // uranus.i.ipfs.io "/ip6/2400:6180:0:d0::151:6001/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu", // saturn.i.ipfs.io "/ip6/2604:a880:800:10::4a:5001/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64", // venus.i.ipfs.io "/ip6/2a03:b0c0:0:1010::23:1001/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd", // earth.i.ipfs.io - "/ip6/2a03:b0c0:1:d0::e7:1/tcp/4001/ipfs/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3", // mercury.i.ipfs.io - "/ip6/2604:a880:1:20::1d9:6001/tcp/4001/ipfs/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx", // jupiter.i.ipfs.io } // BootstrapPeer is a peer used to bootstrap the network. From 9c60623f12f948f8175cf373ee28bbf5792a4355 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Tue, 15 Mar 2016 13:46:03 -0700 Subject: [PATCH 110/262] go-ipfs-config: make datastore configuration nicely customizable License: MIT Signed-off-by: Jeromy make things super customizable License: MIT Signed-off-by: Jeromy better json format License: MIT Signed-off-by: Jeromy Migrate to new flatfs License: MIT Signed-off-by: Jakub Sztandera --- config/datastore.go | 35 +++++++++++++++++++---------------- config/init.go | 39 +++++++++++++++++++++++++++++---------- 2 files changed, 48 insertions(+), 26 deletions(-) diff --git a/config/datastore.go b/config/datastore.go index 2b861a113cf..aec78e0e114 100644 --- a/config/datastore.go +++ b/config/datastore.go @@ -1,40 +1,43 @@ package config -import ( - "encoding/json" -) - // DefaultDataStoreDirectory is the directory to store all the local IPFS data. const DefaultDataStoreDirectory = "datastore" // Datastore tracks the configuration of the datastore. type Datastore struct { - Type string - Path string StorageMax string // in B, kB, kiB, MB, ... StorageGCWatermark int64 // in percentage to multiply on StorageMax GCPeriod string // in ns, us, ms, s, m, h + Path string + NoSync bool // deprecated + + Spec map[string]interface{} - Params *json.RawMessage - NoSync bool HashOnRead bool BloomFilterSize int } -func (d *Datastore) ParamData() []byte { - if d.Params == nil { - return nil - } - - return []byte(*d.Params) -} - type S3Datastore struct { Region string `json:"region"` Bucket string `json:"bucket"` ACL string `json:"acl"` } +type FlatDS struct { + Path string + ShardFunc string + Sync bool +} + +type LevelDB struct { + Path string + Compression string +} + +type SbsDS struct { + Path string +} + // DataStorePath returns the default data store path given a configuration root // (set an empty string to have the default configuration root) func DataStorePath(configroot string) (string, error) { diff --git a/config/init.go b/config/init.go index f31edd42b33..ae41b68e9fa 100644 --- a/config/init.go +++ b/config/init.go @@ -42,7 +42,7 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { Gateway: "/ip4/127.0.0.1/tcp/8080", }, - Datastore: datastore, + Datastore: *datastore, Bootstrap: BootstrapPeerStrings(bootstrapPeers), Identity: identity, Discovery: Discovery{MDNS{ @@ -79,19 +79,38 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { return conf, nil } -func datastoreConfig() (Datastore, error) { - dspath, err := DataStorePath("") - if err != nil { - return Datastore{}, err - } - return Datastore{ - Path: dspath, - Type: "leveldb", +func datastoreConfig() (*Datastore, error) { + return &Datastore{ StorageMax: "10GB", StorageGCWatermark: 90, // 90% GCPeriod: "1h", - HashOnRead: false, BloomFilterSize: 0, + Spec: map[string]interface{}{ + "type": "mount", + "mounts": []interface{}{ + map[string]interface{}{ + "mountpoint": "/blocks", + "type": "measure", + "prefix": "flatfs.datastore", + "child": map[string]interface{}{ + "type": "flatfs", + "path": "blocks", + "nosync": false, + "shardFunc": "/repo/flatfs/shard/v1/next-to-last/2", + }, + }, + map[string]interface{}{ + "mountpoint": "/", + "type": "measure", + "prefix": "leveldb.datastore", + "child": map[string]interface{}{ + "type": "levelds", + "path": "datastore", + "compression": "none", + }, + }, + }, + }, }, nil } From 94a60d3bc70ddaf2aeecc5906baa3a3286b2278e Mon Sep 17 00:00:00 2001 From: Kevin Atkinson Date: Wed, 10 May 2017 03:48:23 -0400 Subject: [PATCH 111/262] go-ipfs-config: cleanup and bug fixes License: MIT Signed-off-by: Kevin Atkinson --- config/datastore.go | 33 ++++++++++----------------------- config/init.go | 2 +- 2 files changed, 11 insertions(+), 24 deletions(-) diff --git a/config/datastore.go b/config/datastore.go index aec78e0e114..2b2bcb51828 100644 --- a/config/datastore.go +++ b/config/datastore.go @@ -1,5 +1,9 @@ package config +import ( + "encoding/json" +) + // DefaultDataStoreDirectory is the directory to store all the local IPFS data. const DefaultDataStoreDirectory = "datastore" @@ -8,8 +12,12 @@ 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 - Path string - NoSync bool // deprecated + + // 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{} @@ -17,27 +25,6 @@ type Datastore struct { BloomFilterSize int } -type S3Datastore struct { - Region string `json:"region"` - Bucket string `json:"bucket"` - ACL string `json:"acl"` -} - -type FlatDS struct { - Path string - ShardFunc string - Sync bool -} - -type LevelDB struct { - Path string - Compression string -} - -type SbsDS struct { - Path string -} - // DataStorePath returns the default data store path given a configuration root // (set an empty string to have the default configuration root) func DataStorePath(configroot string) (string, error) { diff --git a/config/init.go b/config/init.go index ae41b68e9fa..1ab42f6ff7e 100644 --- a/config/init.go +++ b/config/init.go @@ -95,7 +95,7 @@ func datastoreConfig() (*Datastore, error) { "child": map[string]interface{}{ "type": "flatfs", "path": "blocks", - "nosync": false, + "sync": true, "shardFunc": "/repo/flatfs/shard/v1/next-to-last/2", }, }, From f142bea007fd749624e002561d76476e6ebdf89a Mon Sep 17 00:00:00 2001 From: Kevin Atkinson Date: Sat, 20 May 2017 00:12:03 -0400 Subject: [PATCH 112/262] go-ipfs-config: bump repo version, remove support for old config License: MIT Signed-off-by: Kevin Atkinson --- config/init.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/config/init.go b/config/init.go index 1ab42f6ff7e..7b6424920b2 100644 --- a/config/init.go +++ b/config/init.go @@ -21,10 +21,7 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { return nil, err } - datastore, err := datastoreConfig() - if err != nil { - return nil, err - } + datastore := DefaultDatastoreConfig() conf := &Config{ @@ -79,7 +76,8 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { return conf, nil } -func datastoreConfig() (*Datastore, error) { +// DatastoreConfig is an internal function exported to aid in testing. +func DefaultDatastoreConfig() *Datastore { return &Datastore{ StorageMax: "10GB", StorageGCWatermark: 90, // 90% @@ -111,7 +109,7 @@ func datastoreConfig() (*Datastore, error) { }, }, }, - }, nil + } } // identityConfig initializes a new identity. From 4eb6ac60549fb55f32aef34a8c176976521389a4 Mon Sep 17 00:00:00 2001 From: Kevin Atkinson Date: Mon, 12 Jun 2017 21:43:17 -0400 Subject: [PATCH 113/262] go-ipfs-config: address p.r. comments License: MIT Signed-off-by: Kevin Atkinson --- config/init.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/init.go b/config/init.go index 7b6424920b2..e0470c71d73 100644 --- a/config/init.go +++ b/config/init.go @@ -39,7 +39,7 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { Gateway: "/ip4/127.0.0.1/tcp/8080", }, - Datastore: *datastore, + Datastore: datastore, Bootstrap: BootstrapPeerStrings(bootstrapPeers), Identity: identity, Discovery: Discovery{MDNS{ @@ -77,8 +77,8 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { } // DatastoreConfig is an internal function exported to aid in testing. -func DefaultDatastoreConfig() *Datastore { - return &Datastore{ +func DefaultDatastoreConfig() Datastore { + return Datastore{ StorageMax: "10GB", StorageGCWatermark: 90, // 90% GCPeriod: "1h", From 2aa8f0221b87adf642d746a7a1b65a9577f482bd Mon Sep 17 00:00:00 2001 From: Kevin Atkinson Date: Fri, 14 Jul 2017 15:44:48 -0400 Subject: [PATCH 114/262] go-ipfs-config: Address p.r. feedback License: MIT Signed-off-by: Kevin Atkinson --- config/init.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/init.go b/config/init.go index e0470c71d73..80923355e5c 100644 --- a/config/init.go +++ b/config/init.go @@ -76,7 +76,7 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { return conf, nil } -// DatastoreConfig is an internal function exported to aid in testing. +// DefaultDatastoreConfig is an internal function exported to aid in testing. func DefaultDatastoreConfig() Datastore { return Datastore{ StorageMax: "10GB", From 6110648544dbe354f85e35cb6c7819d0b8aea83e Mon Sep 17 00:00:00 2001 From: Jeromy Date: Mon, 4 Sep 2017 12:33:15 -0700 Subject: [PATCH 115/262] go-ipfs-config: add badger init profile License: MIT Signed-off-by: Jeromy --- config/profile.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/config/profile.go b/config/profile.go index 359aa313a58..e276ee573ad 100644 --- a/config/profile.go +++ b/config/profile.go @@ -41,4 +41,11 @@ var ConfigProfiles = map[string]func(*Config) error{ c.Discovery.MDNS.Enabled = false return nil }, + "badgerds": func(c *Config) error { + c.Datastore.Spec = map[string]interface{}{ + "type": "badgerds", + "path": "badgerds", + } + return nil + }, } From 118baa65431ecb9d0ca37a1c4907912dc05ccfaf Mon Sep 17 00:00:00 2001 From: Jeromy Date: Tue, 5 Sep 2017 21:24:48 -0700 Subject: [PATCH 116/262] go-ipfs-config: add measure layer to badgerds profile defaults License: MIT Signed-off-by: Jeromy --- config/profile.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/config/profile.go b/config/profile.go index e276ee573ad..4912e4be02d 100644 --- a/config/profile.go +++ b/config/profile.go @@ -43,8 +43,12 @@ var ConfigProfiles = map[string]func(*Config) error{ }, "badgerds": func(c *Config) error { c.Datastore.Spec = map[string]interface{}{ - "type": "badgerds", - "path": "badgerds", + "type": "measure", + "prefix": "badger.datastore", + "child": map[string]interface{}{ + "type": "badgerds", + "path": "badgerds", + }, } return nil }, From 9e4fa0d44a067cd8c65add26f6d986689e52821c Mon Sep 17 00:00:00 2001 From: Jeromy Date: Tue, 5 Sep 2017 22:46:01 -0700 Subject: [PATCH 117/262] go-ipfs-config: add option to set syncWrites to badger License: MIT Signed-off-by: Jeromy --- config/profile.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/config/profile.go b/config/profile.go index 4912e4be02d..3a7bf3694f3 100644 --- a/config/profile.go +++ b/config/profile.go @@ -46,8 +46,9 @@ var ConfigProfiles = map[string]func(*Config) error{ "type": "measure", "prefix": "badger.datastore", "child": map[string]interface{}{ - "type": "badgerds", - "path": "badgerds", + "type": "badgerds", + "path": "badgerds", + "syncWrites": true, }, } return nil From 842d0d3248cfadb2104c6974be7caef7b6171d32 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Sat, 14 Oct 2017 16:43:30 -0700 Subject: [PATCH 118/262] go-ipfs-config: remove the rest of the supernode code missed in the initial cleanup License: MIT Signed-off-by: Steven Allen --- config/config.go | 21 ++++++++++----------- config/supernode.go | 33 --------------------------------- 2 files changed, 10 insertions(+), 44 deletions(-) delete mode 100644 config/supernode.go diff --git a/config/config.go b/config/config.go index 3e3c891683d..ac7c1152b77 100644 --- a/config/config.go +++ b/config/config.go @@ -14,17 +14,16 @@ import ( // Config is used to load ipfs config files. 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 - SupernodeRouting SupernodeClientConfig // local node's routing servers (if SupernodeRouting enabled) - API API // local node's API settings - Swarm SwarmConfig + 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 diff --git a/config/supernode.go b/config/supernode.go deleted file mode 100644 index a985040b26f..00000000000 --- a/config/supernode.go +++ /dev/null @@ -1,33 +0,0 @@ -package config - -import "github.com/ipfs/go-ipfs/thirdparty/ipfsaddr" - -// TODO replace with final servers before merge - -// TODO rename -type SupernodeClientConfig struct { - Servers []string -} - -var DefaultSNRServers = []string{ - "/ip4/104.236.176.52/tcp/4002/ipfs/QmXdb7tWTxdFEQEFgWBqkuYSrZd3mXrC7HxkD4krGNYx2U", - "/ip4/104.236.179.241/tcp/4002/ipfs/QmVRqViDByUxjUMoPnjurjKvZhaEMFDtK35FJXHAM4Lkj6", - "/ip4/104.236.151.122/tcp/4002/ipfs/QmSZwGx8Tn8tmcM4PtDJaMeUQNRhNFdBLVGPzRiNaRJtFH", - "/ip4/162.243.248.213/tcp/4002/ipfs/QmbHVEEepCi7rn7VL7Exxpd2Ci9NNB6ifvqwhsrbRMgQFP", - "/ip4/128.199.219.111/tcp/4002/ipfs/Qmb3brdCYmKG1ycwqCbo6LUwWxTuo3FisnJV2yir7oN92R", - "/ip4/104.236.76.40/tcp/4002/ipfs/QmdRBCV8Cz2dGhoKLkD3YjPwVFECmqADQkx5ZteF2c6Fy4", - "/ip4/178.62.158.247/tcp/4002/ipfs/QmUdiMPci7YoEUBkyFZAh2pAbjqcPr7LezyiPD2artLw3v", - "/ip4/178.62.61.185/tcp/4002/ipfs/QmVw6fGNqBixZE4bewRLT2VXX7fAHUHs8JyidDiJ1P7RUN", -} - -func (gcr *SupernodeClientConfig) ServerIPFSAddrs() ([]ipfsaddr.IPFSAddr, error) { - var addrs []ipfsaddr.IPFSAddr - for _, server := range gcr.Servers { - addr, err := ipfsaddr.ParseString(server) - if err != nil { - return nil, err - } - addrs = append(addrs, addr) - } - return addrs, nil -} From 810c8e73a41a72220c30f9f82210d18952bdd1b2 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Thu, 14 Sep 2017 13:43:37 -0700 Subject: [PATCH 119/262] go-ipfs-config: Integrate connection manager License: MIT Signed-off-by: Jeromy --- config/swarm.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/config/swarm.go b/config/swarm.go index 25c35d58521..5b128f38aab 100644 --- a/config/swarm.go +++ b/config/swarm.go @@ -6,4 +6,14 @@ type SwarmConfig struct { DisableNatPortMap bool DisableRelay bool EnableRelayHop bool + + ConnMgr ConnMgr +} + +// ConnMgr defines configuration options for the libp2p connection manager +type ConnMgr struct { + Type string + LowWater int + HighWater int + GracePeriod string } From 330b646a349132f3514c940b99815a6c24e74048 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Thu, 19 Oct 2017 09:15:12 -0700 Subject: [PATCH 120/262] go-ipfs-config: default settings for the connection manager License: MIT Signed-off-by: Jeromy --- config/init.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/config/init.go b/config/init.go index 80923355e5c..0b3537d2561 100644 --- a/config/init.go +++ b/config/init.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "io" + "time" peer "gx/ipfs/QmXYjuNuxVzXKJCfWasQk1RqkhVLDM9jtUKhqc2WPQmFSB/go-libp2p-peer" ci "gx/ipfs/QmaPbCnUMBohSGo3KnxEa2bHqyJVVeEEcwtqJAYxerieBo/go-libp2p-crypto" @@ -71,11 +72,31 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { Interval: "12h", Strategy: "all", }, + Swarm: SwarmConfig{ + ConnMgr: ConnMgr{ + LowWater: DefaultConnMgrLowWater, + HighWater: DefaultConnMgrHighWater, + GracePeriod: DefaultConnMgrGracePeriod.String(), + Type: "basic", + }, + }, } return conf, nil } +// DefaultConnMgrHighWater is the default value for the connection managers +// 'high water' mark +const DefaultConnMgrHighWater = 900 + +// DefaultConnMgrLowWater is the default value for the connection managers 'low +// water' mark +const DefaultConnMgrLowWater = 600 + +// DefaultConnMgrGracePeriod is the default value for the connection managers +// grace period +const DefaultConnMgrGracePeriod = time.Second * 20 + // DefaultDatastoreConfig is an internal function exported to aid in testing. func DefaultDatastoreConfig() Datastore { return Datastore{ From 516673de698969acf25a0e6df8fc9d5f3b22309b Mon Sep 17 00:00:00 2001 From: Jeromy Date: Tue, 24 Oct 2017 07:14:01 -0700 Subject: [PATCH 121/262] go-ipfs-config: extract go-ipfs-addr License: MIT Signed-off-by: Jeromy --- config/bootstrap_peers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/bootstrap_peers.go b/config/bootstrap_peers.go index 2b166ff1985..9b3946e3667 100644 --- a/config/bootstrap_peers.go +++ b/config/bootstrap_peers.go @@ -4,7 +4,7 @@ import ( "errors" "fmt" - iaddr "github.com/ipfs/go-ipfs/thirdparty/ipfsaddr" + iaddr "gx/ipfs/QmeS8cCKawUwejVrsBtmC1toTXmwVWZGiRJqzgTURVWeF9/go-ipfs-addr" ) // DefaultBootstrapAddresses are the hardcoded bootstrap addresses From a93e2514df941a7bf97a048b78674709ca5407c6 Mon Sep 17 00:00:00 2001 From: Jan Winkelmann Date: Sat, 1 Apr 2017 16:58:17 +0200 Subject: [PATCH 122/262] go-ipfs-config: cmd: use go-ipfs-cmds License: MIT Signed-off-by: keks --- config/identity.go | 1 + 1 file changed, 1 insertion(+) diff --git a/config/identity.go b/config/identity.go index 077383c9346..c440cc427aa 100644 --- a/config/identity.go +++ b/config/identity.go @@ -2,6 +2,7 @@ package config import ( "encoding/base64" + ic "gx/ipfs/QmaPbCnUMBohSGo3KnxEa2bHqyJVVeEEcwtqJAYxerieBo/go-libp2p-crypto" ) From 8662bbb33056b2bd4f3718b391f4cc641d6bd7ad Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 20 Nov 2017 16:25:06 -0800 Subject: [PATCH 123/262] go-ipfs-config: gx: massive update Note: This commit is technically broken. However, I need to make a bunch of cmds changes to make this work and I'd rather not bundle both changes into a single commit. License: MIT Signed-off-by: Steven Allen --- config/bootstrap_peers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/bootstrap_peers.go b/config/bootstrap_peers.go index 9b3946e3667..b45bfcaeebe 100644 --- a/config/bootstrap_peers.go +++ b/config/bootstrap_peers.go @@ -4,7 +4,7 @@ import ( "errors" "fmt" - iaddr "gx/ipfs/QmeS8cCKawUwejVrsBtmC1toTXmwVWZGiRJqzgTURVWeF9/go-ipfs-addr" + iaddr "gx/ipfs/QmUnAfDeH1Nths56yuMvkw4V3sNF4d1xBbWy5hfZG7LF6G/go-ipfs-addr" ) // DefaultBootstrapAddresses are the hardcoded bootstrap addresses From 85b87f7a04cc700a9298d4f7667c1be6144e0ed4 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Sun, 3 Dec 2017 21:34:29 -0800 Subject: [PATCH 124/262] go-ipfs-config: gx: update go-multihash License: MIT Signed-off-by: Steven Allen --- config/bootstrap_peers.go | 2 +- config/init.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/bootstrap_peers.go b/config/bootstrap_peers.go index b45bfcaeebe..d4f6469dc14 100644 --- a/config/bootstrap_peers.go +++ b/config/bootstrap_peers.go @@ -4,7 +4,7 @@ import ( "errors" "fmt" - iaddr "gx/ipfs/QmUnAfDeH1Nths56yuMvkw4V3sNF4d1xBbWy5hfZG7LF6G/go-ipfs-addr" + iaddr "gx/ipfs/QmdMeXVB1V1SAZcFzoCuM3zR9K8PeuzCYg4zXNHcHh6dHU/go-ipfs-addr" ) // DefaultBootstrapAddresses are the hardcoded bootstrap addresses diff --git a/config/init.go b/config/init.go index 0b3537d2561..1c7874e3d90 100644 --- a/config/init.go +++ b/config/init.go @@ -7,7 +7,7 @@ import ( "io" "time" - peer "gx/ipfs/QmXYjuNuxVzXKJCfWasQk1RqkhVLDM9jtUKhqc2WPQmFSB/go-libp2p-peer" + peer "gx/ipfs/QmWNY7dV54ZDYmTA1ykVdwNCqC11mpU4zSUp6XDpLTH9eG/go-libp2p-peer" ci "gx/ipfs/QmaPbCnUMBohSGo3KnxEa2bHqyJVVeEEcwtqJAYxerieBo/go-libp2p-crypto" ) From 3de82a7c54fb9c21f4c053408e96e5d7dc81c5af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 5 Sep 2017 23:44:37 +0200 Subject: [PATCH 125/262] go-ipfs-config: config: revert profile subcommand MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera --- config/init.go | 26 ++++++---- config/profile.go | 126 ++++++++++++++++++++++++++++------------------ 2 files changed, 92 insertions(+), 60 deletions(-) diff --git a/config/init.go b/config/init.go index 1c7874e3d90..2b1def8b522 100644 --- a/config/init.go +++ b/config/init.go @@ -28,17 +28,7 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { // setup the node's default addresses. // NOTE: two swarm listen addrs, one tcp, one utp. - Addresses: Addresses{ - Swarm: []string{ - "/ip4/0.0.0.0/tcp/4001", - // "/ip4/0.0.0.0/udp/4002/utp", // disabled for now. - "/ip6/::/tcp/4001", - }, - Announce: []string{}, - NoAnnounce: []string{}, - API: "/ip4/127.0.0.1/tcp/5001", - Gateway: "/ip4/127.0.0.1/tcp/8080", - }, + Addresses: addressesConfig(), Datastore: datastore, Bootstrap: BootstrapPeerStrings(bootstrapPeers), @@ -97,6 +87,20 @@ const DefaultConnMgrLowWater = 600 // grace period const DefaultConnMgrGracePeriod = time.Second * 20 +func addressesConfig() Addresses { + return Addresses{ + Swarm: []string{ + "/ip4/0.0.0.0/tcp/4001", + // "/ip4/0.0.0.0/udp/4002/utp", // disabled for now. + "/ip6/::/tcp/4001", + }, + Announce: []string{}, + NoAnnounce: []string{}, + API: "/ip4/127.0.0.1/tcp/5001", + Gateway: "/ip4/127.0.0.1/tcp/8080", + } +} + // DefaultDatastoreConfig is an internal function exported to aid in testing. func DefaultDatastoreConfig() Datastore { return Datastore{ diff --git a/config/profile.go b/config/profile.go index 3a7bf3694f3..a4160306a8b 100644 --- a/config/profile.go +++ b/config/profile.go @@ -1,56 +1,84 @@ package config -// ConfigProfiles is a map holding configuration transformers -var ConfigProfiles = map[string]func(*Config) error{ - "server": func(c *Config) error { - - // 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 - 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 +type Transformer func(c *Config) error + +type Profile struct { + Apply Transformer + Unapply Transformer +} + +// Profiles is a map holding configuration transformers +var Profiles = map[string]*Profile{ + "server": { + Apply: func(c *Config) error { + + // 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 + 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 + }, + Unapply: func(c *Config) error { + c.Swarm.AddrFilters = []string{} + c.Discovery.MDNS.Enabled = true + 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 + "test": { + Apply: 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 + }, + Unapply: func(c *Config) error { + c.Addresses = addressesConfig() + + c.Swarm.DisableNatPortMap = 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, + "badgerds": { + Apply: 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 }, - } - return nil + Unapply: func(c *Config) error { + c.Datastore.Spec = DefaultDatastoreConfig().Spec + return nil + }, }, } From cb7bc06600af76356c2d75a2b7e60e7216b07253 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 126/262] go-ipfs-config: 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 --- config/profile.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/config/profile.go b/config/profile.go index a4160306a8b..7711d9e7c4f 100644 --- a/config/profile.go +++ b/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 { @@ -65,17 +65,17 @@ var Profiles = map[string]*Profile{ }, "badgerds": { Apply: 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 - }, + c.Datastore.Spec = map[string]interface{}{ + "type": "measure", + "prefix": "badger.datastore", + "child": map[string]interface{}{ + "type": "badgerds", + "path": "badgerds", + "syncWrites": true, + }, + } + return nil + }, Unapply: func(c *Config) error { c.Datastore.Spec = DefaultDatastoreConfig().Spec return nil From 151c8dcf4e4a7c9b3f31fd79ad550e5feb4970f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 22 Sep 2017 00:13:58 +0200 Subject: [PATCH 127/262] go-ipfs-config: conifg-patch: apply review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera --- config/profile.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config/profile.go b/config/profile.go index 7711d9e7c4f..92fdbbc8e71 100644 --- a/config/profile.go +++ b/config/profile.go @@ -1,7 +1,9 @@ package config +// Transformer is a function which takes configuration and applies some filter to it type Transformer func(c *Config) error +// Profile applies some set of changes to the configuration type Profile struct { Apply Transformer Unapply Transformer @@ -32,11 +34,13 @@ var Profiles = map[string]*Profile{ "/ip4/240.0.0.0/ipcidr/4", } + c.Addresses.NoAnnounce = append(c.Addresses.NoAnnounce, defaultServerFilters...) c.Swarm.AddrFilters = append(c.Swarm.AddrFilters, defaultServerFilters...) c.Discovery.MDNS.Enabled = false return nil }, Unapply: func(c *Config) error { + c.Addresses.NoAnnounce = []string{} c.Swarm.AddrFilters = []string{} c.Discovery.MDNS.Enabled = true return nil From c2a74652fac692d1c9fd5d9071fc61439d2aa0d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Sun, 5 Nov 2017 14:21:14 +0100 Subject: [PATCH 128/262] go-ipfs-config: config: rename profile.Unapply to Revert MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera --- config/profile.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/config/profile.go b/config/profile.go index 92fdbbc8e71..061a41408eb 100644 --- a/config/profile.go +++ b/config/profile.go @@ -5,8 +5,8 @@ type Transformer func(c *Config) error // Profile applies some set of changes to the configuration type Profile struct { - Apply Transformer - Unapply Transformer + Apply Transformer + Revert Transformer } // Profiles is a map holding configuration transformers. Docs are in docs/config.md @@ -39,7 +39,7 @@ var Profiles = map[string]*Profile{ c.Discovery.MDNS.Enabled = false return nil }, - Unapply: func(c *Config) error { + Revert: func(c *Config) error { c.Addresses.NoAnnounce = []string{} c.Swarm.AddrFilters = []string{} c.Discovery.MDNS.Enabled = true @@ -60,7 +60,7 @@ var Profiles = map[string]*Profile{ c.Discovery.MDNS.Enabled = false return nil }, - Unapply: func(c *Config) error { + Revert: func(c *Config) error { c.Addresses = addressesConfig() c.Swarm.DisableNatPortMap = false @@ -80,7 +80,7 @@ var Profiles = map[string]*Profile{ } return nil }, - Unapply: func(c *Config) error { + Revert: func(c *Config) error { c.Datastore.Spec = DefaultDatastoreConfig().Spec return nil }, From 2423a8fb03d5c06ca7b11303bf8ee5029b5a22a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Sat, 25 Nov 2017 03:16:30 +0100 Subject: [PATCH 129/262] go-ipfs-config: config-patch: apply review suggestions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera --- config/profile.go | 1 + 1 file changed, 1 insertion(+) diff --git a/config/profile.go b/config/profile.go index 061a41408eb..529cf3a97d3 100644 --- a/config/profile.go +++ b/config/profile.go @@ -64,6 +64,7 @@ var Profiles = map[string]*Profile{ c.Addresses = addressesConfig() c.Swarm.DisableNatPortMap = false + c.Discovery.MDNS.Enabled = true return nil }, }, From 4c300c521e19017c95951a7a30c1907a3fa37366 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Sat, 16 Dec 2017 18:16:43 +0100 Subject: [PATCH 130/262] go-ipfs-config: config-patch: docs typo, fix server profile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera --- config/profile.go | 79 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 54 insertions(+), 25 deletions(-) diff --git a/config/profile.go b/config/profile.go index 529cf3a97d3..87668357f66 100644 --- a/config/profile.go +++ b/config/profile.go @@ -9,39 +9,38 @@ type Profile struct { Revert 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{ + "/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", +} + // Profiles is a map holding configuration transformers. Docs are in docs/config.md var Profiles = map[string]*Profile{ "server": { Apply: func(c *Config) error { - - // 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 - 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.Addresses.NoAnnounce = append(c.Addresses.NoAnnounce, defaultServerFilters...) - c.Swarm.AddrFilters = append(c.Swarm.AddrFilters, defaultServerFilters...) + c.Addresses.NoAnnounce = appendSingle(c.Addresses.NoAnnounce, defaultServerFilters) + c.Swarm.AddrFilters = appendSingle(c.Swarm.AddrFilters, defaultServerFilters) c.Discovery.MDNS.Enabled = false return nil }, Revert: func(c *Config) error { - c.Addresses.NoAnnounce = []string{} - c.Swarm.AddrFilters = []string{} + c.Addresses.NoAnnounce = deleteEntries(c.Addresses.NoAnnounce, defaultServerFilters) + c.Swarm.AddrFilters = deleteEntries(c.Swarm.AddrFilters, defaultServerFilters) c.Discovery.MDNS.Enabled = true return nil }, @@ -87,3 +86,33 @@ var Profiles = map[string]*Profile{ }, }, } + +func appendSingle(a []string, b []string) []string { + m := map[string]struct{}{} + for _, f := range a { + m[f] = struct{}{} + } + for _, f := range b { + m[f] = struct{}{} + } + return mapKeys(m) +} + +func deleteEntries(arr []string, del []string) []string { + m := map[string]struct{}{} + for _, f := range arr { + m[f] = struct{}{} + } + for _, f := range del { + delete(m, f) + } + return mapKeys(m) +} + +func mapKeys(m map[string]struct{}) []string { + out := make([]string, 0, len(m)) + for f := range m { + out = append(out, f) + } + return out +} From cdb9c2f316ecdb21bc0483e9eab7c564a4424cd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Sat, 16 Dec 2017 18:59:46 +0100 Subject: [PATCH 131/262] go-ipfs-config: config-patch: Inverse profiles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera --- config/profile.go | 98 +++++++++++++++++++++-------------------------- 1 file changed, 43 insertions(+), 55 deletions(-) diff --git a/config/profile.go b/config/profile.go index 87668357f66..74383cda63f 100644 --- a/config/profile.go +++ b/config/profile.go @@ -3,12 +3,6 @@ package config // Transformer is a function which takes configuration and applies some filter to it type Transformer func(c *Config) error -// Profile applies some set of changes to the configuration -type Profile struct { - Apply Transformer - Revert 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{ @@ -30,60 +24,54 @@ var defaultServerFilters = []string{ } // Profiles is a map holding configuration transformers. Docs are in docs/config.md -var Profiles = map[string]*Profile{ - "server": { - Apply: 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 - }, - Revert: 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 - }, +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 + }, + "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 }, - "test": { - Apply: 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", - } + "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.Swarm.DisableNatPortMap = true - c.Bootstrap = []string{} - c.Discovery.MDNS.Enabled = false - return nil - }, - Revert: func(c *Config) error { - c.Addresses = addressesConfig() + c.Bootstrap = []string{} + c.Discovery.MDNS.Enabled = false + return nil + }, + "default-networking": func(c *Config) error { + c.Addresses = addressesConfig() - c.Swarm.DisableNatPortMap = false - c.Discovery.MDNS.Enabled = true - return nil - }, + 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": { - Apply: 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 - }, - Revert: func(c *Config) error { - c.Datastore.Spec = DefaultDatastoreConfig().Spec - return nil - }, + "default-datastore": func(c *Config) error { + c.Datastore.Spec = DefaultDatastoreConfig().Spec + return nil }, } From 60e814bc830aa40bfe0d9e5b3ccb513bdcbe9e9a Mon Sep 17 00:00:00 2001 From: keks Date: Thu, 7 Dec 2017 19:33:25 +0100 Subject: [PATCH 132/262] go-ipfs-config: cmds: use Executors - some fixes for cmds1.0 - reinsert plugin loading code, pretty print wrapper TODO: if plugin loading fails it only calls log.Warning. returning an error would be better but that would have to happen after PreRun, which is not possible atm. License: MIT Signed-off-by: keks --- config/init.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/config/init.go b/config/init.go index 2b1def8b522..a3ceee6d388 100644 --- a/config/init.go +++ b/config/init.go @@ -25,6 +25,11 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { datastore := DefaultDatastoreConfig() conf := &Config{ + API: API{ + HTTPHeaders: map[string][]string{ + "Server": {"go-ipfs/" + CurrentVersionNumber}, + }, + }, // setup the node's default addresses. // NOTE: two swarm listen addrs, one tcp, one utp. From f1e0a382ca1d728eb851d372cbe943edb24979c2 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 24 Jan 2018 15:55:28 -0800 Subject: [PATCH 133/262] go-ipfs-config: gx: mass update License: MIT Signed-off-by: Steven Allen --- config/bootstrap_peers.go | 2 +- config/init.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/bootstrap_peers.go b/config/bootstrap_peers.go index d4f6469dc14..f59a3f65528 100644 --- a/config/bootstrap_peers.go +++ b/config/bootstrap_peers.go @@ -4,7 +4,7 @@ import ( "errors" "fmt" - iaddr "gx/ipfs/QmdMeXVB1V1SAZcFzoCuM3zR9K8PeuzCYg4zXNHcHh6dHU/go-ipfs-addr" + iaddr "gx/ipfs/QmWto9a6kfznUoW9owbLoBiLUMgRvgsVHRKFzs8zzzKYwp/go-ipfs-addr" ) // DefaultBootstrapAddresses are the hardcoded bootstrap addresses diff --git a/config/init.go b/config/init.go index a3ceee6d388..afcdbfec939 100644 --- a/config/init.go +++ b/config/init.go @@ -7,7 +7,7 @@ import ( "io" "time" - peer "gx/ipfs/QmWNY7dV54ZDYmTA1ykVdwNCqC11mpU4zSUp6XDpLTH9eG/go-libp2p-peer" + peer "gx/ipfs/Qma7H6RW8wRrfZpNSXwxYGcd1E149s42FpWNpDNieSVrnU/go-libp2p-peer" ci "gx/ipfs/QmaPbCnUMBohSGo3KnxEa2bHqyJVVeEEcwtqJAYxerieBo/go-libp2p-crypto" ) From e811add413517244f459310e32028a62288f70a3 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Sat, 27 Jan 2018 18:03:59 -0800 Subject: [PATCH 134/262] go-ipfs-config: update go-lib2p-loggables fixes a UUID bug I introduced (UUIDs were always an error value) License: MIT Signed-off-by: Steven Allen --- config/bootstrap_peers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/bootstrap_peers.go b/config/bootstrap_peers.go index f59a3f65528..ee8b7419dfa 100644 --- a/config/bootstrap_peers.go +++ b/config/bootstrap_peers.go @@ -4,7 +4,7 @@ import ( "errors" "fmt" - iaddr "gx/ipfs/QmWto9a6kfznUoW9owbLoBiLUMgRvgsVHRKFzs8zzzKYwp/go-ipfs-addr" + iaddr "gx/ipfs/QmPWejECnZ4a2eShmnMFBfaLQR7AjuNDPxiY7jmR4fPjg6/go-ipfs-addr" ) // DefaultBootstrapAddresses are the hardcoded bootstrap addresses From ca129b458a21d2114e6a68ed37cfdd545b4bbb42 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 31 Jan 2018 18:54:57 -0800 Subject: [PATCH 135/262] go-ipfs-config: gx: update go-log License: MIT Signed-off-by: Steven Allen --- config/bootstrap_peers.go | 2 +- config/init.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/bootstrap_peers.go b/config/bootstrap_peers.go index ee8b7419dfa..23b5eefe3f2 100644 --- a/config/bootstrap_peers.go +++ b/config/bootstrap_peers.go @@ -4,7 +4,7 @@ import ( "errors" "fmt" - iaddr "gx/ipfs/QmPWejECnZ4a2eShmnMFBfaLQR7AjuNDPxiY7jmR4fPjg6/go-ipfs-addr" + iaddr "gx/ipfs/QmQViVWBHbU6HmYjXcdNq7tVASCNgdg64ZGcauuDkLCivW/go-ipfs-addr" ) // DefaultBootstrapAddresses are the hardcoded bootstrap addresses diff --git a/config/init.go b/config/init.go index afcdbfec939..26ac8e6ccf4 100644 --- a/config/init.go +++ b/config/init.go @@ -7,7 +7,7 @@ import ( "io" "time" - peer "gx/ipfs/Qma7H6RW8wRrfZpNSXwxYGcd1E149s42FpWNpDNieSVrnU/go-libp2p-peer" + peer "gx/ipfs/QmZoWKhxUmZ2seW4BzX6fJkNR8hh9PsGModr7q171yq2SS/go-libp2p-peer" ci "gx/ipfs/QmaPbCnUMBohSGo3KnxEa2bHqyJVVeEEcwtqJAYxerieBo/go-libp2p-crypto" ) From efb99b5e5910d84fc37c3631ec213c2de2765eb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Sun, 20 Aug 2017 16:24:01 +0200 Subject: [PATCH 136/262] go-ipfs-config: daemon: config option for routing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera --- config/discovery.go | 5 ++++- config/init.go | 11 +++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/config/discovery.go b/config/discovery.go index 4fb8508f00a..30c24ea19b3 100644 --- a/config/discovery.go +++ b/config/discovery.go @@ -1,7 +1,10 @@ package config type Discovery struct { - MDNS MDNS + MDNS MDNS + + //Routing sets default daemon routing mode. + Routing string } type MDNS struct { diff --git a/config/init.go b/config/init.go index 26ac8e6ccf4..e2d6a281f12 100644 --- a/config/init.go +++ b/config/init.go @@ -38,10 +38,13 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { Datastore: datastore, Bootstrap: BootstrapPeerStrings(bootstrapPeers), Identity: identity, - Discovery: Discovery{MDNS{ - Enabled: true, - Interval: 10, - }}, + Discovery: Discovery{ + MDNS: MDNS{ + Enabled: true, + Interval: 10, + }, + Routing: "dht", + }, // setup the node mount points. Mounts: Mounts{ From 8d8b02b79715349cca4e9576b9d1bed90eaa8bb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Sun, 20 Aug 2017 17:57:00 +0200 Subject: [PATCH 137/262] go-ipfs-config: init: lowpower profile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera --- config/discovery.go | 2 +- config/profile.go | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/config/discovery.go b/config/discovery.go index 30c24ea19b3..64f7af64a68 100644 --- a/config/discovery.go +++ b/config/discovery.go @@ -1,7 +1,7 @@ package config type Discovery struct { - MDNS MDNS + MDNS MDNS //Routing sets default daemon routing mode. Routing string diff --git a/config/profile.go b/config/profile.go index 74383cda63f..6aa5f505380 100644 --- a/config/profile.go +++ b/config/profile.go @@ -73,6 +73,11 @@ var Profiles = map[string]Transformer{ c.Datastore.Spec = DefaultDatastoreConfig().Spec return nil }, + "lowpower": func(c *Config) error { + c.Discovery.Routing = "dhtclient" + c.Reprovider.Interval = "0" + return nil + }, } func appendSingle(a []string, b []string) []string { From 88d7dfec2ffd3b33890872a2a5138a37d6b2e5f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 31 Oct 2017 19:34:38 +0100 Subject: [PATCH 138/262] go-ipfs-config: config: apply review to lowpower profile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera --- config/config.go | 1 + config/discovery.go | 3 --- config/init.go | 5 ++++- config/profile.go | 8 +++++++- config/routing.go | 7 +++++++ 5 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 config/routing.go diff --git a/config/config.go b/config/config.go index ac7c1152b77..719170baad8 100644 --- a/config/config.go +++ b/config/config.go @@ -19,6 +19,7 @@ type Config struct { Addresses Addresses // local node's addresses Mounts Mounts // local node's mount points Discovery Discovery // local node's discovery mechanisms + Routing Routing // local node's routing settings Ipns Ipns // Ipns settings Bootstrap []string // local nodes's bootstrap peer addresses Gateway Gateway // local node's gateway server options diff --git a/config/discovery.go b/config/discovery.go index 64f7af64a68..4fb8508f00a 100644 --- a/config/discovery.go +++ b/config/discovery.go @@ -2,9 +2,6 @@ package config type Discovery struct { MDNS MDNS - - //Routing sets default daemon routing mode. - Routing string } type MDNS struct { diff --git a/config/init.go b/config/init.go index e2d6a281f12..54d17f7b7bf 100644 --- a/config/init.go +++ b/config/init.go @@ -43,7 +43,10 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { Enabled: true, Interval: 10, }, - Routing: "dht", + }, + + Routing: Routing{ + Type: "dht", }, // setup the node mount points. diff --git a/config/profile.go b/config/profile.go index 6aa5f505380..b20382ef4ed 100644 --- a/config/profile.go +++ b/config/profile.go @@ -1,5 +1,7 @@ package config +import "time" + // Transformer is a function which takes configuration and applies some filter to it type Transformer func(c *Config) error @@ -74,8 +76,12 @@ var Profiles = map[string]Transformer{ return nil }, "lowpower": func(c *Config) error { - c.Discovery.Routing = "dhtclient" + 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 }, } diff --git a/config/routing.go b/config/routing.go new file mode 100644 index 00000000000..e601cd5e8d3 --- /dev/null +++ b/config/routing.go @@ -0,0 +1,7 @@ +package config + +// Routing defines configuration options for libp2p routing +type Routing struct { + // Type sets default daemon routing mode. + Type string +} From 020c55ad623645589c75624ad7b45d2e0b4227ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 20 Mar 2018 17:50:37 +0100 Subject: [PATCH 139/262] go-ipfs-config: Fix missing profile docs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera --- config/profile.go | 157 +++++++++++++++++++++++++++++++--------------- 1 file changed, 107 insertions(+), 50 deletions(-) diff --git a/config/profile.go b/config/profile.go index b20382ef4ed..6d2d2b3a5c3 100644 --- a/config/profile.go +++ b/config/profile.go @@ -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,111 @@ 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 + 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 + 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.`, + + Transform: func(c *Config) error { + c.Addresses = addressesConfig() - c.Swarm.DisableNatPortMap = false - c.Discovery.MDNS.Enabled = true - return nil + 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. + +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. +`, + + 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 + }, }, } From 0c8a2e192f92395ebd44603b5b89b5bdc47ba22c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Mon, 26 Mar 2018 19:32:15 +0200 Subject: [PATCH 140/262] go-ipfs-config: config/profile: disable UPnP/NAT in server profile, docs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera --- config/profile.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/config/profile.go b/config/profile.go index 6d2d2b3a5c3..a7d4f1fe318 100644 --- a/config/profile.go +++ b/config/profile.go @@ -44,6 +44,7 @@ running IPFS on machines with public IPv4 addresses.`, 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 }, }, @@ -56,6 +57,7 @@ profile, enables discovery in local networks.`, 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 }, }, @@ -97,6 +99,11 @@ 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 + WARNING: badger datastore is experimental. Make sure to backup your data frequently.`, @@ -119,6 +126,11 @@ Make sure to backup your data frequently.`, 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 { From af1fc17657d8bf9ce29cc7460d6643c4cc830842 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Sun, 18 Mar 2018 19:54:46 +0100 Subject: [PATCH 141/262] go-ipfs-config: fix error style MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera --- config/config.go | 4 ++-- config/init.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/config.go b/config/config.go index 719170baad8..8ec6d324aeb 100644 --- a/config/config.go +++ b/config/config.go @@ -93,7 +93,7 @@ func FromMap(v map[string]interface{}) (*Config, error) { } var conf Config if err := json.NewDecoder(buf).Decode(&conf); err != nil { - return nil, fmt.Errorf("Failure to decode config: %s", err) + return nil, fmt.Errorf("failure to decode config: %s", err) } return &conf, nil } @@ -105,7 +105,7 @@ func ToMap(conf *Config) (map[string]interface{}, error) { } var m map[string]interface{} if err := json.NewDecoder(buf).Decode(&m); err != nil { - return nil, fmt.Errorf("Failure to decode config: %s", err) + return nil, fmt.Errorf("failure to decode config: %s", err) } return m, nil } diff --git a/config/init.go b/config/init.go index 54d17f7b7bf..6efc8712515 100644 --- a/config/init.go +++ b/config/init.go @@ -153,7 +153,7 @@ func identityConfig(out io.Writer, nbits int) (Identity, error) { // TODO guard higher up ident := Identity{} if nbits < 1024 { - return ident, errors.New("Bitsize less than 1024 is considered unsafe.") + return ident, errors.New("bitsize less than 1024 is considered unsafe") } fmt.Fprintf(out, "generating %v-bit RSA keypair...", nbits) From 97590c70cc3f8d96a42e733a72dcee6856a3ef99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 20 Mar 2018 16:56:56 +0100 Subject: [PATCH 142/262] go-ipfs-config: fix default-net profile not reverting bootstrap config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera --- config/profile.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/config/profile.go b/config/profile.go index a7d4f1fe318..eab44cfb745 100644 --- a/config/profile.go +++ b/config/profile.go @@ -86,6 +86,12 @@ Inverse profile of the test profile.`, Transform: func(c *Config) error { c.Addresses = addressesConfig() + bootstrapPeers, err := DefaultBootstrapPeers() + if err != nil { + return err + } + c.Bootstrap = appendSingle(c.Bootstrap, BootstrapPeerStrings(bootstrapPeers)) + c.Swarm.DisableNatPortMap = false c.Discovery.MDNS.Enabled = true return nil From a55c0fb51d842c9f52c52c16d8450bb32319d779 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 30 Mar 2018 20:38:52 +0200 Subject: [PATCH 143/262] go-ipfs-config: profile: fix test profile tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera --- config/profile.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/config/profile.go b/config/profile.go index eab44cfb745..d3f1b42d09c 100644 --- a/config/profile.go +++ b/config/profile.go @@ -162,14 +162,21 @@ fetching may be degraded. } func appendSingle(a []string, b []string) []string { - m := map[string]struct{}{} + out := make([]string, 0, len(a)+len(b)) + m := map[string]bool{} for _, f := range a { - m[f] = struct{}{} + if !m[f] { + out = append(out, f) + } + m[f] = true } for _, f := range b { - m[f] = struct{}{} + if !m[f] { + out = append(out, f) + } + m[f] = true } - return mapKeys(m) + return out } func deleteEntries(arr []string, del []string) []string { From c78cad770072739909e022aa49a8eabf02c0e0bd Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 3 May 2018 21:39:52 -0700 Subject: [PATCH 144/262] go-ipfs-config: update deps License: MIT Signed-off-by: Steven Allen --- config/bootstrap_peers.go | 2 +- config/identity.go | 2 +- config/init.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config/bootstrap_peers.go b/config/bootstrap_peers.go index 23b5eefe3f2..8fa6f8bb648 100644 --- a/config/bootstrap_peers.go +++ b/config/bootstrap_peers.go @@ -4,7 +4,7 @@ import ( "errors" "fmt" - iaddr "gx/ipfs/QmQViVWBHbU6HmYjXcdNq7tVASCNgdg64ZGcauuDkLCivW/go-ipfs-addr" + iaddr "gx/ipfs/QmcHEQW4F7u74t1Qpgvz654rGoX6frjFm3HJA67YCV9jia/go-ipfs-addr" ) // DefaultBootstrapAddresses are the hardcoded bootstrap addresses diff --git a/config/identity.go b/config/identity.go index c440cc427aa..60fe772d911 100644 --- a/config/identity.go +++ b/config/identity.go @@ -3,7 +3,7 @@ package config import ( "encoding/base64" - ic "gx/ipfs/QmaPbCnUMBohSGo3KnxEa2bHqyJVVeEEcwtqJAYxerieBo/go-libp2p-crypto" + ic "gx/ipfs/Qme1knMqwt1hKZbc1BmQFmnm9f36nyQGwXxPGVpVJ9rMK5/go-libp2p-crypto" ) const IdentityTag = "Identity" diff --git a/config/init.go b/config/init.go index 6efc8712515..2f49b2bfdd2 100644 --- a/config/init.go +++ b/config/init.go @@ -7,8 +7,8 @@ import ( "io" "time" - peer "gx/ipfs/QmZoWKhxUmZ2seW4BzX6fJkNR8hh9PsGModr7q171yq2SS/go-libp2p-peer" - ci "gx/ipfs/QmaPbCnUMBohSGo3KnxEa2bHqyJVVeEEcwtqJAYxerieBo/go-libp2p-crypto" + peer "gx/ipfs/QmcJukH2sAFjY3HdBKq35WDzWoL3UUu2gt9wdfqZTUyM74/go-libp2p-peer" + ci "gx/ipfs/Qme1knMqwt1hKZbc1BmQFmnm9f36nyQGwXxPGVpVJ9rMK5/go-libp2p-crypto" ) func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { From 5455b50a3daf39684538460d9f5820a4cb2a2d9f Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 4 Jun 2018 09:53:40 -0700 Subject: [PATCH 145/262] go-ipfs-config: update multiplexers License: MIT Signed-off-by: Steven Allen --- config/bootstrap_peers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/bootstrap_peers.go b/config/bootstrap_peers.go index 8fa6f8bb648..bf87fea2c8c 100644 --- a/config/bootstrap_peers.go +++ b/config/bootstrap_peers.go @@ -4,7 +4,7 @@ import ( "errors" "fmt" - iaddr "gx/ipfs/QmcHEQW4F7u74t1Qpgvz654rGoX6frjFm3HJA67YCV9jia/go-ipfs-addr" + iaddr "gx/ipfs/QmSMVXVvKFrWoxEixGxY28CUhtyaGTfXiM6m2A7mZUyVHe/go-ipfs-addr" ) // DefaultBootstrapAddresses are the hardcoded bootstrap addresses From e66b6dd87293e5d813e6b32a8291cd3a30325e83 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 5 Jun 2018 23:55:08 -0700 Subject: [PATCH 146/262] go-ipfs-config: update gx imports License: MIT Signed-off-by: Steven Allen --- config/bootstrap_peers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/bootstrap_peers.go b/config/bootstrap_peers.go index bf87fea2c8c..176cdb10b48 100644 --- a/config/bootstrap_peers.go +++ b/config/bootstrap_peers.go @@ -4,7 +4,7 @@ import ( "errors" "fmt" - iaddr "gx/ipfs/QmSMVXVvKFrWoxEixGxY28CUhtyaGTfXiM6m2A7mZUyVHe/go-ipfs-addr" + iaddr "gx/ipfs/Qmey6omaMEzs9DiSQWwnPwTCJRn3RE8rWLjfidRrTzUq6t/go-ipfs-addr" ) // DefaultBootstrapAddresses are the hardcoded bootstrap addresses From 4a566363483e665f356677d52f61d38bc87dd25e Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Fri, 8 Jun 2018 22:01:00 -0700 Subject: [PATCH 147/262] go-ipfs-config: gx update go-log, sys, go-crypto * go-log * sys * go-crypto License: MIT Signed-off-by: Steven Allen --- config/bootstrap_peers.go | 2 +- config/init.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/bootstrap_peers.go b/config/bootstrap_peers.go index 176cdb10b48..e66ad36bb7c 100644 --- a/config/bootstrap_peers.go +++ b/config/bootstrap_peers.go @@ -4,7 +4,7 @@ import ( "errors" "fmt" - iaddr "gx/ipfs/Qmey6omaMEzs9DiSQWwnPwTCJRn3RE8rWLjfidRrTzUq6t/go-ipfs-addr" + iaddr "gx/ipfs/QmckPUj15AbTcLh6MpDEsQpfVCx34tmP2Xg1aNwLb5fiRF/go-ipfs-addr" ) // DefaultBootstrapAddresses are the hardcoded bootstrap addresses diff --git a/config/init.go b/config/init.go index 2f49b2bfdd2..e16806c46f8 100644 --- a/config/init.go +++ b/config/init.go @@ -7,7 +7,7 @@ import ( "io" "time" - peer "gx/ipfs/QmcJukH2sAFjY3HdBKq35WDzWoL3UUu2gt9wdfqZTUyM74/go-libp2p-peer" + peer "gx/ipfs/QmVf8hTAsLLFtn4WPCRNdnaF2Eag2qTBS6uR8AiHPZARXy/go-libp2p-peer" ci "gx/ipfs/Qme1knMqwt1hKZbc1BmQFmnm9f36nyQGwXxPGVpVJ9rMK5/go-libp2p-crypto" ) From 019e7b27d917e19a4209054cfdae7a3529f67f27 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 12 Jun 2018 14:37:29 -0700 Subject: [PATCH 148/262] go-ipfs-config: make ipfs swarm connect /ipfs/QmId work fixes #5102 Also, allow specifying multiple addresses for a single peer. License: MIT Signed-off-by: Steven Allen --- config/bootstrap_peers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/bootstrap_peers.go b/config/bootstrap_peers.go index e66ad36bb7c..74ca92e07cb 100644 --- a/config/bootstrap_peers.go +++ b/config/bootstrap_peers.go @@ -4,7 +4,7 @@ import ( "errors" "fmt" - iaddr "gx/ipfs/QmckPUj15AbTcLh6MpDEsQpfVCx34tmP2Xg1aNwLb5fiRF/go-ipfs-addr" + iaddr "gx/ipfs/QmaKviZCLQrpuyFdSjteik7kJFcQpcyZgb1VuuwaCBBaEa/go-ipfs-addr" ) // DefaultBootstrapAddresses are the hardcoded bootstrap addresses From 4b1900435f29e35df25c98f87042a9e348edcb4c Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 21 Jun 2018 14:35:43 -0700 Subject: [PATCH 149/262] go-ipfs-config: explicitly import go-multiaddr-dns in config/bootstrap_peers We need it to parse the dnsaddr addresses. While we import it elsewhere, we should really be importing it every where we need it so that other users can import our packages directly. fixes #5143 License: MIT Signed-off-by: Steven Allen --- config/bootstrap_peers.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config/bootstrap_peers.go b/config/bootstrap_peers.go index 74ca92e07cb..2c12a8b6588 100644 --- a/config/bootstrap_peers.go +++ b/config/bootstrap_peers.go @@ -5,6 +5,9 @@ import ( "fmt" iaddr "gx/ipfs/QmaKviZCLQrpuyFdSjteik7kJFcQpcyZgb1VuuwaCBBaEa/go-ipfs-addr" + // Needs to be imported so that users can import this package directly + // and still parse the bootstrap addresses. + _ "gx/ipfs/QmT8461vVVyBPyHJHQ6mvm8UdQ8UZNA5n6Z7kBk7GRf1xu/go-multiaddr-dns" ) // DefaultBootstrapAddresses are the hardcoded bootstrap addresses From 7fded300ef2abce8e6cbb2e328a5c2acde9f2d4e Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 25 Jun 2018 20:41:25 -0700 Subject: [PATCH 150/262] go-ipfs-config: gx update Updates: * go-kad-dht: Query performance improvements, DHT client fixes, validates records on *local* put. * go-libp2p-swarm/go-libp2p-transport: Timeout improvements. * go-multiaddr-net: Exposes useful Conn methods (CloseWrite, CloseRead, etc.) * go-log: fixes possible panic when enabling/disabling events. * go-multiaddr: fixes possible panic when stringifying malformed multiaddrs, adds support for consuming /p2p/ multiaddrs. fixes #5113 unblocks #4895 License: MIT Signed-off-by: Steven Allen --- config/bootstrap_peers.go | 4 ++-- config/init.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/bootstrap_peers.go b/config/bootstrap_peers.go index 2c12a8b6588..bf5a4534562 100644 --- a/config/bootstrap_peers.go +++ b/config/bootstrap_peers.go @@ -4,10 +4,10 @@ import ( "errors" "fmt" - iaddr "gx/ipfs/QmaKviZCLQrpuyFdSjteik7kJFcQpcyZgb1VuuwaCBBaEa/go-ipfs-addr" + iaddr "gx/ipfs/QmWUtfQveCqT8cgNzN54at4sDMiFbANFRFCXuSDiTqJwC8/go-ipfs-addr" // Needs to be imported so that users can import this package directly // and still parse the bootstrap addresses. - _ "gx/ipfs/QmT8461vVVyBPyHJHQ6mvm8UdQ8UZNA5n6Z7kBk7GRf1xu/go-multiaddr-dns" + _ "gx/ipfs/QmfXU2MhWoegxHoeMd3A2ytL2P6CY4FfqGWc23LTNWBwZt/go-multiaddr-dns" ) // DefaultBootstrapAddresses are the hardcoded bootstrap addresses diff --git a/config/init.go b/config/init.go index e16806c46f8..218d3251b0c 100644 --- a/config/init.go +++ b/config/init.go @@ -7,7 +7,7 @@ import ( "io" "time" - peer "gx/ipfs/QmVf8hTAsLLFtn4WPCRNdnaF2Eag2qTBS6uR8AiHPZARXy/go-libp2p-peer" + peer "gx/ipfs/QmdVrMn1LhB4ybb8hMVaMLXnA8XRSewMnK6YqXKXoTcRvN/go-libp2p-peer" ci "gx/ipfs/Qme1knMqwt1hKZbc1BmQFmnm9f36nyQGwXxPGVpVJ9rMK5/go-libp2p-crypto" ) From ee071dbd6a09736844b19f322e70303bb792b3e9 Mon Sep 17 00:00:00 2001 From: Kevin Atkinson Date: Sat, 23 Jun 2018 17:03:57 -0400 Subject: [PATCH 151/262] go-ipfs-config: Add config option to enable urlstore. License: MIT Signed-off-by: Kevin Atkinson --- config/experiments.go | 1 + 1 file changed, 1 insertion(+) diff --git a/config/experiments.go b/config/experiments.go index f76572ee2af..ab48c868159 100644 --- a/config/experiments.go +++ b/config/experiments.go @@ -2,6 +2,7 @@ package config type Experiments struct { FilestoreEnabled bool + UrlstoreEnabled bool ShardingEnabled bool Libp2pStreamMounting bool } From 54e8e770fbb651e303cfc6d2c55fe66758d1644f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Sun, 22 Jul 2018 21:31:49 +0200 Subject: [PATCH 152/262] go-ipfs-config: move serialize package to config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera --- config/serialize/serialize.go | 71 ++++++++++++++++++++++++++++++ config/serialize/serialize_test.go | 37 ++++++++++++++++ 2 files changed, 108 insertions(+) create mode 100644 config/serialize/serialize.go create mode 100644 config/serialize/serialize_test.go diff --git a/config/serialize/serialize.go b/config/serialize/serialize.go new file mode 100644 index 00000000000..f1a48251320 --- /dev/null +++ b/config/serialize/serialize.go @@ -0,0 +1,71 @@ +package fsrepo + +import ( + "encoding/json" + "errors" + "fmt" + "io" + "os" + "path/filepath" + + "github.com/ipfs/go-ipfs/repo/config" + + "gx/ipfs/QmPdKqUcHGFdeSpvjVoaTRPPstGif9GBZb5Q56RVw9o69A/go-ipfs-util" + "gx/ipfs/QmdYwCmx8pZRkzdcd8MhmLJqYVoVTC1aGsy5Q4reMGLNLg/atomicfile" +) + +// ReadConfigFile reads the config from `filename` into `cfg`. +func ReadConfigFile(filename string, cfg interface{}) error { + f, err := os.Open(filename) + if err != nil { + return err + } + defer f.Close() + if err := json.NewDecoder(f).Decode(cfg); err != nil { + return fmt.Errorf("failure to decode config: %s", err) + } + return nil +} + +// WriteConfigFile writes the config from `cfg` into `filename`. +func WriteConfigFile(filename string, cfg interface{}) error { + err := os.MkdirAll(filepath.Dir(filename), 0775) + if err != nil { + return err + } + + f, err := atomicfile.New(filename, 0660) + if err != nil { + return err + } + defer f.Close() + + return encode(f, cfg) +} + +// encode configuration with JSON +func encode(w io.Writer, value interface{}) error { + // need to prettyprint, hence MarshalIndent, instead of Encoder + buf, err := config.Marshal(value) + if err != nil { + return err + } + _, err = w.Write(buf) + return err +} + +// Load reads given file and returns the read config, or error. +func Load(filename string) (*config.Config, error) { + // if nothing is there, fail. User must run 'ipfs init' + if !util.FileExists(filename) { + return nil, errors.New("ipfs not initialized, please run 'ipfs init'") + } + + var cfg config.Config + err := ReadConfigFile(filename, &cfg) + if err != nil { + return nil, err + } + + return &cfg, err +} diff --git a/config/serialize/serialize_test.go b/config/serialize/serialize_test.go new file mode 100644 index 00000000000..443024ed8f6 --- /dev/null +++ b/config/serialize/serialize_test.go @@ -0,0 +1,37 @@ +package fsrepo + +import ( + "os" + "runtime" + "testing" + + config "github.com/ipfs/go-ipfs/repo/config" +) + +func TestConfig(t *testing.T) { + const filename = ".ipfsconfig" + cfgWritten := new(config.Config) + cfgWritten.Identity.PeerID = "faketest" + + err := WriteConfigFile(filename, cfgWritten) + if err != nil { + t.Fatal(err) + } + cfgRead, err := Load(filename) + if err != nil { + t.Fatal(err) + } + if cfgWritten.Identity.PeerID != cfgRead.Identity.PeerID { + t.Fatal() + } + st, err := os.Stat(filename) + if err != nil { + t.Fatalf("cannot stat config file: %v", err) + } + + if runtime.GOOS != "windows" { // see https://golang.org/src/os/types_windows.go + if g := st.Mode().Perm(); g&0117 != 0 { + t.Fatalf("config file should not be executable or accessible to world: %v", g) + } + } +} From d67080f478b0dc7671addd0b52cda27ee6f83421 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Mon, 23 Jul 2018 16:12:26 +0200 Subject: [PATCH 153/262] go-ipfs-config: Setup gx --- config/config.go | 2 +- config/serialize/serialize.go | 2 +- config/serialize/serialize_test.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/config.go b/config/config.go index 8ec6d324aeb..59c1c6c46b9 100644 --- a/config/config.go +++ b/config/config.go @@ -9,7 +9,7 @@ import ( "path/filepath" "strings" - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/mitchellh/go-homedir" + "gx/ipfs/QmdcULN1WCzgoQmcCaUAmEhwcxHYsDrbZ2LvRJKCL8dMrK/go-homedir" ) // Config is used to load ipfs config files. diff --git a/config/serialize/serialize.go b/config/serialize/serialize.go index f1a48251320..366d167995b 100644 --- a/config/serialize/serialize.go +++ b/config/serialize/serialize.go @@ -8,7 +8,7 @@ import ( "os" "path/filepath" - "github.com/ipfs/go-ipfs/repo/config" + "github.com/ipfs/go-ipfs-config" "gx/ipfs/QmPdKqUcHGFdeSpvjVoaTRPPstGif9GBZb5Q56RVw9o69A/go-ipfs-util" "gx/ipfs/QmdYwCmx8pZRkzdcd8MhmLJqYVoVTC1aGsy5Q4reMGLNLg/atomicfile" diff --git a/config/serialize/serialize_test.go b/config/serialize/serialize_test.go index 443024ed8f6..e5abdb852f3 100644 --- a/config/serialize/serialize_test.go +++ b/config/serialize/serialize_test.go @@ -5,7 +5,7 @@ import ( "runtime" "testing" - config "github.com/ipfs/go-ipfs/repo/config" + config "github.com/ipfs/go-ipfs-config" ) func TestConfig(t *testing.T) { From 757f25d4b152aa72817b84a780ac606c499e5894 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Mon, 23 Jul 2018 16:13:00 +0200 Subject: [PATCH 154/262] go-ipfs-config: gx-go uw --- config/bootstrap_peers.go | 4 ++-- config/config.go | 2 +- config/identity.go | 2 +- config/init.go | 4 ++-- config/serialize/serialize.go | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/config/bootstrap_peers.go b/config/bootstrap_peers.go index bf5a4534562..92fc580eabe 100644 --- a/config/bootstrap_peers.go +++ b/config/bootstrap_peers.go @@ -4,10 +4,10 @@ import ( "errors" "fmt" - iaddr "gx/ipfs/QmWUtfQveCqT8cgNzN54at4sDMiFbANFRFCXuSDiTqJwC8/go-ipfs-addr" + iaddr "github.com/ipfs/go-ipfs-addr" // Needs to be imported so that users can import this package directly // and still parse the bootstrap addresses. - _ "gx/ipfs/QmfXU2MhWoegxHoeMd3A2ytL2P6CY4FfqGWc23LTNWBwZt/go-multiaddr-dns" + _ "github.com/multiformats/go-multiaddr-dns" ) // DefaultBootstrapAddresses are the hardcoded bootstrap addresses diff --git a/config/config.go b/config/config.go index 59c1c6c46b9..c1eefea10b1 100644 --- a/config/config.go +++ b/config/config.go @@ -9,7 +9,7 @@ import ( "path/filepath" "strings" - "gx/ipfs/QmdcULN1WCzgoQmcCaUAmEhwcxHYsDrbZ2LvRJKCL8dMrK/go-homedir" + "github.com/mitchellh/go-homedir" ) // Config is used to load ipfs config files. diff --git a/config/identity.go b/config/identity.go index 60fe772d911..c09af56440f 100644 --- a/config/identity.go +++ b/config/identity.go @@ -3,7 +3,7 @@ package config import ( "encoding/base64" - ic "gx/ipfs/Qme1knMqwt1hKZbc1BmQFmnm9f36nyQGwXxPGVpVJ9rMK5/go-libp2p-crypto" + ic "github.com/libp2p/go-libp2p-crypto" ) const IdentityTag = "Identity" diff --git a/config/init.go b/config/init.go index 218d3251b0c..5f8ab8a43f6 100644 --- a/config/init.go +++ b/config/init.go @@ -7,8 +7,8 @@ import ( "io" "time" - peer "gx/ipfs/QmdVrMn1LhB4ybb8hMVaMLXnA8XRSewMnK6YqXKXoTcRvN/go-libp2p-peer" - ci "gx/ipfs/Qme1knMqwt1hKZbc1BmQFmnm9f36nyQGwXxPGVpVJ9rMK5/go-libp2p-crypto" + ci "github.com/libp2p/go-libp2p-crypto" + peer "github.com/libp2p/go-libp2p-peer" ) func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { diff --git a/config/serialize/serialize.go b/config/serialize/serialize.go index 366d167995b..eedf7e1aa53 100644 --- a/config/serialize/serialize.go +++ b/config/serialize/serialize.go @@ -10,8 +10,8 @@ import ( "github.com/ipfs/go-ipfs-config" - "gx/ipfs/QmPdKqUcHGFdeSpvjVoaTRPPstGif9GBZb5Q56RVw9o69A/go-ipfs-util" - "gx/ipfs/QmdYwCmx8pZRkzdcd8MhmLJqYVoVTC1aGsy5Q4reMGLNLg/atomicfile" + "github.com/facebookgo/atomicfile" + "github.com/ipfs/go-ipfs-util" ) // ReadConfigFile reads the config from `filename` into `cfg`. From 512b4d3b156104fc32c3930b3736b4fe290b28fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Mon, 23 Jul 2018 19:04:48 +0200 Subject: [PATCH 155/262] go-ipfs-config: remove version.go --- config/init.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/config/init.go b/config/init.go index 5f8ab8a43f6..c4ea9e41bcd 100644 --- a/config/init.go +++ b/config/init.go @@ -26,9 +26,7 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { conf := &Config{ API: API{ - HTTPHeaders: map[string][]string{ - "Server": {"go-ipfs/" + CurrentVersionNumber}, - }, + HTTPHeaders: map[string][]string{}, }, // setup the node's default addresses. From 212b72f236c6c6d0836a0eafacb774c17e67e52d Mon Sep 17 00:00:00 2001 From: vyzo Date: Sun, 12 Aug 2018 14:16:38 +0300 Subject: [PATCH 156/262] go-ipfs-config: add pubsub configuration --- config/config.go | 1 + config/pubsub.go | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 config/pubsub.go diff --git a/config/config.go b/config/config.go index c1eefea10b1..44b700f1141 100644 --- a/config/config.go +++ b/config/config.go @@ -25,6 +25,7 @@ type Config struct { Gateway Gateway // local node's gateway server options API API // local node's API settings Swarm SwarmConfig + Pubsub PubsubConfig Reprovider Reprovider Experimental Experiments diff --git a/config/pubsub.go b/config/pubsub.go new file mode 100644 index 00000000000..da25b0f24d1 --- /dev/null +++ b/config/pubsub.go @@ -0,0 +1,5 @@ +package config + +type PubsubConfig struct { + Router string +} From 32cf2a65d75139a91d6c028fe4bdfe42ac8b9ca8 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Sun, 26 Aug 2018 10:42:03 +0700 Subject: [PATCH 157/262] go-ipfs-config: add QUIC experiment --- config/experiments.go | 1 + 1 file changed, 1 insertion(+) diff --git a/config/experiments.go b/config/experiments.go index ab48c868159..d6c3d99531c 100644 --- a/config/experiments.go +++ b/config/experiments.go @@ -5,4 +5,5 @@ type Experiments struct { UrlstoreEnabled bool ShardingEnabled bool Libp2pStreamMounting bool + QUIC bool } From 6a618df199319152a78fdf343f3bbb0d1720f201 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Sat, 15 Sep 2018 13:56:12 -0700 Subject: [PATCH 158/262] go-ipfs-config: allow multiple API/Gateway addresses Alternative to #6 that doesn't require a migration. --- config/addresses.go | 4 ++-- config/init.go | 4 ++-- config/profile.go | 4 ++-- config/types.go | 37 +++++++++++++++++++++++++++++++++++++ 4 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 config/types.go diff --git a/config/addresses.go b/config/addresses.go index 22c530655b2..2d88468fdac 100644 --- a/config/addresses.go +++ b/config/addresses.go @@ -5,6 +5,6 @@ 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 + API Strings // address for the local API (RPC) + Gateway Strings // address to listen on for IPFS HTTP object gateway } diff --git a/config/init.go b/config/init.go index c4ea9e41bcd..f45bf56725b 100644 --- a/config/init.go +++ b/config/init.go @@ -105,8 +105,8 @@ func addressesConfig() Addresses { }, Announce: []string{}, NoAnnounce: []string{}, - API: "/ip4/127.0.0.1/tcp/5001", - Gateway: "/ip4/127.0.0.1/tcp/8080", + API: Strings{"/ip4/127.0.0.1/tcp/5001"}, + Gateway: Strings{"/ip4/127.0.0.1/tcp/8080"}, } } diff --git a/config/profile.go b/config/profile.go index d3f1b42d09c..d23cadc6d97 100644 --- a/config/profile.go +++ b/config/profile.go @@ -66,8 +66,8 @@ profile, enables discovery in local networks.`, 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.API = Strings{"/ip4/127.0.0.1/tcp/0"} + c.Addresses.Gateway = Strings{"/ip4/127.0.0.1/tcp/0"} c.Addresses.Swarm = []string{ "/ip4/127.0.0.1/tcp/0", } diff --git a/config/types.go b/config/types.go new file mode 100644 index 00000000000..376cc64f072 --- /dev/null +++ b/config/types.go @@ -0,0 +1,37 @@ +package config + +import ( + "encoding/json" +) + +// Strings is a helper type that (un)marshals a single string to/from a single +// JSON string and a slice of strings to/from a JSON array of strings. +type Strings []string + +// UnmarshalJSON conforms to the json.Unmarshaler interface. +func (o *Strings) UnmarshalJSON(data []byte) error { + if data[0] == '[' { + return json.Unmarshal(data, (*[]string)(o)) + } + var value string + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *o = []string{value} + return nil +} + +// MarshalJSON conforms to the json.Marshaler interface. +func (o Strings) MarshalJSON() ([]byte, error) { + switch len(o) { + case 0: + return json.Marshal(nil) + case 1: + return json.Marshal(o[0]) + default: + return json.Marshal([]string(o)) + } +} + +var _ json.Unmarshaler = (*Strings)(nil) +var _ json.Marshaler = (*Strings)(nil) From d7c1f55724a48c24372628096c0bf3300bb4f0fd Mon Sep 17 00:00:00 2001 From: Lars Gierth Date: Sat, 15 Sep 2018 21:22:38 +0200 Subject: [PATCH 159/262] go-ipfs-config: Add Gateway.APICommands for /api allowlists --- config/gateway.go | 1 + config/init.go | 1 + 2 files changed, 2 insertions(+) diff --git a/config/gateway.go b/config/gateway.go index a8ba7059071..7e64b566fb4 100644 --- a/config/gateway.go +++ b/config/gateway.go @@ -6,4 +6,5 @@ type Gateway struct { RootRedirect string Writable bool PathPrefixes []string + APICommands []string } diff --git a/config/init.go b/config/init.go index c4ea9e41bcd..22aa699b8e3 100644 --- a/config/init.go +++ b/config/init.go @@ -66,6 +66,7 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { "Access-Control-Allow-Methods": []string{"GET"}, "Access-Control-Allow-Headers": []string{"X-Requested-With", "Range"}, }, + APICommands: []string{}, }, Reprovider: Reprovider{ Interval: "12h", From 6a3a087039664e3735aece67f887d32e0006d27e Mon Sep 17 00:00:00 2001 From: Lars Gierth Date: Wed, 3 Oct 2018 08:04:32 +0200 Subject: [PATCH 160/262] go-ipfs-config: Fix handling of null strings --- config/types.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/config/types.go b/config/types.go index 376cc64f072..58451c68f12 100644 --- a/config/types.go +++ b/config/types.go @@ -17,7 +17,11 @@ func (o *Strings) UnmarshalJSON(data []byte) error { if err := json.Unmarshal(data, &value); err != nil { return err } - *o = []string{value} + if len(value) == 0 { + *o = []string{} + } else { + *o = []string{value} + } return nil } From 43a6230e1409a68dd7a3f874cef7e1e16288dea0 Mon Sep 17 00:00:00 2001 From: Dr Ian Preston Date: Thu, 4 Oct 2018 23:42:48 +0100 Subject: [PATCH 161/262] go-ipfs-config: add experiment for p2p http proxy License: MIT Signed-off-by: Ian Preston --- config/experiments.go | 1 + 1 file changed, 1 insertion(+) diff --git a/config/experiments.go b/config/experiments.go index d6c3d99531c..828953360e6 100644 --- a/config/experiments.go +++ b/config/experiments.go @@ -5,5 +5,6 @@ type Experiments struct { UrlstoreEnabled bool ShardingEnabled bool Libp2pStreamMounting bool + P2pHttpProxy bool QUIC bool } From 1ca5f8e640203f2d1ea7aff2222dfcb6cc43c228 Mon Sep 17 00:00:00 2001 From: Ivan Date: Sun, 14 Oct 2018 21:32:55 +0200 Subject: [PATCH 162/262] go-ipfs-config: Allow the use of the User-Agent header License: MIT Signed-off-by: Ivan --- config/init.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/init.go b/config/init.go index a6e70b71184..f45a596737f 100644 --- a/config/init.go +++ b/config/init.go @@ -64,7 +64,7 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { HTTPHeaders: map[string][]string{ "Access-Control-Allow-Origin": []string{"*"}, "Access-Control-Allow-Methods": []string{"GET"}, - "Access-Control-Allow-Headers": []string{"X-Requested-With", "Range"}, + "Access-Control-Allow-Headers": []string{"X-Requested-With", "Range", "User-Agent"}, }, APICommands: []string{}, }, From 7cecbb9dce8b6db19d0c976248f1f0d2d6ca85f5 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 25 Oct 2018 10:15:54 -0700 Subject: [PATCH 163/262] go-ipfs-config: add pubsub message signing options to config --- config/pubsub.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/config/pubsub.go b/config/pubsub.go index da25b0f24d1..94e03e28b82 100644 --- a/config/pubsub.go +++ b/config/pubsub.go @@ -1,5 +1,18 @@ package config type PubsubConfig struct { + // Router can be either floodsub (legacy) or gossipsub (new and + // backwards compatible). Router string + + // DisableSigning disables message signing. Message signing is *enabled* + // by default. + DisableSigning bool + + // StrictSignatureVerification enables strict signature verification. + // When enabled, unsigned messages will be rejected. Eventually, this + // will be made the default and this option will disappear. Once this + // happens, networks will either need to completely disable or + // completely enable message signing. + StrictSignatureVerification bool } From 77a3e94a6330a964aa27f8269d50ae1ee39aa613 Mon Sep 17 00:00:00 2001 From: Lucas Molas Date: Mon, 29 Oct 2018 11:03:54 -0300 Subject: [PATCH 164/262] go-ipfs-config: profile: add badger truncate option --- config/profile.go | 1 + 1 file changed, 1 insertion(+) diff --git a/config/profile.go b/config/profile.go index d23cadc6d97..38f3f861d58 100644 --- a/config/profile.go +++ b/config/profile.go @@ -121,6 +121,7 @@ Make sure to backup your data frequently.`, "type": "badgerds", "path": "badgerds", "syncWrites": true, + "truncate": true, }, } return nil From b83ea099ff15ff9952d0f078302025838bfa926d Mon Sep 17 00:00:00 2001 From: tarekbadr Date: Sat, 3 Nov 2018 15:41:49 +0200 Subject: [PATCH 165/262] go-ipfs-config: change randomports Description --- config/profile.go | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/config/profile.go b/config/profile.go index d23cadc6d97..ee568b4033f 100644 --- a/config/profile.go +++ b/config/profile.go @@ -1,6 +1,10 @@ package config -import "time" +import ( + "fmt" + "net" + "time" +) // Transformer is a function which takes configuration and applies some filter to it type Transformer func(c *Config) error @@ -159,6 +163,31 @@ fetching may be degraded. return nil }, }, + "randomports": { + Description: `Use a random port number for swarm.`, + + Transform: func(c *Config) error { + port, err := getAvailablePort() + if err != nil { + return err + } + c.Addresses.Swarm = []string{ + fmt.Sprintf("/ip4/0.0.0.0/tcp/%d", port), + fmt.Sprintf("/ip6/::/tcp/%d", port), + } + return nil + }, + }, +} + +func getAvailablePort() (port int, err error) { + ln, err := net.Listen("tcp", "[::]:0") + if err != nil { + return 0, err + } + defer ln.Close() + port = ln.Addr().(*net.TCPAddr).Port + return port, nil } func appendSingle(a []string, b []string) []string { From bf2923e47b37089c85c20ab339ab84083e8f59df Mon Sep 17 00:00:00 2001 From: vyzo Date: Tue, 20 Nov 2018 12:53:47 +0200 Subject: [PATCH 166/262] go-ipfs-config: autorelay options --- config/swarm.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/config/swarm.go b/config/swarm.go index 5b128f38aab..16dc54d9cba 100644 --- a/config/swarm.go +++ b/config/swarm.go @@ -7,6 +7,12 @@ type SwarmConfig struct { DisableRelay bool EnableRelayHop bool + // autorelay functionality + // if true, then the libp2p host will be constructed with autorelay functionality. + EnableAutoRelay bool + // if true, then an AutoNATService will be instantiated to facilitate autorelay + EnableAutoNATService bool + ConnMgr ConnMgr } From b627585f2826938f964cbb5a44b5f710d08bdeee Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 23 Oct 2018 09:47:51 -0700 Subject: [PATCH 167/262] go-ipfs-config: add a Clone function The user must call this before modifying the config. Given that the config contains slices/maps modifications can modified *shared* state, even after dereferencing. --- config/config.go | 16 ++++++++++++++++ config/config_test.go | 23 +++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 config/config_test.go diff --git a/config/config.go b/config/config.go index 44b700f1141..dc987547951 100644 --- a/config/config.go +++ b/config/config.go @@ -110,3 +110,19 @@ func ToMap(conf *Config) (map[string]interface{}, error) { } return m, nil } + +// Clone copies the config. Use when updating. +func (c *Config) Clone() (*Config, error) { + var newConfig Config + var buf bytes.Buffer + + if err := json.NewEncoder(&buf).Encode(c); err != nil { + return nil, fmt.Errorf("failure to encode config: %s", err) + } + + if err := json.NewDecoder(&buf).Decode(&newConfig); err != nil { + return nil, fmt.Errorf("failure to decode config: %s", err) + } + + return &newConfig, nil +} diff --git a/config/config_test.go b/config/config_test.go new file mode 100644 index 00000000000..9c82bb2ff1a --- /dev/null +++ b/config/config_test.go @@ -0,0 +1,23 @@ +package config + +import ( + "testing" +) + +func TestClone(t *testing.T) { + c := new(Config) + c.Identity.PeerID = "faketest" + c.API.HTTPHeaders = map[string][]string{"foo": []string{"bar"}} + + newCfg, err := c.Clone() + if err != nil { + t.Fatal(err) + } + if newCfg.Identity.PeerID != c.Identity.PeerID { + t.Fatal("peer ID not preserved") + } + delete(c.API.HTTPHeaders, "foo") + if newCfg.API.HTTPHeaders["foo"][0] != "bar" { + t.Fatal("HTTP headers not preserved") + } +} From 3cd45d889ab0326cbafd6b36c17aa9d81991cea7 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 23 Oct 2018 09:49:35 -0700 Subject: [PATCH 168/262] go-ipfs-config: add tests for the "Strings" type (missed in my previous PR) --- config/types_test.go | 53 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 config/types_test.go diff --git a/config/types_test.go b/config/types_test.go new file mode 100644 index 00000000000..7523962ae83 --- /dev/null +++ b/config/types_test.go @@ -0,0 +1,53 @@ +package config + +import ( + "encoding/json" + "testing" +) + +func TestOneStrings(t *testing.T) { + out, err := json.Marshal(Strings{"one"}) + if err != nil { + t.Fatal(err) + + } + expected := "\"one\"" + if string(out) != expected { + t.Fatalf("expected %s, got %s", expected, string(out)) + } +} + +func TestNoStrings(t *testing.T) { + out, err := json.Marshal(Strings{}) + if err != nil { + t.Fatal(err) + + } + expected := "null" + if string(out) != expected { + t.Fatalf("expected %s, got %s", expected, string(out)) + } +} + +func TestManyStrings(t *testing.T) { + out, err := json.Marshal(Strings{"one", "two"}) + if err != nil { + t.Fatal(err) + + } + expected := "[\"one\",\"two\"]" + if string(out) != expected { + t.Fatalf("expected %s, got %s", expected, string(out)) + } +} + +func TestFunkyStrings(t *testing.T) { + toParse := " [ \"one\", \"two\" ] " + var s Strings + if err := json.Unmarshal([]byte(toParse), &s); err != nil { + t.Fatal(err) + } + if len(s) != 2 || s[0] != "one" && s[1] != "two" { + t.Fatalf("unexpected result: %v", s) + } +} From e4282bdb7ab3f69d892b1d4e0798b3823e181555 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 6 Nov 2018 15:39:53 +0100 Subject: [PATCH 169/262] go-ipfs-config: Add one more test for config.Clone --- config/config_test.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/config/config_test.go b/config/config_test.go index 9c82bb2ff1a..dead06f8a23 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -7,7 +7,7 @@ import ( func TestClone(t *testing.T) { c := new(Config) c.Identity.PeerID = "faketest" - c.API.HTTPHeaders = map[string][]string{"foo": []string{"bar"}} + c.API.HTTPHeaders = map[string][]string{"foo": {"bar"}} newCfg, err := c.Clone() if err != nil { @@ -16,6 +16,12 @@ func TestClone(t *testing.T) { if newCfg.Identity.PeerID != c.Identity.PeerID { t.Fatal("peer ID not preserved") } + + c.API.HTTPHeaders["foo"] = []string{"baz"} + if newCfg.API.HTTPHeaders["foo"][0] != "bar" { + t.Fatal("HTTP headers not preserved") + } + delete(c.API.HTTPHeaders, "foo") if newCfg.API.HTTPHeaders["foo"][0] != "bar" { t.Fatal("HTTP headers not preserved") From bc31fd957c8d9db529f69e20f39954d0b0971570 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 26 Oct 2018 01:55:25 +0200 Subject: [PATCH 170/262] go-ipfs-config: Add Gateway.NoFetch --- config/gateway.go | 1 + config/init.go | 1 + 2 files changed, 2 insertions(+) diff --git a/config/gateway.go b/config/gateway.go index 7e64b566fb4..017be9b285b 100644 --- a/config/gateway.go +++ b/config/gateway.go @@ -7,4 +7,5 @@ type Gateway struct { Writable bool PathPrefixes []string APICommands []string + NoFetch bool } diff --git a/config/init.go b/config/init.go index f45a596737f..0697cc4c928 100644 --- a/config/init.go +++ b/config/init.go @@ -60,6 +60,7 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { Gateway: Gateway{ RootRedirect: "", Writable: false, + NoFetch: false, PathPrefixes: []string{}, HTTPHeaders: map[string][]string{ "Access-Control-Allow-Origin": []string{"*"}, From 3475f8350a253eb09f99aeff5ff2f65ab5052865 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Thu, 18 Apr 2019 09:11:09 +0900 Subject: [PATCH 171/262] go-ipfs-config: add an experiment to prefer TLS over secio --- config/experiments.go | 1 + 1 file changed, 1 insertion(+) diff --git a/config/experiments.go b/config/experiments.go index 828953360e6..c5cb0cf2fbd 100644 --- a/config/experiments.go +++ b/config/experiments.go @@ -7,4 +7,5 @@ type Experiments struct { Libp2pStreamMounting bool P2pHttpProxy bool QUIC bool + PreferTLS bool } From c920b46f46ae71e284778762d34df2151cfcbc86 Mon Sep 17 00:00:00 2001 From: Teran McKinney Date: Wed, 1 May 2019 17:21:56 +0000 Subject: [PATCH 172/262] go-ipfs-config: Closes: #6284 Add appropriate IPv6 ranges to defaultServerFilters --- config/profile.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/config/profile.go b/config/profile.go index f293202eac5..458f6a82214 100644 --- a/config/profile.go +++ b/config/profile.go @@ -18,8 +18,9 @@ type Profile struct { 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 +// defaultServerFilters has is a list of IPv4 and IPv6 prefixes that are private, local only, or unrouteable. +// according to https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml +// and https://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtml var defaultServerFilters = []string{ "/ip4/10.0.0.0/ipcidr/8", "/ip4/100.64.0.0/ipcidr/10", @@ -36,6 +37,11 @@ var defaultServerFilters = []string{ "/ip4/198.51.100.0/ipcidr/24", "/ip4/203.0.113.0/ipcidr/24", "/ip4/240.0.0.0/ipcidr/4", + "/ip6/100::/ipcidr/64", + "/ip6/2001:2::/ipcidr/48", + "/ip6/2001:db8::/ipcidr/32", + "/ip6/fc00::/ipcidr/7", + "/ip6/fe80::/ipcidr/10", } // Profiles is a map holding configuration transformers. Docs are in docs/config.md From b2029f15c7a8cc618da4ebf709cc3b2f21b95ce7 Mon Sep 17 00:00:00 2001 From: Michael Avila Date: Thu, 18 Apr 2019 13:54:58 -0700 Subject: [PATCH 173/262] go-ipfs-config: Add provider system experiment --- config/experiments.go | 1 + 1 file changed, 1 insertion(+) diff --git a/config/experiments.go b/config/experiments.go index c5cb0cf2fbd..6821ed6bc81 100644 --- a/config/experiments.go +++ b/config/experiments.go @@ -8,4 +8,5 @@ type Experiments struct { P2pHttpProxy bool QUIC bool PreferTLS bool + StrategicProviding bool } From e76a8cf714d93cf5c1dd3561d82225fa0aa6db7c Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Fri, 31 May 2019 12:54:12 -0700 Subject: [PATCH 174/262] go-ipfs-config: migrate to the consolidated libp2p BREAKING: this also removes the dependency on go-ipfs-addr so we can deprecate that package. This only appears to affect go-ipfs itself. --- config/bootstrap_peers.go | 36 +++++++++++++++--------------------- config/identity.go | 2 +- config/init.go | 4 ++-- 3 files changed, 18 insertions(+), 24 deletions(-) diff --git a/config/bootstrap_peers.go b/config/bootstrap_peers.go index 92fc580eabe..9141c8bee89 100644 --- a/config/bootstrap_peers.go +++ b/config/bootstrap_peers.go @@ -4,7 +4,9 @@ import ( "errors" "fmt" - iaddr "github.com/ipfs/go-ipfs-addr" + peer "github.com/libp2p/go-libp2p-core/peer" + ma "github.com/multiformats/go-multiaddr" + // Needs to be imported so that users can import this package directly // and still parse the bootstrap addresses. _ "github.com/multiformats/go-multiaddr-dns" @@ -32,20 +34,17 @@ var DefaultBootstrapAddresses = []string{ "/ip6/2a03:b0c0:0:1010::23:1001/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd", // earth.i.ipfs.io } -// BootstrapPeer is a peer used to bootstrap the network. -type BootstrapPeer iaddr.IPFSAddr - // ErrInvalidPeerAddr signals an address is not a valid peer address. var ErrInvalidPeerAddr = errors.New("invalid peer address") -func (c *Config) BootstrapPeers() ([]BootstrapPeer, error) { +func (c *Config) BootstrapPeers() ([]peer.AddrInfo, error) { return ParseBootstrapPeers(c.Bootstrap) } // 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 DefaultBootstrapPeers() ([]BootstrapPeer, error) { +func DefaultBootstrapPeers() ([]peer.AddrInfo, error) { ps, err := ParseBootstrapPeers(DefaultBootstrapAddresses) if err != nil { return nil, fmt.Errorf(`failed to parse hardcoded bootstrap peers: %s @@ -54,31 +53,26 @@ This is a problem with the ipfs codebase. Please report it to the dev team.`, er return ps, nil } -func (c *Config) SetBootstrapPeers(bps []BootstrapPeer) { +func (c *Config) SetBootstrapPeers(bps []peer.AddrInfo) { c.Bootstrap = BootstrapPeerStrings(bps) } -func ParseBootstrapPeer(addr string) (BootstrapPeer, error) { - ia, err := iaddr.ParseString(addr) - if err != nil { - return nil, err - } - return BootstrapPeer(ia), err -} - -func ParseBootstrapPeers(addrs []string) ([]BootstrapPeer, error) { - peers := make([]BootstrapPeer, len(addrs)) - var err error +// ParseBootstrapPeer parses a bootstrap list into a list of AddrInfos. +func ParseBootstrapPeers(addrs []string) ([]peer.AddrInfo, error) { + maddrs := make([]ma.Multiaddr, len(addrs)) for i, addr := range addrs { - peers[i], err = ParseBootstrapPeer(addr) + var err error + maddrs[i], err = ma.NewMultiaddr(addr) if err != nil { return nil, err } } - return peers, nil + return peer.AddrInfosFromP2pAddrs(maddrs...) } -func BootstrapPeerStrings(bps []BootstrapPeer) []string { +// BootstrapPeerStrings formats a list of AddrInfos as a bootstrap peer list +// suitable for serialization. +func BootstrapPeerStrings(bps []peer.AddrInfo) []string { bpss := make([]string, len(bps)) for i, p := range bps { bpss[i] = p.String() diff --git a/config/identity.go b/config/identity.go index c09af56440f..f4e7c87200d 100644 --- a/config/identity.go +++ b/config/identity.go @@ -3,7 +3,7 @@ package config import ( "encoding/base64" - ic "github.com/libp2p/go-libp2p-crypto" + ic "github.com/libp2p/go-libp2p-core/crypto" ) const IdentityTag = "Identity" diff --git a/config/init.go b/config/init.go index 0697cc4c928..7f11c3a3d06 100644 --- a/config/init.go +++ b/config/init.go @@ -7,8 +7,8 @@ import ( "io" "time" - ci "github.com/libp2p/go-libp2p-crypto" - peer "github.com/libp2p/go-libp2p-peer" + ci "github.com/libp2p/go-libp2p-core/crypto" + peer "github.com/libp2p/go-libp2p-core/peer" ) func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { From e9c30cf35647e317588dec94c9cdc7a8b19ca7d1 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Sat, 1 Jun 2019 09:00:12 -0700 Subject: [PATCH 175/262] go-ipfs-config: fix string formatting of bootstrap peers --- config/bootstrap_peers.go | 13 ++++++++++--- config/bootstrap_peers_test.go | 24 ++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 config/bootstrap_peers_test.go diff --git a/config/bootstrap_peers.go b/config/bootstrap_peers.go index 9141c8bee89..f4a13dc9d06 100644 --- a/config/bootstrap_peers.go +++ b/config/bootstrap_peers.go @@ -73,9 +73,16 @@ func ParseBootstrapPeers(addrs []string) ([]peer.AddrInfo, error) { // BootstrapPeerStrings formats a list of AddrInfos as a bootstrap peer list // suitable for serialization. func BootstrapPeerStrings(bps []peer.AddrInfo) []string { - bpss := make([]string, len(bps)) - for i, p := range bps { - bpss[i] = p.String() + bpss := make([]string, 0, len(bps)) + for _, pi := range bps { + addrs, err := peer.AddrInfoToP2pAddrs(&pi) + if err != nil { + // programmer error. + panic(err) + } + for _, addr := range addrs { + bpss = append(bpss, addr.String()) + } } return bpss } diff --git a/config/bootstrap_peers_test.go b/config/bootstrap_peers_test.go new file mode 100644 index 00000000000..eeea9b5fdc0 --- /dev/null +++ b/config/bootstrap_peers_test.go @@ -0,0 +1,24 @@ +package config + +import ( + "sort" + "testing" +) + +func TestBoostrapPeerStrings(t *testing.T) { + parsed, err := ParseBootstrapPeers(DefaultBootstrapAddresses) + if err != nil { + t.Fatal(err) + } + + formatted := BootstrapPeerStrings(parsed) + sort.Strings(formatted) + expected := append([]string{}, DefaultBootstrapAddresses...) + sort.Strings(expected) + + for i, s := range formatted { + if expected[i] != s { + t.Fatalf("expected %s, %s", expected[i], s) + } + } +} From f61d052ce10a04119867d18b5959deb385f5656f Mon Sep 17 00:00:00 2001 From: Michael Avila Date: Thu, 27 Jun 2019 12:20:44 -0700 Subject: [PATCH 176/262] go-ipfs-config: Add very basic (possibly temporary) Provider configs --- config/config.go | 1 + config/provider.go | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 config/provider.go diff --git a/config/config.go b/config/config.go index dc987547951..3a5d3fe2060 100644 --- a/config/config.go +++ b/config/config.go @@ -27,6 +27,7 @@ type Config struct { Swarm SwarmConfig Pubsub PubsubConfig + Provider Provider Reprovider Reprovider Experimental Experiments } diff --git a/config/provider.go b/config/provider.go new file mode 100644 index 00000000000..f2b5afe05b4 --- /dev/null +++ b/config/provider.go @@ -0,0 +1,5 @@ +package config + +type Provider struct { + Strategy string // Which keys to announce +} From 86abf1fc5758f08e30244c30c9826d338200a545 Mon Sep 17 00:00:00 2001 From: Michael Avila Date: Thu, 27 Jun 2019 12:52:23 -0700 Subject: [PATCH 177/262] go-ipfs-config: Fix bad go fmt --- config/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index 3a5d3fe2060..ba12fa645c8 100644 --- a/config/config.go +++ b/config/config.go @@ -27,7 +27,7 @@ type Config struct { Swarm SwarmConfig Pubsub PubsubConfig - Provider Provider + Provider Provider Reprovider Reprovider Experimental Experiments } From a7ff340af6b0663589de0a1237f53bf61b14fac8 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 29 Aug 2019 10:15:25 -0700 Subject: [PATCH 178/262] go-ipfs-config: chore: bump minimum key size to 2048 --- config/init.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/init.go b/config/init.go index 7f11c3a3d06..d658866ef62 100644 --- a/config/init.go +++ b/config/init.go @@ -152,8 +152,8 @@ func DefaultDatastoreConfig() Datastore { func identityConfig(out io.Writer, nbits int) (Identity, error) { // TODO guard higher up ident := Identity{} - if nbits < 1024 { - return ident, errors.New("bitsize less than 1024 is considered unsafe") + if nbits < 2048 { + return ident, errors.New("bitsize less than 2048 is considered unsafe") } fmt.Fprintf(out, "generating %v-bit RSA keypair...", nbits) From a04a858922618fcb0164c5c13f4564aca4de88b0 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 29 Aug 2019 10:15:31 -0700 Subject: [PATCH 179/262] go-ipfs-config: add plugins config section * Allow users to store plugin specific config options. * Allow users to disable specific plugins. Eventually, we can use this to allow loading plugins from non-standard locations. --- config/config.go | 1 + config/plugins.go | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 config/plugins.go diff --git a/config/config.go b/config/config.go index ba12fa645c8..3f140474566 100644 --- a/config/config.go +++ b/config/config.go @@ -30,6 +30,7 @@ type Config struct { Provider Provider Reprovider Reprovider Experimental Experiments + Plugins Plugins } const ( diff --git a/config/plugins.go b/config/plugins.go new file mode 100644 index 00000000000..004f5468f74 --- /dev/null +++ b/config/plugins.go @@ -0,0 +1,11 @@ +package config + +type Plugins struct { + Plugins map[string]Plugin `json:",omitempty"` + // TODO: Loader Path? Leaving that out for now due to security concerns. +} + +type Plugin struct { + Disabled bool + Config interface{} +} From 25e3e1974b849b2410cb1f5b2a24ad17f682d252 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 29 Aug 2019 10:25:35 -0700 Subject: [PATCH 180/262] go-ipfs-config: nit: omit empty plugin values Let's try to slim down default configs a bit. --- config/plugins.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/plugins.go b/config/plugins.go index 004f5468f74..c9b148049a1 100644 --- a/config/plugins.go +++ b/config/plugins.go @@ -6,6 +6,6 @@ type Plugins struct { } type Plugin struct { - Disabled bool - Config interface{} + Disabled bool `json:",omitempty"` + Config interface{} `json:",omitempty"` } From 40bc2372f975792227f48a6ac2dc06f56470555c Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 29 Aug 2019 11:48:53 -0700 Subject: [PATCH 181/262] go-ipfs-config: make it easier to detect an uninitialized repo --- config/serialize/serialize.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/config/serialize/serialize.go b/config/serialize/serialize.go index eedf7e1aa53..af11774b409 100644 --- a/config/serialize/serialize.go +++ b/config/serialize/serialize.go @@ -11,13 +11,19 @@ import ( "github.com/ipfs/go-ipfs-config" "github.com/facebookgo/atomicfile" - "github.com/ipfs/go-ipfs-util" ) +// ErrNotInitialized is returned when we fail to read the config because the +// repo doesn't exist. +var ErrNotInitialized = errors.New("ipfs not initialized, please run 'ipfs init'") + // ReadConfigFile reads the config from `filename` into `cfg`. func ReadConfigFile(filename string, cfg interface{}) error { f, err := os.Open(filename) if err != nil { + if os.IsNotExist(err) { + err = ErrNotInitialized + } return err } defer f.Close() @@ -56,11 +62,6 @@ func encode(w io.Writer, value interface{}) error { // Load reads given file and returns the read config, or error. func Load(filename string) (*config.Config, error) { - // if nothing is there, fail. User must run 'ipfs init' - if !util.FileExists(filename) { - return nil, errors.New("ipfs not initialized, please run 'ipfs init'") - } - var cfg config.Config err := ReadConfigFile(filename, &cfg) if err != nil { From f0b5fe9733aaa35b24312c46d0687f024b31b645 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 29 Aug 2019 13:54:28 -0700 Subject: [PATCH 182/262] go-ipfs-config: plugins: don't omit empty config values Turns out the go-ipfs config logic really doesn't play well with this. Let's just keep them and avoid encoding empty values another way. --- config/plugins.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/plugins.go b/config/plugins.go index c9b148049a1..08a1acb34f5 100644 --- a/config/plugins.go +++ b/config/plugins.go @@ -1,11 +1,11 @@ package config type Plugins struct { - Plugins map[string]Plugin `json:",omitempty"` + Plugins map[string]Plugin // TODO: Loader Path? Leaving that out for now due to security concerns. } type Plugin struct { - Disabled bool `json:",omitempty"` - Config interface{} `json:",omitempty"` + Disabled bool + Config interface{} } From 66886eb1ffd43f7b30bbc0b3eeabba8547d0058c Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 4 Dec 2019 13:31:28 -0500 Subject: [PATCH 183/262] go-ipfs-config: fix(init): use key size constraints defined in libp2p --- config/init.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/config/init.go b/config/init.go index d658866ef62..54e862fe129 100644 --- a/config/init.go +++ b/config/init.go @@ -2,7 +2,6 @@ package config import ( "encoding/base64" - "errors" "fmt" "io" "time" @@ -152,8 +151,8 @@ func DefaultDatastoreConfig() Datastore { func identityConfig(out io.Writer, nbits int) (Identity, error) { // TODO guard higher up ident := Identity{} - if nbits < 2048 { - return ident, errors.New("bitsize less than 2048 is considered unsafe") + if nbits < ci.MinRsaKeyBits { + return ident, ci.ErrRsaKeyTooSmall } fmt.Fprintf(out, "generating %v-bit RSA keypair...", nbits) From d0d55a8548dd413919b6a2c1fd0cf497918e7c3c Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 23 Jul 2019 16:30:34 -0700 Subject: [PATCH 184/262] go-ipfs-config: migrate multiaddrs from /ipfs -> /p2p See: https://github.com/libp2p/libp2p/issues/79 --- config/bootstrap_peers.go | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/config/bootstrap_peers.go b/config/bootstrap_peers.go index f4a13dc9d06..a4027f824af 100644 --- a/config/bootstrap_peers.go +++ b/config/bootstrap_peers.go @@ -19,19 +19,19 @@ import ( // 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 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", // mars.i.ipfs.io - "/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM", // pluto.i.ipfs.io - "/ip4/128.199.219.111/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu", // saturn.i.ipfs.io - "/ip4/104.236.76.40/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64", // venus.i.ipfs.io - "/ip4/178.62.158.247/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd", // earth.i.ipfs.io - "/ip6/2604:a880:1:20::203:d001/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM", // pluto.i.ipfs.io - "/ip6/2400:6180:0:d0::151:6001/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu", // saturn.i.ipfs.io - "/ip6/2604:a880:800:10::4a:5001/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64", // venus.i.ipfs.io - "/ip6/2a03:b0c0:0:1010::23:1001/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd", // earth.i.ipfs.io + "/dnsaddr/bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN", + "/dnsaddr/bootstrap.libp2p.io/p2p/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa", + "/dnsaddr/bootstrap.libp2p.io/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb", + "/dnsaddr/bootstrap.libp2p.io/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt", + "/ip4/104.131.131.82/tcp/4001/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ", // mars.i.ipfs.io + "/ip4/104.236.179.241/tcp/4001/p2p/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM", // pluto.i.ipfs.io + "/ip4/128.199.219.111/tcp/4001/p2p/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu", // saturn.i.ipfs.io + "/ip4/104.236.76.40/tcp/4001/p2p/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64", // venus.i.ipfs.io + "/ip4/178.62.158.247/tcp/4001/p2p/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd", // earth.i.ipfs.io + "/ip6/2604:a880:1:20::203:d001/tcp/4001/p2p/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM", // pluto.i.ipfs.io + "/ip6/2400:6180:0:d0::151:6001/tcp/4001/p2p/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu", // saturn.i.ipfs.io + "/ip6/2604:a880:800:10::4a:5001/tcp/4001/p2p/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64", // venus.i.ipfs.io + "/ip6/2a03:b0c0:0:1010::23:1001/tcp/4001/p2p/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd", // earth.i.ipfs.io } // ErrInvalidPeerAddr signals an address is not a valid peer address. From 95a14f43ac32abec20de73035b27fbc154fbaa43 Mon Sep 17 00:00:00 2001 From: Adin Schmahmann Date: Mon, 16 Dec 2019 13:28:05 -0500 Subject: [PATCH 185/262] go-ipfs-config: profile: badger profile now defaults to asynchronous writes --- config/profile.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/profile.go b/config/profile.go index 458f6a82214..bf0569535da 100644 --- a/config/profile.go +++ b/config/profile.go @@ -130,7 +130,7 @@ Make sure to backup your data frequently.`, "child": map[string]interface{}{ "type": "badgerds", "path": "badgerds", - "syncWrites": true, + "syncWrites": false, "truncate": true, }, } From 7dfdeeb04e3eb35b4e045e83dec88f23313a1ce8 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 11 Feb 2020 19:16:27 -0800 Subject: [PATCH 186/262] go-ipfs-config: feat: add graphsync option related to https://github.com/ipfs/go-ipfs/issues/6830 --- config/experiments.go | 1 + 1 file changed, 1 insertion(+) diff --git a/config/experiments.go b/config/experiments.go index 6821ed6bc81..2e14ce89a5a 100644 --- a/config/experiments.go +++ b/config/experiments.go @@ -4,6 +4,7 @@ type Experiments struct { FilestoreEnabled bool UrlstoreEnabled bool ShardingEnabled bool + GraphsyncEnabled bool Libp2pStreamMounting bool P2pHttpProxy bool QUIC bool From 265f8cf95d2a49a836c450d6cad63d3fa3fa3ed3 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Thu, 14 Mar 2019 20:31:46 -0700 Subject: [PATCH 187/262] go-ipfs-config: add config options for proxy/subdomain Co-authored-by: Steven --- config/gateway.go | 68 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 64 insertions(+), 4 deletions(-) diff --git a/config/gateway.go b/config/gateway.go index 017be9b285b..644467891c9 100644 --- a/config/gateway.go +++ b/config/gateway.go @@ -1,11 +1,71 @@ package config +type GatewaySpec struct { + // Paths is explicit list of path prefixes that should be handled by + // this gateway. Example: `["/ipfs", "/ipns", "/api"]` + Paths []string + + // UseSubdomains indicates whether or not this gateway uses subdomains + // for IPFS resources instead of paths. That is: http://CID.ipfs.GATEWAY/... + // + // If this flag is set, any /ipns/$id and/or /ipfs/$id paths in PathPrefixes + // will be permanently redirected to http://$id.[ipns|ipfs].$gateway/. + // + // We do not support using both paths and subdomains for a single domain + // for security reasons (Origin isolation). + UseSubdomains bool + + // NoDNSLink configures this gateway to _not_ resolve DNSLink for the FQDN + // provided in `Host` HTTP header. + NoDNSLink bool +} + // Gateway contains options for the HTTP gateway server. type Gateway struct { - HTTPHeaders map[string][]string // HTTP headers to return with the gateway + + // HTTPHeaders configures the headers that should be returned by this + // gateway. + HTTPHeaders map[string][]string // HTTP headers to return with the gateway + + // RootRedirect is the path to which requests to `/` on this gateway + // should be redirected. RootRedirect string - Writable bool + + // Writable enables PUT/POST request handling by this gateway. Usually, + // writing is done through the API, not the gateway. + Writable bool + + // PathPrefixes is an array of acceptable url paths that a client can + // specify in X-Ipfs-Path-Prefix header. + // + // The X-Ipfs-Path-Prefix header is used to specify a base path to prepend + // to links in directory listings and for trailing-slash redirects. It is + // intended to be set by a frontend http proxy like nginx. + // + // Example: To mount blog.ipfs.io (a DNSLink site) at ipfs.io/blog + // set PathPrefixes to ["/blog"] and nginx config to translate paths + // and pass Host header (for DNSLink): + // location /blog/ { + // rewrite "^/blog(/.*)$" $1 break; + // proxy_set_header Host blog.ipfs.io; + // proxy_set_header X-Ipfs-Gateway-Prefix /blog; + // proxy_pass http://127.0.0.1:8080; + // } PathPrefixes []string - APICommands []string - NoFetch bool + + // FIXME: Not yet implemented + APICommands []string + + // NoFetch configures the gateway to _not_ fetch blocks in response to + // requests. + NoFetch bool + + // NoDNSLink configures the gateway to _not_ perform DNS TXT record + // lookups in response to requests with values in `Host` HTTP header. + // This flag can be overriden per FQDN in PublicGateways. + NoDNSLink bool + + // PublicGateways configures behavior of known public gateways. + // Each key is a fully qualified domain name (FQDN). + PublicGateways map[string]*GatewaySpec } From f455264a4b6e2310c999e470ae3a4522287bda98 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 17 Mar 2020 19:07:14 -0700 Subject: [PATCH 188/262] go-ipfs-config: feat: remove old bootstrap peers --- config/bootstrap_peers.go | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/config/bootstrap_peers.go b/config/bootstrap_peers.go index a4027f824af..9f586baf7d3 100644 --- a/config/bootstrap_peers.go +++ b/config/bootstrap_peers.go @@ -23,15 +23,7 @@ var DefaultBootstrapAddresses = []string{ "/dnsaddr/bootstrap.libp2p.io/p2p/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa", "/dnsaddr/bootstrap.libp2p.io/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb", "/dnsaddr/bootstrap.libp2p.io/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt", - "/ip4/104.131.131.82/tcp/4001/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ", // mars.i.ipfs.io - "/ip4/104.236.179.241/tcp/4001/p2p/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM", // pluto.i.ipfs.io - "/ip4/128.199.219.111/tcp/4001/p2p/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu", // saturn.i.ipfs.io - "/ip4/104.236.76.40/tcp/4001/p2p/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64", // venus.i.ipfs.io - "/ip4/178.62.158.247/tcp/4001/p2p/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd", // earth.i.ipfs.io - "/ip6/2604:a880:1:20::203:d001/tcp/4001/p2p/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM", // pluto.i.ipfs.io - "/ip6/2400:6180:0:d0::151:6001/tcp/4001/p2p/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu", // saturn.i.ipfs.io - "/ip6/2604:a880:800:10::4a:5001/tcp/4001/p2p/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64", // venus.i.ipfs.io - "/ip6/2a03:b0c0:0:1010::23:1001/tcp/4001/p2p/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd", // earth.i.ipfs.io + "/ip4/104.131.131.82/tcp/4001/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ", // mars.i.ipfs.io } // ErrInvalidPeerAddr signals an address is not a valid peer address. From f83f2b1487f4a734a3a20f33e337ec667d1e72ae Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 17 Mar 2020 19:08:22 -0700 Subject: [PATCH 189/262] go-ipfs-config: chore: remove unnecessary dependency We _used_ to need this dependency to parse the dns addresses. However, dnsaddr protocols are now all defined directly in go-multiaddr. --- config/bootstrap_peers.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/config/bootstrap_peers.go b/config/bootstrap_peers.go index 9f586baf7d3..91d01457307 100644 --- a/config/bootstrap_peers.go +++ b/config/bootstrap_peers.go @@ -6,10 +6,6 @@ import ( peer "github.com/libp2p/go-libp2p-core/peer" ma "github.com/multiformats/go-multiaddr" - - // Needs to be imported so that users can import this package directly - // and still parse the bootstrap addresses. - _ "github.com/multiformats/go-multiaddr-dns" ) // DefaultBootstrapAddresses are the hardcoded bootstrap addresses From cc723f94b8b1fd35b8c1914d25b86fde7f892319 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 25 Mar 2020 15:35:05 -0700 Subject: [PATCH 190/262] go-ipfs-config: feat: mark badger as stable We're still not ready to enable it by default but at least mark it as stable. --- config/init.go | 61 ++++++++++++++++++++++------------- config/profile.go | 81 +++++++++++++++++++++++++---------------------- 2 files changed, 82 insertions(+), 60 deletions(-) diff --git a/config/init.go b/config/init.go index 54e862fe129..ea1530c224d 100644 --- a/config/init.go +++ b/config/init.go @@ -118,29 +118,46 @@ func DefaultDatastoreConfig() Datastore { StorageGCWatermark: 90, // 90% GCPeriod: "1h", BloomFilterSize: 0, - Spec: map[string]interface{}{ - "type": "mount", - "mounts": []interface{}{ - map[string]interface{}{ - "mountpoint": "/blocks", - "type": "measure", - "prefix": "flatfs.datastore", - "child": map[string]interface{}{ - "type": "flatfs", - "path": "blocks", - "sync": true, - "shardFunc": "/repo/flatfs/shard/v1/next-to-last/2", - }, + Spec: flatfsSpec(), + } +} + +func badgerSpec() map[string]interface{} { + return map[string]interface{}{ + "type": "measure", + "prefix": "badger.datastore", + "child": map[string]interface{}{ + "type": "badgerds", + "path": "badgerds", + "syncWrites": false, + "truncate": true, + }, + } +} + +func flatfsSpec() map[string]interface{} { + return map[string]interface{}{ + "type": "mount", + "mounts": []interface{}{ + map[string]interface{}{ + "mountpoint": "/blocks", + "type": "measure", + "prefix": "flatfs.datastore", + "child": map[string]interface{}{ + "type": "flatfs", + "path": "blocks", + "sync": true, + "shardFunc": "/repo/flatfs/shard/v1/next-to-last/2", }, - map[string]interface{}{ - "mountpoint": "/", - "type": "measure", - "prefix": "leveldb.datastore", - "child": map[string]interface{}{ - "type": "levelds", - "path": "datastore", - "compression": "none", - }, + }, + map[string]interface{}{ + "mountpoint": "/", + "type": "measure", + "prefix": "leveldb.datastore", + "child": map[string]interface{}{ + "type": "levelds", + "path": "datastore", + "compression": "none", }, }, }, diff --git a/config/profile.go b/config/profile.go index bf0569535da..3f339dbf0e5 100644 --- a/config/profile.go +++ b/config/profile.go @@ -11,11 +11,14 @@ 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 briefly describes the functionality of the profile. Description string - // Transform takes ipfs configuration and applies the profile to it + // Transform takes ipfs configuration and applies the profile to it. Transform Transformer + + // InitOnly specifies that this profile can only be applied on init. + InitOnly bool } // defaultServerFilters has is a list of IPv4 and IPv6 prefixes that are private, local only, or unrouteable. @@ -107,51 +110,49 @@ Inverse profile of the test profile.`, 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. - -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.`, + "flatfs": { + Description: `Configures the node to use the flatfs datastore. + +This is the most battle-tested and reliable datastore, but it's significantly +slower than the badger datastore. You should use this datastore if: + +* You need a very simple and very reliable datastore you and trust your + filesystem. This datastore stores each block as a separate file in the + underlying filesystem so it's unlikely to loose data unless there's an issue + with the underlying file system. +* You need to run garbage collection on a small (<= 10GiB) datastore. The + default datastore, badger, can leave several gigabytes of data behind when + garbage collecting. +* You're concerned about memory usage. In its default configuration, badger can + use up to several gigabytes of memory. + +This profile may only be applied when first initializing the node. +`, + InitOnly: true, 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": false, - "truncate": true, - }, - } + c.Datastore.Spec = flatfsSpec() return nil }, }, - "default-datastore": { - Description: `Restores default datastore configuration. + "badgerds": { + Description: `Configures the node to use the 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. +This is the fastest datastore. Use this datastore if performance, especially +when adding many gigabytes of files, is critical. However: -For more on ipfs-ds-convert see -$ ipfs-ds-convert --help -and -$ ipfs-ds-convert convert --help -`, +* This datastore will not properly reclaim space when your datastore is + smaller than several gigabytes. If you run IPFS with '--enable-gc' (you have + enabled block-level garbage collection), you plan on storing very little data in + your IPFS node, and disk usage is more critical than performance, consider using + flatfs. +* This datastore uses up to several gigabytes of memory. +This profile may only be applied when first initializing the node.`, + + InitOnly: true, Transform: func(c *Config) error { - c.Datastore.Spec = DefaultDatastoreConfig().Spec + c.Datastore.Spec = badgerSpec() return nil }, }, @@ -187,6 +188,10 @@ fetching may be degraded. }, } +func init() { + Profiles["default-datatore"] = Profiles["badgerds"] +} + func getAvailablePort() (port int, err error) { ln, err := net.Listen("tcp", "[::]:0") if err != nil { From 542ca9296bd565f612ea70527aa26d4c8b50b001 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Sun, 29 Mar 2020 18:50:34 -0700 Subject: [PATCH 191/262] go-ipfs-config: feat: remove PreferTLS experiment This will now be enabled by default. --- config/experiments.go | 1 - 1 file changed, 1 deletion(-) diff --git a/config/experiments.go b/config/experiments.go index 2e14ce89a5a..5a27bab5bf0 100644 --- a/config/experiments.go +++ b/config/experiments.go @@ -8,6 +8,5 @@ type Experiments struct { Libp2pStreamMounting bool P2pHttpProxy bool QUIC bool - PreferTLS bool StrategicProviding bool } From 043f20c1f8cf4b2039cd64254f992ce8c1a13f9b Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 6 Apr 2020 15:42:36 -0700 Subject: [PATCH 192/262] go-ipfs-config: feat: add private routing config field That way, users can enable/disable/configure routing on their local network. --- config/routing.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config/routing.go b/config/routing.go index e601cd5e8d3..d63140aa108 100644 --- a/config/routing.go +++ b/config/routing.go @@ -4,4 +4,8 @@ package config type Routing struct { // Type sets default daemon routing mode. Type string + + // PrivateType sets the routing mode for private networks. If unset, + // Type will be used. + PrivateType string } From 7b9225113ff63e4fba08c81c6372a52566181914 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 6 Apr 2020 17:32:07 -0700 Subject: [PATCH 193/262] go-ipfs-config: doc: add a bit of documentation. --- config/routing.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/config/routing.go b/config/routing.go index d63140aa108..341e2653a61 100644 --- a/config/routing.go +++ b/config/routing.go @@ -3,9 +3,11 @@ package config // Routing defines configuration options for libp2p routing type Routing struct { // Type sets default daemon routing mode. + // + // Can be one of "dht", "dhtclient", "dhtserver", "none", or unset. Type string - // PrivateType sets the routing mode for private networks. If unset, - // Type will be used. + // PrivateType sets the routing mode for private networks. Can take the + // same values as Type and defaults to Type if unset. PrivateType string } From ab3a78d78e80263c80b0fbd8e350b3ddc3a6a2b4 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 9 Apr 2020 13:24:03 -0700 Subject: [PATCH 194/262] go-ipfs-config: feat: remove Routing.PrivateType This can't be set independently at this point. We can add something back when we know the form this option should take. --- config/routing.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/config/routing.go b/config/routing.go index 341e2653a61..c6157ec9637 100644 --- a/config/routing.go +++ b/config/routing.go @@ -6,8 +6,4 @@ type Routing struct { // // Can be one of "dht", "dhtclient", "dhtserver", "none", or unset. Type string - - // PrivateType sets the routing mode for private networks. Can take the - // same values as Type and defaults to Type if unset. - PrivateType string } From 4554fc924679f7e8e250b53ab738c3766da08604 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 14 Apr 2020 18:40:16 -0700 Subject: [PATCH 195/262] go-ipfs-config: feat: add an autonat config section And remove the current EnableAutoNATService option from the swarm config. While a breaking change, this shouldn't cause _too_ much trouble given that we're going to enable AutoNAT everywhere by default anyways. --- config/autonat.go | 79 +++++++++++++++++++++++++++++++++++++++++++++++ config/config.go | 1 + config/swarm.go | 2 -- 3 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 config/autonat.go diff --git a/config/autonat.go b/config/autonat.go new file mode 100644 index 00000000000..05009ffc5dc --- /dev/null +++ b/config/autonat.go @@ -0,0 +1,79 @@ +package config + +import ( + "fmt" +) + +// AutoNATServiceMode configures the ipfs node's AutoNAT service. +type AutoNATServiceMode int + +const ( + // AutoNATServiceUnset indicates that the user has not set the + // AutoNATService mode. + // + // When unset, nodes configured to be public DHT nodes will _also_ + // perform limited AutoNAT dialbacks. + AutoNATServiceUnset AutoNATServiceMode = iota + // AutoNATServiceEnabled indicates that the user has enabled the + // AutoNATService. + AutoNATServiceEnabled + // AutoNATServiceDisabled indicates that the user has disabled the + // AutoNATService. + AutoNATServiceDisabled +) + +func (m *AutoNATServiceMode) UnmarshalText(text []byte) error { + switch string(text) { + case "": + *m = AutoNATServiceUnset + case "enabled": + *m = AutoNATServiceEnabled + case "disabled": + *m = AutoNATServiceDisabled + default: + return fmt.Errorf("unknown autonat mode: %s", string(text)) + } + return nil +} + +func (m AutoNATServiceMode) MarshalText() ([]byte, error) { + switch m { + case AutoNATServiceUnset: + return nil, nil + case AutoNATServiceEnabled: + return []byte("enabled"), nil + case AutoNATServiceDisabled: + return []byte("disabled"), nil + default: + return nil, fmt.Errorf("unknown autonat mode: %d", m) + } +} + +// AutoNATConfig configures the node's AutoNAT subsystem. +type AutoNATConfig struct { + // ServiceMode configures the node's AutoNAT service mode. + ServiceMode AutoNATServiceMode `json:",omitempty"` + + // Throttle configures AutoNAT dialback throttling. + // + // If unset, the conservative libp2p defaults will be unset. To help the + // network, please consider setting this and increasing the limits. + // + // By default, the limits will be a total of 30 dialbacks, with a + // per-peer max of 3 peer, resetting every minute. + Throttle *AutoNATThrottleConfig `json:",omitempty"` +} + +// AutoNATThrottleConfig configures the throttle limites +type AutoNATThrottleConfig struct { + // GlobalLimit and PeerLimit sets the global and per-peer dialback + // limits. The AutoNAT service will only perform the specified number of + // dialbacks per interval. + // + // Setting either to 0 will disable the appropriate limit. + GlobalLimit, PeerLimit int + + // Interval specifies how frequently this node should reset the + // global/peer dialback limits. + Interval string +} diff --git a/config/config.go b/config/config.go index 3f140474566..9af0cf68f19 100644 --- a/config/config.go +++ b/config/config.go @@ -25,6 +25,7 @@ type Config struct { Gateway Gateway // local node's gateway server options API API // local node's API settings Swarm SwarmConfig + AutoNAT AutoNATConfig Pubsub PubsubConfig Provider Provider diff --git a/config/swarm.go b/config/swarm.go index 16dc54d9cba..86060299623 100644 --- a/config/swarm.go +++ b/config/swarm.go @@ -10,8 +10,6 @@ type SwarmConfig struct { // autorelay functionality // if true, then the libp2p host will be constructed with autorelay functionality. EnableAutoRelay bool - // if true, then an AutoNATService will be instantiated to facilitate autorelay - EnableAutoNATService bool ConnMgr ConnMgr } From 25a96cfb1bdcfcd6ee0090a28bbd5df051f67345 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 14 Apr 2020 19:55:26 -0700 Subject: [PATCH 196/262] go-ipfs-config: feat: add and use a duration helper type --- config/autonat.go | 4 +++- config/types.go | 20 ++++++++++++++++++++ config/types_test.go | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/config/autonat.go b/config/autonat.go index 05009ffc5dc..a1a3f699cda 100644 --- a/config/autonat.go +++ b/config/autonat.go @@ -75,5 +75,7 @@ type AutoNATThrottleConfig struct { // Interval specifies how frequently this node should reset the // global/peer dialback limits. - Interval string + // + // When unset, this defaults to 1 minute. + Interval Duration `json:",omitempty"` } diff --git a/config/types.go b/config/types.go index 58451c68f12..90363e30dc4 100644 --- a/config/types.go +++ b/config/types.go @@ -2,6 +2,7 @@ package config import ( "encoding/json" + "time" ) // Strings is a helper type that (un)marshals a single string to/from a single @@ -39,3 +40,22 @@ func (o Strings) MarshalJSON() ([]byte, error) { var _ json.Unmarshaler = (*Strings)(nil) var _ json.Marshaler = (*Strings)(nil) + +// Duration wraps time.Duration to provide json serialization and deserialization. +// +// NOTE: the zero value encodes to an empty string. +type Duration time.Duration + +func (d *Duration) UnmarshalText(text []byte) error { + dur, err := time.ParseDuration(string(text)) + *d = Duration(dur) + return err +} + +func (d Duration) MarshalText() ([]byte, error) { + return []byte(time.Duration(d).String()), nil +} + +func (d Duration) String() string { + return time.Duration(d).String() +} diff --git a/config/types_test.go b/config/types_test.go index 7523962ae83..295ce922995 100644 --- a/config/types_test.go +++ b/config/types_test.go @@ -3,8 +3,40 @@ package config import ( "encoding/json" "testing" + "time" ) +func TestDuration(t *testing.T) { + out, err := json.Marshal(Duration(time.Second)) + if err != nil { + t.Fatal(err) + + } + expected := "\"1s\"" + if string(out) != expected { + t.Fatalf("expected %s, got %s", expected, string(out)) + } + var d Duration + err = json.Unmarshal(out, &d) + if err != nil { + t.Fatal(err) + } + if time.Duration(d) != time.Second { + t.Fatal("expected a second") + } + type Foo struct { + D Duration `json:",omitempty"` + } + out, err = json.Marshal(new(Foo)) + if err != nil { + t.Fatal(err) + } + expected = "{}" + if string(out) != expected { + t.Fatal("expected omitempty to omit the duration") + } +} + func TestOneStrings(t *testing.T) { out, err := json.Marshal(Strings{"one"}) if err != nil { From cf3fa1bdb60a2bd4d36b965e16b926bc5bf93ea9 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 14 Apr 2020 20:29:05 -0700 Subject: [PATCH 197/262] go-ipfs-config: feat: disable autonat service when in lowpower mode --- config/profile.go | 1 + 1 file changed, 1 insertion(+) diff --git a/config/profile.go b/config/profile.go index 3f339dbf0e5..a95ba0f1fe9 100644 --- a/config/profile.go +++ b/config/profile.go @@ -163,6 +163,7 @@ fetching may be degraded. `, Transform: func(c *Config) error { c.Routing.Type = "dhtclient" + c.AutoNAT.ServiceMode = AutoNATServiceDisabled c.Reprovider.Interval = "0" c.Swarm.ConnMgr.LowWater = 20 From d02cdb3963957867b1e93edbb4ccf91a8290dec7 Mon Sep 17 00:00:00 2001 From: Will Scott Date: Mon, 20 Apr 2020 17:37:46 -0700 Subject: [PATCH 198/262] go-ipfs-config: Add Init Alternative allowing specification of ED25519 key --- config/init.go | 45 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/config/init.go b/config/init.go index ea1530c224d..22c95107710 100644 --- a/config/init.go +++ b/config/init.go @@ -1,17 +1,23 @@ package config import ( + "crypto/rand" "encoding/base64" "fmt" "io" "time" + "github.com/ipfs/interface-go-ipfs-core/options" ci "github.com/libp2p/go-libp2p-core/crypto" peer "github.com/libp2p/go-libp2p-core/peer" ) func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { - identity, err := identityConfig(out, nBitsForKeypair) + return InitWithOptions(out, []options.KeyGenerateOption{options.Key.Size(nBitsForKeypair)}) +} + +func InitWithOptions(out io.Writer, opts []options.KeyGenerateOption) (*Config, error) { + identity, err := identityConfig(out, opts) if err != nil { return nil, err } @@ -165,18 +171,43 @@ func flatfsSpec() map[string]interface{} { } // identityConfig initializes a new identity. -func identityConfig(out io.Writer, nbits int) (Identity, error) { +func identityConfig(out io.Writer, opts []options.KeyGenerateOption) (Identity, error) { // TODO guard higher up ident := Identity{} - if nbits < ci.MinRsaKeyBits { - return ident, ci.ErrRsaKeyTooSmall - } - fmt.Fprintf(out, "generating %v-bit RSA keypair...", nbits) - sk, pk, err := ci.GenerateKeyPair(ci.RSA, nbits) + settings, err := options.KeyGenerateOptions(opts...) if err != nil { return ident, err } + + var sk ci.PrivKey + var pk ci.PubKey + + fmt.Fprintf(out, "generating %s keypair...", settings.Algorithm) + switch settings.Algorithm { + case "rsa": + if settings.Size == -1 { + settings.Size = options.DefaultRSALen + } + + priv, pub, err := ci.GenerateKeyPair(ci.RSA, settings.Size) + if err != nil { + return ident, err + } + + sk = priv + pk = pub + case "ed25519": + priv, pub, err := ci.GenerateEd25519Key(rand.Reader) + if err != nil { + return ident, err + } + + sk = priv + pk = pub + default: + return ident, fmt.Errorf("unrecognized key type: %s", settings.Algorithm) + } fmt.Fprintf(out, "done\n") // currently storing key unencrypted. in the future we need to encrypt it. From c6336c3303df300e88b592029390b0af6772afca Mon Sep 17 00:00:00 2001 From: Will Scott Date: Tue, 21 Apr 2020 08:08:21 -0700 Subject: [PATCH 199/262] go-ipfs-config: interface --- config/init.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/config/init.go b/config/init.go index 22c95107710..2a9c631d62a 100644 --- a/config/init.go +++ b/config/init.go @@ -13,15 +13,15 @@ import ( ) func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { - return InitWithOptions(out, []options.KeyGenerateOption{options.Key.Size(nBitsForKeypair)}) -} - -func InitWithOptions(out io.Writer, opts []options.KeyGenerateOption) (*Config, error) { - identity, err := identityConfig(out, opts) + identity, err := CreateIdentity(out, []options.KeyGenerateOption{options.Key.Size(nBitsForKeypair)}) if err != nil { return nil, err } + return InitWithIdentity(identity) +} + +func InitWithIdentity(identity Identity) (*Config, error) { bootstrapPeers, err := DefaultBootstrapPeers() if err != nil { return nil, err @@ -170,8 +170,8 @@ func flatfsSpec() map[string]interface{} { } } -// identityConfig initializes a new identity. -func identityConfig(out io.Writer, opts []options.KeyGenerateOption) (Identity, error) { +// CreateIdentity initializes a new identity. +func CreateIdentity(out io.Writer, opts []options.KeyGenerateOption) (Identity, error) { // TODO guard higher up ident := Identity{} From 515d6905e38e4593a730c54725d43873ee2b2200 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 27 Apr 2020 14:34:28 -0700 Subject: [PATCH 200/262] go-ipfs-config: fix: correct the default-datastore config profile And use an actual profile instead of just aliasing. --- config/profile.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/config/profile.go b/config/profile.go index a95ba0f1fe9..697ca305aea 100644 --- a/config/profile.go +++ b/config/profile.go @@ -110,6 +110,20 @@ Inverse profile of the test profile.`, return nil }, }, + "default-datastore": { + Description: `Configures the node to use the default datastore (flatfs). + +Read the "flatfs" profile description for more information on this datastore. + +This profile may only be applied when first initializing the node. +`, + + InitOnly: true, + Transform: func(c *Config) error { + c.Datastore.Spec = flatfsSpec() + return nil + }, + }, "flatfs": { Description: `Configures the node to use the flatfs datastore. @@ -189,10 +203,6 @@ fetching may be degraded. }, } -func init() { - Profiles["default-datatore"] = Profiles["badgerds"] -} - func getAvailablePort() (port int, err error) { ln, err := net.Listen("tcp", "[::]:0") if err != nil { From a70d82e4ba8cefefc7829d10faf69049d79b7d7d Mon Sep 17 00:00:00 2001 From: Will Scott Date: Tue, 28 Apr 2020 09:40:59 -0700 Subject: [PATCH 201/262] go-ipfs-config: add test validating that createIdentity follows algorithm preference --- config/init_test.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 config/init_test.go diff --git a/config/init_test.go b/config/init_test.go new file mode 100644 index 00000000000..635c78afc5c --- /dev/null +++ b/config/init_test.go @@ -0,0 +1,36 @@ +package config + +import ( + "bytes" + "testing" + + "github.com/ipfs/interface-go-ipfs-core/options" + crypto_pb "github.com/libp2p/go-libp2p-core/crypto/pb" +) + +func TestCreateIdentity(t *testing.T) { + writer := bytes.NewBuffer(nil) + id, err := CreateIdentity(writer, []options.KeyGenerateOption{options.Key.Type(options.Ed25519Key)}) + if err != nil { + t.Fatal(err) + } + pk, err := id.DecodePrivateKey("") + if err != nil { + t.Fatal(err) + } + if pk.Type() != crypto_pb.KeyType_Ed25519 { + t.Fatal("unexpected type:", pk.Type()) + } + + id, err = CreateIdentity(writer, []options.KeyGenerateOption{options.Key.Type(options.RSAKey)}) + if err != nil { + t.Fatal(err) + } + pk, err = id.DecodePrivateKey("") + if err != nil { + t.Fatal(err) + } + if pk.Type() != crypto_pb.KeyType_RSA { + t.Fatal("unexpected type:", pk.Type()) + } +} From ed0f306c2cccc5ac484a303f66fa978489723ae0 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 19 May 2020 19:05:59 -0700 Subject: [PATCH 202/262] go-ipfs-config: feat: remove strict signing pubsub option. It's still possible to disable signing. However, it's no longer possible to enable signing _and_ disable strict signature verification. --- config/pubsub.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/config/pubsub.go b/config/pubsub.go index 94e03e28b82..bed6058478f 100644 --- a/config/pubsub.go +++ b/config/pubsub.go @@ -8,11 +8,4 @@ type PubsubConfig struct { // DisableSigning disables message signing. Message signing is *enabled* // by default. DisableSigning bool - - // StrictSignatureVerification enables strict signature verification. - // When enabled, unsigned messages will be rejected. Eventually, this - // will be made the default and this option will disappear. Once this - // happens, networks will either need to completely disable or - // completely enable message signing. - StrictSignatureVerification bool } From ca7098926ffcdb0cf067c90542899238587b4a1c Mon Sep 17 00:00:00 2001 From: "@RubenKelevra" Date: Thu, 21 May 2020 23:45:44 +0200 Subject: [PATCH 203/262] go-ipfs-config: default config: add QUIC listening ports + quic to mars.i.ipfs.io fixes 1) of https://github.com/ipfs/go-ipfs/issues/7343 --- config/bootstrap_peers.go | 3 ++- config/init.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/config/bootstrap_peers.go b/config/bootstrap_peers.go index 91d01457307..a8064d255a7 100644 --- a/config/bootstrap_peers.go +++ b/config/bootstrap_peers.go @@ -19,7 +19,8 @@ var DefaultBootstrapAddresses = []string{ "/dnsaddr/bootstrap.libp2p.io/p2p/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa", "/dnsaddr/bootstrap.libp2p.io/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb", "/dnsaddr/bootstrap.libp2p.io/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt", - "/ip4/104.131.131.82/tcp/4001/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ", // mars.i.ipfs.io + "/ip4/104.131.131.82/tcp/4001/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ", // mars.i.ipfs.io + "/ip4/104.131.131.82/quic/4001/quic/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ", // mars.i.ipfs.io } // ErrInvalidPeerAddr signals an address is not a valid peer address. diff --git a/config/init.go b/config/init.go index 2a9c631d62a..f43b4fe1ec8 100644 --- a/config/init.go +++ b/config/init.go @@ -107,8 +107,9 @@ func addressesConfig() Addresses { return Addresses{ Swarm: []string{ "/ip4/0.0.0.0/tcp/4001", - // "/ip4/0.0.0.0/udp/4002/utp", // disabled for now. "/ip6/::/tcp/4001", + "/ip4/0.0.0.0/udp/4001/quic", + "/ip6/::/udp/4001/quic", }, Announce: []string{}, NoAnnounce: []string{}, From 7f51e84a5509d9e14ee41826c11660920afc5c80 Mon Sep 17 00:00:00 2001 From: "@RubenKelevra" Date: Fri, 22 May 2020 03:11:41 +0200 Subject: [PATCH 204/262] go-ipfs-config: QUIC: remove experimental config option --- config/experiments.go | 1 - 1 file changed, 1 deletion(-) diff --git a/config/experiments.go b/config/experiments.go index 5a27bab5bf0..d63580f26c0 100644 --- a/config/experiments.go +++ b/config/experiments.go @@ -7,6 +7,5 @@ type Experiments struct { GraphsyncEnabled bool Libp2pStreamMounting bool P2pHttpProxy bool - QUIC bool StrategicProviding bool } From 5f248ac78cb12ec5805b7a1e6630c6a65b94a473 Mon Sep 17 00:00:00 2001 From: "@RubenKelevra" Date: Fri, 22 May 2020 04:28:17 +0200 Subject: [PATCH 205/262] go-ipfs-config: fix boostrap peers --- config/bootstrap_peers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/bootstrap_peers.go b/config/bootstrap_peers.go index a8064d255a7..55d0f3b822f 100644 --- a/config/bootstrap_peers.go +++ b/config/bootstrap_peers.go @@ -20,7 +20,7 @@ var DefaultBootstrapAddresses = []string{ "/dnsaddr/bootstrap.libp2p.io/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb", "/dnsaddr/bootstrap.libp2p.io/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt", "/ip4/104.131.131.82/tcp/4001/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ", // mars.i.ipfs.io - "/ip4/104.131.131.82/quic/4001/quic/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ", // mars.i.ipfs.io + "/ip4/104.131.131.82/udp/4001/quic/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ", // mars.i.ipfs.io } // ErrInvalidPeerAddr signals an address is not a valid peer address. From ba2e10aecc06329f182d798ead57ef6ff5bb0cd0 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Fri, 22 May 2020 16:37:25 -0700 Subject: [PATCH 206/262] go-ipfs-config: fix: include key size in key init method --- config/init.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config/init.go b/config/init.go index f43b4fe1ec8..2d2e2e6ef9d 100644 --- a/config/init.go +++ b/config/init.go @@ -184,13 +184,14 @@ func CreateIdentity(out io.Writer, opts []options.KeyGenerateOption) (Identity, var sk ci.PrivKey var pk ci.PubKey - fmt.Fprintf(out, "generating %s keypair...", settings.Algorithm) switch settings.Algorithm { case "rsa": if settings.Size == -1 { settings.Size = options.DefaultRSALen } + fmt.Fprintf(out, "generating %d-bit RSA keypair...", settings.Size) + priv, pub, err := ci.GenerateKeyPair(ci.RSA, settings.Size) if err != nil { return ident, err @@ -199,6 +200,7 @@ func CreateIdentity(out io.Writer, opts []options.KeyGenerateOption) (Identity, sk = priv pk = pub case "ed25519": + fmt.Fprintf(out, "generating ED25519 keypair...") priv, pub, err := ci.GenerateEd25519Key(rand.Reader) if err != nil { return ident, err From 13bcc4da44446d837c2fec15588ac9d1f994ba58 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 25 May 2020 14:05:24 -0700 Subject: [PATCH 207/262] go-ipfs-config: feat: add peering service config section --- config/config.go | 1 + config/peering.go | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 config/peering.go diff --git a/config/config.go b/config/config.go index 9af0cf68f19..5f6be8e5ac5 100644 --- a/config/config.go +++ b/config/config.go @@ -27,6 +27,7 @@ type Config struct { Swarm SwarmConfig AutoNAT AutoNATConfig Pubsub PubsubConfig + Peering Peering Provider Provider Reprovider Reprovider diff --git a/config/peering.go b/config/peering.go new file mode 100644 index 00000000000..21724686629 --- /dev/null +++ b/config/peering.go @@ -0,0 +1,9 @@ +package config + +import "github.com/libp2p/go-libp2p-core/peer" + +// Peering configures the peering service. +type Peering struct { + // Peer lists all peers with which this peer peers. + Peers []peer.AddrInfo +} From 75bde89788a3feac84fb258b9edc2d09ac24ce0b Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 25 May 2020 19:14:40 -0700 Subject: [PATCH 208/262] go-ipfs-config: doc: improve wording for peering config Co-authored-by: Will --- config/peering.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/peering.go b/config/peering.go index 21724686629..242ce2d9898 100644 --- a/config/peering.go +++ b/config/peering.go @@ -4,6 +4,6 @@ import "github.com/libp2p/go-libp2p-core/peer" // Peering configures the peering service. type Peering struct { - // Peer lists all peers with which this peer peers. + // Peers lists the nodes to attempt to stay connected with. Peers []peer.AddrInfo } From e69fcd9d01416aacd704d224298229d6a194ac10 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 25 May 2020 23:06:42 -0700 Subject: [PATCH 209/262] go-ipfs-config: feat: add an option for security transport experiments We should have a more permanent way to configure security transports, but experimental flags are a quick and unstable way to do this without making any promises. --- config/experiments.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/config/experiments.go b/config/experiments.go index d63580f26c0..22e87a65950 100644 --- a/config/experiments.go +++ b/config/experiments.go @@ -8,4 +8,11 @@ type Experiments struct { Libp2pStreamMounting bool P2pHttpProxy bool StrategicProviding bool + + // OverrideSecurityTransports overrides the set of available security + // transports when non-empty. This option should eventually migrate some + // place more stable. + // + // Default: ["tls", "secio", "noise"]. + OverrideSecurityTransports []string `json:",omitempty"` } From 9ebfb4953020a09b94664c4a74a7d87f86427797 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 3 Jun 2020 09:03:56 -0700 Subject: [PATCH 210/262] go-ipfs-config: fix: remove group permissions There's no reason to give the group access to these files by default. --- config/serialize/serialize.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/serialize/serialize.go b/config/serialize/serialize.go index af11774b409..04492c5f38f 100644 --- a/config/serialize/serialize.go +++ b/config/serialize/serialize.go @@ -35,12 +35,12 @@ func ReadConfigFile(filename string, cfg interface{}) error { // WriteConfigFile writes the config from `cfg` into `filename`. func WriteConfigFile(filename string, cfg interface{}) error { - err := os.MkdirAll(filepath.Dir(filename), 0775) + err := os.MkdirAll(filepath.Dir(filename), 0755) if err != nil { return err } - f, err := atomicfile.New(filename, 0660) + f, err := atomicfile.New(filename, 0600) if err != nil { return err } From dfe53cd5b62fff8d81f74bb6a33ab4d91d9e398c Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 15 Jun 2020 13:17:26 -0700 Subject: [PATCH 211/262] go-ipfs-config: feat: add flag and priority types These let us zero-encode "default" to "null" (and omit it with "omitempty") so we don't have to hard code the default in the config. --- config/types.go | 127 +++++++++++++++++++++++++++++++++++++++++++ config/types_test.go | 99 +++++++++++++++++++++++++++++++++ 2 files changed, 226 insertions(+) diff --git a/config/types.go b/config/types.go index 90363e30dc4..60c4c77d5f7 100644 --- a/config/types.go +++ b/config/types.go @@ -1,7 +1,9 @@ package config import ( + "encoding" "encoding/json" + "fmt" "time" ) @@ -41,6 +43,128 @@ func (o Strings) MarshalJSON() ([]byte, error) { var _ json.Unmarshaler = (*Strings)(nil) var _ json.Marshaler = (*Strings)(nil) +// Flag represents a ternary value: false (-1), default (0), or true (+1). +// +// When encoded in json, False is "false", Default is "null" (or empty), and True +// is "true". +type Flag int8 + +const ( + False Flag = -1 + Default Flag = 0 + True Flag = 1 +) + +func (f Flag) MarshalJSON() ([]byte, error) { + switch f { + case Default: + return json.Marshal(nil) + case True: + return json.Marshal(true) + case False: + return json.Marshal(false) + default: + return nil, fmt.Errorf("invalid flag value: %d", f) + } +} + +func (f *Flag) UnmarshalJSON(input []byte) error { + switch string(input) { + case "null", "undefined": + *f = Default + case "false": + *f = False + case "true": + *f = True + default: + return fmt.Errorf("failed to unmarshal %q into a flag: must be null/undefined, true, or false", string(input)) + } + return nil +} + +func (f Flag) String() string { + switch f { + case Default: + return "default" + case True: + return "true" + case False: + return "false" + default: + return fmt.Sprintf("", f) + } +} + +var _ json.Unmarshaler = (*Flag)(nil) +var _ json.Marshaler = (*Flag)(nil) + +// Priority represents a value with a priority where 0 means "default" and -11 +// means "disabled". +// +// When encoded in json, Default is encoded as "null" and Disabled is encoded as +// "false". +type Priority int64 + +const ( + DefaultPriority Priority = 0 + Disabled Priority = -1 +) + +func (p Priority) MarshalJSON() ([]byte, error) { + // > 0 == Priority + if p > 0 { + return json.Marshal(int64(p)) + } + // <= 0 == special + switch p { + case DefaultPriority: + return json.Marshal(nil) + case Disabled: + return json.Marshal(false) + default: + return nil, fmt.Errorf("invalid priority value: %d", p) + } +} + +func (p *Priority) UnmarshalJSON(input []byte) error { + switch string(input) { + case "null", "undefined": + *p = DefaultPriority + case "false": + *p = Disabled + case "true": + return fmt.Errorf("'true' is not a valid priority") + default: + var priority int64 + err := json.Unmarshal(input, &priority) + if err != nil { + return err + } + if priority <= 0 { + return fmt.Errorf("priority must be positive: %d <= 0", priority) + } + *p = Priority(priority) + } + return nil +} + +func (p Priority) String() string { + if p > 0 { + return fmt.Sprintf("%d", p) + } + switch p { + case DefaultPriority: + return "default" + case Disabled: + return "false" + default: + return fmt.Sprintf("", p) + } +} + +var _ json.Unmarshaler = (*Flag)(nil) +var _ json.Marshaler = (*Flag)(nil) + // Duration wraps time.Duration to provide json serialization and deserialization. // // NOTE: the zero value encodes to an empty string. @@ -59,3 +183,6 @@ func (d Duration) MarshalText() ([]byte, error) { func (d Duration) String() string { return time.Duration(d).String() } + +var _ encoding.TextUnmarshaler = (*Duration)(nil) +var _ encoding.TextMarshaler = (*Duration)(nil) diff --git a/config/types_test.go b/config/types_test.go index 295ce922995..dbc08cb888f 100644 --- a/config/types_test.go +++ b/config/types_test.go @@ -83,3 +83,102 @@ func TestFunkyStrings(t *testing.T) { t.Fatalf("unexpected result: %v", s) } } + +func TestFlag(t *testing.T) { + // make sure we have the right zero value. + var defaultFlag Flag + if defaultFlag != Default { + t.Errorf("expected default flag to be %q, got %q", Default, defaultFlag) + } + + for jsonStr, goValue := range map[string]Flag{ + "null": Default, + "true": True, + "false": False, + } { + var d Flag + err := json.Unmarshal([]byte(jsonStr), &d) + if err != nil { + t.Fatal(err) + } + if d != goValue { + t.Fatalf("expected %s, got %s", goValue, d) + } + + // Reverse + out, err := json.Marshal(goValue) + if err != nil { + t.Fatal(err) + } + if string(out) != jsonStr { + t.Fatalf("expected %s, got %s", jsonStr, string(out)) + } + } + + type Foo struct { + F Flag `json:",omitempty"` + } + out, err := json.Marshal(new(Foo)) + if err != nil { + t.Fatal(err) + } + expected := "{}" + if string(out) != expected { + t.Fatal("expected omitempty to omit the flag") + } +} + +func TestPriority(t *testing.T) { + // make sure we have the right zero value. + var defaultPriority Priority + if defaultPriority != DefaultPriority { + t.Errorf("expected default priority to be %q, got %q", DefaultPriority, defaultPriority) + } + + for jsonStr, goValue := range map[string]Priority{ + "null": DefaultPriority, + "false": Disabled, + "1": 1, + "2": 2, + "100": 100, + } { + var d Priority + err := json.Unmarshal([]byte(jsonStr), &d) + if err != nil { + t.Fatal(err) + } + if d != goValue { + t.Fatalf("expected %s, got %s", goValue, d) + } + + // Reverse + out, err := json.Marshal(goValue) + if err != nil { + t.Fatal(err) + } + if string(out) != jsonStr { + t.Fatalf("expected %s, got %s", jsonStr, string(out)) + } + } + + type Foo struct { + P Priority `json:",omitempty"` + } + out, err := json.Marshal(new(Foo)) + if err != nil { + t.Fatal(err) + } + expected := "{}" + if string(out) != expected { + t.Fatal("expected omitempty to omit the flag") + } + for _, invalid := range []string{ + "0", "-1", "-2", "1.1", "0.0", + } { + var p Priority + err := json.Unmarshal([]byte(invalid), &p) + if err == nil { + t.Errorf("expected to fail to decode %s as a priority", invalid) + } + } +} From 4f3aeb74286ae89137af690f2ea0aec989639c7b Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 15 Jun 2020 13:41:37 -0700 Subject: [PATCH 212/262] go-ipfs-config: feat: add a transports section for enabling/disabling/prioritizing transports --- config/swarm.go | 67 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 61 insertions(+), 6 deletions(-) diff --git a/config/swarm.go b/config/swarm.go index 86060299623..dc54ae902b2 100644 --- a/config/swarm.go +++ b/config/swarm.go @@ -1,19 +1,74 @@ package config type SwarmConfig struct { - AddrFilters []string + // AddrFilters specifies a set libp2p addresses that we should never + // dial or receive connections from. + AddrFilters []string + + // DisableBandwidthMetrics disables recording of bandwidth metrics for a + // slight reduction in memory usage. You probably don't need to set this + // flag. DisableBandwidthMetrics bool - DisableNatPortMap bool - DisableRelay bool - EnableRelayHop bool - // autorelay functionality - // if true, then the libp2p host will be constructed with autorelay functionality. + // DisableNatPortMap turns off NAT port mapping (UPnP, etc.). + DisableNatPortMap bool + + // DisableRelay explicitly disables the relay transport. + // + // Deprecated: This flag is deprecated and is overridden by + // `Transports.Relay` if specified. + DisableRelay bool `json:",omitempty"` + + // EnableRelayHop makes this node act as a public relay, relaying + // traffic between other nodes. + EnableRelayHop bool + + // EnableAutoRelay enables the "auto relay" feature. + // + // When both EnableAutoRelay and RelayHop are set, this go-ipfs node + // will advertise itself as a public relay, instead of finding and using + // advertised public relays. EnableAutoRelay bool + // Transports contains flags to enable/disable libp2p transports. + Transports Transports + + // ConnMgr configures the connection manager. ConnMgr ConnMgr } +type Transports struct { + // Network specifies the base transports we'll use for dialing. To + // listen on a transport, add the transport to your Addresses.Swarm. + Network struct { + // All default to on. + QUIC Flag `json:",omitempty"` + TCP Flag `json:",omitempty"` + Websocket Flag `json:",omitempty"` + Relay Flag `json:",omitempty"` + } + + // Security specifies the transports used to encrypt insecure network + // transports. + Security struct { + // Defaults to 100. + TLS Priority `json:",omitempty"` + // Defaults to 200. + SECIO Priority `json:",omitempty"` + // Defaults to 300. + Noise Priority `json:",omitempty"` + } + + // Multiplexers specifies the transports used to multiplex multiple + // connections over a single duplex connection. + Multiplex struct { + // Defaults to 100. + Yamux Priority `json:",omitempty"` + // Defaults to 200. + Mplex Priority `json:",omitempty"` + } +} + // ConnMgr defines configuration options for the libp2p connection manager type ConnMgr struct { Type string From 57089fd66bffc38285de36b37b091a1e664d4d88 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 15 Jun 2020 15:24:41 -0700 Subject: [PATCH 213/262] go-ipfs-config: feat: remove OverrideSecurityTransports This was never included in a release, and has been replaced by a flexible transport prioritization system. --- config/experiments.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/config/experiments.go b/config/experiments.go index 22e87a65950..d63580f26c0 100644 --- a/config/experiments.go +++ b/config/experiments.go @@ -8,11 +8,4 @@ type Experiments struct { Libp2pStreamMounting bool P2pHttpProxy bool StrategicProviding bool - - // OverrideSecurityTransports overrides the set of available security - // transports when non-empty. This option should eventually migrate some - // place more stable. - // - // Default: ["tls", "secio", "noise"]. - OverrideSecurityTransports []string `json:",omitempty"` } From 7ce67b895457339b33b0560bd3f5cc346da432e1 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 15 Jun 2020 19:19:01 -0700 Subject: [PATCH 214/262] go-ipfs-config: feat: add WithDefault for flag/priority This makes it easier to resolve these fields. --- config/types.go | 30 ++++++++++++++++++++++++++++++ config/types_test.go | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/config/types.go b/config/types.go index 60c4c77d5f7..57d8a59ec81 100644 --- a/config/types.go +++ b/config/types.go @@ -55,6 +55,19 @@ const ( True Flag = 1 ) +func (f Flag) WithDefault(defaultValue bool) bool { + switch f { + case False: + return false + case Default: + return defaultValue + case True: + return true + default: + panic(fmt.Sprintf("invalid flag value %d", f)) + } +} + func (f Flag) MarshalJSON() ([]byte, error) { switch f { case Default: @@ -110,6 +123,23 @@ const ( Disabled Priority = -1 ) +// WithDefault resolves the priority with the given default. +// +// If `defaultPriority` is Default/0, this function will return 0. +func (p Priority) WithDefault(defaultPriority Priority) (priority int64, enabled bool) { + switch p { + case Disabled: + return 0, false + case DefaultPriority: + if defaultPriority < 0 { + return 0, false + } + return int64(defaultPriority), true + default: + return int64(p), true + } +} + func (p Priority) MarshalJSON() ([]byte, error) { // > 0 == Priority if p > 0 { diff --git a/config/types_test.go b/config/types_test.go index dbc08cb888f..8d4c62fd2aa 100644 --- a/config/types_test.go +++ b/config/types_test.go @@ -91,6 +91,30 @@ func TestFlag(t *testing.T) { t.Errorf("expected default flag to be %q, got %q", Default, defaultFlag) } + if defaultFlag.WithDefault(true) != true { + t.Error("expected default & true to be true") + } + + if defaultFlag.WithDefault(false) != false { + t.Error("expected default & false to be false") + } + + if True.WithDefault(false) != true { + t.Error("default should only apply to default") + } + + if False.WithDefault(true) != false { + t.Error("default should only apply to default") + } + + if True.WithDefault(true) != true { + t.Error("true & true is true") + } + + if False.WithDefault(true) != false { + t.Error("false & false is false") + } + for jsonStr, goValue := range map[string]Flag{ "null": Default, "true": True, @@ -135,6 +159,18 @@ func TestPriority(t *testing.T) { t.Errorf("expected default priority to be %q, got %q", DefaultPriority, defaultPriority) } + if _, ok := defaultPriority.WithDefault(Disabled); ok { + t.Error("should have been disabled") + } + + if p, ok := defaultPriority.WithDefault(1); !ok || p != 1 { + t.Errorf("priority should have been 1, got %d", p) + } + + if p, ok := defaultPriority.WithDefault(DefaultPriority); !ok || p != 0 { + t.Errorf("priority should have been 0, got %d", p) + } + for jsonStr, goValue := range map[string]Priority{ "null": DefaultPriority, "false": Disabled, From 0f17ef601f60da9e358cc6604a0de3329e865ca2 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 15 Jun 2020 19:55:50 -0700 Subject: [PATCH 215/262] go-ipfs-config: doc(swarm): fix autorelay description Co-authored-by: Adin Schmahmann --- config/swarm.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/swarm.go b/config/swarm.go index dc54ae902b2..bc01e88efd4 100644 --- a/config/swarm.go +++ b/config/swarm.go @@ -25,8 +25,8 @@ type SwarmConfig struct { // EnableAutoRelay enables the "auto relay" feature. // - // When both EnableAutoRelay and RelayHop are set, this go-ipfs node - // will advertise itself as a public relay, instead of finding and using + // When both EnableAutoRelay and EnableRelayHop are set, this go-ipfs node + // will advertise itself as a public relay. Otherwise it will find and use // advertised public relays. EnableAutoRelay bool From f74d15eacfe0ec256b3bc631217e1df5744b6959 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 15 Jun 2020 19:56:38 -0700 Subject: [PATCH 216/262] go-ipfs-config: fix: fix type name typo --- config/swarm.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/swarm.go b/config/swarm.go index bc01e88efd4..7ce55bec855 100644 --- a/config/swarm.go +++ b/config/swarm.go @@ -61,7 +61,7 @@ type Transports struct { // Multiplexers specifies the transports used to multiplex multiple // connections over a single duplex connection. - Multiplex struct { + Multiplexers struct { // Defaults to 100. Yamux Priority `json:",omitempty"` // Defaults to 200. From f55b515255aeffef58ada9eb399396e7c2bff4d2 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 15 Jun 2020 19:57:41 -0700 Subject: [PATCH 217/262] go-ipfs-config: doc(swarm): extend autorelay docs --- config/swarm.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/swarm.go b/config/swarm.go index 7ce55bec855..d662bb30d44 100644 --- a/config/swarm.go +++ b/config/swarm.go @@ -27,7 +27,8 @@ type SwarmConfig struct { // // When both EnableAutoRelay and EnableRelayHop are set, this go-ipfs node // will advertise itself as a public relay. Otherwise it will find and use - // advertised public relays. + // advertised public relays when it determines that it's not reachable + // from the public internet. EnableAutoRelay bool // Transports contains flags to enable/disable libp2p transports. From e26444e4c78eff5c311f5a245717ee34f871d4c0 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 15 Jun 2020 20:00:51 -0700 Subject: [PATCH 218/262] go-ipfs-config: fix typo Co-authored-by: Adin Schmahmann --- config/types.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/types.go b/config/types.go index 57d8a59ec81..3d5418a2c88 100644 --- a/config/types.go +++ b/config/types.go @@ -111,7 +111,7 @@ func (f Flag) String() string { var _ json.Unmarshaler = (*Flag)(nil) var _ json.Marshaler = (*Flag)(nil) -// Priority represents a value with a priority where 0 means "default" and -11 +// Priority represents a value with a priority where 0 means "default" and -1 // means "disabled". // // When encoded in json, Default is encoded as "null" and Disabled is encoded as From 5c1b4cd0e686cd41d6cbf48a324b45e5209f3407 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 15 Jun 2020 20:01:33 -0700 Subject: [PATCH 219/262] go-ipfs-config: doc: document Flag.WithDefault --- config/types.go | 1 + 1 file changed, 1 insertion(+) diff --git a/config/types.go b/config/types.go index 3d5418a2c88..979182233bd 100644 --- a/config/types.go +++ b/config/types.go @@ -55,6 +55,7 @@ const ( True Flag = 1 ) +// WithDefault resolves the value of the flag given the provided default value. func (f Flag) WithDefault(defaultValue bool) bool { switch f { case False: From 38ad98d84d1d00b02ad64fbf53cc6bd1612e1fc8 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 16 Jun 2020 00:45:58 -0700 Subject: [PATCH 220/262] go-ipfs-config: fix: remove undefined support from unmarshal It's not a part of the JSON spec. --- config/types.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/types.go b/config/types.go index 979182233bd..2ca65540882 100644 --- a/config/types.go +++ b/config/types.go @@ -84,7 +84,7 @@ func (f Flag) MarshalJSON() ([]byte, error) { func (f *Flag) UnmarshalJSON(input []byte) error { switch string(input) { - case "null", "undefined": + case "null": *f = Default case "false": *f = False From 44e005e57709ee7e1b95270476d8a32aa0d23076 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 16 Jun 2020 10:17:06 -0700 Subject: [PATCH 221/262] go-ipfs-config: fix: panic on invalid priority/flag values --- config/types.go | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/config/types.go b/config/types.go index 2ca65540882..d22fd5dfad5 100644 --- a/config/types.go +++ b/config/types.go @@ -56,6 +56,8 @@ const ( ) // WithDefault resolves the value of the flag given the provided default value. +// +// Panics if Flag is an invalid value. func (f Flag) WithDefault(defaultValue bool) bool { switch f { case False: @@ -126,17 +128,30 @@ const ( // WithDefault resolves the priority with the given default. // -// If `defaultPriority` is Default/0, this function will return 0. +// If defaultPriority is Default/0, this function will return 0. +// +// Panics if the priority has an invalid value (e.g., not DefaultPriority, +// Disabled, or > 0). func (p Priority) WithDefault(defaultPriority Priority) (priority int64, enabled bool) { switch p { case Disabled: return 0, false case DefaultPriority: - if defaultPriority < 0 { + switch defaultPriority { + case Disabled: return 0, false + case DefaultPriority: + return 0, true + default: + if defaultPriority <= 0 { + panic(fmt.Sprintf("invalid priority %d < 0", int64(defaultPriority))) + } + return int64(defaultPriority), true } - return int64(defaultPriority), true default: + if p <= 0 { + panic(fmt.Sprintf("invalid priority %d < 0", int64(p))) + } return int64(p), true } } From da979299da9b12a2808c28af5650cae53708d4cf Mon Sep 17 00:00:00 2001 From: Petar Maymounkov Date: Tue, 14 Jul 2020 09:50:10 -0700 Subject: [PATCH 222/262] go-ipfs-config: error if bit size specified with ed25519 keys (#105) --- config/init.go | 3 +++ config/init_test.go | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/config/init.go b/config/init.go index 2d2e2e6ef9d..448fffa73c1 100644 --- a/config/init.go +++ b/config/init.go @@ -200,6 +200,9 @@ func CreateIdentity(out io.Writer, opts []options.KeyGenerateOption) (Identity, sk = priv pk = pub case "ed25519": + if settings.Size != -1 { + return ident, fmt.Errorf("number of key bits does not apply when using ed25519 keys") + } fmt.Fprintf(out, "generating ED25519 keypair...") priv, pub, err := ci.GenerateEd25519Key(rand.Reader) if err != nil { diff --git a/config/init_test.go b/config/init_test.go index 635c78afc5c..3e66e60cd2c 100644 --- a/config/init_test.go +++ b/config/init_test.go @@ -34,3 +34,16 @@ func TestCreateIdentity(t *testing.T) { t.Fatal("unexpected type:", pk.Type()) } } + +func TestCreateIdentityOptions(t *testing.T) { + var w bytes.Buffer + + // ed25519 keys with bit size must fail. + _, err := CreateIdentity(&w, []options.KeyGenerateOption{ + options.Key.Type(options.Ed25519Key), + options.Key.Size(2048), + }) + if err == nil { + t.Errorf("ed25519 keys cannot have a custom bit size") + } +} From 1ec9262cdaac5547b88bb6b5f600a75a327f5456 Mon Sep 17 00:00:00 2001 From: gammazero Date: Thu, 24 Sep 2020 05:21:22 -0700 Subject: [PATCH 223/262] go-ipfs-config: Add badger2 profile and config spec --- config/init.go | 13 +++++++++++++ config/profile.go | 25 +++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/config/init.go b/config/init.go index 448fffa73c1..32d5a1f222b 100644 --- a/config/init.go +++ b/config/init.go @@ -142,6 +142,19 @@ func badgerSpec() map[string]interface{} { } } +func badger2Spec() map[string]interface{} { + return map[string]interface{}{ + "type": "measure", + "prefix": "badger2.datastore", + "child": map[string]interface{}{ + "type": "badger2ds", + "path": "badger2ds", + "syncWrites": false, + "truncate": true, + }, + } +} + func flatfsSpec() map[string]interface{} { return map[string]interface{}{ "type": "mount", diff --git a/config/profile.go b/config/profile.go index 697ca305aea..ba101331629 100644 --- a/config/profile.go +++ b/config/profile.go @@ -130,7 +130,7 @@ This profile may only be applied when first initializing the node. This is the most battle-tested and reliable datastore, but it's significantly slower than the badger datastore. You should use this datastore if: -* You need a very simple and very reliable datastore you and trust your +* You need a very simple and very reliable datastore and you trust your filesystem. This datastore stores each block as a separate file in the underlying filesystem so it's unlikely to loose data unless there's an issue with the underlying file system. @@ -152,7 +152,7 @@ This profile may only be applied when first initializing the node. "badgerds": { Description: `Configures the node to use the badger datastore. -This is the fastest datastore. Use this datastore if performance, especially +This is a fast datastore. Use this datastore if performance, especially when adding many gigabytes of files, is critical. However: * This datastore will not properly reclaim space when your datastore is @@ -170,6 +170,27 @@ This profile may only be applied when first initializing the node.`, return nil }, }, + "badger2ds": { + Description: `Configures the node to use the badger2 datastore. + +This is the fastest datastore. Use this datastore if performance, especially +when adding many gigabytes of files, is critical. However: + +* This datastore will not properly reclaim space when your datastore is + smaller than several gigabytes. If you run IPFS with '--enable-gc' (you have + enabled block-level garbage collection), you plan on storing very little data in + your IPFS node, and disk usage is more critical than performance, consider using + flatfs. +* This datastore uses up to several gigabytes of memory. + +This profile may only be applied when first initializing the node.`, + + InitOnly: true, + Transform: func(c *Config) error { + c.Datastore.Spec = badger2Spec() + return nil + }, + }, "lowpower": { Description: `Reduces daemon overhead on the system. May affect node functionality - performance of content discovery and data From 74dcf427fcbb9389574294a7e3ec6ed6a9dcaed7 Mon Sep 17 00:00:00 2001 From: gammazero Date: Mon, 23 Nov 2020 17:09:21 -0800 Subject: [PATCH 224/262] go-ipfs-config: Remove badger2 profile This is needed for the upcoming release since there is not yet an official badger2 release with the items needed for use by IPFS. --- config/init.go | 13 ------------- config/profile.go | 23 +---------------------- 2 files changed, 1 insertion(+), 35 deletions(-) diff --git a/config/init.go b/config/init.go index 32d5a1f222b..448fffa73c1 100644 --- a/config/init.go +++ b/config/init.go @@ -142,19 +142,6 @@ func badgerSpec() map[string]interface{} { } } -func badger2Spec() map[string]interface{} { - return map[string]interface{}{ - "type": "measure", - "prefix": "badger2.datastore", - "child": map[string]interface{}{ - "type": "badger2ds", - "path": "badger2ds", - "syncWrites": false, - "truncate": true, - }, - } -} - func flatfsSpec() map[string]interface{} { return map[string]interface{}{ "type": "mount", diff --git a/config/profile.go b/config/profile.go index ba101331629..c0fa947f164 100644 --- a/config/profile.go +++ b/config/profile.go @@ -152,27 +152,6 @@ This profile may only be applied when first initializing the node. "badgerds": { Description: `Configures the node to use the badger datastore. -This is a fast datastore. Use this datastore if performance, especially -when adding many gigabytes of files, is critical. However: - -* This datastore will not properly reclaim space when your datastore is - smaller than several gigabytes. If you run IPFS with '--enable-gc' (you have - enabled block-level garbage collection), you plan on storing very little data in - your IPFS node, and disk usage is more critical than performance, consider using - flatfs. -* This datastore uses up to several gigabytes of memory. - -This profile may only be applied when first initializing the node.`, - - InitOnly: true, - Transform: func(c *Config) error { - c.Datastore.Spec = badgerSpec() - return nil - }, - }, - "badger2ds": { - Description: `Configures the node to use the badger2 datastore. - This is the fastest datastore. Use this datastore if performance, especially when adding many gigabytes of files, is critical. However: @@ -187,7 +166,7 @@ This profile may only be applied when first initializing the node.`, InitOnly: true, Transform: func(c *Config) error { - c.Datastore.Spec = badger2Spec() + c.Datastore.Spec = badgerSpec() return nil }, }, From 06fe9679550d1cb5b5e19cca2b87ede7aa1e9a91 Mon Sep 17 00:00:00 2001 From: Adin Schmahmann Date: Fri, 4 Dec 2020 15:51:38 -0500 Subject: [PATCH 225/262] go-ipfs-config: add remote pinning services config --- config/config.go | 1 + config/remotepin.go | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 config/remotepin.go diff --git a/config/config.go b/config/config.go index 5f6be8e5ac5..7d44316abd3 100644 --- a/config/config.go +++ b/config/config.go @@ -33,6 +33,7 @@ type Config struct { Reprovider Reprovider Experimental Experiments Plugins Plugins + Pinning Pinning } const ( diff --git a/config/remotepin.go b/config/remotepin.go new file mode 100644 index 00000000000..9da2af1bf0b --- /dev/null +++ b/config/remotepin.go @@ -0,0 +1,20 @@ +package config + +const ( + PinningTag = "Pinning" + RemoteServicesTag = "RemoteServices" + RemoteServicesSelector = PinningTag + "." + RemoteServicesTag +) + +type Pinning struct { + RemoteServices map[string]RemotePinningService +} + +type RemotePinningService struct { + Api RemotePinningServiceApi +} + +type RemotePinningServiceApi struct { + Endpoint string + Key string +} From d643a2bce4e92b5ec980588c9d58def491008e6e Mon Sep 17 00:00:00 2001 From: Adin Schmahmann Date: Fri, 4 Dec 2020 15:52:59 -0500 Subject: [PATCH 226/262] go-ipfs-config: go fmt --- config/bootstrap_peers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/bootstrap_peers.go b/config/bootstrap_peers.go index 55d0f3b822f..27715843da0 100644 --- a/config/bootstrap_peers.go +++ b/config/bootstrap_peers.go @@ -19,7 +19,7 @@ var DefaultBootstrapAddresses = []string{ "/dnsaddr/bootstrap.libp2p.io/p2p/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa", "/dnsaddr/bootstrap.libp2p.io/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb", "/dnsaddr/bootstrap.libp2p.io/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt", - "/ip4/104.131.131.82/tcp/4001/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ", // mars.i.ipfs.io + "/ip4/104.131.131.82/tcp/4001/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ", // mars.i.ipfs.io "/ip4/104.131.131.82/udp/4001/quic/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ", // mars.i.ipfs.io } From 2690c10bcacc6c5c286dcc6f2f3137dc1cf879a5 Mon Sep 17 00:00:00 2001 From: Adin Schmahmann Date: Thu, 28 Jan 2021 18:05:47 -0500 Subject: [PATCH 227/262] go-ipfs-config: add support for pinning mfs (#116) * add support for pinning mfs * add pin conceal selector * add RemoteServicesPath Co-authored-by: Petar Maymounkov --- config/init.go | 3 +++ config/remotepin.go | 25 +++++++++++++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/config/init.go b/config/init.go index 448fffa73c1..ecda3047ddb 100644 --- a/config/init.go +++ b/config/init.go @@ -86,6 +86,9 @@ func InitWithIdentity(identity Identity) (*Config, error) { Type: "basic", }, }, + Pinning: Pinning{ + RemoteServices: map[string]RemotePinningService{}, + }, } return conf, nil diff --git a/config/remotepin.go b/config/remotepin.go index 9da2af1bf0b..135aa664d17 100644 --- a/config/remotepin.go +++ b/config/remotepin.go @@ -1,9 +1,8 @@ package config -const ( - PinningTag = "Pinning" - RemoteServicesTag = "RemoteServices" - RemoteServicesSelector = PinningTag + "." + RemoteServicesTag +var ( + RemoteServicesPath = "Pinning.RemoteServices" + PinningConcealSelector = []string{"Pinning", "RemoteServices", "*", "API", "Key"} ) type Pinning struct { @@ -11,10 +10,24 @@ type Pinning struct { } type RemotePinningService struct { - Api RemotePinningServiceApi + API RemotePinningServiceAPI + Policies RemotePinningServicePolicies } -type RemotePinningServiceApi struct { +type RemotePinningServiceAPI struct { Endpoint string Key string } + +type RemotePinningServicePolicies struct { + MFS RemotePinningServiceMFSPolicy +} + +type RemotePinningServiceMFSPolicy struct { + // Enable enables watching for changes in MFS and re-pinning the MFS root cid whenever a change occurs. + Enable bool + // Name is the pin name for MFS. + PinName string + // RepinInterval determines the repin interval when the policy is enabled. In ns, us, ms, s, m, h. + RepinInterval string +} From f5fb70ee0faf3d5891c4292d6cc734f5a7eb9983 Mon Sep 17 00:00:00 2001 From: "@RubenKelevra" Date: Wed, 24 Mar 2021 12:44:46 +0100 Subject: [PATCH 228/262] go-ipfs-config: remove duplicate entries in defaultServerFilters --- config/profile.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/config/profile.go b/config/profile.go index c0fa947f164..1d379d97db0 100644 --- a/config/profile.go +++ b/config/profile.go @@ -30,10 +30,6 @@ var defaultServerFilters = []string{ "/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", From 8a8b161da461c8e340f7a37178df3e1ea882fad9 Mon Sep 17 00:00:00 2001 From: vyzo Date: Mon, 12 Apr 2021 13:53:19 +0300 Subject: [PATCH 229/262] go-ipfs-config: add custom DNS Resolver configuration --- config/config.go | 1 + config/dns.go | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100644 config/dns.go diff --git a/config/config.go b/config/config.go index 7d44316abd3..d9b060e64b8 100644 --- a/config/config.go +++ b/config/config.go @@ -28,6 +28,7 @@ type Config struct { AutoNAT AutoNATConfig Pubsub PubsubConfig Peering Peering + DNS DNSConfig Provider Provider Reprovider Reprovider diff --git a/config/dns.go b/config/dns.go new file mode 100644 index 00000000000..5f18a9c6940 --- /dev/null +++ b/config/dns.go @@ -0,0 +1,10 @@ +package config + +// DNSConfig specifies custom resolvers using DoH +type DNSConfig struct { + // DefaultResolver, if present, is a URL for the default DoH resolver. + // If empty, DNS resolution will use the system resolver. + DefaultResolver string `json:",omitempty"` + // CustomResolvers is a map of domains to URLs for custom DoH resolution. + CustomResolvers map[string]string `json:",omitempty"` +} From 28553d793ad0e52129102d094b249a0893ee96c5 Mon Sep 17 00:00:00 2001 From: vyzo Date: Tue, 13 Apr 2021 17:32:15 +0300 Subject: [PATCH 230/262] go-ipfs-config: simplify DNS config --- config/dns.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/config/dns.go b/config/dns.go index 5f18a9c6940..ae390d91c62 100644 --- a/config/dns.go +++ b/config/dns.go @@ -1,10 +1,7 @@ package config -// DNSConfig specifies custom resolvers using DoH +// DNSConfig specifies DNS resolution rules using custom resolvers type DNSConfig struct { - // DefaultResolver, if present, is a URL for the default DoH resolver. - // If empty, DNS resolution will use the system resolver. - DefaultResolver string `json:",omitempty"` - // CustomResolvers is a map of domains to URLs for custom DoH resolution. - CustomResolvers map[string]string `json:",omitempty"` + // CustomResolvers is a map of FQDNs to URLs for custom DNS resolution. + Resolvers map[string]string } From f264de41392227173da5ec44d929831d37d60161 Mon Sep 17 00:00:00 2001 From: vyzo Date: Tue, 13 Apr 2021 17:53:47 +0300 Subject: [PATCH 231/262] go-ipfs-config: update comments Co-authored-by: Marcin Rataj --- config/dns.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/config/dns.go b/config/dns.go index ae390d91c62..aadea8904c0 100644 --- a/config/dns.go +++ b/config/dns.go @@ -2,6 +2,14 @@ package config // DNSConfig specifies DNS resolution rules using custom resolvers type DNSConfig struct { - // CustomResolvers is a map of FQDNs to URLs for custom DNS resolution. + // Resolvers is a map of FQDNs to URLs for custom DNS resolution. + // URLs starting with `https://` indicate DoH endpoints. + // Support for other resolver types can be added in the future. + // https://en.wikipedia.org/wiki/Fully_qualified_domain_name + // https://en.wikipedia.org/wiki/DNS_over_HTTPS + // + // Example: + // - Custom resolver for ENS: `eth.` → `https://eth.link/dns-query` + // - Override the default OS resolver: `.` → `https://doh.applied-privacy.net/query` Resolvers map[string]string } From c932e6b7008901e2dea8e8dd4e4bafa9fb2fe77d Mon Sep 17 00:00:00 2001 From: vyzo Date: Wed, 14 Apr 2021 18:46:35 +0300 Subject: [PATCH 232/262] go-ipfs-config: add default empty config for DNS, rename struct from DNSConfig to DNS --- config/config.go | 2 +- config/dns.go | 10 +++++----- config/init.go | 3 +++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/config/config.go b/config/config.go index d9b060e64b8..b593e7a7e36 100644 --- a/config/config.go +++ b/config/config.go @@ -28,7 +28,7 @@ type Config struct { AutoNAT AutoNATConfig Pubsub PubsubConfig Peering Peering - DNS DNSConfig + DNS DNS Provider Provider Reprovider Reprovider diff --git a/config/dns.go b/config/dns.go index aadea8904c0..5c4e62da0cc 100644 --- a/config/dns.go +++ b/config/dns.go @@ -1,13 +1,13 @@ package config -// DNSConfig specifies DNS resolution rules using custom resolvers -type DNSConfig struct { - // Resolvers is a map of FQDNs to URLs for custom DNS resolution. +// DNS specifies DNS resolution rules using custom resolvers +type DNS struct { + // Resolvers is a map of FQDNs to URLs for custom DNS resolution. // URLs starting with `https://` indicate DoH endpoints. // Support for other resolver types can be added in the future. // https://en.wikipedia.org/wiki/Fully_qualified_domain_name - // https://en.wikipedia.org/wiki/DNS_over_HTTPS - // + // https://en.wikipedia.org/wiki/DNS_over_HTTPS + // // Example: // - Custom resolver for ENS: `eth.` → `https://eth.link/dns-query` // - Override the default OS resolver: `.` → `https://doh.applied-privacy.net/query` diff --git a/config/init.go b/config/init.go index ecda3047ddb..56a99884fa8 100644 --- a/config/init.go +++ b/config/init.go @@ -89,6 +89,9 @@ func InitWithIdentity(identity Identity) (*Config, error) { Pinning: Pinning{ RemoteServices: map[string]RemotePinningService{}, }, + DNS: DNS{ + Resolvers: map[string]string{}, + }, } return conf, nil From 67456e2e647a28080259b6f38eb59b0a911070b4 Mon Sep 17 00:00:00 2001 From: gammazero Date: Fri, 16 Apr 2021 17:22:03 -0700 Subject: [PATCH 233/262] go-ipfs-config: Add config for downloading repo migrations --- config/config.go | 1 + config/init.go | 4 ++++ config/migration.go | 22 ++++++++++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 config/migration.go diff --git a/config/config.go b/config/config.go index b593e7a7e36..5a603015ce8 100644 --- a/config/config.go +++ b/config/config.go @@ -29,6 +29,7 @@ type Config struct { Pubsub PubsubConfig Peering Peering DNS DNS + Migration Migration Provider Provider Reprovider Reprovider diff --git a/config/init.go b/config/init.go index 56a99884fa8..db0eff5f284 100644 --- a/config/init.go +++ b/config/init.go @@ -92,6 +92,10 @@ func InitWithIdentity(identity Identity) (*Config, error) { DNS: DNS{ Resolvers: map[string]string{}, }, + Migration: Migration{ + DownloadSources: DefaultMigrationDownloadSources, + Keep: DefaultMigrationKeep, + }, } return conf, nil diff --git a/config/migration.go b/config/migration.go new file mode 100644 index 00000000000..e55734f88c7 --- /dev/null +++ b/config/migration.go @@ -0,0 +1,22 @@ +package config + +import "github.com/libp2p/go-libp2p-core/peer" + +const DefaultMigrationKeep = "cache" + +var DefaultMigrationDownloadSources = []string{"HTTPS", "IPFS"} + +// Migration configures how migrations are downloaded and if the downloads are +// added to IPFS locally +type Migration struct { + // Sources in order of preference where "HTTPS" means our gateways and + // "IPFS" means over IPFS. Any other values are interpretes as hostnames + // for custom gateways. An empty list means "do the default thing" + DownloadSources []string + // Whether or not to keep the migration after downloading it. + // Options are "discard", "cache", "pin". Empty string for default. + Keep string + // Peers lists the nodes to attempt to connect with when downloading + // migrations. + Peers []peer.AddrInfo +} From 5e6df6f54a5467f540e15624909487776cb77508 Mon Sep 17 00:00:00 2001 From: gammazero Date: Sat, 17 Apr 2021 18:19:05 -0700 Subject: [PATCH 234/262] go-ipfs-config: unit test for migration config --- config/migration_test.go | 70 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 config/migration_test.go diff --git a/config/migration_test.go b/config/migration_test.go new file mode 100644 index 00000000000..47e2bed2aca --- /dev/null +++ b/config/migration_test.go @@ -0,0 +1,70 @@ +package config + +import ( + "encoding/json" + "testing" +) + +func TestMigrationDecode(t *testing.T) { + str := ` + { + "DownloadSources": ["IPFS", "HTTP", "127.0.0.1"], + "Keep": "cache", + "Peers": [ + { + "ID": "12D3KooWGC6TvWhfapngX6wvJHMYvKpDMXPb3ZnCZ6dMoaMtimQ5", + "Addrs": ["/ip4/127.0.0.1/tcp/4001", "/ip4/127.0.0.1/udp/4001/quic"] + }, + { + "ID": "12D3KooWGC6TvWhfajpgX6wvJHMYvKpDMXPb3ZnCZ6dMoaMtimQ7", + "Addrs": ["/ip4/10.0.0.2/tcp/4001"] + } + ] + } + ` + + var cfg Migration + if err := json.Unmarshal([]byte(str), &cfg); err != nil { + t.Errorf("failed while unmarshalling migration struct: %s", err) + } + + if len(cfg.DownloadSources) != 3 { + t.Fatal("wrong number of DownloadSources") + } + expect := []string{"IPFS", "HTTP", "127.0.0.1"} + for i := range expect { + if cfg.DownloadSources[i] != expect[i] { + t.Errorf("wrong DownloadSource at %d", i) + } + } + + if cfg.Keep != "cache" { + t.Error("wrong value for Keep") + } + + if len(cfg.Peers) != 2 { + t.Fatal("wrong number of peers") + } + + peer := cfg.Peers[0] + if peer.ID.String() != "12D3KooWGC6TvWhfapngX6wvJHMYvKpDMXPb3ZnCZ6dMoaMtimQ5" { + t.Errorf("wrong ID for first peer") + } + if len(peer.Addrs) != 2 { + t.Error("wrong number of addrs for first peer") + } + if peer.Addrs[0].String() != "/ip4/127.0.0.1/tcp/4001" { + t.Error("wrong first addr for first peer") + } + if peer.Addrs[1].String() != "/ip4/127.0.0.1/udp/4001/quic" { + t.Error("wrong second addr for first peer") + } + + peer = cfg.Peers[1] + if len(peer.Addrs) != 1 { + t.Fatal("wrong number of addrs for second peer") + } + if peer.Addrs[0].String() != "/ip4/10.0.0.2/tcp/4001" { + t.Error("wrong first addr for second peer") + } +} From ec1659d79ace0c8688c348b0946c20ff408112e4 Mon Sep 17 00:00:00 2001 From: gammazero Date: Mon, 19 Apr 2021 23:41:54 -0700 Subject: [PATCH 235/262] go-ipfs-config: Init migration config with empty values --- config/init.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/init.go b/config/init.go index db0eff5f284..be07eec2404 100644 --- a/config/init.go +++ b/config/init.go @@ -93,8 +93,8 @@ func InitWithIdentity(identity Identity) (*Config, error) { Resolvers: map[string]string{}, }, Migration: Migration{ - DownloadSources: DefaultMigrationDownloadSources, - Keep: DefaultMigrationKeep, + DownloadSources: []string{}, + Keep: "", }, } From dbb5fa78a59e09addf7368eff6aaefbbbf08c741 Mon Sep 17 00:00:00 2001 From: gammazero Date: Tue, 20 Apr 2021 00:29:38 -0700 Subject: [PATCH 236/262] go-ipfs-config: Fix comment --- config/migration.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/migration.go b/config/migration.go index e55734f88c7..24e92f73071 100644 --- a/config/migration.go +++ b/config/migration.go @@ -9,9 +9,9 @@ var DefaultMigrationDownloadSources = []string{"HTTPS", "IPFS"} // Migration configures how migrations are downloaded and if the downloads are // added to IPFS locally type Migration struct { - // Sources in order of preference where "HTTPS" means our gateways and - // "IPFS" means over IPFS. Any other values are interpretes as hostnames - // for custom gateways. An empty list means "do the default thing" + // Sources in order of preference, where "IPFS" means use IPFS and "HTTPS" + // means use default gateways. Any other values are interpreted as + // hostnames for custom gateways. Empty list means "use default sources". DownloadSources []string // Whether or not to keep the migration after downloading it. // Options are "discard", "cache", "pin". Empty string for default. From 4b778ce3267b6e5ce5f69cf57d1217218bdf01a4 Mon Sep 17 00:00:00 2001 From: gammazero Date: Mon, 3 May 2021 09:08:16 -0700 Subject: [PATCH 237/262] go-ipfs-config: Removed Peers from migration config --- config/migration.go | 5 ----- config/migration_test.go | 38 +------------------------------------- 2 files changed, 1 insertion(+), 42 deletions(-) diff --git a/config/migration.go b/config/migration.go index 24e92f73071..27d4b3c7025 100644 --- a/config/migration.go +++ b/config/migration.go @@ -1,7 +1,5 @@ package config -import "github.com/libp2p/go-libp2p-core/peer" - const DefaultMigrationKeep = "cache" var DefaultMigrationDownloadSources = []string{"HTTPS", "IPFS"} @@ -16,7 +14,4 @@ type Migration struct { // Whether or not to keep the migration after downloading it. // Options are "discard", "cache", "pin". Empty string for default. Keep string - // Peers lists the nodes to attempt to connect with when downloading - // migrations. - Peers []peer.AddrInfo } diff --git a/config/migration_test.go b/config/migration_test.go index 47e2bed2aca..a6cbd4438e7 100644 --- a/config/migration_test.go +++ b/config/migration_test.go @@ -9,17 +9,7 @@ func TestMigrationDecode(t *testing.T) { str := ` { "DownloadSources": ["IPFS", "HTTP", "127.0.0.1"], - "Keep": "cache", - "Peers": [ - { - "ID": "12D3KooWGC6TvWhfapngX6wvJHMYvKpDMXPb3ZnCZ6dMoaMtimQ5", - "Addrs": ["/ip4/127.0.0.1/tcp/4001", "/ip4/127.0.0.1/udp/4001/quic"] - }, - { - "ID": "12D3KooWGC6TvWhfajpgX6wvJHMYvKpDMXPb3ZnCZ6dMoaMtimQ7", - "Addrs": ["/ip4/10.0.0.2/tcp/4001"] - } - ] + "Keep": "cache" } ` @@ -41,30 +31,4 @@ func TestMigrationDecode(t *testing.T) { if cfg.Keep != "cache" { t.Error("wrong value for Keep") } - - if len(cfg.Peers) != 2 { - t.Fatal("wrong number of peers") - } - - peer := cfg.Peers[0] - if peer.ID.String() != "12D3KooWGC6TvWhfapngX6wvJHMYvKpDMXPb3ZnCZ6dMoaMtimQ5" { - t.Errorf("wrong ID for first peer") - } - if len(peer.Addrs) != 2 { - t.Error("wrong number of addrs for first peer") - } - if peer.Addrs[0].String() != "/ip4/127.0.0.1/tcp/4001" { - t.Error("wrong first addr for first peer") - } - if peer.Addrs[1].String() != "/ip4/127.0.0.1/udp/4001/quic" { - t.Error("wrong second addr for first peer") - } - - peer = cfg.Peers[1] - if len(peer.Addrs) != 1 { - t.Fatal("wrong number of addrs for second peer") - } - if peer.Addrs[0].String() != "/ip4/10.0.0.2/tcp/4001" { - t.Error("wrong first addr for second peer") - } } From 22d2b6b8b83b97551db2af2da657b2365bf2a3a6 Mon Sep 17 00:00:00 2001 From: Adin Schmahmann Date: Mon, 5 Apr 2021 12:51:52 -0400 Subject: [PATCH 238/262] go-ipfs-config: add option for Accelerated DHT Client experiment --- config/experiments.go | 1 + 1 file changed, 1 insertion(+) diff --git a/config/experiments.go b/config/experiments.go index d63580f26c0..c4f906394b5 100644 --- a/config/experiments.go +++ b/config/experiments.go @@ -8,4 +8,5 @@ type Experiments struct { Libp2pStreamMounting bool P2pHttpProxy bool StrategicProviding bool + AcceleratedDHTClient bool } From e7bb833760c70227ead661be55114181d5ff1030 Mon Sep 17 00:00:00 2001 From: Michael Burns <5170+mburns@users.noreply.github.com> Date: Fri, 14 May 2021 14:31:24 -0700 Subject: [PATCH 239/262] go-ipfs-config: [LINT] error strings should not end with punctuation or a newline (ST1005) --- config/bootstrap_peers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/bootstrap_peers.go b/config/bootstrap_peers.go index 27715843da0..e22c55fb8a7 100644 --- a/config/bootstrap_peers.go +++ b/config/bootstrap_peers.go @@ -37,7 +37,7 @@ func DefaultBootstrapPeers() ([]peer.AddrInfo, error) { ps, err := ParseBootstrapPeers(DefaultBootstrapAddresses) if err != nil { return nil, fmt.Errorf(`failed to parse hardcoded bootstrap peers: %s -This is a problem with the ipfs codebase. Please report it to the dev team.`, err) +This is a problem with the ipfs codebase. Please report it to the dev team`, err) } return ps, nil } From 8f09fa547f53eae317c81e0b860f253c57a624fe Mon Sep 17 00:00:00 2001 From: web3-bot Date: Mon, 17 May 2021 17:00:43 +0000 Subject: [PATCH 240/262] go-ipfs-config: run gofmt -s --- config/init.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/init.go b/config/init.go index be07eec2404..13d40b6ddb8 100644 --- a/config/init.go +++ b/config/init.go @@ -68,9 +68,9 @@ func InitWithIdentity(identity Identity) (*Config, error) { NoFetch: false, PathPrefixes: []string{}, HTTPHeaders: map[string][]string{ - "Access-Control-Allow-Origin": []string{"*"}, - "Access-Control-Allow-Methods": []string{"GET"}, - "Access-Control-Allow-Headers": []string{"X-Requested-With", "Range", "User-Agent"}, + "Access-Control-Allow-Origin": {"*"}, + "Access-Control-Allow-Methods": {"GET"}, + "Access-Control-Allow-Headers": {"X-Requested-With", "Range", "User-Agent"}, }, APICommands: []string{}, }, From c692e73f3f9c27d43414923acff972b65df07361 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 22 Jul 2021 15:54:33 -0700 Subject: [PATCH 241/262] go-ipfs-config: fix: remove deprecated calls And rename imports. --- config/init.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/config/init.go b/config/init.go index 13d40b6ddb8..cf0cca5929a 100644 --- a/config/init.go +++ b/config/init.go @@ -8,8 +8,8 @@ import ( "time" "github.com/ipfs/interface-go-ipfs-core/options" - ci "github.com/libp2p/go-libp2p-core/crypto" - peer "github.com/libp2p/go-libp2p-core/peer" + "github.com/libp2p/go-libp2p-core/crypto" + "github.com/libp2p/go-libp2p-core/peer" ) func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { @@ -191,8 +191,8 @@ func CreateIdentity(out io.Writer, opts []options.KeyGenerateOption) (Identity, return ident, err } - var sk ci.PrivKey - var pk ci.PubKey + var sk crypto.PrivKey + var pk crypto.PubKey switch settings.Algorithm { case "rsa": @@ -202,7 +202,7 @@ func CreateIdentity(out io.Writer, opts []options.KeyGenerateOption) (Identity, fmt.Fprintf(out, "generating %d-bit RSA keypair...", settings.Size) - priv, pub, err := ci.GenerateKeyPair(ci.RSA, settings.Size) + priv, pub, err := crypto.GenerateKeyPair(crypto.RSA, settings.Size) if err != nil { return ident, err } @@ -214,7 +214,7 @@ func CreateIdentity(out io.Writer, opts []options.KeyGenerateOption) (Identity, return ident, fmt.Errorf("number of key bits does not apply when using ed25519 keys") } fmt.Fprintf(out, "generating ED25519 keypair...") - priv, pub, err := ci.GenerateEd25519Key(rand.Reader) + priv, pub, err := crypto.GenerateEd25519Key(rand.Reader) if err != nil { return ident, err } @@ -228,7 +228,7 @@ func CreateIdentity(out io.Writer, opts []options.KeyGenerateOption) (Identity, // currently storing key unencrypted. in the future we need to encrypt it. // TODO(security) - skbytes, err := sk.Bytes() + skbytes, err := crypto.MarshalPrivateKey(sk) if err != nil { return ident, err } From 7c1029c5151a8890b2e8d2404a7aae70e74361da Mon Sep 17 00:00:00 2001 From: Adin Schmahmann Date: Wed, 11 Aug 2021 17:29:54 -0400 Subject: [PATCH 242/262] go-ipfs-config: fix: make sure the Priority type properly implements the JSON marshal/unmarshal interfaces --- config/types.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/types.go b/config/types.go index d22fd5dfad5..cf6e947caeb 100644 --- a/config/types.go +++ b/config/types.go @@ -208,8 +208,8 @@ func (p Priority) String() string { } } -var _ json.Unmarshaler = (*Flag)(nil) -var _ json.Marshaler = (*Flag)(nil) +var _ json.Unmarshaler = (*Priority)(nil) +var _ json.Marshaler = (*Priority)(nil) // Duration wraps time.Duration to provide json serialization and deserialization. // From ac81804c8c4b76aa1de7358abdd45c69ed53978a Mon Sep 17 00:00:00 2001 From: Adin Schmahmann Date: Mon, 16 Aug 2021 00:01:51 -0400 Subject: [PATCH 243/262] go-ipfs-config: feat: add an OptionalInteger type --- config/types.go | 52 +++++++++++++++++++++++++ config/types_test.go | 90 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 142 insertions(+) diff --git a/config/types.go b/config/types.go index cf6e947caeb..14b9f7cc020 100644 --- a/config/types.go +++ b/config/types.go @@ -232,3 +232,55 @@ func (d Duration) String() string { var _ encoding.TextUnmarshaler = (*Duration)(nil) var _ encoding.TextMarshaler = (*Duration)(nil) + +// OptionalInteger represents an integer that has a default value +// +// When encoded in json, Default is encoded as "null" +type OptionalInteger struct { + value *int64 +} + +// WithDefault resolves the integer with the given default. +func (p OptionalInteger) WithDefault(defaultValue int64) (value int64) { + if p.value == nil { + return defaultValue + } + return *p.value +} + +// IsDefault returns if this is a default optional integer +func (p OptionalInteger) IsDefault() bool { + return p.value == nil +} + +func (p OptionalInteger) MarshalJSON() ([]byte, error) { + if p.value != nil { + return json.Marshal(p.value) + } + return json.Marshal(nil) +} + +func (p *OptionalInteger) UnmarshalJSON(input []byte) error { + switch string(input) { + case "null", "undefined": + *p = OptionalInteger{} + default: + var value int64 + err := json.Unmarshal(input, &value) + if err != nil { + return err + } + *p = OptionalInteger{value: &value} + } + return nil +} + +func (p OptionalInteger) String() string { + if p.value == nil { + return "default" + } + return fmt.Sprintf("%d", p.value) +} + +var _ json.Unmarshaler = (*OptionalInteger)(nil) +var _ json.Marshaler = (*OptionalInteger)(nil) diff --git a/config/types_test.go b/config/types_test.go index 8d4c62fd2aa..94a7a633d07 100644 --- a/config/types_test.go +++ b/config/types_test.go @@ -218,3 +218,93 @@ func TestPriority(t *testing.T) { } } } + +func TestOptionalInteger(t *testing.T) { + makeInt64Pointer := func(v int64) *int64 { + return &v + } + + var defaultOptionalInt OptionalInteger + if !defaultOptionalInt.IsDefault() { + t.Fatal("should be the default") + } + if val := defaultOptionalInt.WithDefault(0); val != 0 { + t.Errorf("optional integer should have been 0, got %d", val) + } + + if val := defaultOptionalInt.WithDefault(1); val != 1 { + t.Errorf("optional integer should have been 1, got %d", val) + } + + if val := defaultOptionalInt.WithDefault(-1); val != -1 { + t.Errorf("optional integer should have been -1, got %d", val) + } + + var filledInt OptionalInteger + filledInt = OptionalInteger{value: makeInt64Pointer(1)} + if filledInt.IsDefault() { + t.Fatal("should not be the default") + } + if val := filledInt.WithDefault(0); val != 1 { + t.Errorf("optional integer should have been 1, got %d", val) + } + + if val := filledInt.WithDefault(-1); val != 1 { + t.Errorf("optional integer should have been 1, got %d", val) + } + + filledInt = OptionalInteger{value: makeInt64Pointer(0)} + if val := filledInt.WithDefault(1); val != 0 { + t.Errorf("optional integer should have been 0, got %d", val) + } + + for jsonStr, goValue := range map[string]OptionalInteger{ + "null": {}, + "0": {value: makeInt64Pointer(0)}, + "1": {value: makeInt64Pointer(1)}, + "-1": {value: makeInt64Pointer(-1)}, + } { + var d OptionalInteger + err := json.Unmarshal([]byte(jsonStr), &d) + if err != nil { + t.Fatal(err) + } + + if goValue.value == nil && d.value == nil { + } else if goValue.value == nil && d.value != nil { + t.Errorf("expected default, got %s", d) + } else if *d.value != *goValue.value { + t.Fatalf("expected %s, got %s", goValue, d) + } + + // Reverse + out, err := json.Marshal(goValue) + if err != nil { + t.Fatal(err) + } + if string(out) != jsonStr { + t.Fatalf("expected %s, got %s", jsonStr, string(out)) + } + } + + type Foo struct { + I *OptionalInteger `json:",omitempty"` + } + out, err := json.Marshal(new(Foo)) + if err != nil { + t.Fatal(err) + } + expected := "{}" + if string(out) != expected { + t.Fatal("expected omitempty to omit the optional integer") + } + for _, invalid := range []string{ + "foo", "-1.1", "1.1", "0.0", "[]", + } { + var p Priority + err := json.Unmarshal([]byte(invalid), &p) + if err == nil { + t.Errorf("expected to fail to decode %s as a priority", invalid) + } + } +} From 44291176e63ee0d4b666216670f75e258cb6022c Mon Sep 17 00:00:00 2001 From: Petar Maymounkov Date: Fri, 23 Jul 2021 09:29:33 -0400 Subject: [PATCH 244/262] go-ipfs-config: feat: add Internal and Internal.Bitswap config options --- config/config.go | 2 ++ config/internal.go | 12 ++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 config/internal.go diff --git a/config/config.go b/config/config.go index 5a603015ce8..419a6a71f3a 100644 --- a/config/config.go +++ b/config/config.go @@ -36,6 +36,8 @@ type Config struct { Experimental Experiments Plugins Plugins Pinning Pinning + + Internal Internal // experimental/unstable options } const ( diff --git a/config/internal.go b/config/internal.go new file mode 100644 index 00000000000..2e71ac16eb7 --- /dev/null +++ b/config/internal.go @@ -0,0 +1,12 @@ +package config + +type Internal struct { + Bitswap *InternalBitswap `json:",omitempty"` // This is omitempty since we are expecting to make changes to all subcomponents of Internal +} + +type InternalBitswap struct { + TaskWorkerCount OptionalInteger + EngineBlockstoreWorkerCount OptionalInteger + EngineTaskWorkerCount OptionalInteger + MaxOutstandingBytesPerPeer OptionalInteger +} From 2cf170d5fae00da6625bb0831beb5c67a4f71ee1 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Wed, 27 Oct 2021 18:23:35 +0200 Subject: [PATCH 245/262] go-ipfs-config: feat: add an OptionalDuration type (#148) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: make it possible to define optional durations * test: empty/default optional durations does not crash if user restores default value and sets it to empty string "" * refactor: use null in JSON * refactor(duration): use JSON null as the default Rationale: https://github.com/ipfs/go-ipfs-config/pull/148#discussion_r736975879 * refactor: Duration → OptionalDuration This makes it possible to use OptionalDuration with `json:",omitempty"` so the null is not serialized to JSON, and get working WithDefault as well. Co-authored-by: Marcin Rataj --- config/autonat.go | 2 +- config/types.go | 57 ++++++++++++----- config/types_test.go | 144 ++++++++++++++++++++++++++++++++++--------- 3 files changed, 160 insertions(+), 43 deletions(-) diff --git a/config/autonat.go b/config/autonat.go index a1a3f699cda..64856faa680 100644 --- a/config/autonat.go +++ b/config/autonat.go @@ -77,5 +77,5 @@ type AutoNATThrottleConfig struct { // global/peer dialback limits. // // When unset, this defaults to 1 minute. - Interval Duration `json:",omitempty"` + Interval OptionalDuration `json:",omitempty"` } diff --git a/config/types.go b/config/types.go index 14b9f7cc020..ac90fa9b82a 100644 --- a/config/types.go +++ b/config/types.go @@ -1,9 +1,9 @@ package config import ( - "encoding" "encoding/json" "fmt" + "strings" "time" ) @@ -211,27 +211,56 @@ func (p Priority) String() string { var _ json.Unmarshaler = (*Priority)(nil) var _ json.Marshaler = (*Priority)(nil) -// Duration wraps time.Duration to provide json serialization and deserialization. +// OptionalDuration wraps time.Duration to provide json serialization and deserialization. // -// NOTE: the zero value encodes to an empty string. -type Duration time.Duration +// NOTE: the zero value encodes to JSON nill +type OptionalDuration struct { + value *time.Duration +} -func (d *Duration) UnmarshalText(text []byte) error { - dur, err := time.ParseDuration(string(text)) - *d = Duration(dur) - return err +func (d *OptionalDuration) UnmarshalJSON(input []byte) error { + switch string(input) { + case "null", "undefined", "\"null\"", "", "default", "\"\"", "\"default\"": + *d = OptionalDuration{} + return nil + default: + text := strings.Trim(string(input), "\"") + value, err := time.ParseDuration(text) + if err != nil { + return err + } + *d = OptionalDuration{value: &value} + return nil + } } -func (d Duration) MarshalText() ([]byte, error) { - return []byte(time.Duration(d).String()), nil +func (d *OptionalDuration) IsDefault() bool { + return d == nil || d.value == nil } -func (d Duration) String() string { - return time.Duration(d).String() +func (d *OptionalDuration) WithDefault(defaultValue time.Duration) time.Duration { + if d == nil || d.value == nil { + return defaultValue + } + return *d.value +} + +func (d OptionalDuration) MarshalJSON() ([]byte, error) { + if d.value == nil { + return json.Marshal(nil) + } + return json.Marshal(d.value.String()) +} + +func (d OptionalDuration) String() string { + if d.value == nil { + return "default" + } + return d.value.String() } -var _ encoding.TextUnmarshaler = (*Duration)(nil) -var _ encoding.TextMarshaler = (*Duration)(nil) +var _ json.Unmarshaler = (*OptionalDuration)(nil) +var _ json.Marshaler = (*OptionalDuration)(nil) // OptionalInteger represents an integer that has a default value // diff --git a/config/types_test.go b/config/types_test.go index 94a7a633d07..06ea73a260c 100644 --- a/config/types_test.go +++ b/config/types_test.go @@ -1,40 +1,128 @@ package config import ( + "bytes" "encoding/json" "testing" "time" ) -func TestDuration(t *testing.T) { - out, err := json.Marshal(Duration(time.Second)) - if err != nil { - t.Fatal(err) +func TestOptionalDuration(t *testing.T) { + makeDurationPointer := func(d time.Duration) *time.Duration { return &d } - } - expected := "\"1s\"" - if string(out) != expected { - t.Fatalf("expected %s, got %s", expected, string(out)) - } - var d Duration - err = json.Unmarshal(out, &d) - if err != nil { - t.Fatal(err) - } - if time.Duration(d) != time.Second { - t.Fatal("expected a second") - } - type Foo struct { - D Duration `json:",omitempty"` - } - out, err = json.Marshal(new(Foo)) - if err != nil { - t.Fatal(err) - } - expected = "{}" - if string(out) != expected { - t.Fatal("expected omitempty to omit the duration") - } + t.Run("marshalling and unmarshalling", func(t *testing.T) { + out, err := json.Marshal(OptionalDuration{value: makeDurationPointer(time.Second)}) + if err != nil { + t.Fatal(err) + } + expected := "\"1s\"" + if string(out) != expected { + t.Fatalf("expected %s, got %s", expected, string(out)) + } + var d OptionalDuration + + if err := json.Unmarshal(out, &d); err != nil { + t.Fatal(err) + } + if *d.value != time.Second { + t.Fatal("expected a second") + } + }) + + t.Run("default value", func(t *testing.T) { + for _, jsonStr := range []string{"null", "\"null\"", "\"\"", "\"default\""} { + var d OptionalDuration + if !d.IsDefault() { + t.Fatal("expected value to be the default initially") + } + if err := json.Unmarshal([]byte(jsonStr), &d); err != nil { + t.Fatalf("%s failed to unmarshall with %s", jsonStr, err) + } + if dur := d.WithDefault(time.Hour); dur != time.Hour { + t.Fatalf("expected default value to be used, got %s", dur) + } + if !d.IsDefault() { + t.Fatal("expected value to be the default") + } + } + }) + + t.Run("omitempty with default value", func(t *testing.T) { + type Foo struct { + D *OptionalDuration `json:",omitempty"` + } + // marshall to JSON without empty field + out, err := json.Marshal(new(Foo)) + if err != nil { + t.Fatal(err) + } + if string(out) != "{}" { + t.Fatalf("expected omitempty to omit the duration, got %s", out) + } + // unmarshall missing value and get the default + var foo2 Foo + if err := json.Unmarshal(out, &foo2); err != nil { + t.Fatalf("%s failed to unmarshall with %s", string(out), err) + } + if dur := foo2.D.WithDefault(time.Hour); dur != time.Hour { + t.Fatalf("expected default value to be used, got %s", dur) + } + if !foo2.D.IsDefault() { + t.Fatal("expected value to be the default") + } + }) + + t.Run("roundtrip including the default values", func(t *testing.T) { + for jsonStr, goValue := range map[string]OptionalDuration{ + // there are various footguns user can hit, normalize them to the canonical default + "null": {}, // JSON null → default value + "\"null\"": {}, // JSON string "null" sent/set by "ipfs config" cli → default value + "\"default\"": {}, // explicit "default" as string + "\"\"": {}, // user removed custom value, empty string should also parse as default + "\"1s\"": {value: makeDurationPointer(time.Second)}, + "\"42h1m3s\"": {value: makeDurationPointer(42*time.Hour + 1*time.Minute + 3*time.Second)}, + } { + var d OptionalDuration + err := json.Unmarshal([]byte(jsonStr), &d) + if err != nil { + t.Fatal(err) + } + + if goValue.value == nil && d.value == nil { + } else if goValue.value == nil && d.value != nil { + t.Errorf("expected nil for %s, got %s", jsonStr, d) + } else if *d.value != *goValue.value { + t.Fatalf("expected %s for %s, got %s", goValue, jsonStr, d) + } + + // Test Reverse + out, err := json.Marshal(goValue) + if err != nil { + t.Fatal(err) + } + if goValue.value == nil { + if !bytes.Equal(out, []byte("null")) { + t.Fatalf("expected JSON null for %s, got %s", jsonStr, string(out)) + } + continue + } + if string(out) != jsonStr { + t.Fatalf("expected %s, got %s", jsonStr, string(out)) + } + } + }) + + t.Run("invalid duration values", func(t *testing.T) { + for _, invalid := range []string{ + "\"s\"", "\"1ę\"", "\"-1\"", "\"1H\"", "\"day\"", + } { + var d OptionalDuration + err := json.Unmarshal([]byte(invalid), &d) + if err == nil { + t.Errorf("expected to fail to decode %s as an OptionalDuration, got %s instead", invalid, d) + } + } + }) } func TestOneStrings(t *testing.T) { From 9eaf572b284cdc6408c6186b664d306c5f2ebebf Mon Sep 17 00:00:00 2001 From: jwh Date: Wed, 27 Oct 2021 21:50:10 +0200 Subject: [PATCH 246/262] go-ipfs-config: feat: pubsub and ipns pubsub flags (#145) * enable pubsub and namesys pubsub to be enable via config * rename Ipns key, switch type to Flag * omit the fields if empty --- config/ipns.go | 3 +++ config/pubsub.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/config/ipns.go b/config/ipns.go index 44a95b0990c..d5191088409 100644 --- a/config/ipns.go +++ b/config/ipns.go @@ -5,4 +5,7 @@ type Ipns struct { RecordLifetime string ResolveCacheSize int + + // Enable namesys pubsub (--enable-namesys-pubsub) + UsePubsub Flag `json:",omitempty"` } diff --git a/config/pubsub.go b/config/pubsub.go index bed6058478f..aabc35a0e0f 100644 --- a/config/pubsub.go +++ b/config/pubsub.go @@ -8,4 +8,7 @@ type PubsubConfig struct { // DisableSigning disables message signing. Message signing is *enabled* // by default. DisableSigning bool + + // Enable pubsub (--enable-pubsub-experiment) + Enabled Flag `json:",omitempty"` } From cdaa222b22424a615e16fe349bc47c1e1f47c752 Mon Sep 17 00:00:00 2001 From: Adin Schmahmann Date: Thu, 28 Oct 2021 13:55:08 -0700 Subject: [PATCH 247/262] go-ipfs-config: feat: OptionalString type and UnixFSShardingSizeThreshold (#149) * feat: add OptionalString type * test: fix OptionalInteger test * add Internal.UnixFSShardingSizeThreshold as optional string * test: OptionalString null unmarshal with default * fix: omitempty UnixFSShardingSizeThreshold Co-authored-by: Marcin Rataj --- config/internal.go | 3 +- config/types.go | 52 +++++++++++++++++++++++ config/types_test.go | 98 +++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 151 insertions(+), 2 deletions(-) diff --git a/config/internal.go b/config/internal.go index 2e71ac16eb7..318bb339232 100644 --- a/config/internal.go +++ b/config/internal.go @@ -1,7 +1,8 @@ package config type Internal struct { - Bitswap *InternalBitswap `json:",omitempty"` // This is omitempty since we are expecting to make changes to all subcomponents of Internal + Bitswap *InternalBitswap `json:",omitempty"` // This is omitempty since we are expecting to make changes to all subcomponents of Internal + UnixFSShardingSizeThreshold *OptionalString `json:",omitempty"` } type InternalBitswap struct { diff --git a/config/types.go b/config/types.go index ac90fa9b82a..baa073ab460 100644 --- a/config/types.go +++ b/config/types.go @@ -313,3 +313,55 @@ func (p OptionalInteger) String() string { var _ json.Unmarshaler = (*OptionalInteger)(nil) var _ json.Marshaler = (*OptionalInteger)(nil) + +// OptionalString represents a string that has a default value +// +// When encoded in json, Default is encoded as "null" +type OptionalString struct { + value *string +} + +// WithDefault resolves the integer with the given default. +func (p *OptionalString) WithDefault(defaultValue string) (value string) { + if p == nil || p.value == nil { + return defaultValue + } + return *p.value +} + +// IsDefault returns if this is a default optional integer +func (p *OptionalString) IsDefault() bool { + return p == nil || p.value == nil +} + +func (p OptionalString) MarshalJSON() ([]byte, error) { + if p.value != nil { + return json.Marshal(p.value) + } + return json.Marshal(nil) +} + +func (p *OptionalString) UnmarshalJSON(input []byte) error { + switch string(input) { + case "null", "undefined": + *p = OptionalString{} + default: + var value string + err := json.Unmarshal(input, &value) + if err != nil { + return err + } + *p = OptionalString{value: &value} + } + return nil +} + +func (p OptionalString) String() string { + if p.value == nil { + return "default" + } + return fmt.Sprintf("%d", p.value) +} + +var _ json.Unmarshaler = (*OptionalInteger)(nil) +var _ json.Marshaler = (*OptionalInteger)(nil) diff --git a/config/types_test.go b/config/types_test.go index 06ea73a260c..2477f8bcf9a 100644 --- a/config/types_test.go +++ b/config/types_test.go @@ -389,10 +389,106 @@ func TestOptionalInteger(t *testing.T) { for _, invalid := range []string{ "foo", "-1.1", "1.1", "0.0", "[]", } { - var p Priority + var p OptionalInteger err := json.Unmarshal([]byte(invalid), &p) if err == nil { t.Errorf("expected to fail to decode %s as a priority", invalid) } } } + +func TestOptionalString(t *testing.T) { + makeStringPointer := func(v string) *string { + return &v + } + + var defaultOptionalString OptionalString + if !defaultOptionalString.IsDefault() { + t.Fatal("should be the default") + } + if val := defaultOptionalString.WithDefault(""); val != "" { + t.Errorf("optional integer should have been empty, got %s", val) + } + + if val := defaultOptionalString.WithDefault("foo"); val != "foo" { + t.Errorf("optional integer should have been foo, got %s", val) + } + + var filledStr OptionalString + filledStr = OptionalString{value: makeStringPointer("foo")} + if filledStr.IsDefault() { + t.Fatal("should not be the default") + } + if val := filledStr.WithDefault("bar"); val != "foo" { + t.Errorf("optional integer should have been foo, got %s", val) + } + + filledStr = OptionalString{value: makeStringPointer("")} + if val := filledStr.WithDefault("foo"); val != "" { + t.Errorf("optional integer should have been 0, got %s", val) + } + + for jsonStr, goValue := range map[string]OptionalString{ + "null": {}, + "\"0\"": {value: makeStringPointer("0")}, + `"1"`: {value: makeStringPointer("1")}, + `"-1"`: {value: makeStringPointer("-1")}, + `"qwerty"`: {value: makeStringPointer("qwerty")}, + } { + var d OptionalString + err := json.Unmarshal([]byte(jsonStr), &d) + if err != nil { + t.Fatal(err) + } + + if goValue.value == nil && d.value == nil { + } else if goValue.value == nil && d.value != nil { + t.Errorf("expected default, got %s", d) + } else if *d.value != *goValue.value { + t.Fatalf("expected %s, got %s", goValue, d) + } + + // Reverse + out, err := json.Marshal(goValue) + if err != nil { + t.Fatal(err) + } + if string(out) != jsonStr { + t.Fatalf("expected %s, got %s", jsonStr, string(out)) + } + } + + // marshal with omitempty + type Foo struct { + S *OptionalString `json:",omitempty"` + } + out, err := json.Marshal(new(Foo)) + if err != nil { + t.Fatal(err) + } + expected := "{}" + if string(out) != expected { + t.Fatal("expected omitempty to omit the optional integer") + } + // unmarshal from omitempty output and get default value + var foo2 Foo + if err := json.Unmarshal(out, &foo2); err != nil { + t.Fatalf("%s failed to unmarshall with %s", string(out), err) + } + if s := foo2.S.WithDefault("foo"); s != "foo" { + t.Fatalf("expected default value to be used, got %s", s) + } + if !foo2.S.IsDefault() { + t.Fatal("expected value to be the default") + } + + for _, invalid := range []string{ + "[]", "{}", "0", "a", "'b'", + } { + var p OptionalString + err := json.Unmarshal([]byte(invalid), &p) + if err == nil { + t.Errorf("expected to fail to decode %s as an optional string", invalid) + } + } +} From ba9d9f609c972b807bc98bebc42a6a9ff44f1aa4 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Fri, 29 Oct 2021 17:21:53 +0200 Subject: [PATCH 248/262] go-ipfs-config: fix: String method on the OptionalString (#153) * fix: String method on the OptionalString * test(OptionalString): empty string is preserved Co-authored-by: Marcin Rataj --- config/types.go | 2 +- config/types_test.go | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/config/types.go b/config/types.go index baa073ab460..fccae22b5ae 100644 --- a/config/types.go +++ b/config/types.go @@ -360,7 +360,7 @@ func (p OptionalString) String() string { if p.value == nil { return "default" } - return fmt.Sprintf("%d", p.value) + return *p.value } var _ json.Unmarshaler = (*OptionalInteger)(nil) diff --git a/config/types_test.go b/config/types_test.go index 2477f8bcf9a..3a1fd6a8426 100644 --- a/config/types_test.go +++ b/config/types_test.go @@ -407,11 +407,13 @@ func TestOptionalString(t *testing.T) { t.Fatal("should be the default") } if val := defaultOptionalString.WithDefault(""); val != "" { - t.Errorf("optional integer should have been empty, got %s", val) + t.Errorf("optional string should have been empty, got %s", val) + } + if val := defaultOptionalString.String(); val != "default" { + t.Fatalf("default optional string should be the 'default' string, got %s", val) } - if val := defaultOptionalString.WithDefault("foo"); val != "foo" { - t.Errorf("optional integer should have been foo, got %s", val) + t.Errorf("optional string should have been foo, got %s", val) } var filledStr OptionalString @@ -420,17 +422,20 @@ func TestOptionalString(t *testing.T) { t.Fatal("should not be the default") } if val := filledStr.WithDefault("bar"); val != "foo" { - t.Errorf("optional integer should have been foo, got %s", val) + t.Errorf("optional string should have been foo, got %s", val) + } + if val := filledStr.String(); val != "foo" { + t.Fatalf("optional string should have been foo, got %s", val) } - filledStr = OptionalString{value: makeStringPointer("")} if val := filledStr.WithDefault("foo"); val != "" { - t.Errorf("optional integer should have been 0, got %s", val) + t.Errorf("optional string should have been 0, got %s", val) } for jsonStr, goValue := range map[string]OptionalString{ "null": {}, "\"0\"": {value: makeStringPointer("0")}, + "\"\"": {value: makeStringPointer("")}, `"1"`: {value: makeStringPointer("1")}, `"-1"`: {value: makeStringPointer("-1")}, `"qwerty"`: {value: makeStringPointer("qwerty")}, From d2268793dc0e5faa6e7424cdbbcd35180cb42738 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Sat, 13 Nov 2021 15:07:14 +0400 Subject: [PATCH 249/262] go-ipfs-config: feat: Swarm.RelayService (circuit v2) (#146) * remove the EnableRelayHop option in the SwarmConfig * add an option to disable the limited relay * make the relay service resources configurable * refactor: use custom types This enables us to swap defaults in go-ipfs without touching the config file generated during `ipfs init` https://github.com/ipfs/go-ipfs-config/pull/146#discussion_r734728162 https://github.com/ipfs/go-ipfs-config/pull/146#discussion_r734728019 * use OptionalDuration in RelayService configuration * fix: *OptionalInteger with omitempty This removes null values from the config * fix: Flag does not need to be a pointer * refactor: flatten RelayService limits this simplifies consumer code and removes nil footgun * docs: clarify different relay types * feat: flag for ForceReachability mode in libp2p (#150) adds Internal.Libp2pForceReachability needed for sharness tests in ipfs/go-ipfs#8522 Co-authored-by: Marcin Rataj Co-authored-by: Marcin Rataj --- config/internal.go | 4 +++- config/swarm.go | 48 ++++++++++++++++++++++++++++++++++---------- config/types.go | 8 ++++---- config/types_test.go | 15 ++++++++++++++ 4 files changed, 59 insertions(+), 16 deletions(-) diff --git a/config/internal.go b/config/internal.go index 318bb339232..dcd834e701c 100644 --- a/config/internal.go +++ b/config/internal.go @@ -1,8 +1,10 @@ package config type Internal struct { - Bitswap *InternalBitswap `json:",omitempty"` // This is omitempty since we are expecting to make changes to all subcomponents of Internal + // All marked as omitempty since we are expecting to make changes to all subcomponents of Internal + Bitswap *InternalBitswap `json:",omitempty"` UnixFSShardingSizeThreshold *OptionalString `json:",omitempty"` + Libp2pForceReachability *OptionalString `json:",omitempty"` } type InternalBitswap struct { diff --git a/config/swarm.go b/config/swarm.go index d662bb30d44..95d4a3d8912 100644 --- a/config/swarm.go +++ b/config/swarm.go @@ -16,21 +16,18 @@ type SwarmConfig struct { // DisableRelay explicitly disables the relay transport. // // Deprecated: This flag is deprecated and is overridden by - // `Transports.Relay` if specified. + // `Swarm.Transports.Relay` if specified. DisableRelay bool `json:",omitempty"` - // EnableRelayHop makes this node act as a public relay, relaying - // traffic between other nodes. - EnableRelayHop bool - - // EnableAutoRelay enables the "auto relay" feature. - // - // When both EnableAutoRelay and EnableRelayHop are set, this go-ipfs node - // will advertise itself as a public relay. Otherwise it will find and use - // advertised public relays when it determines that it's not reachable - // from the public internet. + // EnableAutoRelay enables the "auto relay user" feature. + // Node will find and use advertised public relays when it determines that + // it's not reachable from the public internet. EnableAutoRelay bool + // RelayService.* controls the "auto relay service" feature. + // When enabled, node will provide a limited relay service to other peers. + RelayService RelayService + // Transports contains flags to enable/disable libp2p transports. Transports Transports @@ -38,6 +35,35 @@ type SwarmConfig struct { ConnMgr ConnMgr } +// RelayService configures the resources of the circuit v2 relay. +// For every field a reasonable default will be defined in go-ipfs. +type RelayService struct { + // Enables the limited relay (circuit v2 relay). + Enabled Flag `json:",omitempty"` + + // ConnectionDurationLimit is the time limit before resetting a relayed connection. + ConnectionDurationLimit *OptionalDuration `json:",omitempty"` + // ConnectionDataLimit is the limit of data relayed (on each direction) before resetting the connection. + ConnectionDataLimit *OptionalInteger `json:",omitempty"` + + // ReservationTTL is the duration of a new (or refreshed reservation). + ReservationTTL *OptionalDuration `json:",omitempty"` + + // MaxReservations is the maximum number of active relay slots. + MaxReservations *OptionalInteger `json:",omitempty"` + // MaxCircuits is the maximum number of open relay connections for each peer; defaults to 16. + MaxCircuits *OptionalInteger `json:",omitempty"` + // BufferSize is the size of the relayed connection buffers. + BufferSize *OptionalInteger `json:",omitempty"` + + // MaxReservationsPerPeer is the maximum number of reservations originating from the same peer. + MaxReservationsPerPeer *OptionalInteger `json:",omitempty"` + // MaxReservationsPerIP is the maximum number of reservations originating from the same IP address. + MaxReservationsPerIP *OptionalInteger `json:",omitempty"` + // MaxReservationsPerASN is the maximum number of reservations origination from the same ASN. + MaxReservationsPerASN *OptionalInteger `json:",omitempty"` +} + type Transports struct { // Network specifies the base transports we'll use for dialing. To // listen on a transport, add the transport to your Addresses.Swarm. diff --git a/config/types.go b/config/types.go index fccae22b5ae..c33689c5b2a 100644 --- a/config/types.go +++ b/config/types.go @@ -270,16 +270,16 @@ type OptionalInteger struct { } // WithDefault resolves the integer with the given default. -func (p OptionalInteger) WithDefault(defaultValue int64) (value int64) { - if p.value == nil { +func (p *OptionalInteger) WithDefault(defaultValue int64) (value int64) { + if p == nil || p.value == nil { return defaultValue } return *p.value } // IsDefault returns if this is a default optional integer -func (p OptionalInteger) IsDefault() bool { - return p.value == nil +func (p *OptionalInteger) IsDefault() bool { + return p == nil || p.value == nil } func (p OptionalInteger) MarshalJSON() ([]byte, error) { diff --git a/config/types_test.go b/config/types_test.go index 3a1fd6a8426..caef2b112c0 100644 --- a/config/types_test.go +++ b/config/types_test.go @@ -375,6 +375,7 @@ func TestOptionalInteger(t *testing.T) { } } + // marshal with omitempty type Foo struct { I *OptionalInteger `json:",omitempty"` } @@ -386,6 +387,20 @@ func TestOptionalInteger(t *testing.T) { if string(out) != expected { t.Fatal("expected omitempty to omit the optional integer") } + + // unmarshal from omitempty output and get default value + var foo2 Foo + if err := json.Unmarshal(out, &foo2); err != nil { + t.Fatalf("%s failed to unmarshall with %s", string(out), err) + } + if i := foo2.I.WithDefault(42); i != 42 { + t.Fatalf("expected default value to be used, got %d", i) + } + if !foo2.I.IsDefault() { + t.Fatal("expected value to be the default") + } + + // test invalid values for _, invalid := range []string{ "foo", "-1.1", "1.1", "0.0", "[]", } { From dcf17eb24a7e2b81b3da2a8779609fa74ddb234b Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Sun, 14 Nov 2021 16:49:10 +0400 Subject: [PATCH 250/262] go-ipfs-config: improve AutoRelay configuration, add config option for static relays --- config/swarm.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/config/swarm.go b/config/swarm.go index 95d4a3d8912..5f02b08376d 100644 --- a/config/swarm.go +++ b/config/swarm.go @@ -22,9 +22,16 @@ type SwarmConfig struct { // EnableAutoRelay enables the "auto relay user" feature. // Node will find and use advertised public relays when it determines that // it's not reachable from the public internet. + // + // Deprecated: This flag is deprecated and is overriden by + // `Swarm.AutoRelay.Enabled` if specified. EnableAutoRelay bool - // RelayService.* controls the "auto relay service" feature. + // AutoRelay controls the "auto relay service" feature. + // When enabled, the node will use relays if it is not publicly reachable. + AutoRelay AutoRelay + + // RelayService.* controls the "relay service". // When enabled, node will provide a limited relay service to other peers. RelayService RelayService @@ -35,6 +42,16 @@ type SwarmConfig struct { ConnMgr ConnMgr } +type AutoRelay struct { + // Enables the AutoRelay. + Enabled Flag `json:",omitempty"` + + // StaticRelays configures static relays to use when this node is not + // publicly reachable. If set, auto relay will not try to find any + // other relay servers. + StaticRelays []string `json:",omitempty"` +} + // RelayService configures the resources of the circuit v2 relay. // For every field a reasonable default will be defined in go-ipfs. type RelayService struct { From bf3a2ca8de921e58c32d75f2c5f771e43ff70998 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Mon, 15 Nov 2021 17:34:58 +0400 Subject: [PATCH 251/262] go-ipfs-config: set Swarm.EnableAutoRelay to omitempty Co-authored-by: Marcin Rataj --- config/swarm.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/swarm.go b/config/swarm.go index 5f02b08376d..2d2a3813377 100644 --- a/config/swarm.go +++ b/config/swarm.go @@ -25,7 +25,7 @@ type SwarmConfig struct { // // Deprecated: This flag is deprecated and is overriden by // `Swarm.AutoRelay.Enabled` if specified. - EnableAutoRelay bool + EnableAutoRelay bool `json:",omitempty"` // AutoRelay controls the "auto relay service" feature. // When enabled, the node will use relays if it is not publicly reachable. From aefce5a6cd2881d50fc56192e770c0420255d06b Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Mon, 15 Nov 2021 15:44:27 +0100 Subject: [PATCH 252/262] =?UTF-8?q?go-ipfs-config:=20refactor:=20AutoRelay?= =?UTF-8?q?=20=E2=86=92=20RelayClient?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/ipfs/go-ipfs-config/pull/154#discussion_r749324695 --- config/swarm.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/config/swarm.go b/config/swarm.go index 2d2a3813377..e79d42c97ee 100644 --- a/config/swarm.go +++ b/config/swarm.go @@ -27,9 +27,9 @@ type SwarmConfig struct { // `Swarm.AutoRelay.Enabled` if specified. EnableAutoRelay bool `json:",omitempty"` - // AutoRelay controls the "auto relay service" feature. + // RelayClient controls the client side of "auto relay" feature. // When enabled, the node will use relays if it is not publicly reachable. - AutoRelay AutoRelay + RelayClient RelayClient // RelayService.* controls the "relay service". // When enabled, node will provide a limited relay service to other peers. @@ -42,8 +42,8 @@ type SwarmConfig struct { ConnMgr ConnMgr } -type AutoRelay struct { - // Enables the AutoRelay. +type RelayClient struct { + // Enables the auto relay feature: will use relays if it is not publicly reachable. Enabled Flag `json:",omitempty"` // StaticRelays configures static relays to use when this node is not @@ -55,7 +55,7 @@ type AutoRelay struct { // RelayService configures the resources of the circuit v2 relay. // For every field a reasonable default will be defined in go-ipfs. type RelayService struct { - // Enables the limited relay (circuit v2 relay). + // Enables the limited relay service for other peers (circuit v2 relay). Enabled Flag `json:",omitempty"` // ConnectionDurationLimit is the time limit before resetting a relayed connection. From 7fe155c287d43eab47c8324b4e4be5201fce64e1 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Tue, 16 Nov 2021 14:55:46 +0400 Subject: [PATCH 253/262] go-ipfs-config: feat: add a flag to enable the hole punching service (#155) * add a flag to enable the hole punching service * chore: omitempty EnableHolePunching Co-authored-by: Marcin Rataj --- config/swarm.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config/swarm.go b/config/swarm.go index e79d42c97ee..8cbeb122f13 100644 --- a/config/swarm.go +++ b/config/swarm.go @@ -35,6 +35,9 @@ type SwarmConfig struct { // When enabled, node will provide a limited relay service to other peers. RelayService RelayService + // EnableHolePunching enables the hole punching service. + EnableHolePunching Flag `json:",omitempty"` + // Transports contains flags to enable/disable libp2p transports. Transports Transports From 5ca82266102145575f03d8e2861792dfa326ca1e Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Thu, 18 Nov 2021 01:35:49 +0100 Subject: [PATCH 254/262] go-ipfs-config: chore: update comment to match struct --- config/swarm.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/swarm.go b/config/swarm.go index 8cbeb122f13..33d7c53b723 100644 --- a/config/swarm.go +++ b/config/swarm.go @@ -24,7 +24,7 @@ type SwarmConfig struct { // it's not reachable from the public internet. // // Deprecated: This flag is deprecated and is overriden by - // `Swarm.AutoRelay.Enabled` if specified. + // `Swarm.RelayClient.Enabled` if specified. EnableAutoRelay bool `json:",omitempty"` // RelayClient controls the client side of "auto relay" feature. From d50960f9e3d9d3c21e48f1000dff9a64ad2a7ea2 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Tue, 23 Nov 2021 18:44:35 +0100 Subject: [PATCH 255/262] go-ipfs-config: chore: omitempty Experimental.ShardingEnabled (#158) We switch to autosharding setup in https://github.com/ipfs/go-ipfs/pull/8527 --- config/experiments.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/experiments.go b/config/experiments.go index c4f906394b5..dba0ea7139b 100644 --- a/config/experiments.go +++ b/config/experiments.go @@ -3,7 +3,7 @@ package config type Experiments struct { FilestoreEnabled bool UrlstoreEnabled bool - ShardingEnabled bool + ShardingEnabled bool `json:",omitempty"` // deprecated by autosharding: https://github.com/ipfs/go-ipfs/pull/8527 GraphsyncEnabled bool Libp2pStreamMounting bool P2pHttpProxy bool From ded27a5473d77601d03aa70a2aa785ab3397eb8f Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Tue, 23 Nov 2021 21:45:11 +0400 Subject: [PATCH 256/262] go-ipfs-config: feat: omitempty Swarm.EnableRelayHop for circuit v1 migration (#157) * re-add the Swarm.EnableRelayHop option * make Swarm.EnableRelayHop omitempty Co-authored-by: Marcin Rataj --- config/swarm.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/config/swarm.go b/config/swarm.go index 33d7c53b723..d03406126e0 100644 --- a/config/swarm.go +++ b/config/swarm.go @@ -19,6 +19,12 @@ type SwarmConfig struct { // `Swarm.Transports.Relay` if specified. DisableRelay bool `json:",omitempty"` + // EnableRelayHop makes this node act as a public relay v1 + // + // Deprecated: The circuit v1 protocol is deprecated. + // Use `Swarm.RelayService` to configure the circuit v2 relay. + EnableRelayHop bool `json:",omitempty"` + // EnableAutoRelay enables the "auto relay user" feature. // Node will find and use advertised public relays when it determines that // it's not reachable from the public internet. From a6008f0e36b7a70cb038a069d3e541a133e02e77 Mon Sep 17 00:00:00 2001 From: Jorropo Date: Tue, 23 Nov 2021 19:09:58 +0100 Subject: [PATCH 257/262] go-ipfs-config: feat: add Addresses.AppendAnnounce (#135) --- config/addresses.go | 11 ++++++----- config/init.go | 9 +++++---- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/config/addresses.go b/config/addresses.go index 2d88468fdac..709b28d5847 100644 --- a/config/addresses.go +++ b/config/addresses.go @@ -2,9 +2,10 @@ package config // Addresses stores the (string) multiaddr addresses for the node. 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 Strings // address for the local API (RPC) - Gateway Strings // address to listen on for IPFS HTTP object gateway + Swarm []string // addresses for the swarm to listen on + Announce []string // swarm addresses to announce to the network, if len > 0 replaces auto detected addresses + AppendAnnounce []string // similar to Announce but doesn't overwride auto detected addresses, they are just appended + NoAnnounce []string // swarm addresses not to announce to the network + API Strings // address for the local API (RPC) + Gateway Strings // address to listen on for IPFS HTTP object gateway } diff --git a/config/init.go b/config/init.go index cf0cca5929a..8e54eaa5866 100644 --- a/config/init.go +++ b/config/init.go @@ -121,10 +121,11 @@ func addressesConfig() Addresses { "/ip4/0.0.0.0/udp/4001/quic", "/ip6/::/udp/4001/quic", }, - Announce: []string{}, - NoAnnounce: []string{}, - API: Strings{"/ip4/127.0.0.1/tcp/5001"}, - Gateway: Strings{"/ip4/127.0.0.1/tcp/8080"}, + Announce: []string{}, + AppendAnnounce: []string{}, + NoAnnounce: []string{}, + API: Strings{"/ip4/127.0.0.1/tcp/5001"}, + Gateway: Strings{"/ip4/127.0.0.1/tcp/8080"}, } } From 9a0bd0fa7a67c8d646b261bd74b69311195a85ea Mon Sep 17 00:00:00 2001 From: Thibault Meunier Date: Thu, 20 Jan 2022 20:04:53 +0100 Subject: [PATCH 258/262] go-ipfs-config: feat: add DNS.MaxCacheTTL for DNS-over-HTTPS resolvers (#161) --- config/dns.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/dns.go b/config/dns.go index 5c4e62da0cc..b0f7b2710b6 100644 --- a/config/dns.go +++ b/config/dns.go @@ -12,4 +12,6 @@ type DNS struct { // - Custom resolver for ENS: `eth.` → `https://eth.link/dns-query` // - Override the default OS resolver: `.` → `https://doh.applied-privacy.net/query` Resolvers map[string]string + // MaxCacheTTL is the maximum duration DNS entries are valid in the cache. + MaxCacheTTL *OptionalDuration `json:",omitempty"` } From 74e6436814a120f3aee802d89cc52bd3f798771d Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Fri, 28 Jan 2022 23:39:10 +0100 Subject: [PATCH 259/262] go-ipfs-config: docs: updated flatfs/badger profile helptext (#167) This is copy-paste from https://github.com/ipfs/go-ipfs/pull/8662 to ensure consistency. --- config/profile.go | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/config/profile.go b/config/profile.go index 1d379d97db0..cbc7c976453 100644 --- a/config/profile.go +++ b/config/profile.go @@ -123,18 +123,16 @@ This profile may only be applied when first initializing the node. "flatfs": { Description: `Configures the node to use the flatfs datastore. -This is the most battle-tested and reliable datastore, but it's significantly -slower than the badger datastore. You should use this datastore if: +This is the most battle-tested and reliable datastore. +You should use this datastore if: -* You need a very simple and very reliable datastore and you trust your +* You need a very simple and very reliable datastore, and you trust your filesystem. This datastore stores each block as a separate file in the underlying filesystem so it's unlikely to loose data unless there's an issue with the underlying file system. -* You need to run garbage collection on a small (<= 10GiB) datastore. The - default datastore, badger, can leave several gigabytes of data behind when - garbage collecting. -* You're concerned about memory usage. In its default configuration, badger can - use up to several gigabytes of memory. +* You need to run garbage collection in a way that reclaims free space as soon as possible. +* You want to minimize memory usage. +* You are ok with the default speed of data import, or prefer to use --nocopy. This profile may only be applied when first initializing the node. `, @@ -146,17 +144,21 @@ This profile may only be applied when first initializing the node. }, }, "badgerds": { - Description: `Configures the node to use the badger datastore. + Description: `Configures the node to use the experimental badger datastore. -This is the fastest datastore. Use this datastore if performance, especially -when adding many gigabytes of files, is critical. However: +Use this datastore if some aspects of performance, +especially the speed of adding many gigabytes of files, are critical. +However, be aware that: * This datastore will not properly reclaim space when your datastore is - smaller than several gigabytes. If you run IPFS with '--enable-gc' (you have - enabled block-level garbage collection), you plan on storing very little data in - your IPFS node, and disk usage is more critical than performance, consider using - flatfs. -* This datastore uses up to several gigabytes of memory. + smaller than several gigabytes. If you run IPFS with --enable-gc, you plan + on storing very little data in your IPFS node, and disk usage is more + critical than performance, consider using flatfs. +* This datastore uses up to several gigabytes of memory. +* Good for medium-size datastores, but may run into performance issues + if your dataset is bigger than a terabyte. +* The current implementation is based on old badger 1.x + which is no longer supported by the upstream team. This profile may only be applied when first initializing the node.`, From c9cf47dad5a35e36bbf355ffe009b6d7a54ecbe5 Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Fri, 25 Feb 2022 18:50:04 +0100 Subject: [PATCH 260/262] config: remove go-ipfs-config code --- README.md | 1 - go.mod | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8c279efe046..f8d17ad20a3 100644 --- a/README.md +++ b/README.md @@ -412,7 +412,6 @@ Listing of the main packages used in the IPFS ecosystem. There are also three sp | **Namesys** | | [`go-ipns`](//github.com/ipfs/go-ipns) | [![Travis CI](https://flat.badgen.net/travis/ipfs/go-ipns/master)](https://travis-ci.com/ipfs/go-ipns) | [![codecov](https://codecov.io/gh/ipfs/go-ipns/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/ipfs/go-ipns) | IPNS datastructures and validation logic | | **Repo** | -| [`go-ipfs-config`](//github.com/ipfs/go-ipfs-config) | [![Travis CI](https://flat.badgen.net/travis/ipfs/go-ipfs-config/master)](https://travis-ci.com/ipfs/go-ipfs-config) | [![codecov](https://codecov.io/gh/ipfs/go-ipfs-config/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/ipfs/go-ipfs-config) | go-ipfs config file definitions | | [`go-fs-lock`](//github.com/ipfs/go-fs-lock) | [![Travis CI](https://flat.badgen.net/travis/ipfs/go-fs-lock/master)](https://travis-ci.com/ipfs/go-fs-lock) | [![codecov](https://codecov.io/gh/ipfs/go-fs-lock/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/ipfs/go-fs-lock) | lockfile management functions | | [`fs-repo-migrations`](//github.com/ipfs/fs-repo-migrations) | [![Travis CI](https://flat.badgen.net/travis/ipfs/fs-repo-migrations/master)](https://travis-ci.com/ipfs/fs-repo-migrations) | [![codecov](https://codecov.io/gh/ipfs/fs-repo-migrations/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/ipfs/fs-repo-migrations) | repo migrations | | **IPLD** | diff --git a/go.mod b/go.mod index 8546b9057b3..92c15f6ccea 100644 --- a/go.mod +++ b/go.mod @@ -9,6 +9,7 @@ require ( github.com/coreos/go-systemd/v22 v22.3.2 github.com/dustin/go-humanize v1.0.0 github.com/elgris/jsondiff v0.0.0-20160530203242-765b5c24c302 + github.com/facebookgo/atomicfile v0.0.0-20151019160806-2de1f203e7d5 github.com/fsnotify/fsnotify v1.5.1 github.com/gabriel-vasile/mimetype v1.4.0 github.com/go-bindata/go-bindata/v3 v3.1.3 From 8d549f03f3e02ef6c5efad11c9aab969fc6861ed Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Wed, 2 Mar 2022 14:48:24 +0100 Subject: [PATCH 261/262] fix: rewrite dependencies over the go-ipfs-config package --- cmd/ipfs/daemon.go | 4 ++-- cmd/ipfs/init.go | 2 +- cmd/ipfs/main.go | 2 +- cmd/ipfs/pinmfs.go | 2 +- cmd/ipfs/pinmfs_test.go | 2 +- cmd/ipfswatch/main.go | 3 ++- commands/context.go | 2 +- config/serialize/serialize.go | 2 +- config/serialize/serialize_test.go | 2 +- core/commands/bootstrap.go | 2 +- core/commands/cmdenv/env.go | 2 +- core/commands/config.go | 2 +- core/commands/keystore.go | 2 +- core/commands/mount_unix.go | 3 ++- core/commands/pin/remotepin.go | 2 +- core/commands/swarm.go | 2 +- core/core_test.go | 2 +- core/coreapi/test/api_test.go | 6 +++--- core/corehttp/commands.go | 2 +- core/corehttp/gateway_test.go | 2 +- core/corehttp/hostname.go | 2 +- core/corehttp/hostname_test.go | 2 +- core/coreunix/add_test.go | 2 +- core/mock/mock.go | 2 +- core/node/bitswap.go | 2 +- core/node/builder.go | 2 +- core/node/dns.go | 2 +- core/node/groups.go | 2 +- core/node/libp2p/libp2p.go | 2 +- core/node/libp2p/nat.go | 2 +- core/node/libp2p/relay.go | 2 +- core/node/libp2p/sec.go | 2 +- core/node/libp2p/smux.go | 2 +- core/node/libp2p/transport.go | 2 +- core/node/storage.go | 2 +- go.mod | 1 - go.sum | 2 -- package-list.json | 1 - plugin/loader/loader.go | 4 ++-- repo/fsrepo/config_test.go | 2 +- repo/fsrepo/fsrepo.go | 4 ++-- repo/fsrepo/fsrepo_test.go | 2 +- repo/fsrepo/migrations/ipfsfetcher/ipfsfetcher.go | 2 +- repo/fsrepo/migrations/migrations.go | 2 +- repo/fsrepo/migrations/migrations_test.go | 2 +- repo/fsrepo/misc.go | 2 +- repo/mock.go | 2 +- repo/repo.go | 2 +- test/bench/bench_cli_ipfs_add/main.go | 2 +- test/bench/offline_add/main.go | 2 +- 50 files changed, 54 insertions(+), 56 deletions(-) diff --git a/cmd/ipfs/daemon.go b/cmd/ipfs/daemon.go index 5de7e056eac..a2c65b5b99e 100644 --- a/cmd/ipfs/daemon.go +++ b/cmd/ipfs/daemon.go @@ -17,10 +17,10 @@ import ( multierror "github.com/hashicorp/go-multierror" version "github.com/ipfs/go-ipfs" - config "github.com/ipfs/go-ipfs-config" - cserial "github.com/ipfs/go-ipfs-config/serialize" utilmain "github.com/ipfs/go-ipfs/cmd/ipfs/util" oldcmds "github.com/ipfs/go-ipfs/commands" + config "github.com/ipfs/go-ipfs/config" + cserial "github.com/ipfs/go-ipfs/config/serialize" "github.com/ipfs/go-ipfs/core" commands "github.com/ipfs/go-ipfs/core/commands" "github.com/ipfs/go-ipfs/core/coreapi" diff --git a/cmd/ipfs/init.go b/cmd/ipfs/init.go index de3ad1180fa..dfbf01bb3a6 100644 --- a/cmd/ipfs/init.go +++ b/cmd/ipfs/init.go @@ -19,8 +19,8 @@ import ( unixfs "github.com/ipfs/go-unixfs" cmds "github.com/ipfs/go-ipfs-cmds" - config "github.com/ipfs/go-ipfs-config" files "github.com/ipfs/go-ipfs-files" + config "github.com/ipfs/go-ipfs/config" options "github.com/ipfs/interface-go-ipfs-core/options" ) diff --git a/cmd/ipfs/main.go b/cmd/ipfs/main.go index d975d18971f..11b21c89905 100644 --- a/cmd/ipfs/main.go +++ b/cmd/ipfs/main.go @@ -24,8 +24,8 @@ import ( cmds "github.com/ipfs/go-ipfs-cmds" "github.com/ipfs/go-ipfs-cmds/cli" cmdhttp "github.com/ipfs/go-ipfs-cmds/http" - config "github.com/ipfs/go-ipfs-config" u "github.com/ipfs/go-ipfs-util" + config "github.com/ipfs/go-ipfs/config" logging "github.com/ipfs/go-log" loggables "github.com/libp2p/go-libp2p-loggables" ma "github.com/multiformats/go-multiaddr" diff --git a/cmd/ipfs/pinmfs.go b/cmd/ipfs/pinmfs.go index 8ea9d2dcc8e..5eadef5a7e8 100644 --- a/cmd/ipfs/pinmfs.go +++ b/cmd/ipfs/pinmfs.go @@ -13,7 +13,7 @@ import ( logging "github.com/ipfs/go-log" pinclient "github.com/ipfs/go-pinning-service-http-client" - config "github.com/ipfs/go-ipfs-config" + config "github.com/ipfs/go-ipfs/config" "github.com/ipfs/go-ipfs/core" ) diff --git a/cmd/ipfs/pinmfs_test.go b/cmd/ipfs/pinmfs_test.go index e38e196beb3..63c8af070ee 100644 --- a/cmd/ipfs/pinmfs_test.go +++ b/cmd/ipfs/pinmfs_test.go @@ -7,7 +7,7 @@ import ( "testing" "time" - config "github.com/ipfs/go-ipfs-config" + config "github.com/ipfs/go-ipfs/config" ipld "github.com/ipfs/go-ipld-format" merkledag "github.com/ipfs/go-merkledag" "github.com/libp2p/go-libp2p-core/host" diff --git a/cmd/ipfswatch/main.go b/cmd/ipfswatch/main.go index e0bd00e17dc..f810ada12c8 100644 --- a/cmd/ipfswatch/main.go +++ b/cmd/ipfswatch/main.go @@ -1,3 +1,4 @@ +//go:build !plan9 // +build !plan9 package main @@ -18,8 +19,8 @@ import ( fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo" fsnotify "github.com/fsnotify/fsnotify" - config "github.com/ipfs/go-ipfs-config" files "github.com/ipfs/go-ipfs-files" + config "github.com/ipfs/go-ipfs/config" process "github.com/jbenet/goprocess" homedir "github.com/mitchellh/go-homedir" ) diff --git a/commands/context.go b/commands/context.go index e43672eee49..984071a05cd 100644 --- a/commands/context.go +++ b/commands/context.go @@ -11,7 +11,7 @@ import ( loader "github.com/ipfs/go-ipfs/plugin/loader" cmds "github.com/ipfs/go-ipfs-cmds" - config "github.com/ipfs/go-ipfs-config" + config "github.com/ipfs/go-ipfs/config" logging "github.com/ipfs/go-log" coreiface "github.com/ipfs/interface-go-ipfs-core" options "github.com/ipfs/interface-go-ipfs-core/options" diff --git a/config/serialize/serialize.go b/config/serialize/serialize.go index 04492c5f38f..e51e9211575 100644 --- a/config/serialize/serialize.go +++ b/config/serialize/serialize.go @@ -8,7 +8,7 @@ import ( "os" "path/filepath" - "github.com/ipfs/go-ipfs-config" + "github.com/ipfs/go-ipfs/config" "github.com/facebookgo/atomicfile" ) diff --git a/config/serialize/serialize_test.go b/config/serialize/serialize_test.go index e5abdb852f3..0c8e12f40c0 100644 --- a/config/serialize/serialize_test.go +++ b/config/serialize/serialize_test.go @@ -5,7 +5,7 @@ import ( "runtime" "testing" - config "github.com/ipfs/go-ipfs-config" + config "github.com/ipfs/go-ipfs/config" ) func TestConfig(t *testing.T) { diff --git a/core/commands/bootstrap.go b/core/commands/bootstrap.go index 1aaa6456501..d572e8c079b 100644 --- a/core/commands/bootstrap.go +++ b/core/commands/bootstrap.go @@ -11,7 +11,7 @@ import ( fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo" cmds "github.com/ipfs/go-ipfs-cmds" - config "github.com/ipfs/go-ipfs-config" + config "github.com/ipfs/go-ipfs/config" peer "github.com/libp2p/go-libp2p-core/peer" ma "github.com/multiformats/go-multiaddr" ) diff --git a/core/commands/cmdenv/env.go b/core/commands/cmdenv/env.go index c21612c3305..06d401db4cf 100644 --- a/core/commands/cmdenv/env.go +++ b/core/commands/cmdenv/env.go @@ -9,7 +9,7 @@ import ( "github.com/ipfs/go-ipfs/core" cmds "github.com/ipfs/go-ipfs-cmds" - config "github.com/ipfs/go-ipfs-config" + config "github.com/ipfs/go-ipfs/config" logging "github.com/ipfs/go-log" coreiface "github.com/ipfs/interface-go-ipfs-core" options "github.com/ipfs/interface-go-ipfs-core/options" diff --git a/core/commands/config.go b/core/commands/config.go index 86037ceb4f9..7a6e5abaf07 100644 --- a/core/commands/config.go +++ b/core/commands/config.go @@ -16,7 +16,7 @@ import ( "github.com/elgris/jsondiff" cmds "github.com/ipfs/go-ipfs-cmds" - config "github.com/ipfs/go-ipfs-config" + config "github.com/ipfs/go-ipfs/config" ) // ConfigUpdateOutput is config profile apply command's output diff --git a/core/commands/keystore.go b/core/commands/keystore.go index 5596ceee03a..4f7ca4af80f 100644 --- a/core/commands/keystore.go +++ b/core/commands/keystore.go @@ -14,9 +14,9 @@ import ( "text/tabwriter" cmds "github.com/ipfs/go-ipfs-cmds" - config "github.com/ipfs/go-ipfs-config" keystore "github.com/ipfs/go-ipfs-keystore" oldcmds "github.com/ipfs/go-ipfs/commands" + config "github.com/ipfs/go-ipfs/config" cmdenv "github.com/ipfs/go-ipfs/core/commands/cmdenv" "github.com/ipfs/go-ipfs/core/commands/e" ke "github.com/ipfs/go-ipfs/core/commands/keyencode" diff --git a/core/commands/mount_unix.go b/core/commands/mount_unix.go index c6678d17585..1c72c6bd990 100644 --- a/core/commands/mount_unix.go +++ b/core/commands/mount_unix.go @@ -1,3 +1,4 @@ +//go:build !windows && !nofuse // +build !windows,!nofuse package commands @@ -10,7 +11,7 @@ import ( nodeMount "github.com/ipfs/go-ipfs/fuse/node" cmds "github.com/ipfs/go-ipfs-cmds" - config "github.com/ipfs/go-ipfs-config" + config "github.com/ipfs/go-ipfs/config" ) const ( diff --git a/core/commands/pin/remotepin.go b/core/commands/pin/remotepin.go index 0e4bf373ee0..495a1400367 100644 --- a/core/commands/pin/remotepin.go +++ b/core/commands/pin/remotepin.go @@ -17,7 +17,7 @@ import ( cid "github.com/ipfs/go-cid" cmds "github.com/ipfs/go-ipfs-cmds" - config "github.com/ipfs/go-ipfs-config" + config "github.com/ipfs/go-ipfs/config" "github.com/ipfs/go-ipfs/core/commands/cmdenv" fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo" logging "github.com/ipfs/go-log" diff --git a/core/commands/swarm.go b/core/commands/swarm.go index 7c7ee3e814f..00899eacbed 100644 --- a/core/commands/swarm.go +++ b/core/commands/swarm.go @@ -16,7 +16,7 @@ import ( fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo" cmds "github.com/ipfs/go-ipfs-cmds" - config "github.com/ipfs/go-ipfs-config" + config "github.com/ipfs/go-ipfs/config" inet "github.com/libp2p/go-libp2p-core/network" peer "github.com/libp2p/go-libp2p-core/peer" ma "github.com/multiformats/go-multiaddr" diff --git a/core/core_test.go b/core/core_test.go index 051b812c11a..e1563789e73 100644 --- a/core/core_test.go +++ b/core/core_test.go @@ -9,7 +9,7 @@ import ( datastore "github.com/ipfs/go-datastore" syncds "github.com/ipfs/go-datastore/sync" - config "github.com/ipfs/go-ipfs-config" + config "github.com/ipfs/go-ipfs/config" ) func TestInitialization(t *testing.T) { diff --git a/core/coreapi/test/api_test.go b/core/coreapi/test/api_test.go index 54f3b48ca43..5c078558b7f 100644 --- a/core/coreapi/test/api_test.go +++ b/core/coreapi/test/api_test.go @@ -9,7 +9,7 @@ import ( "testing" "github.com/ipfs/go-filestore" - "github.com/ipfs/go-ipfs-keystore" + keystore "github.com/ipfs/go-ipfs-keystore" "github.com/ipfs/go-ipfs/core" "github.com/ipfs/go-ipfs/core/bootstrap" "github.com/ipfs/go-ipfs/core/coreapi" @@ -19,12 +19,12 @@ import ( "github.com/ipfs/go-datastore" syncds "github.com/ipfs/go-datastore/sync" - "github.com/ipfs/go-ipfs-config" + "github.com/ipfs/go-ipfs/config" coreiface "github.com/ipfs/interface-go-ipfs-core" "github.com/ipfs/interface-go-ipfs-core/tests" "github.com/libp2p/go-libp2p-core/crypto" peer "github.com/libp2p/go-libp2p-core/peer" - "github.com/libp2p/go-libp2p/p2p/net/mock" + mocknet "github.com/libp2p/go-libp2p/p2p/net/mock" ) const testPeerID = "QmTFauExutTsy4XP6JbMFcw2Wa9645HJt2bTqL6qYDCKfe" diff --git a/core/corehttp/commands.go b/core/corehttp/commands.go index c5443f6eb3f..8de1e6be44a 100644 --- a/core/corehttp/commands.go +++ b/core/corehttp/commands.go @@ -16,7 +16,7 @@ import ( cmds "github.com/ipfs/go-ipfs-cmds" cmdsHttp "github.com/ipfs/go-ipfs-cmds/http" - config "github.com/ipfs/go-ipfs-config" + config "github.com/ipfs/go-ipfs/config" path "github.com/ipfs/go-path" ) diff --git a/core/corehttp/gateway_test.go b/core/corehttp/gateway_test.go index 8cccde0e22a..ae010421767 100644 --- a/core/corehttp/gateway_test.go +++ b/core/corehttp/gateway_test.go @@ -19,8 +19,8 @@ import ( datastore "github.com/ipfs/go-datastore" syncds "github.com/ipfs/go-datastore/sync" - config "github.com/ipfs/go-ipfs-config" files "github.com/ipfs/go-ipfs-files" + config "github.com/ipfs/go-ipfs/config" path "github.com/ipfs/go-path" iface "github.com/ipfs/interface-go-ipfs-core" nsopts "github.com/ipfs/interface-go-ipfs-core/options/namesys" diff --git a/core/corehttp/hostname.go b/core/corehttp/hostname.go index 57c2c2191a6..6c0ad5bca13 100644 --- a/core/corehttp/hostname.go +++ b/core/corehttp/hostname.go @@ -18,7 +18,7 @@ import ( mbase "github.com/multiformats/go-multibase" - config "github.com/ipfs/go-ipfs-config" + config "github.com/ipfs/go-ipfs/config" iface "github.com/ipfs/interface-go-ipfs-core" options "github.com/ipfs/interface-go-ipfs-core/options" nsopts "github.com/ipfs/interface-go-ipfs-core/options/namesys" diff --git a/core/corehttp/hostname_test.go b/core/corehttp/hostname_test.go index f7ba89a8c9b..df0f4f22971 100644 --- a/core/corehttp/hostname_test.go +++ b/core/corehttp/hostname_test.go @@ -7,8 +7,8 @@ import ( "testing" cid "github.com/ipfs/go-cid" - config "github.com/ipfs/go-ipfs-config" files "github.com/ipfs/go-ipfs-files" + config "github.com/ipfs/go-ipfs/config" coreapi "github.com/ipfs/go-ipfs/core/coreapi" path "github.com/ipfs/go-path" ) diff --git a/core/coreunix/add_test.go b/core/coreunix/add_test.go index 7dd2b0cec65..de326559c3f 100644 --- a/core/coreunix/add_test.go +++ b/core/coreunix/add_test.go @@ -21,9 +21,9 @@ import ( "github.com/ipfs/go-datastore" syncds "github.com/ipfs/go-datastore/sync" blockstore "github.com/ipfs/go-ipfs-blockstore" - config "github.com/ipfs/go-ipfs-config" files "github.com/ipfs/go-ipfs-files" pi "github.com/ipfs/go-ipfs-posinfo" + config "github.com/ipfs/go-ipfs/config" dag "github.com/ipfs/go-merkledag" coreiface "github.com/ipfs/interface-go-ipfs-core" ) diff --git a/core/mock/mock.go b/core/mock/mock.go index d0a5cd7f65c..65c028ac5e8 100644 --- a/core/mock/mock.go +++ b/core/mock/mock.go @@ -13,7 +13,7 @@ import ( "github.com/ipfs/go-datastore" syncds "github.com/ipfs/go-datastore/sync" - config "github.com/ipfs/go-ipfs-config" + config "github.com/ipfs/go-ipfs/config" "github.com/libp2p/go-libp2p" "github.com/libp2p/go-libp2p-core/host" diff --git a/core/node/bitswap.go b/core/node/bitswap.go index a2548ab3ce6..44698f92123 100644 --- a/core/node/bitswap.go +++ b/core/node/bitswap.go @@ -6,8 +6,8 @@ import ( "github.com/ipfs/go-bitswap" "github.com/ipfs/go-bitswap/network" blockstore "github.com/ipfs/go-ipfs-blockstore" - config "github.com/ipfs/go-ipfs-config" exchange "github.com/ipfs/go-ipfs-exchange-interface" + config "github.com/ipfs/go-ipfs/config" "github.com/libp2p/go-libp2p-core/host" "github.com/libp2p/go-libp2p-core/routing" "go.uber.org/fx" diff --git a/core/node/builder.go b/core/node/builder.go index 803caf51885..689f151b17a 100644 --- a/core/node/builder.go +++ b/core/node/builder.go @@ -14,7 +14,7 @@ import ( ds "github.com/ipfs/go-datastore" dsync "github.com/ipfs/go-datastore/sync" - cfg "github.com/ipfs/go-ipfs-config" + cfg "github.com/ipfs/go-ipfs/config" "github.com/libp2p/go-libp2p-core/crypto" peer "github.com/libp2p/go-libp2p-core/peer" ) diff --git a/core/node/dns.go b/core/node/dns.go index aeec23de145..2fc6327635c 100644 --- a/core/node/dns.go +++ b/core/node/dns.go @@ -6,7 +6,7 @@ import ( "strings" "time" - config "github.com/ipfs/go-ipfs-config" + config "github.com/ipfs/go-ipfs/config" doh "github.com/libp2p/go-doh-resolver" madns "github.com/multiformats/go-multiaddr-dns" diff --git a/core/node/groups.go b/core/node/groups.go index 80367156e55..26b2fae8475 100644 --- a/core/node/groups.go +++ b/core/node/groups.go @@ -7,8 +7,8 @@ import ( "time" blockstore "github.com/ipfs/go-ipfs-blockstore" - config "github.com/ipfs/go-ipfs-config" util "github.com/ipfs/go-ipfs-util" + config "github.com/ipfs/go-ipfs/config" "github.com/ipfs/go-log" "github.com/libp2p/go-libp2p-core/peer" pubsub "github.com/libp2p/go-libp2p-pubsub" diff --git a/core/node/libp2p/libp2p.go b/core/node/libp2p/libp2p.go index 309490bdc52..9d864ad467b 100644 --- a/core/node/libp2p/libp2p.go +++ b/core/node/libp2p/libp2p.go @@ -6,7 +6,7 @@ import ( "time" version "github.com/ipfs/go-ipfs" - config "github.com/ipfs/go-ipfs-config" + config "github.com/ipfs/go-ipfs/config" logging "github.com/ipfs/go-log" "github.com/libp2p/go-libp2p" diff --git a/core/node/libp2p/nat.go b/core/node/libp2p/nat.go index ce0ca345f70..28560662d2c 100644 --- a/core/node/libp2p/nat.go +++ b/core/node/libp2p/nat.go @@ -3,7 +3,7 @@ package libp2p import ( "time" - config "github.com/ipfs/go-ipfs-config" + config "github.com/ipfs/go-ipfs/config" "github.com/libp2p/go-libp2p" ) diff --git a/core/node/libp2p/relay.go b/core/node/libp2p/relay.go index 33d958d5c9d..d30adcfaed9 100644 --- a/core/node/libp2p/relay.go +++ b/core/node/libp2p/relay.go @@ -1,7 +1,7 @@ package libp2p import ( - config "github.com/ipfs/go-ipfs-config" + config "github.com/ipfs/go-ipfs/config" "github.com/libp2p/go-libp2p-core/peer" "github.com/libp2p/go-libp2p" diff --git a/core/node/libp2p/sec.go b/core/node/libp2p/sec.go index bef2efe476a..6246d2fe30d 100644 --- a/core/node/libp2p/sec.go +++ b/core/node/libp2p/sec.go @@ -1,7 +1,7 @@ package libp2p import ( - config "github.com/ipfs/go-ipfs-config" + config "github.com/ipfs/go-ipfs/config" "github.com/libp2p/go-libp2p" noise "github.com/libp2p/go-libp2p-noise" tls "github.com/libp2p/go-libp2p-tls" diff --git a/core/node/libp2p/smux.go b/core/node/libp2p/smux.go index 8ce540109ce..a405e5a3274 100644 --- a/core/node/libp2p/smux.go +++ b/core/node/libp2p/smux.go @@ -5,7 +5,7 @@ import ( "os" "strings" - config "github.com/ipfs/go-ipfs-config" + config "github.com/ipfs/go-ipfs/config" "github.com/libp2p/go-libp2p" smux "github.com/libp2p/go-libp2p-core/mux" mplex "github.com/libp2p/go-libp2p-mplex" diff --git a/core/node/libp2p/transport.go b/core/node/libp2p/transport.go index c5112e9c0b8..303a70d8061 100644 --- a/core/node/libp2p/transport.go +++ b/core/node/libp2p/transport.go @@ -3,7 +3,7 @@ package libp2p import ( "fmt" - config "github.com/ipfs/go-ipfs-config" + config "github.com/ipfs/go-ipfs/config" libp2p "github.com/libp2p/go-libp2p" metrics "github.com/libp2p/go-libp2p-core/metrics" libp2pquic "github.com/libp2p/go-libp2p-quic-transport" diff --git a/core/node/storage.go b/core/node/storage.go index 3e3e90fa174..6a647ffd7bc 100644 --- a/core/node/storage.go +++ b/core/node/storage.go @@ -3,7 +3,7 @@ package node import ( "github.com/ipfs/go-datastore" blockstore "github.com/ipfs/go-ipfs-blockstore" - config "github.com/ipfs/go-ipfs-config" + config "github.com/ipfs/go-ipfs/config" "go.uber.org/fx" "github.com/ipfs/go-filestore" diff --git a/go.mod b/go.mod index 92c15f6ccea..af332571d8c 100644 --- a/go.mod +++ b/go.mod @@ -32,7 +32,6 @@ require ( github.com/ipfs/go-ipfs-blockstore v1.1.2 github.com/ipfs/go-ipfs-chunker v0.0.5 github.com/ipfs/go-ipfs-cmds v0.6.0 - github.com/ipfs/go-ipfs-config v0.19.0 github.com/ipfs/go-ipfs-exchange-interface v0.1.0 github.com/ipfs/go-ipfs-exchange-offline v0.1.1 github.com/ipfs/go-ipfs-files v0.0.9 diff --git a/go.sum b/go.sum index e791d5ea3cf..49abc3cac6d 100644 --- a/go.sum +++ b/go.sum @@ -476,8 +476,6 @@ github.com/ipfs/go-ipfs-chunker v0.0.5 h1:ojCf7HV/m+uS2vhUGWcogIIxiO5ubl5O57Q7Na github.com/ipfs/go-ipfs-chunker v0.0.5/go.mod h1:jhgdF8vxRHycr00k13FM8Y0E+6BoalYeobXmUyTreP8= github.com/ipfs/go-ipfs-cmds v0.6.0 h1:yAxdowQZzoFKjcLI08sXVNnqVj3jnABbf9smrPQmBsw= github.com/ipfs/go-ipfs-cmds v0.6.0/go.mod h1:ZgYiWVnCk43ChwoH8hAmI1IRbuVtq3GSTHwtRB/Kqhk= -github.com/ipfs/go-ipfs-config v0.19.0 h1:OuKIL+BkOZgJ+hb4Wg/9ynCtE/BaZBWcGy8hgdMepAo= -github.com/ipfs/go-ipfs-config v0.19.0/go.mod h1:wz2lKzOjgJeYJa6zx8W9VT7mz+iSd0laBMqS/9wmX6A= github.com/ipfs/go-ipfs-delay v0.0.0-20181109222059-70721b86a9a8/go.mod h1:8SP1YXK1M1kXuc4KJZINY3TQQ03J2rwBG9QfXmbRPrw= github.com/ipfs/go-ipfs-delay v0.0.1 h1:r/UXYyRcddO6thwOnhiznIAiSvxMECGgtv35Xs1IeRQ= github.com/ipfs/go-ipfs-delay v0.0.1/go.mod h1:8SP1YXK1M1kXuc4KJZINY3TQQ03J2rwBG9QfXmbRPrw= diff --git a/package-list.json b/package-list.json index 934e5e34515..7dfc5648cf0 100644 --- a/package-list.json +++ b/package-list.json @@ -42,7 +42,6 @@ ["ipfs/go-ipns", "go-ipns", "IPNS datastructures and validation logic"], "Repo", - ["ipfs/go-ipfs-config", "go-ipfs-config", "go-ipfs config file definitions"], ["ipfs/go-fs-lock", "go-fs-lock", "lockfile management functions"], ["ipfs/fs-repo-migrations", "fs-repo-migrations", "repo migrations"], diff --git a/plugin/loader/loader.go b/plugin/loader/loader.go index 167e1b3090b..6bf13a370c0 100644 --- a/plugin/loader/loader.go +++ b/plugin/loader/loader.go @@ -8,8 +8,8 @@ import ( "runtime" "strings" - config "github.com/ipfs/go-ipfs-config" - cserialize "github.com/ipfs/go-ipfs-config/serialize" + config "github.com/ipfs/go-ipfs/config" + cserialize "github.com/ipfs/go-ipfs/config/serialize" "github.com/ipld/go-ipld-prime/multicodec" "github.com/ipfs/go-ipfs/core" diff --git a/repo/fsrepo/config_test.go b/repo/fsrepo/config_test.go index f7c19c30765..0ffdababe27 100644 --- a/repo/fsrepo/config_test.go +++ b/repo/fsrepo/config_test.go @@ -10,7 +10,7 @@ import ( "github.com/ipfs/go-ipfs/plugin/loader" "github.com/ipfs/go-ipfs/repo/fsrepo" - "github.com/ipfs/go-ipfs-config" + "github.com/ipfs/go-ipfs/config" ) // note: to test sorting of the mountpoints in the disk spec they are diff --git a/repo/fsrepo/fsrepo.go b/repo/fsrepo/fsrepo.go index 2aa4a5e46c8..176ac46189b 100644 --- a/repo/fsrepo/fsrepo.go +++ b/repo/fsrepo/fsrepo.go @@ -20,9 +20,9 @@ import ( ds "github.com/ipfs/go-datastore" measure "github.com/ipfs/go-ds-measure" lockfile "github.com/ipfs/go-fs-lock" - config "github.com/ipfs/go-ipfs-config" - serialize "github.com/ipfs/go-ipfs-config/serialize" util "github.com/ipfs/go-ipfs-util" + config "github.com/ipfs/go-ipfs/config" + serialize "github.com/ipfs/go-ipfs/config/serialize" "github.com/ipfs/go-ipfs/repo/fsrepo/migrations" logging "github.com/ipfs/go-log" homedir "github.com/mitchellh/go-homedir" diff --git a/repo/fsrepo/fsrepo_test.go b/repo/fsrepo/fsrepo_test.go index cd2d66618a5..cf9aeabec0e 100644 --- a/repo/fsrepo/fsrepo_test.go +++ b/repo/fsrepo/fsrepo_test.go @@ -11,7 +11,7 @@ import ( "github.com/ipfs/go-ipfs/thirdparty/assert" datastore "github.com/ipfs/go-datastore" - config "github.com/ipfs/go-ipfs-config" + config "github.com/ipfs/go-ipfs/config" ) // swap arg order diff --git a/repo/fsrepo/migrations/ipfsfetcher/ipfsfetcher.go b/repo/fsrepo/migrations/ipfsfetcher/ipfsfetcher.go index 11203ed5a05..21a6038a7eb 100644 --- a/repo/fsrepo/migrations/ipfsfetcher/ipfsfetcher.go +++ b/repo/fsrepo/migrations/ipfsfetcher/ipfsfetcher.go @@ -12,8 +12,8 @@ import ( "strings" "sync" - "github.com/ipfs/go-ipfs-config" files "github.com/ipfs/go-ipfs-files" + "github.com/ipfs/go-ipfs/config" "github.com/ipfs/go-ipfs/core" "github.com/ipfs/go-ipfs/core/coreapi" "github.com/ipfs/go-ipfs/core/node/libp2p" diff --git a/repo/fsrepo/migrations/migrations.go b/repo/fsrepo/migrations/migrations.go index 5eac91b2932..726870ea004 100644 --- a/repo/fsrepo/migrations/migrations.go +++ b/repo/fsrepo/migrations/migrations.go @@ -15,7 +15,7 @@ import ( "strings" "sync" - config "github.com/ipfs/go-ipfs-config" + config "github.com/ipfs/go-ipfs/config" ) const ( diff --git a/repo/fsrepo/migrations/migrations_test.go b/repo/fsrepo/migrations/migrations_test.go index 0e52b3a65ed..2472d4706aa 100644 --- a/repo/fsrepo/migrations/migrations_test.go +++ b/repo/fsrepo/migrations/migrations_test.go @@ -9,7 +9,7 @@ import ( "strings" "testing" - config "github.com/ipfs/go-ipfs-config" + config "github.com/ipfs/go-ipfs/config" ) func TestFindMigrations(t *testing.T) { diff --git a/repo/fsrepo/misc.go b/repo/fsrepo/misc.go index 7f0c01640a2..71b640331d4 100644 --- a/repo/fsrepo/misc.go +++ b/repo/fsrepo/misc.go @@ -3,7 +3,7 @@ package fsrepo import ( "os" - config "github.com/ipfs/go-ipfs-config" + config "github.com/ipfs/go-ipfs/config" homedir "github.com/mitchellh/go-homedir" ) diff --git a/repo/mock.go b/repo/mock.go index 0576498716a..15313ab373c 100644 --- a/repo/mock.go +++ b/repo/mock.go @@ -7,7 +7,7 @@ import ( filestore "github.com/ipfs/go-filestore" keystore "github.com/ipfs/go-ipfs-keystore" - config "github.com/ipfs/go-ipfs-config" + config "github.com/ipfs/go-ipfs/config" ma "github.com/multiformats/go-multiaddr" ) diff --git a/repo/repo.go b/repo/repo.go index 744bfdf5d57..00735eb94ee 100644 --- a/repo/repo.go +++ b/repo/repo.go @@ -9,7 +9,7 @@ import ( keystore "github.com/ipfs/go-ipfs-keystore" ds "github.com/ipfs/go-datastore" - config "github.com/ipfs/go-ipfs-config" + config "github.com/ipfs/go-ipfs/config" ma "github.com/multiformats/go-multiaddr" ) diff --git a/test/bench/bench_cli_ipfs_add/main.go b/test/bench/bench_cli_ipfs_add/main.go index 727a87aea2f..b11b5f83c7d 100644 --- a/test/bench/bench_cli_ipfs_add/main.go +++ b/test/bench/bench_cli_ipfs_add/main.go @@ -12,7 +12,7 @@ import ( "github.com/ipfs/go-ipfs/thirdparty/unit" - config "github.com/ipfs/go-ipfs-config" + config "github.com/ipfs/go-ipfs/config" random "github.com/jbenet/go-random" ) diff --git a/test/bench/offline_add/main.go b/test/bench/offline_add/main.go index 94e8cac23ba..5d3f27fed1a 100644 --- a/test/bench/offline_add/main.go +++ b/test/bench/offline_add/main.go @@ -11,7 +11,7 @@ import ( "github.com/ipfs/go-ipfs/thirdparty/unit" - config "github.com/ipfs/go-ipfs-config" + config "github.com/ipfs/go-ipfs/config" random "github.com/jbenet/go-random" ) From 6379013e41ffbd4e3e1b9ee0e4d7e364a3073a06 Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Thu, 3 Mar 2022 14:46:31 +0100 Subject: [PATCH 262/262] ci: tweak example testing to pass with internal config package --- .circleci/main.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.circleci/main.yml b/.circleci/main.yml index 78ff3d707db..9838b0f4de5 100644 --- a/.circleci/main.yml +++ b/.circleci/main.yml @@ -120,11 +120,18 @@ jobs: # make sure the examples run against the current version of go-ipfs go mod edit -replace github.com/ipfs/go-ipfs=./../../.. go mod tidy + + # use the internal config package when we test the current version of go-ipfs + sed -i.bak 's;"github.com/ipfs/go-ipfs-config";"github.com/ipfs/go-ipfs/config";' ./main.go + go test -v ./... # restore the go.mod and go.sum files to their original state mv go.mod.bak go.mod mv go.sum.bak go.sum + + # restore the main.go to its original state + mv main.go.bak main.go working_directory: ~/ipfs/go-ipfs/docs/examples/go-ipfs-as-a-library - run: