sharing

package
v1.77.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: AGPL-3.0 Imports: 63 Imported by: 0

Documentation

Index

Constants

View Source
const FilePlaceholder = ".file_placeholder"

FilePlaceholder is the name of a prefixed empty object which is created when a user creates a folder in the satellite UI, so folders are visible without user objects. https://github.com/storj/storj/blob/4545aacea30a4ed9fd5dd5b978656590164d8ffc/web/satellite/src/store/modules/objectBrowserStore.ts#L646

Variables

View Source
var (

	// ErrInvalidListPageLimit is an error returned when list page limit is not greater than zero.
	ErrInvalidListPageLimit = errs.New("list page limit must be greater than zero")

	// Assets contains filesystems for HTML templates and static web assets.
	Assets = AssetsFS{}
)
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

func EventHandler(h http.Handler) http.Handler

EventHandler collects event data to send to eventkit.

func SimpleRanger

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 AssetsFS added in v1.77.0

type AssetsFS struct {
	Templates fs.FS
	Static    fs.FS
}

AssetsFS contains filesystems for HTML templates and static web assets.

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

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

	// Maximum number of paths to list on a single page.
	ListPageLimit int
}

Config specifies the handler configuration.

type ConnectionPoolConfig

type ConnectionPoolConfig struct {
	Capacity       int
	KeyCapacity    int
	IdleExpiration time.Duration
	MaxLifetime    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) LookupTXTRecordSet added in v1.77.0

func (cli *DNSClient) LookupTXTRecordSet(ctx context.Context, host string) (_ *TXTRecordSet, err error)

LookupTXTRecordSet fetches record set from the specified host.

func (*DNSClient) ValidateCNAME added in v1.77.0

func (cli *DNSClient) ValidateCNAME(ctx context.Context, name string, bases []*url.URL) (err error)

ValidateCNAME checks name has a CNAME record with a value of one of the public URL bases.

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

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

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

Result is the result of a query on TXTRecords.

type StaticDNSClient added in v1.77.0

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

StaticDNSClient provides static responses to dns queries.

func ParseStaticDNSClientFromZoneFile added in v1.77.0

func ParseStaticDNSClientFromZoneFile(data []byte) (*StaticDNSClient, error)

ParseStaticDNSClientFromZoneFile parses zone file for txt records.

func (*StaticDNSClient) LookupTXTRecordSet added in v1.77.0

func (cli *StaticDNSClient) LookupTXTRecordSet(ctx context.Context, host string) (_ *TXTRecordSet, err error)

LookupTXTRecordSet fetches record set from the specified host.

func (*StaticDNSClient) ValidateCNAME added in v1.77.0

func (cli *StaticDNSClient) ValidateCNAME(ctx context.Context, host string, bases []*url.URL) (err error)

ValidateCNAME checks host has a CNAME record with a value of one of the public URL bases.

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

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

TXTRecords fetches and caches linksharing DNS txt records.

func NewTXTRecords

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

NewTXTRecords constructs a TXTRecords.

func (*TXTRecords) FetchAccessForHost

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

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

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

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

func NewTierQueryingService

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

NewTierQueryingService constructs a TierQueryingService.

func (*TierQueryingService) Do

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