proxy

package
v0.0.0-...-da4d284 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2020 License: ISC Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const MaxHeaderSize = 8 << 10 // 8KB

MaxHeaderSize represents the maximum size that the proxy will look throught to find a Host header

Variables

View Source
var (
	HeadersTooLarge = []byte("HTTP/1.0 413\r\nContent-Length: 0\r\nConnection: close\r\n\r\n")
	BadRequest      = []byte("HTTP/1.0 400\r\nContent-Length: 0\r\nConnection: close\r\n\r\n")
)

Two preconstructed responses to certain errors

View Source
var (
	ErrIsDefault   = errors.New("host is default")
	ErrProxyClosed = errors.New("proxy closed")
)

Errors

View Source
var (
	ErrInvalidHost = errors.New("invalid host")
	ErrRunning     = errors.New("already running")
	ErrNotRunning  = errors.New("not running")
	ErrNoDefault   = errors.New("no default host set")
)

Errors

View Source
var (
	ErrBadSocket = errors.New("bad socket type")
)

Errors

Functions

This section is empty.

Types

type ErrAliasInUse

type ErrAliasInUse struct {
	Name string
}

ErrAliasInUse is an error returned when trying to give a host an alias already in use by another host

func (ErrAliasInUse) Error

func (e ErrAliasInUse) Error() string

type ErrUnknownAlias

type ErrUnknownAlias struct {
	Name string
}

ErrUnknownAlias is an error returned when trying to remove an alias from a host where it is not set

func (ErrUnknownAlias) Error

func (e ErrUnknownAlias) Error() string

type Host

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

Host represents a single host and its aliases

func (*Host) AddAliases

func (h *Host) AddAliases(names ...string) error

AddAliases simply adds aliases to the host

func (*Host) Aliases

func (h *Host) Aliases() []string

Aliases returns a list of the hosts aliases

func (*Host) RemoveAlias

func (h *Host) RemoveAlias(names ...string) error

RemoveAlias removes an alias from a host

func (*Host) Replace

func (h *Host) Replace(c *exec.Cmd) error

Replace stops the current host executeable and starts the given command in its place

func (*Host) Restart

func (h *Host) Restart() error

Restart will restart the host

func (*Host) Stop

func (h *Host) Stop() error

Stop will stop the host

type Proxy

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

Proxy repsents a listener that will proxy connections to hosts

func New

func New(http, https net.Listener) *Proxy

New creates a new Proxy will optional http and https listeners

func (*Proxy) Default

func (p *Proxy) Default(h *Host) error

Default sets the default host, one which will be used if a host cannot be determined from the headers

func (*Proxy) IsDefault

func (p *Proxy) IsDefault(h *Host) bool

IsDefault returns whether the given host is currently the default

func (*Proxy) NewHost

func (p *Proxy) NewHost(c *exec.Cmd) (*Host, error)

NewHost creates a new Host from the given command, setting up the proxied connections and running the command

func (*Proxy) Run

func (p *Proxy) Run() error

Run starts the proxy and waits until it is closed to return any errors

func (*Proxy) Start

func (p *Proxy) Start() error

Start starts the proxy and returns immediately

func (*Proxy) Wait

func (p *Proxy) Wait() error

Wait will block until the proxy is stopped

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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