Documentation
¶
Overview ¶
Package proxy forwards connections to the internet with HTTP CONNECT.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Log ¶ added in v1.3.0
type Log struct {
// contains filtered or unexported fields
}
Log writes each target the proxy connected to or refused to a writer once, and keeps them with how often and when last they were used. It writes what the guest asked for, not what went through.
func (*Log) Closed ¶ added in v1.5.0
Closed notes when a connection to a target ended. It is an OnClosed function.
func (*Log) Connected ¶ added in v1.3.0
Connected logs a target the proxy connected to. It is an OnConnected function.
func (*Log) Refused ¶ added in v1.3.0
Refused logs a target the proxy refused. It is an OnRefused function.
type Options ¶
type Options struct {
// Allow is called with the host name and port of each CONNECT request
// and returns whether they may be reached. Nil allows everything.
Allow func(host, port string) bool
// OnConnected is called with the host:port of each request once the
// proxy reached it, before the tunnel opens.
OnConnected func(target string)
// OnRefused is called with the host:port of each refused request.
OnRefused func(target string)
// OnClosed is called with the host:port of each request the proxy
// reached once its tunnel has closed.
OnClosed func(target string)
// Hint is a line added to each refusal, such as where to allow the host.
Hint string
// Resolve looks a host name up. Nil uses the system resolver.
Resolve func(ctx context.Context, host string) ([]net.IP, error)
// Local returns the handler that answers a target itself, over HTTP in
// the tunnel, or nil for a target the proxy connects to. A target it
// answers needs no place on the allow list.
Local func(host, port string) http.Handler
// Pinned returns the addresses a name stands for without asking DNS,
// such as localhost. They are dialed even when they are not public. Nil,
// or no addresses, resolves the name as usual.
Pinned func(host, port string) []net.IP
}
Options control what the proxy lets through.
Click to show internal directories.
Click to hide internal directories.