Documentation ¶
Overview ¶
Package proxied provides http.Client implementations that use various combinations of chained and direct domain-fronted proxies.
Remember to call SetProxyAddr before obtaining an http.Client.
Index ¶
- Variables
- func AsRoundTripper(fn func(req *http.Request) (*http.Response, error)) http.RoundTripper
- func ChainedNonPersistent(rootCA string) (http.RoundTripper, error)
- func ChainedPersistent(rootCA string) (http.RoundTripper, error)
- func DirectThenFrontedClient(timeout time.Duration) *http.Client
- func SetProxyAddr(addr eventual.Getter)
- type RoundTripper
Constants ¶
This section is empty.
Variables ¶
var ( // proxy. ErrChainedProxyUnavailable = "chained proxy unavailable" )
Functions ¶
func AsRoundTripper ¶
AsRoundTripper turns the given function into an http.RoundTripper.
func ChainedNonPersistent ¶
func ChainedNonPersistent(rootCA string) (http.RoundTripper, error)
ChainedNonPersistent creates an http.RoundTripper that proxies through chained servers and does not use keepalive connections. If rootCA is specified, the RoundTripper will validate the server's certificate on TLS connections against that RootCA.
func ChainedPersistent ¶
func ChainedPersistent(rootCA string) (http.RoundTripper, error)
ChainedPersistent creates an http.RoundTripper that uses keepalive connectionspersists and proxies through chained servers. If rootCA is specified, the RoundTripper will validate the server's certificate on TLS connections against that RootCA.
func DirectThenFrontedClient ¶
DirectThenFrontedClient returns an http.Client that first attempts to connect directly to the origin and then falls back to using domain fronting. WARNING - if using this for non-idempotent requests like POST, you may see duplicate POSTS if the direct submission succeeds but fails to return a response by the timeout!
func SetProxyAddr ¶
SetProxyAddr sets the eventual.Getter that's used to determine the proxy's address. This MUST be called before attempting to use the proxied package.
Types ¶
type RoundTripper ¶
type RoundTripper interface { http.RoundTripper // SetMasqueradeTimeout specifies how long we're willing to wait for a valid // fronting masquerade before failing. SetMasqueradeTimeout(time.Duration) }
RoundTripper implements http.RoundTripper and allows configuration of the masquerade timeout.
func ChainedThenFronted ¶
func ChainedThenFronted() RoundTripper
ChainedThenFronted creates a new http.RoundTripper that attempts to send requests first through a chained server and then falls back to using a direct fronted server if the chained route didn't work.
func ChainedThenFrontedWith ¶
func ChainedThenFrontedWith(rootCA string) RoundTripper
ChainedThenFrontedWith creates a new http.RoundTripper that attempts to send requests first through a chained server and then falls back to using a direct fronted server if the chained route didn't work.
func ParallelPreferChained ¶
func ParallelPreferChained() RoundTripper
ParallelPreferChained creates a new http.RoundTripper that attempts to send requests through both chained and direct fronted routes in parallel. Once a chained request succeeds, subsequent requests will only go through Chained servers unless and until a request fails, in which case we'll start trying fronted requests again.
func ParallelPreferChainedWith ¶
func ParallelPreferChainedWith(rootCA string) RoundTripper
ParallelPreferChainedWith creates a new http.RoundTripper that attempts to send requests through both chained and direct fronted routes in parallel. Once a chained request succeeds, subsequent requests will only go through Chained servers unless and until a request fails, in which case we'll start trying fronted requests again.