proxied

package
v0.0.0-...-3c82484 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2021 License: Apache-2.0 Imports: 21 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
var (

	// ErrChainedProxyUnavailable indicates that we weren't able to find a chained
	// proxy.
	ErrChainedProxyUnavailable = "chained proxy unavailable"
)

Functions

func AsRoundTripper

func AsRoundTripper(fn func(req *http.Request) (*http.Response, error)) http.RoundTripper

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

func DirectThenFrontedClient(timeout time.Duration) *http.Client

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

func SetProxyAddr(addr eventual.Getter)

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.

Jump to

Keyboard shortcuts

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