Documentation ¶
Index ¶
- Variables
- func GetAction(err error, defValue string) string
- func GetStatus(err error, defValue int) int
- func WithAction(err error, action string) error
- func WithStatus(err error, statusCode int) error
- type AuthServiceConfig
- type AuthServiceResponse
- type Config
- type ConnectionPoolConfig
- type DNSClient
- type ExponentialBackoff
- type Handler
- type MutexGroup
- type TXTRecordSet
Constants ¶
This section is empty.
Variables ¶
var AuthServiceError = errs.Class("auth service")
AuthServiceError wraps all the errors returned when resolving an access key.
Functions ¶
func GetAction ¶ added in v1.5.0
GetAction returns the most recent action annotation on the error. If none is found, defValue is returned instead.
func GetStatus ¶ added in v1.5.0
GetStatus returns the most recent status code annotation on the error. If none is found, defValue is returned instead.
func WithAction ¶ added in v1.5.0
WithAction annotates an error with an action. If err is nil, does nothing.
func WithStatus ¶ added in v1.5.0
WithStatus annotates an error with a status. If err is nil, does nothing.
Types ¶
type AuthServiceConfig ¶ added in v1.5.0
type AuthServiceConfig struct { // Base url to use for the auth service to resolve access key ids BaseURL string // Authorization token used for the auth service to resolve access key ids. Token string }
AuthServiceConfig describes configuration necessary to interact with the auth service.
func (AuthServiceConfig) Resolve ¶ added in v1.5.0
func (a AuthServiceConfig) Resolve(ctx context.Context, accessKeyID string, clientIP string) (_ *AuthServiceResponse, err error)
Resolve maps an access key into an auth service response. clientIP is the IP of the client that originated the request and it's required to be sent to the Auth Service.
type AuthServiceResponse ¶ added in v1.5.0
type AuthServiceResponse struct { AccessGrant string `json:"access_grant"` Public bool `json:"public"` }
AuthServiceResponse is the struct representing the response from the auth service.
type Config ¶
type Config struct { // URLBases is the collection of potential base URLs of the link sharing // handler. The first one in the list is used to construct URLs returned // to clients. All should be a fully formed URL. URLBases []string // Templates location with html templates. Templates string // StaticSourcesPath is the path to where the web assets are located // on disk. StaticSourcesPath string // TxtRecordTTL is the duration for which an entry in the txtRecordCache is valid. TxtRecordTTL time.Duration // AuthServiceConfig contains configuration required to use the auth service to resolve // access key ids into access grants. AuthServiceConfig AuthServiceConfig // DNS Server address, for TXT record lookup DNSServer string // RedirectHTTPS enables redirection to https://. RedirectHTTPS bool // LandingRedirectTarget is the url to redirect empty requests to. LandingRedirectTarget string // uplink Config settings Uplink *uplink.Config // ConnectionPool is configuration for RPC connection pool options. ConnectionPool ConnectionPoolConfig // UseQOSAndCC indicates if congestion control and QOS settings from BackgroundDialer should be used. UseQosAndCC bool // ClientTrustedIPsList is the list of client IPs which are trusted. These IPs // are usually from gateways, load balancers, etc., which expose the service // to the public internet. Trusting them implies that the service may use // information of the request (e.g. getting client, the originator of the // request, IP from headers). ClientTrustedIPsList []string // UseClientIPHeaders indicates that the HTTP headers `Forwarded`, // `X-Forwarded-Ip`, and `X-Real-Ip` (in this order) are used to get the // client IP before falling back of getting from the client request. // // When true it reads them only from the trusted IPs (ClientTrustedIPList) if // it isn't empty. UseClientIPHeaders bool }
Config specifies the handler configuration.
type ConnectionPoolConfig ¶ added in v1.11.0
ConnectionPoolConfig is a config struct for configuring RPC connection pool options.
type DNSClient ¶ added in v1.5.0
type DNSClient struct {
// contains filtered or unexported fields
}
DNSClient is a wrapper utility around github.com/miekg/dns to make it a bit more palatable and client user friendly.
func NewDNSClient ¶ added in v1.5.0
NewDNSClient creates a DNS Client that uses the given dnsServerAddr. Currently requires that the DNS Server speaks TCP.
type ExponentialBackoff ¶ added in v1.6.0
type ExponentialBackoff struct { Max time.Duration Min time.Duration // contains filtered or unexported fields }
ExponentialBackoff keeps track of how long we should sleep between failing attempts.
func (*ExponentialBackoff) Maxed ¶ added in v1.6.0
func (e *ExponentialBackoff) Maxed() bool
Maxed returns true if the wait time has maxed out.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler implements the link sharing HTTP handler.
architecture: Service
func NewHandler ¶
NewHandler creates a new link sharing HTTP handler.
type MutexGroup ¶ added in v1.6.0
type MutexGroup struct {
// contains filtered or unexported fields
}
MutexGroup is a group of mutexes by name that attempts to only keep track of live mutexes. The zero value is okay to use.
func (*MutexGroup) Lock ¶ added in v1.6.0
func (m *MutexGroup) Lock(name string) (unlock func())
Lock will lock the mutex named by name. It will return the appropriate function to call to unlock that lock.
type TXTRecordSet ¶ added in v1.5.0
type TXTRecordSet struct {
// contains filtered or unexported fields
}
TXTRecordSet is somewhat like a url.Values wrapper type for key/value pairs defined across multiple TXT records.
TXT records can be defined in a number of ways:
- TXT sub.domain.tld "a value"
- TXT sub.domain.tld "field:value"
- TXT sub.domain.tld "another-field:value" "another-field-again:value"
This data structure ignores the first type (TXT records without a colon) but presents all of the key/value representations in a uniform manner.
func NewTXTRecordSet ¶ added in v1.5.0
func NewTXTRecordSet() *TXTRecordSet
NewTXTRecordSet constructs an empty TXTRecordSet.
func ResponseToTXTRecordSet ¶ added in v1.5.0
func ResponseToTXTRecordSet(resp *dns.Msg) *TXTRecordSet
ResponseToTXTRecordSet returns a TXTRecordSet from a dns Lookup response.
func (*TXTRecordSet) Add ¶ added in v1.5.0
func (set *TXTRecordSet) Add(txt string, ttl time.Duration)
Add adds a new TXT record to the record set.
func (*TXTRecordSet) Finalize ¶ added in v1.5.0
func (set *TXTRecordSet) Finalize()
Finalize makes all values in the TXTRecordSet deterministic, regardless of TXT record response order, by sorting the values.
func (*TXTRecordSet) Lookup ¶ added in v1.5.0
func (set *TXTRecordSet) Lookup(field string) (value string)
Lookup will return the first value named by a given field in a TXT record set. Because TXT records have length limitations, if Lookup doesn't find the field directly, it will try to concatenate fields with ordered number suffixes. For instance:
- TXT sub.domain.tld "field-3:c"
- TXT sub.domain.tld "field-1:a" "field-2:b"
will be concatenated as when "field" is looked up as "abc".
func (*TXTRecordSet) TTL ¶ added in v1.5.0
func (set *TXTRecordSet) TTL() time.Duration
TTL returns the minimum TTL seen in the reecord set.