ipfsproxy

package
v0.0.0-...-6646f2c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 15, 2019 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultListenAddr         = "/ip4/127.0.0.1/tcp/9095"
	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
)

Default values for Config.

Variables

View Source
var DNSTimeout = 5 * time.Second

DNSTimeout is used when resolving DNS multiaddresses in this module

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

	// 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

	// 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
}

Config allows to customize behaviour of IPFSProxy. It implements the config.ComponentConfig interface.

func (*Config) ConfigKey

func (cfg *Config) ConfigKey() string

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

func (*Config) Default

func (cfg *Config) Default() error

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

func (*Config) LoadJSON

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

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

func (*Config) ToJSON

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

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

func (*Config) Validate

func (cfg *Config) Validate() error

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

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.

func New

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

New returns and ipfs Proxy component

func (*Server) SetClient

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

SetClient makes the component ready to perform RPC requests.

func (*Server) Shutdown

func (proxy *Server) Shutdown() error

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL