config

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Properties

type Properties struct {
	// Registries the more front the position, the higher priority.
	// You could add an empty Registry at the end to proxy all other requests
	// with those origin schema and host.
	Registries []*Registry `yaml:"registries"`
}

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

registries:
    - regx: (^localhost$)|(^127.0.0.1$)
      schema: http
      host: a.com
    - regx: ^reg.com:1001$
      schema: http
      host: reg.com
    - regx: ^reg.com:1002$
      schema: https
      host: reg.com
      certs: ['/etc/ssl/reg.com/server.crt']

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 Registry

type Registry struct {
	// Schema can be 'http', 'https' or empty. It will use dfdaemon's schema if
	// it's empty.
	Schema string `yaml:"schema"`

	// Host is the host of proxied registry, including ip and port.
	Host string `yaml:"host"`

	// Certs is the path of server-side certification. It should be provided when
	// the 'Schema' is 'https' and the dfdaemon is worked on proxy pattern and
	// the proxied registry is self-certificated.
	// The server-side certification could be get by using this command:
	// openssl x509 -in <(openssl s_client -showcerts -servername xxx -connect xxx:443 -prexit 2>/dev/null)
	Certs []string `yaml:"certs"`

	// Regx is a regular expression, dfdaemon use this registry to process the
	// requests whose host is matched.
	Regx string `yaml:"regx"`
	// contains filtered or unexported fields
}

Registry is the proxied registry base information.

func NewRegistry

func NewRegistry(schema, host, regx string, certs []string) (*Registry, error)

NewRegistry create and init registry proxy with the giving values.

func (*Registry) Match

func (r *Registry) Match(s string) bool

Match reports whether the Registry matches the string s.

func (*Registry) TLSConfig

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

TLSConfig returns a initialized tls.Config instance.

Jump to

Keyboard shortcuts

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