Issue #453 Extract the IPFS Proxy from ipfshttp

Warning about old config style(proxy inside ipfs connector) getting
removed in future

License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
This commit is contained in:
Kishan Sagathiya 2018-11-12 05:33:07 +05:30
parent 253185ad13
commit e21d84dbee
4 changed files with 17 additions and 3 deletions

View File

@ -131,7 +131,7 @@ func (cfg *Config) LoadJSON(raw []byte) error {
cfg.NodeAddr = nodeAddr
err = config.ParseDurations(
"ipfshttp",
"ipfsproxy",
&config.DurationOpt{Duration: jcfg.ProxyReadTimeout, Dst: &cfg.ProxyReadTimeout, Name: "proxy_read_timeout"},
&config.DurationOpt{Duration: jcfg.ProxyReadHeaderTimeout, Dst: &cfg.ProxyReadHeaderTimeout, Name: "proxy_read_header_timeout"},
&config.DurationOpt{Duration: jcfg.ProxyWriteTimeout, Dst: &cfg.ProxyWriteTimeout, Name: "proxy_write_timeout"},

View File

@ -319,6 +319,12 @@ func (cfg *Manager) LoadJSON(bs []byte) error {
// Should we change hardcoded "ipfsproxy" to something else
if _, ok := jcfg.API["ipfsproxy"]; !ok {
loadCompJSON("ipfsproxy", sections[API]["ipfsproxy"], jcfg.IPFSConn)
logger.Warning(`
The IPFS proxy functionality has been extracted as a separate component and now uses
its own configuration section ("ipfsproxy" in the "api" section).
To keep compatibility, since you did not define an "ipfsproxy" section, the proxy configuration is taken from the "ipfshttp" section as before, but this will be removed in future versions.
`)
}
loadSectionJSON(sections[IPFSConn], jcfg.IPFSConn)
loadSectionJSON(sections[State], jcfg.State)

View File

@ -58,6 +58,14 @@ type jsonConfig struct {
IPFSRequestTimeout string `json:"ipfs_request_timeout"`
PinTimeout string `json:"pin_timeout"`
UnpinTimeout string `json:"unpin_timeout"`
// Fields below are only to maintain compatibility
// They can be removed in future
ProxyListenMultiaddress string `json:"proxy_listen_multiaddress,omitempty"`
ProxyReadTimeout string `json:"proxy_read_timeout,omitempty"`
ProxyReadHeaderTimeout string `json:"proxy_read_header_timeout,omitempty"`
ProxyWriteTimeout string `json:"proxy_write_timeout,omitempty"`
ProxyIdleTimeout string `json:"proxy_idle_timeout,omitempty"`
}
// ConfigKey provides a human-friendly identifier for this type of Config.

View File

@ -181,14 +181,14 @@ func (ipfs *Connector) Shutdown() error {
return nil
}
logger.Info("stopping IPFS Connector")
ipfs.cancel()
close(ipfs.rpcReady)
ipfs.wg.Wait()
ipfs.shutdown = true
logger.Info("stopping IPFS Connector")
return nil
}