Documentation
¶
Index ¶
Constants ¶
const ( X_ENPROXY_ID = "X-Enproxy-Id" X_ENPROXY_DEST_ADDR = "X-Enproxy-Dest-Addr" X_ENPROXY_EOF = "X-Enproxy-EOF" X_ENPROXY_PROXY_HOST = "X-Enproxy-Proxy-Host" X_ENPROXY_OP = "X-Enproxy-Op" OP_WRITE = "write" OP_READ = "read" )
const ( DEFAULT_BYTES_BEFORE_FLUSH = 1024768 DEFAULT_READ_BUFFER_SIZE = 65536 )
Variables ¶
This section is empty.
Functions ¶
func Dial ¶
Dial creates a Conn, opens a connection to the proxy and starts processing writes and reads on the Conn.
addr: the host:port of the destination server that we're trying to reach
config: configuration for this Conn
func DumpConnTrace ¶
func DumpConnTrace()
DumpConnTrace dumps connection tracing information to the debug log.
Types ¶
type Config ¶
type Config struct {
// DialProxy: function to open a connection to the proxy
DialProxy dialFunc
// NewRequest: function to create a new request to the proxy
NewRequest newRequestFunc
// OnFirstResponse: optional callback that gets called on the first response
// from the proxy.
OnFirstResponse func(resp *http.Response)
// FlushTimeout: how long to let writes idle before writing out a
// request to the proxy. Defaults to 15 milliseconds.
FlushTimeout time.Duration
// IdleTimeout: how long to wait before closing an idle connection, defaults
// to 30 seconds on the client and 70 seconds on the server proxy.
//
// For clients, the value should be set lower than the proxy's idle timeout
// so that enproxy redials before the active connection is closed. The value
// should be set higher than the maximum possible time between the proxy
// receiving the last data from a request and the proxy returning the first
// data of the response, otherwise the connection will be closed in the
// middle of processing a request.
IdleTimeout time.Duration
// BufferRequests: if true, requests to the proxy will be buffered and sent
// with identity encoding. If false, they'll be streamed with chunked
// encoding.
BufferRequests bool
}
Config configures a Conn
type Proxy ¶
type Proxy struct {
// Dial: function used to dial the destination server. If nil, a default
// TCP dialer is used.
Dial dialFunc
// Host: (Deprecated; use HostFn instead) FQDN of this particular proxy.
// Either this or HostFn is required if this server was originally reached
// by DNS round robin.
Host string
// HostFn: given a http.Request, return the FQDN of this particular proxy,
// hopefully through the same front. This is used to support multiple
// domain fronts. Either this or Host is required if this server was
// originally reached by DNS round robin.
HostFn func(*http.Request) string
// FlushTimeout: how long to let reads idle before writing out a
// response to the client. Defaults to 35 milliseconds.
FlushTimeout time.Duration
// BytesBeforeFlush: how many bytes to read before flushing response to
// client. Periodically flushing the response keeps the response buffer
// from getting too big when processing big downloads.
BytesBeforeFlush int
// IdleTimeout: how long to wait before closing an idle connection, defaults
// to 70 seconds
IdleTimeout time.Duration
// ReadBufferSize: size of read buffer in bytes
ReadBufferSize int
// OnBytesReceived is an optional callback for learning about bytes received
// from a client
OnBytesReceived statCallback
// OnBytesSent is an optional callback for learning about bytes sent to a
// client
OnBytesSent statCallback
// Allow: Optional function that checks whether the given request to the
// given destAddr is allowed. If it is not allowed, this function should
// return the HTTP error code and an error.
Allow func(req *http.Request, destAddr string) (int, error)
// contains filtered or unexported fields
}
Proxy is the server side to an enproxy.Client. Proxy implements the http.Handler interface for plugging into an HTTP server, and it also provides a convenience ListenAndServe() function for quickly starting up a dedicated HTTP server using this Proxy as its handler.
func (*Proxy) ListenAndServe ¶
ListenAndServe: convenience function for quickly starting up a dedicated HTTP server using this Proxy as its handler
func (*Proxy) Serve ¶
Serve: convenience function for quickly starting up a dedicated HTTP server using this Proxy as its handler

