Documentation ¶
Overview ¶
Package origin implements parsing of origins and origin patterns and provides a data structure useful for representing a set of origins.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Corpus ¶
A Corpus represents a set of allowed (tuple) Web origins. The keys in this map correspond to origin schemes.
type Host ¶
type Host struct { // Value is the origin's raw host. Value string // AssumeIP indicates whether the origin's host // should be treated as an IP address. AssumeIP bool }
Host represents a host, whether it be an IP address or a domain.
type HostPattern ¶
type HostPattern struct { Value string // Value is the host pattern's raw value. Kind PatternKind // Kind is the host pattern's kind. }
A HostPattern represents a host pattern.
func (*HostPattern) IsIP ¶
func (hp *HostPattern) IsIP() bool
IsIP reports whether the host of p is an IP address (as opposed to a domain).
type Origin ¶
type Origin struct { // Scheme is the origin's scheme. Scheme string // Host is the origin's host. Host // Port is the origin's port (if any). // The zero value marks the absence of an explicit port. Port int }
Origin represents a (tuple) Web origin.
func Parse ¶
Parse parses str into an Origin structure. It is lenient insofar as it performs just enough validation for Corpus.Contains to know what to do with the resulting Origin value. In particular, the scheme and port of the resulting origin are guaranteed to be valid, but its host isn't.
type Pattern ¶
type Pattern struct { // Scheme is the origin pattern's scheme. Scheme string // Scheme is the origin pattern's host pattern. HostPattern // Port is the origin pattern's port number (if any). // 0 is used as a sentinel value marking the absence of an explicit port. // -1 is used as a sentinel value to indicate that all ports are allowed. Port int }
A Pattern represents an origin pattern.
func ParsePattern ¶
ParsePattern parses str into a Pattern structure.
func (*Pattern) HostIsEffectiveTLD ¶
HostIsEffectiveTLD, if the host of p is an effective top-level domain (eTLD), also known as public suffix, returns the eTLD in question and true. Otherwise, HostIsEffectiveTLD returns the empty string and false.
func (*Pattern) IsDeemedInsecure ¶
IsDeemedInsecure reports whether all of the following conditions are fulfilled:
- p's scheme is not https,
- p's host is not a loopback IP address,
- p's host is not localhost.
type PatternKind ¶
type PatternKind uint8
PatternKind represents the kind of a host pattern.
const ( PatternKindDomain PatternKind = iota // domain PatternKindNonLoopbackIP // non-loopback IP address PatternKindLoopbackIP // loopback IP address PatternKindSubdomains // arbitrary subdomains )