proxy

package
v2.5.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2019 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Overview

Based on net/http/internal

Index

Constants

View Source
const MaxDockerHostname = 64

Variables

View Source
var (
	ErrLineTooLong        = errors.New("header line too long")
	ErrInvalidChunkLength = errors.New("invalid byte in chunk length")
)
View Source
var (
	ErrWeaveCIDRNone = errors.New("the container was created with the '-e WEAVE_CIDR=none' option")
	ErrNoDefaultIPAM = errors.New("the container was created without specifying an IP address with '-e WEAVE_CIDR=...' and the proxy was started with the '--no-default-ipalloc' option")
)
View Source
var (
	ErrNoCommandSpecified = errors.New("No command specified")
)
View Source
var (
	Log = common.Log
)

Functions

This section is empty.

Types

type ChunkedReader

type ChunkedReader struct {
	// contains filtered or unexported fields
}

func NewChunkedReader

func NewChunkedReader(r io.Reader) *ChunkedReader

Unlike net/http/internal.chunkedReader, this has an interface where we can handle individual chunks. The interface is based on database/sql.Rows.

func (*ChunkedReader) Chunk

func (cr *ChunkedReader) Chunk() io.Reader

Chunk returns the io.Reader of the current chunk. On each call, this returns the same io.Reader for a given chunk.

func (*ChunkedReader) Err

func (cr *ChunkedReader) Err() error

Err returns the error, if any, that was encountered during iteration.

func (*ChunkedReader) Next

func (cr *ChunkedReader) Next() bool

Next prepares the next chunk for reading. It returns true on success, or false if there is no next chunk or an error happened while preparing it. Err should be consulted to distinguish between the two cases.

Every call to Chunk, even the first one, must be preceded by a call to Next.

Calls to Next will discard any unread bytes in the current Chunk.

type Config

type Config struct {
	Enabled             bool
	HostnameFromLabel   string
	HostnameMatch       string
	HostnameReplacement string
	Image               string
	ListenAddrs         []string
	RewriteInspect      bool
	NoDefaultIPAM       bool
	NoRewriteHosts      bool
	TLSConfig           TLSConfig
	WithoutDNS          bool
	DNSListenAddress    string
	DNSDomain           string
	NoMulticastRoute    bool
	KeepTXOn            bool
	DockerBridge        string
	DockerHost          string
}

type ErrNoSuchImage

type ErrNoSuchImage struct {
	Name string
}

ErrNoSuchImage replaces docker.NoSuchImage, which does not contain the image name, which in turn breaks docker clients post 1.7.0 since they expect the image name to be present in errors.

func (*ErrNoSuchImage) Error

func (err *ErrNoSuchImage) Error() string

type MalformedHostHeaderOverride

type MalformedHostHeaderOverride struct {
	net.Listener
}

MalformedHostHeaderOverride is a wrapper to be able to overcome the 400 Bad request coming from old docker clients that send an invalid Host header.

func (*MalformedHostHeaderOverride) Accept

func (l *MalformedHostHeaderOverride) Accept() (net.Conn, error)

Accept makes the listener accepts connections and wraps the connection in a MalformedHostHeaderOverrideConn initilizing first to true.

type MalformedHostHeaderOverrideConn

type MalformedHostHeaderOverrideConn struct {
	net.Conn
	// contains filtered or unexported fields
}

MalformedHostHeaderOverrideConn wraps the underlying unix connection and keeps track of the first read from http.Server which just reads the headers.

func (*MalformedHostHeaderOverrideConn) Read

func (l *MalformedHostHeaderOverrideConn) Read(b []byte) (n int, err error)

Read reads the first *read* request from http.Server to inspect the Host header. If the Host starts with / then we're talking to an old docker client which send an invalid Host header. To not error out in http.Server we rewrite the first bytes of the request to sanitize the Host header itself. In case we're not dealing with old docker clients the data is just passed to the server w/o modification.

type Proxy

type Proxy struct {
	sync.Mutex
	Config
	// contains filtered or unexported fields
}

func NewProxy

func NewProxy(c Config) (*Proxy, error)

func StubProxy

func StubProxy(c Config) (*Proxy, error)

func (*Proxy) AttachExistingContainers

func (proxy *Proxy) AttachExistingContainers()

func (*Proxy) ContainerDestroyed

func (proxy *Proxy) ContainerDestroyed(ident string)

func (*Proxy) ContainerDied

func (proxy *Proxy) ContainerDied(ident string)

func (*Proxy) ContainerStarted

func (proxy *Proxy) ContainerStarted(ident string)

weavedocker.ContainerObserver interface

func (*Proxy) Dial

func (proxy *Proxy) Dial() (net.Conn, error)

func (*Proxy) Intercept

func (proxy *Proxy) Intercept(i interceptor, w http.ResponseWriter, r *http.Request)

func (*Proxy) Listen

func (proxy *Proxy) Listen() []net.Listener

func (*Proxy) RewriteEtcHosts

func (proxy *Proxy) RewriteEtcHosts(hostsPath, fqdn string, ips []*net.IPNet, extraHosts []string) error

rewrite /etc/hosts, unlinking the file (so Docker does not modify it again) but leaving it with valid contents...

func (*Proxy) Serve

func (proxy *Proxy) Serve(listeners []net.Listener, ready func())

func (*Proxy) ServeHTTP

func (proxy *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Proxy) StatusHTTP

func (proxy *Proxy) StatusHTTP(w http.ResponseWriter, r *http.Request)

func (*Proxy) Stop

func (proxy *Proxy) Stop()

type Status

type Status struct {
	Addresses []string
}

func NewStatus

func NewStatus(proxy *Proxy) *Status

type TLSConfig

type TLSConfig struct {
	Enabled, Verify   bool
	Cert, Key, CACert string
	*tls.Config
}

func (*TLSConfig) IsEnabled

func (c *TLSConfig) IsEnabled() bool

IsEnabled returns true if TLS is enable, according to the config.

func (*TLSConfig) LoadCerts

func (c *TLSConfig) LoadCerts() error

LoadCerts loads the certificates into c.Config, if TLS is enabled.

type UnmarshalWrongTypeError

type UnmarshalWrongTypeError struct {
	Field, Expected string
	Got             interface{}
}

func (*UnmarshalWrongTypeError) Error

func (e *UnmarshalWrongTypeError) Error() string

Jump to

Keyboard shortcuts

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