shared

package
v0.0.0-...-62f2ae4 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2020 License: Apache-2.0 Imports: 12 Imported by: 6

Documentation

Index

Constants

View Source
const CRConfigMatchListTypeHost = `HOST`
View Source
const CRConfigMatchSetProtocolDNS = `DNS`
View Source
const CRConfigMatchSetProtocolHTTP = `HTTP`
View Source
const DefaultHTTPRoutingName = "ccr"

Variables

This section is empty.

Functions

func BuildCGRoutersFromCRConfig

func BuildCGRoutersFromCRConfig(crc *tc.CRConfig) (map[tc.CacheGroupName]DNSDSServers, error)

func BuildDSServersFromCRConfig

func BuildDSServersFromCRConfig(crc *tc.CRConfig) (map[tc.DeliveryServiceName]map[tc.CacheGroupName]DNSDSServers, error)

func BuildHTTPSecondDNSMatches

func BuildHTTPSecondDNSMatches(crc *tc.CRConfig, cdnDomain string) map[string]tc.CacheName

BuildHTTPSecondDNSMatches returns a map[fqdn]cache for the DNS FQDNs for HTTP Delivery Services.

That is, for an HTTP DS, a client 1. Makes a DNS request to TR, and gets an IP back of TR itself 2. Makes a HTTP request to TR 3. Gets a 302 redirect to a FQDN, which is cache-host.ds-name.cdn-domain. 4. Makes a DNS request for that FQDN, and gets the IP of that cache 6. Makes an HTTP request to the cache.

The matches here are for step 4, the second DNS lookup of an HTTP DS, for cache-name.ds-name.cdn-domain.

func BuildMatchesFromCRConfig

func BuildMatchesFromCRConfig(crc *tc.CRConfig, cdnDomain string) ([]DSAndMatch, []DSAndMatch, error)

BuildMatchesFromCRConfig builds DSAndMatch objects from the CRConfig Delivery Services.

Note if an error is returned, the []DSAndMatch is still valid, and contains successful matches from all DSes that didn't error. This is very important for Self-Service: if a DS is broken, it must not break other DSes.

Returns the DNS matches, HTTP DNS matches, and any errors from malformed DSes

func BuildServerAvailableFromCRStates

func BuildServerAvailableFromCRStates(crs *tc.CRStates) map[tc.CacheName]bool

func ParseIPOrCIDR

func ParseIPOrCIDR(str string) net.IP

Types

type DNSDS

type DNSDS struct {
	Name string // TODO necesary?

}

type DNSDSServer

type DNSDSServer struct {
	HostName tc.CacheName
	Addr     string         // Addr is the IPv4 or IPv6 address of the server, to be returned via DNS.
	Status   tc.CacheStatus // Status is the TO Status (Reported, ONLINE, etc) - TODO change to int, faster compare?
}

type DNSDSServers

type DNSDSServers struct {
	V4s []DNSDSServer
	V6s []DNSDSServer
}

DNSDSServers contains hash rings of servers to route to, for a certain deliveryservice and cachegroup. These have already been hashed, but will need checked for health before sending clients to them. If a server is unhealthy, the next server in the hash ring should be used instead. TODO sort by hash

type DSAndMatch

type DSAndMatch struct {
	Matches []match.DNSDSMatch
	DS      tc.DeliveryServiceName
}

type DSMatches

type DSMatches []DSAndMatch

func (DSMatches) Match

func (matches DSMatches) Match(fqdn string) (tc.DeliveryServiceName, bool)

type Shared

type Shared struct {
	// contains filtered or unexported fields
}

func NewShared

func NewShared(czf *czf.ParsedCZF, crc *tc.CRConfig, crs *tc.CRStates, certs map[string]*tls.Certificate) *Shared

NewShared creates a new Shared data object. Logs all errors, fatal and non-fatal. On fatal error, returns nil

func (*Shared) GetCDNDomain

func (sh *Shared) GetCDNDomain() string

func (*Shared) GetCRConfig

func (sh *Shared) GetCRConfig() *tc.CRConfig

GetCRConfig gets the Content Router Config (CRConfig). The returned CRConfig MUST NOT be modified.

Safe for use by handlers.

func (*Shared) GetCRStates

func (sh *Shared) GetCRStates() *tc.CRStates

func (*Shared) GetCZF

func (sh *Shared) GetCZF() *czf.ParsedCZF

GetCZF gets the Coverage Zone File (CZF). The returned CZF MUST NOT be modified.

Safe for use by handlers.

func (*Shared) GetCerts

func (sh *Shared) GetCerts() map[string]*tls.Certificate

func (*Shared) GetServerForDomain

func (sh *Shared) GetServerForDomain(addr net.Addr, zone string, domain string, v4 bool) (string, string, string, bool, bool)

GetServerForDomain returns the IP of the cache, the cache hostname, the DS name, whether to immediately return a refused (because the domain was not in the DS list), and whether to return a SERVFAIL (because there was a server error looking up the DS). Error messages are logged. TODO NXDOMAIN instead of refusing if it's a CDN domain e.g. top.comcast.net but just a nonexistent DS? TODO change to return multiple IPs, depending on DS configuration.

func (*Shared) GetServerForDomainDNS

func (sh *Shared) GetServerForDomainDNS(
	addr net.Addr,
	zone string,
	domain string,
	v4 bool,
	dsName tc.DeliveryServiceName,
) (string, string, string, bool, bool)

func (*Shared) GetServerForDomainHTTP

func (sh *Shared) GetServerForDomainHTTP(
	addr net.Addr,
	zone string,
	domain string,
	v4 bool,
	dsName tc.DeliveryServiceName,
) (string, string, string, bool, bool)

GetServerForDomainHTTP returns the server IP to return to the client, for the given HTTP DS' initial DNS request.

Because it's an HTTP DS, the initial DNS request returns the IP of a Traffic Router (which will then be requested over HTTP by the client, and which will return a 302 to a cache).

func (*Shared) GetServerName

func (sh *Shared) GetServerName(cacheName tc.CacheName, v4 bool) (string, string, string, bool, bool)

func (*Shared) SetCRConfig

func (sh *Shared) SetCRConfig(crConfig *tc.CRConfig)

func (*Shared) SetCRStates

func (sh *Shared) SetCRStates(crStates *tc.CRStates)

Jump to

Keyboard shortcuts

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