Documentation ¶
Overview ¶
Package origin implements parsing of origins and origin patterns and provides data structures 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 is the host pattern's raw value. Value string // Kind is the host pattern's kind. Kind PatternKind }
func (*HostPattern) IsIP ¶
func (p *HostPattern) IsIP() bool
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 a raw Web origin 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 ¶ added in v0.9.0
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 }
func ParsePattern ¶ added in v0.9.0
func (*Pattern) HostIsEffectiveTLD ¶ added in v0.9.0
func (*Pattern) IsDeemedInsecure ¶ added in v0.9.0
type PatternKind ¶ added in v0.9.0
type PatternKind uint8
PatternKind represents the kind of a host pattern.
const ( // domain PatternKindDomain PatternKind = iota // non-loopback IP address PatternKindNonLoopbackIP // loopback IP address PatternKindLoopbackIP // arbitrary subdomains of depth one or more PatternKindSubdomains )