srp

package module
v0.0.0-...-081d5a9 Latest Latest
Warning

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

Go to latest
Published: May 11, 2020 License: Apache-2.0 Imports: 20 Imported by: 0

README

SRP moved to egt.run/srp

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Pledge

func Pledge() error

Pledge is not supported outside of OpenBSD.

func Unveil

func Unveil(filename string) error

Unveil is not supported outside of OpenBSD.

Types

type Logger

type Logger interface {
	Printf(format string, vals ...interface{})
	ReqPrintf(reqID, format string, vals ...interface{})
}

Logger logs error messages for the caller where those errors don't require returning, i.e. the logging itself constitutes handling the error.

type Registry

type Registry struct {
	// Services maps hostnames to one of the following:
	//
	// * IPs with optional healthcheck paths, OR
	// * A redirect to another hostname
	Services map[string]*backend

	// API restricts internal API access to a subnet, which should be an
	// private LAN.
	API struct{ Subnet string }
}

Registry maps hosts to backends with other helpful info, such as healthchecks.

func NewRegistry

func NewRegistry(filename string) (*Registry, error)

NewRegistry for a given configuration file. This reports an error if any frontend host has no backends.

func (*Registry) Hosts

func (r *Registry) Hosts() []string

Hosts for the registry suitable for generating HTTPS certificates. This automatically removes *.internal domains.

type ReverseProxy

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

ReverseProxy maps frontend hosts to backends. If HealthPath is set in the config.json file, ReverseProxy checks the health of backend servers periodically and automatically removes them from rotation until health checks pass.

func NewProxy

func NewProxy(log Logger, reg *Registry) *ReverseProxy

NewProxy from a given Registry.

func (*ReverseProxy) CheckHealth

func (r *ReverseProxy) CheckHealth() error

CheckHealth of backend servers in the registry concurrently, and update the registry so requests are only routed to healthy servers.

func (*ReverseProxy) RedirectHTTPHandler

func (rp *ReverseProxy) RedirectHTTPHandler() (http.Handler, error)

RedirectHTTPHandler redirects http requests to use the API if the request originated from the whitelisted subnet. In all other GET and HEAD requests, this handler redirects to HTTPS. For POST, PUT, etc. this handler throws an error letting the client know to use HTTPS.

func (*ReverseProxy) ServeHTTP

func (r *ReverseProxy) ServeHTTP(w http.ResponseWriter, req *http.Request)

func (*ReverseProxy) UpdateRegistry

func (r *ReverseProxy) UpdateRegistry(reg *Registry)

UpdateRegistry for the reverse proxy with new frontends, backends, and health checks.

Directories

Path Synopsis
cmd
srp

Jump to

Keyboard shortcuts

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