ipfs-cluster: github.com/ipfs/ipfs-cluster/api/ipfsproxy Index | Files

package ipfsproxy

import "github.com/ipfs/ipfs-cluster/api/ipfsproxy"

Index

Package Files

config.go headers.go ipfsproxy.go util.go

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.

type Config Uses

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 behaviour of IPFSProxy. It implements the config.ComponentConfig interface.

func (*Config) ApplyEnvVars Uses

func (cfg *Config) ApplyEnvVars() error

ApplyEnvVars fills in any Config fields found as environment variables.

func (*Config) ConfigKey Uses

func (cfg *Config) ConfigKey() string

ConfigKey provides a human-friendly identifier for this type of Config.

func (*Config) Default Uses

func (cfg *Config) Default() error

Default sets the fields of this Config to sensible default values.

func (*Config) LoadJSON Uses

func (cfg *Config) LoadJSON(raw []byte) error

LoadJSON parses a JSON representation of this Config as generated by ToJSON.

func (*Config) ToDisplayJSON Uses

func (cfg *Config) ToDisplayJSON() ([]byte, error)

ToDisplayJSON returns JSON config as a string.

func (*Config) ToJSON Uses

func (cfg *Config) ToJSON() (raw []byte, err error)

ToJSON generates a human-friendly JSON representation of this Config.

func (*Config) Validate Uses

func (cfg *Config) Validate() error

Validate checks that the fields of this Config have sensible values, at least in appearance.

type Server Uses

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.

func New Uses

func New(cfg *Config) (*Server, error)

New returns and ipfs Proxy component

func (*Server) SetClient Uses

func (proxy *Server) SetClient(c *rpc.Client)

SetClient makes the component ready to perform RPC requests.

func (*Server) Shutdown Uses

func (proxy *Server) Shutdown(ctx context.Context) error

Shutdown stops any listeners and stops the component from taking any requests.

Package ipfsproxy imports 35 packages (graph) and is imported by 1 packages. Updated 2020-10-17. Refresh now. Tools for package owners.