Documentation ¶
Overview ¶
Package ipfsproxy implements the Cluster API interface by providing an IPFS HTTP interface as exposed by the go-ipfs daemon.
In this API, select endpoints like pin*, add*, and repo* endpoints are used to instead perform cluster operations. Requests for any other endpoints are passed to the underlying IPFS daemon.
Index ¶
Constants ¶
const ( DefaultNodeAddr = "/ip4/127.0.0.1/tcp/5001" DefaultNodeHTTPS = false DefaultReadTimeout = 0 DefaultReadHeaderTimeout = 5 * time.Second DefaultWriteTimeout = 0 DefaultIdleTimeout = 60 * time.Second DefaultExtractHeadersPath = "/api/v0/version" DefaultExtractHeadersTTL = 5 * time.Minute DefaultMaxHeaderBytes = minMaxHeaderBytes )
Default values for Config.
Variables ¶
var DNSTimeout = 5 * time.Second
DNSTimeout is used when resolving DNS multiaddresses in this module
var DefaultListenAddrs = []string{
"/ip4/127.0.0.1/tcp/9095",
}
DefaultListenAddrs contains the default listeners for the proxy.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { config.Saver // Listen parameters for the IPFS Proxy. ListenAddr []ma.Multiaddr // Host/Port for the IPFS daemon. NodeAddr ma.Multiaddr // Should we talk to the IPFS API over HTTPS? (experimental, untested) NodeHTTPS bool // LogFile is path of the file that would save Proxy API logs. If this // path is empty, logs would be sent to standard output. This path // should either be absolute or relative to cluster base directory. Its // default value is empty. LogFile string // Maximum duration before timing out reading a full request ReadTimeout time.Duration // Maximum duration before timing out reading the headers of a request ReadHeaderTimeout time.Duration // Maximum duration before timing out write of the response WriteTimeout time.Duration // Maximum cumulative size of HTTP request headers in bytes // accepted by the server MaxHeaderBytes int // Server-side amount of time a Keep-Alive connection will be // kept idle before being reused IdleTimeout time.Duration // A list of custom headers that should be extracted from // IPFS daemon responses and re-used in responses from hijacked paths. // This is only useful if the user has configured custom headers // in the IPFS daemon. CORS-related headers are already // taken care of by the proxy. ExtractHeadersExtra []string // If the user wants to extract some extra custom headers configured // on the IPFS daemon so that they are used in hijacked responses, // this request path will be used. Defaults to /version. This will // trigger a single request to extract those headers and remember them // for future requests (until TTL expires). ExtractHeadersPath string // Establishes how long we should remember extracted headers before we // refresh them with a new request. 0 means always. ExtractHeadersTTL time.Duration // Tracing flag used to skip tracing specific paths when not enabled. Tracing bool }
Config allows to customize behavior of IPFSProxy. It implements the config.ComponentConfig interface.
func (*Config) ApplyEnvVars ¶ added in v0.10.0
ApplyEnvVars fills in any Config fields found as environment variables.
func (*Config) LoadJSON ¶
LoadJSON parses a JSON representation of this Config as generated by ToJSON.
func (*Config) ToDisplayJSON ¶ added in v1.0.2
ToDisplayJSON returns JSON config as a string.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server offers an IPFS API, hijacking some interesting requests and forwarding the rest to the ipfs daemon it proxies HTTP requests to the configured IPFS daemon. It is able to intercept these requests though, and perform extra operations on them.