config

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2020 License: Apache-2.0 Imports: 12 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CertPool added in v0.3.1

type CertPool struct {
	Files []string
	*x509.CertPool
}

CertPool is a wrapper around x509.CertPool, which can be unmarshalled and constructed from a list of filenames.

func (*CertPool) MarshalJSON added in v0.4.0

func (cp *CertPool) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaller to print the cert pool.

func (*CertPool) MarshalYAML added in v0.4.0

func (cp *CertPool) MarshalYAML() (interface{}, error)

MarshalYAML implements yaml.Marshaller to print the cert pool.

func (*CertPool) UnmarshalJSON added in v0.3.1

func (cp *CertPool) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaller.

func (*CertPool) UnmarshalYAML added in v0.3.1

func (cp *CertPool) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements yaml.Unmarshaller.

type DFGetConfig added in v0.4.0

type DFGetConfig struct {
	DfgetFlags  []string      `yaml:"dfget_flags"`
	SuperNodes  []string      `yaml:"supernodes"`
	RateLimit   string        `yaml:"ratelimit"`
	DFRepo      string        `yaml:"localrepo"`
	DFPath      string        `yaml:"dfpath"`
	HostsConfig []*HijackHost `yaml:"hosts" json:"hosts"`
	PeerPort    int           `yaml:"peerPort"`
	LocalIP     string        `yaml:"localIP"`
}

DFGetConfig configures how dfdaemon calls dfget.

type HijackConfig added in v0.3.1

type HijackConfig struct {
	Cert  string        `yaml:"cert" json:"cert"`
	Key   string        `yaml:"key" json:"key"`
	Hosts []*HijackHost `yaml:"hosts" json:"hosts"`
}

HijackConfig represents how dfdaemon hijacks http requests.

type HijackHost added in v0.3.1

type HijackHost struct {
	Regx     *Regexp   `yaml:"regx" json:"regx"`
	Insecure bool      `yaml:"insecure" json:"insecure"`
	Certs    *CertPool `yaml:"certs" json:"certs"`
}

HijackHost is a hijack rule for the hosts that matches Regx.

type Properties

type Properties struct {
	// Registry mirror settings
	RegistryMirror *RegistryMirror `yaml:"registry_mirror" json:"registry_mirror"`

	// Proxies is the list of rules for the transparent proxy. If no rules
	// are provided, all requests will be proxied directly. Request will be
	// proxied with the first matching rule.
	Proxies []*Proxy `yaml:"proxies" json:"proxies"`

	// HijackHTTPS is the list of hosts whose https requests should be hijacked
	// by dfdaemon. Dfdaemon will be able to proxy requests from them with dfget
	// if the url matches the proxy rules. The first matched rule will be used.
	HijackHTTPS *HijackConfig `yaml:"hijack_https" json:"hijack_https"`

	// https options
	Port    uint   `yaml:"port" json:"port"`
	HostIP  string `yaml:"hostIp" json:"hostIp"`
	CertPem string `yaml:"certpem" json:"certpem"`
	KeyPem  string `yaml:"keypem" json:"keypem"`

	Verbose bool `yaml:"verbose" json:"verbose"`

	MaxProcs int `yaml:"maxprocs" json:"maxprocs"`

	// dfget config
	DfgetFlags []string  `yaml:"dfget_flags" json:"dfget_flags"`
	SuperNodes []string  `yaml:"supernodes" json:"supernodes"`
	RateLimit  rate.Rate `yaml:"ratelimit" json:"ratelimit"`
	WorkHome   string    `yaml:"workHome" json:"workHome,omitempty"`
	DFRepo     string    `yaml:"localrepo" json:"localrepo"`
	DFPath     string    `yaml:"dfpath" json:"dfpath"`

	LogConfig  dflog.LogConfig `yaml:"logConfig" json:"logConfig"`
	LocalIP    string          `yaml:"localIP" json:"localIP"`
	PeerPort   int             `yaml:"peerPort" json:"peerPort"`
	StreamMode bool            `yaml:"streamMode" json:"streamMode"`
}

Properties holds all configurable properties of dfdaemon. The default path is '/etc/dragonfly/dfdaemon.yml' For examples:

dfget_flags: ["--node","192.168.33.21","--verbose","--ip","192.168.33.23",
              "--port","15001","--expiretime","3m0s","--alivetime","5m0s",
              "-f","filterParam1&filterParam2"]

