config

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2019 License: Apache-2.0 Imports: 9 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 {
	*x509.CertPool
	// contains filtered or unexported fields
}

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

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 HijackConfig added in v0.3.1

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

HijackConfig represents how dfdaemon hijacks http requests

type HijackHost added in v0.3.1

type HijackHost struct {
	Regx  *Regexp   `yaml:"regx"`
	Certs *CertPool `yaml:"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"`

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

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

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

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: []

proxies:
# proxy all http image layer download requests with dfget
- regx: blob/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

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 NewProperties

func NewProperties() *Properties

NewProperties create a new properties with default values.

func (*Properties) Load

func (p *Properties) Load(path string) error

Load loads properties from config file.

type Proxy added in v0.3.1

type Proxy struct {
	Regx     *Regexp `yaml:"regx"`
	UseHTTPS bool    `yaml:"use_https"`
	Direct   bool    `yaml:"direct"`
}

Proxy describe 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) (*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 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 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) 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"`

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

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

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