Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type T ¶
type T struct {
// AllowedUrl defines the list of URL patterns that are explicitly
// permitted by the policy regardless BlockedUrl setting.
AllowedUrl []string
// BlockedURL define the URLs patterns that are explicitly disallowed by the policy.
// Empty value is treated the same as a []string{"*"} (all URLs are blocked
// unless explicitly allowed).
BlockedUrl []string
// AllowedCIDR defines CIDR blocks explicitly allowed by the policy,
// overriding any entries in BlockedCIDR.
AllowedCIDR []string
// BlockedCIDR defines a list of CIDR blocks that are explicitly disallowed
// by the policy for incoming requests.
BlockedCIDR []string
}
func New ¶
New creates and returns a new instance of T initialized with the provided whitelist URLs and blocked CIDRs.
func (*T) Check ¶
Check validates the given rawURL, resolves its IP, determines its port, and ensures it complies with set rules. The accepted ip, port is returned to prevent TOCTOU bugs.
func (*T) CheckRedirect ¶
CheckRedirect validates the target of a redirect served by a url Check accepted: its addresses are held to the cidr lists, as every request is, and its url is not held to the url lists. The url lists say which sources an operator trusts, by the url a configuration names; where that source keeps its content, as the storage a release download redirects to, is the source's to say. An address blocked is refused whatever redirects to it.