Documentation
¶
Index ¶
Constants ¶
const ( // HTTP Methods GET = iota POST = iota )
Variables ¶
var ( // defaults DefaultBlacklist = NewBlacklist() // errors HostnameBlacklisted = errors.New("This hostname has been blacklisted.") SourceAddressBlacklisted = errors.New("This source address has been blacklisted.") )
var ( // defaults DefaultHttpClient = retryablehttp.NewClient() // errors UnknownMethodError = errors.New("Unknown method for proxy request") )
var (
DefaultBlacklistJSONFile = "./proxy/blacklist.json"
)
Functions ¶
This section is empty.
Types ¶
type Blacklist ¶
Blacklist is a type which handles marking if a `Request` should not be processed. This most often happens based on hostname or source ip.
See `DefaultBacklist` for a shared instance
func NewBlacklist ¶
func NewBlacklist() Blacklist
func NewEmptyBlacklist ¶
func NewEmptyBlacklist() Blacklist
NewEmptyBlacklist returns an empty instance of EmptyBlacklist
func NewJSONBlacklist ¶
NewJSONBlacklist returns a defaulted instance of the `blacklist.json` file parsed.
func NewJSONBlacklistFromFile ¶
NewJSONBlacklistFromFile reads the given file and returns a `JSONBlacklist` instance.
type EmptyBlacklist ¶
type EmptyBlacklist struct {
Blacklist
}
EmptyBlacklist allows all requests through. This isn't recommended for most deployments because it offers no prevention of clients or requests.
However, right now it is used when there is an error loading another blacklist.
func (EmptyBlacklist) IsBlacklisted ¶
func (b EmptyBlacklist) IsBlacklisted(req Request) *error
type HTMLTransformer ¶
type HTMLTransformer struct {
Transformer
}
type JSONBlacklist ¶
type JSONBlacklist struct { Blacklist // contains filtered or unexported fields }
JSONBlacklist represents a blacklist that's read from a JSON blob from the local filesystem.
func (JSONBlacklist) IsBlacklisted ¶
func (b JSONBlacklist) IsBlacklisted(req Request) *error
type JSONBlacklistData ¶
type JSONBlacklistData struct { Hostnames []string `json:"hostnames"` SourceIPs []string `json:"sourceIPs"` }
JSONBlacklistData contains the json structure of the blacklist file to read and return inside the JSONBlacklist.
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
A Proxy is a shared interface for making requests it is supposed to be shared across goroutines and also will perform changes to the request and response in accordance to this proxy's requirements (headers, response parsing / transforms, etc).
Usage
var DefaultProxy := NewProxy() res, err := DefaultProxy.Get("http://example.com")
type Request ¶
type Request struct { URL url.URL Method int SourceAddress net.IP // contains filtered or unexported fields }
Request holds onto the information from the requestor to make the request on their behalf. Often we want to bring in as little information as possible from them.
There are a few options along the request to be included for metrics and performance monitoring.
type Response ¶
Response contains a buffered output of the interaction performed on behalf of the requestor.
type Transformer ¶
Transformer is a type which performs some action on a `Response` and returns another `Response`.
Typical use cases are for doing things with html or metrics.
func NewHTMLTransformer ¶
func NewHTMLTransformer() Transformer