proxy

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 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 CertificateProvider added in v0.2.0

type CertificateProvider interface {
	GetCertificate(preferredSupplier string, subject string, altNames []string) (*tls.Certificate, error)
	GetExistingCertificate(preferredSupplier string, subject string, altNames []string) (*tls.Certificate, bool, error)
}

CertificateProvider defines the interface for providing certificates to a Manager.

type CertificateStatus added in v0.3.0

type CertificateStatus int

CertificateStatus describes the current status of the route's certificate

const (
	CertificateNotChecked   CertificateStatus = iota // The route has just been initialised, so we don't yet know
	CertificateMissing                               // The certificate is required and no valid one is held
	CertificateExpiringSoon                          // We have a certificate but it needs to be renewed
	CertificateGood                                  // We have a certificate and it is in good order
	CertificateNotRequired                           // We don't have a certificate and are happy about it
)
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(provider CertificateProvider) *Manager

NewManager creates a new route provider. Routes should be set using the SetRoutes method after creation. If the provider is nil, then the manager will not obtain certificates and CertificateForClient will always return an error.

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

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
	Upstreams []Upstream
	Headers   []Header
	Provider  string
	// contains filtered or unexported fields
}

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

type Upstream added in v0.4.0

type Upstream struct {
	Host string
}

Upstream represents a configured upstream server for a route.

Jump to

Keyboard shortcuts

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