Documentation ¶
Index ¶
Constants ¶
View Source
const ( // MetricDialUpstream is the Server-Timing metric to record milliseconds to // dial upstream site when handling a CONNECT request. MetricDialUpstream = "dialupstream" // DialTimeoutHeader is a header that sets a timeout for dialing upstream // (only respected on CONNECT requests). The timeout is specified in // milliseconds. DialTimeoutHeader = "X-Lantern-Dial-Timeout" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BufferSource ¶
BufferSource is a source for buffers used in reading/writing.
type DialFunc ¶
type DialFunc func(ctx context.Context, isCONNECT bool, network, addr string) (conn net.Conn, err error)
DialFunc is the dial function to use for dialing the proxy.
type Opts ¶
type Opts struct { // IdleTimeout, if specified, lets us know to include an appropriate // KeepAlive: timeout header in the responses. IdleTimeout time.Duration // BufferSource specifies a BufferSource, leave nil to use default. BufferSource BufferSource // Filter is an optional Filter that will be invoked for every Request Filter filters.Filter // OnError, if specified, can return a response to be presented to the client // in the event that there's an error round-tripping upstream. If the function // returns no response, nothing is written to the client. Read indicates // whether the error occurred on reading a request or not. (HTTP only) OnError func(cs *filters.ConnectionState, req *http.Request, read bool, err error) *http.Response // OKWaitsForUpstream specifies whether or not to wait on dialing upstream // before responding OK to a CONNECT request (CONNECT only). OKWaitsForUpstream bool // OKSendsServerTiming specifies whether or not to send back Server-Timing header // when responding OK to CONNECT request. // See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Server-Timing. // The only metric for now is dialupstream, so the value is in the form "dialupstream;dur=42". OKSendsServerTiming bool // Dial is the function that's used to dial upstream. Dial DialFunc // ShouldMITM is an optional function for determining whether or not the given // HTTP CONNECT request to the given upstreamAddr is eligible for being MITM'ed. ShouldMITM func(req *http.Request, upstreamAddr string) bool // MITMOpts, if specified, instructs proxy to attempt to man-in-the-middle // connections and handle them as an HTTP proxy. If the connection cannot be // mitm'ed (e.g. Client Hello doesn't include an SNI header) or if the // contents isn't HTTP, the connection is handled as normal without MITM. MITMOpts *mitm.Opts }
Opts defines options for configuring a Proxy
type Proxy ¶
type Proxy interface { // Handle handles a single connection, with in specified separately in case // there's a buffered reader or something of that sort in use. // dialCtx applies only when dialing upstream. Handle(dialCtx context.Context, in io.Reader, conn net.Conn) error // Connect opens a CONNECT tunnel to the origin without requiring a CONNECT // request to first be sent on conn. It will not reply with CONNECT OK. // dialCtx applies only when dialing upstream. Connect(dialCtx context.Context, in io.Reader, conn net.Conn, origin string) error // Serve runs a server on the given Listener Serve(l net.Listener) error // ApplyMITMOptions updates the configuration of the MITM interceptor ApplyMITMOptions(MITMOpts *mitm.Opts) error }
Proxy is a proxy that can handle HTTP(S) traffic
type RequestAware ¶
type RequestAware interface { // OnRequest allows this connection to make modifications to the request as // needed OnRequest(req *http.Request) }
RequestAware is an interface for connections that are able to modify requests before they're sent on the connection.
Source Files ¶
Click to show internal directories.
Click to hide internal directories.