diff --git a/config.go b/config.go index d38bd98..d7016c5 100644 --- a/config.go +++ b/config.go @@ -14,23 +14,24 @@ import ( // Config is used to load ipfs config files. type Config struct { - ChainInfo ChainInfo // local node's chain info - 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 - 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 - API API // local node's API settings - Swarm SwarmConfig - AutoNAT AutoNATConfig - Pubsub PubsubConfig - Peering Peering - DNS DNS - Services Services // External service domains and info + ChainInfo ChainInfo // local node's chain info + 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 + 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 + API API // local node's API settings + S3CompatibleAPI S3CompatibleAPI //s3-compatible-api settings + Swarm SwarmConfig + AutoNAT AutoNATConfig + Pubsub PubsubConfig + Peering Peering + DNS DNS + Services Services // External service domains and info Provider Provider Reprovider Reprovider diff --git a/init.go b/init.go index 449c909..e81f379 100644 --- a/init.go +++ b/init.go @@ -72,7 +72,8 @@ func Init(out io.Writer, nBitsForKeypair int, keyType string, importKey string, }, APICommands: []string{}, }, - Services: DefaultServicesConfig(), + S3CompatibleAPI: DefaultS3CompatibleAPIConfig(), + Services: DefaultServicesConfig(), Reprovider: Reprovider{ Interval: NewOptionalDuration(time.Hour * 12), Strategy: NewOptionalString("all"), @@ -213,6 +214,14 @@ func flatfsSpec() map[string]interface{} { } } +func DefaultS3CompatibleAPIConfig() S3CompatibleAPI { + return S3CompatibleAPI{ + Address: "127.0.0.1:6001", + Enable: false, + HTTPHeaders: nil, + } +} + // DefaultServicesConfig returns the default set of configs for external services. func DefaultServicesConfig() Services { return Services{ diff --git a/migrations.go b/migrations.go index 8f2c6c6..1fd09d0 100644 --- a/migrations.go +++ b/migrations.go @@ -258,6 +258,16 @@ func migrate_17_Sync_Hosts(cfg *Config) bool { return false } +func migrate_18_S3CompatibleAPI(cfg *Config) bool { + if len(cfg.S3CompatibleAPI.Address) == 0 { + cfg.S3CompatibleAPI.Enable = false + cfg.S3CompatibleAPI.Address = "127.0.0.1:6001" + cfg.S3CompatibleAPI.HTTPHeaders = nil + return true + } + return false +} + // MigrateConfig migrates config options to the latest known version // It may correct incompatible configs as well // inited = just initialized in the same call @@ -283,5 +293,6 @@ func MigrateConfig(cfg *Config, inited, hasHval bool) bool { updated = migrate_15_MissingRemoteAPI(cfg) || updated updated = migrate_16_TrongridDomain(cfg) || updated updated = migrate_17_Sync_Hosts(cfg) || updated + updated = migrate_18_S3CompatibleAPI(cfg) || updated return updated } diff --git a/s3_compatible_api.go b/s3_compatible_api.go new file mode 100644 index 0000000..bf69abd --- /dev/null +++ b/s3_compatible_api.go @@ -0,0 +1,7 @@ +package config + +type S3CompatibleAPI struct { + Enable bool + Address string + HTTPHeaders map[string][]string // Leave nil for default headers +}