sharing

package
v1.65.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: AGPL-3.0 Imports: 54 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var UnsupportedRange = errs.Class("unsupported range")

UnsupportedRange is returned if a SimpleRanger is used in a way unsupported by a Reader.

Functions

func EventHandler added in v1.63.0

func EventHandler(h http.Handler) http.Handler

EventHandler collects event data to send to eventkit.

func SimpleRanger added in v1.21.0

func SimpleRanger(readCloser io.ReadCloser, size int64) ranger.Ranger

SimpleRanger implements a Ranger using a ReadCloser, throwing an error for unsupported Range reads.

Types

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 authclient.Config

	// 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

	// SatelliteConnectionPool is configuration for satellite RPC connection pool options.
	SatelliteConnectionPool ConnectionPoolConfig

	// ConnectionPool is configuration for RPC connection pool options.
	ConnectionPool ConnectionPoolConfig

	// 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

	// StandardRendersContent controls whether to enable standard (non-hosting)
	// requests to render content and not only download it.
	StandardRendersContent bool

	// StandardViewsHTML controls whether to serve HTML as text/html instead of
	// text/plain for standard (non-hosting) requests.
	StandardViewsHTML bool
}

Config specifies the handler configuration.

type ConnectionPoolConfig

type ConnectionPoolConfig struct {
	Capacity       int
	KeyCapacity    int
	IdleExpiration time.Duration
}

ConnectionPoolConfig is a config struct for configuring RPC connection pool options.

type DNSClient

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

func NewDNSClient(dnsServerAddr string) (*DNSClient, error)

NewDNSClient creates a DNS Client that uses the given dnsServerAddr. Currently requires that the DNS Server speaks TCP.

func (*DNSClient) Lookup

func (cli *DNSClient) Lookup(ctx context.Context, host string, recordType uint16) (_ *dns.Msg, err error)

Lookup is a helper method that never returns truncated DNS messages. The current implementation does this by doing all lookups over TCP.

type Handler

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

Handler implements the link sharing HTTP handler.

architecture: Service

func NewHandler

func NewHandler(log *zap.Logger, mapper *objectmap.IPDB, txtRecords *TXTRecords, authClient *authclient.AuthClient, tqs *TierQueryingService, inShutdown *int32, config Config) (*Handler, error)

NewHandler creates a new link sharing HTTP handler.

func (*Handler) CredentialsHandler added in v1.63.0

func (h *Handler) CredentialsHandler(next http.Handler) http.Handler

CredentialsHandler retrieves and saves credentials as a context value.

func (*Handler) ServeHTTP

func (handler *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP handles link sharing requests.

type MutexGroup

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

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 Result added in v1.44.0

type Result struct {
	SerializedAccess string
	Access           *uplink.Access
	Root             string
	TLS              bool
}

Result is the result of a query on TXTRecords.

type TXTRecordSet

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

func NewTXTRecordSet() *TXTRecordSet

NewTXTRecordSet constructs an empty TXTRecordSet.

func ResponseToTXTRecordSet

func ResponseToTXTRecordSet(resp *dns.Msg) *TXTRecordSet

ResponseToTXTRecordSet returns a TXTRecordSet from a dns Lookup response.

func (*TXTRecordSet) Add

func (set *TXTRecordSet) Add(txt string, ttl time.Duration)

Add adds a new TXT record to the record set.

func (*TXTRecordSet) Finalize

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

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

func (set *TXTRecordSet) TTL() time.Duration

TTL returns the minimum TTL seen in the reecord set.

type TXTRecords added in v1.43.0

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

TXTRecords fetches and caches linksharing DNS txt records.

func NewTXTRecords added in v1.43.0

func NewTXTRecords(maxTTL time.Duration, dns *DNSClient, auth *authclient.AuthClient) *TXTRecords

NewTXTRecords constructs a TXTRecords.

func (*TXTRecords) FetchAccessForHost added in v1.43.0

func (records *TXTRecords) FetchAccessForHost(ctx context.Context, hostname, clientIP string) (_ Result, err error)

FetchAccessForHost fetches

  • access/grant
  • root/path
  • tls

TXT records from cache or DNS when applicable.

Allows the use of Access Grants and Access Key IDs in storj-access.

clientIP is the IP of the client that originated the request.

func (*TXTRecords) FetchAccessForHostNoAccessGrant added in v1.44.0

func (records *TXTRecords) FetchAccessForHostNoAccessGrant(ctx context.Context, hostname, clientIP string) (_ Result, err error)

FetchAccessForHostNoAccessGrant is like FetchAccessForHost, but it errors if storj-access contains an Access Grant.

type TierQueryingService added in v1.44.0

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

TierQueryingService asks satellite if a APIKey belongs to a paid account.

func NewTierQueryingService added in v1.44.0

func NewTierQueryingService(identConfig identity.Config, expiration time.Duration, capacity int) (*TierQueryingService, error)

NewTierQueryingService constructs a TierQueryingService.

func (*TierQueryingService) Do added in v1.44.0

func (t *TierQueryingService) Do(ctx context.Context, uplinkAccess *uplink.Access, hostname string) (paidTier bool, err error)

Do fetches and caches the paid status of an account.

Directories

Path Synopsis
internal
signed
Package signed provides verification of requests signed with AWS Signature Version 4 machinery.
Package signed provides verification of requests signed with AWS Signature Version 4 machinery.

Jump to

Keyboard shortcuts

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