proxy

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CertificateManager

type CertificateManager interface {
	GetCertificate(subject string, altNames []string) (*tls.Certificate, error)
}

CertificateManager defines the interface for providing certificates to a Manager.

type Header struct {
	Name      string
	Value     string
	Operation HeaderOp
}

Header represents a header that should be modified in the response from upstream.

type HeaderOp

type HeaderOp int

HeaderOp determines how a header should be modified.

const (
	HeaderOpDelete  HeaderOp = iota // Deletes all instances of the header
	HeaderOpAdd                     // Adds a new header, regardless of existing ones
	HeaderOpReplace                 // Removes any existing headers of the same name, and adds a new one
	HeaderOpDefault                 // Sets the header if it doesn't already exist, otherwise leaves it alone
)

type Manager

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

Manager is responsible for maintaining a set of routes, mapping domains to those routes, and refreshing the certificates for those routes.

func NewManager

func NewManager(wildcardDomains []string, certManager CertificateManager) *Manager

NewManager creates a new route provider. Routes should be set using the SetRoutes method after creation. Wildcard domains, if provided, MUST each have a leading dot (e.g. ".example.com").

func (*Manager) CertificateForClient

func (m *Manager) CertificateForClient(hello *tls.ClientHelloInfo) (*tls.Certificate, error)

CertificateForClient returns a certificate (if one exists) for the domain specified in the provided client hello. If no certificate is available, nil is returned. The error return value is unused, but is kept to maintain compatibility with the tls.Config.GetCertificate func signature.

func (*Manager) CheckCertificates

func (m *Manager) CheckCertificates() error

CheckCertificates checks and updates the certificates required for registered routes. It should be called periodically to renew certificates and obtain new OCSP staples.

func (*Manager) RouteForDomain

func (m *Manager) RouteForDomain(domain string) *Route

RouteForDomain returns the previously-registered route for the given domain. If no routes match the domain, nil is returned.

func (*Manager) SetRoutes

func (m *Manager) SetRoutes(newRoutes []*Route) error

SetRoutes replaces all previously registered routes with the given new routes. This func may block while new certificates are obtained; during this time the old routes will continue to be served to avoid too much disruption.

type Redirector

type Redirector struct {
}

Redirector is a http.Handler that redirects all requests to HTTPS.

func (*Redirector) ServeHTTP

func (r *Redirector) ServeHTTP(writer http.ResponseWriter, request *http.Request)

type Rewriter

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

Rewriter facilitates rewriting HTTP requests and responses according to the routes provided by a Manager.

func NewRewriter

func NewRewriter(manager *Manager) *Rewriter

NewRewriter creates a new Rewriter backed by the given route manager.

func (*Rewriter) RewriteRequest

func (r *Rewriter) RewriteRequest(req *http.Request)

RewriteRequest modifies the given request according to the routes provided by the Manager. It satisfies the signature of the Director field of httputil.ReverseProxy.

func (*Rewriter) RewriteResponse

func (r *Rewriter) RewriteResponse(response *http.Response) error

RewriteResponse modifies the given response according to the routes provided by the Manager. It satisfies the signature of the ModifyResponse field of httputil.ReverseProxy.

type Route

type Route struct {
	Domains  []string
	Upstream string
	Headers  []Header
	// contains filtered or unexported fields
}

Route describes one way which a request may be mapped from the original HTTP request to an upstream server.

Jump to

Keyboard shortcuts

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