registry_mirror:
  # url for the registry mirror
  remote: https://index.docker.io
  # whether to ignore https certificate errors
  insecure: false
  # optional certificates if the remote server uses self-signed certificates
  certs: []
  # whether to request the remote registry directly
  direct: false

proxies:
# proxy all http image layer download requests with dfget
- regx: blobs/sha256.*
# change http requests to some-registry to https and proxy them with dfget
- regx: some-registry/
  use_https: true
# proxy requests directly, without dfget
- regx: no-proxy-reg
  direct: true
# proxy requests with redirect
- regx: some-registry
  redirect: another-registry

hijack_https:
  # key pair used to hijack https requests
  cert: df.crt
  key: df.key
  hosts:
  - regx: mirror.aliyuncs.com:443  # regexp to match request hosts
    # whether to ignore https certificate errors
    insecure: false
    # optional certificates if the host uses self-signed certificates
    certs: []

func (*Properties) DFGetConfig added in v0.4.0

func (p *Properties) DFGetConfig() DFGetConfig

DFGetConfig returns config for dfget downloader.

func (*Properties) Validate added in v0.4.0

func (p *Properties) Validate() error

Validate validates the config

type Proxy added in v0.3.1

type Proxy struct {
	Regx     *Regexp `yaml:"regx" json:"regx"`
	UseHTTPS bool    `yaml:"use_https" json:"use_https"`
	Direct   bool    `yaml:"direct" json:"direct"`
	// Redirect is the host to redirect to, if not empty
	Redirect string `yaml:"redirect" json:"redirect"`
}

Proxy describes a regular expression matching rule for how to proxy a request.

func NewProxy added in v0.3.1

func NewProxy(regx string, useHTTPS bool, direct bool, redirect string) (*Proxy, error)

NewProxy returns a new proxy rule with given attributes.

func (*Proxy) Match added in v0.3.1

func (r *Proxy) Match(url string) bool

Match checks if the given url matches the rule.

type Regexp added in v0.3.1

type Regexp struct {
	*regexp.Regexp
}

Regexp is a simple wrapper around regexp. Regexp to make it unmarshallable from a string.

func NewRegexp added in v0.3.1

func NewRegexp(exp string) (*Regexp, error)

NewRegexp returns a new Regexp instance compiled from the given string.

func (*Regexp) MarshalJSON added in v0.3.1

func (r *Regexp) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaller to print the regexp.

func (*Regexp) MarshalYAML added in v0.4.0

func (r *Regexp) MarshalYAML() (interface{}, error)

MarshalYAML implements yaml.Marshaller to print the regexp.

func (*Regexp) UnmarshalJSON added in v0.3.1

func (r *Regexp) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaller.

func (*Regexp) UnmarshalYAML added in v0.3.1

func (r *Regexp) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements yaml.Unmarshaller.

type RegistryMirror added in v0.3.1

type RegistryMirror struct {
	// Remote url for the registry mirror, default is https://index.docker.io
	Remote *URL `yaml:"remote" json:"remote"`

	// Optional certificates if the mirror uses self-signed certificates
	Certs *CertPool `yaml:"certs" json:"certs"`

	// Whether to ignore certificates errors for the registry
	Insecure bool `yaml:"insecure" json:"insecure"`

	// Request the remote registry directly.
	Direct bool `yaml:"direct" json:"direct"`
}

RegistryMirror configures the mirror of the official docker registry

func (*RegistryMirror) TLSConfig added in v0.3.1

func (r *RegistryMirror) TLSConfig() *tls.Config

TLSConfig returns the tls.Config used to communicate with the mirror.

type URL added in v0.3.1

type URL struct {
	*url.URL
}

URL is simple wrapper around url.URL to make it unmarshallable from a string.

func NewURL added in v0.3.1

func NewURL(s string) (*URL, error)

NewURL parses url from the given string.

func (*URL) MarshalJSON added in v0.3.1

func (u *URL) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaller to print the url.

func (*URL) MarshalYAML added in v0.4.0

func (u *URL) MarshalYAML() (interface{}, error)

MarshalYAML implements yaml.Marshaller to print the url.

func (*URL) UnmarshalJSON added in v0.3.1

func (u *URL) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaller.

func (*URL) UnmarshalYAML added in v0.3.1

func (u *URL) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements yaml.Unmarshaller.

Jump to

Keyboard shortcuts

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