director

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2023 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdvertiseOSDF

func AdvertiseOSDF() error

Populate internal cache with origin/cache ads

func CreateAdvertiseToken

func CreateAdvertiseToken(namespace string) (string, error)

func DownloadDB

func DownloadDB(localFile string) error

func GetAdsForPath

func GetAdsForPath(reqPath string) (originNamespace NamespaceAd, originAds []ServerAd, cacheAds []ServerAd)

func GetIssuerURL

func GetIssuerURL(prefix string) (string, error)

func GetLatLong

func GetLatLong(addr netip.Addr) (lat float64, long float64, err error)

func InitializeDB

func InitializeDB()

func PeriodicCacheReload

func PeriodicCacheReload()

func PeriodicMaxMindReload

func PeriodicMaxMindReload()

func RecordAd

func RecordAd(ad ServerAd, namespaceAds *[]NamespaceAd)

func RedirectToCache

func RedirectToCache(ginCtx *gin.Context)

func RedirectToOrigin

func RedirectToOrigin(ginCtx *gin.Context)

func RegisterDirector

func RegisterDirector(router *gin.RouterGroup)

func RegisterOrigin

func RegisterOrigin(ctx *gin.Context)

func ShortcutMiddleware

func ShortcutMiddleware(defaultResponse string) gin.HandlerFunc

Middleware sends GET /foo/bar to the RedirectToCache function, as if the original request had been made to /api/v1.0/director/object/foo/bar

func UpdateLatLong

func UpdateLatLong(ad *ServerAd) error

func VerifyAdvertiseToken

func VerifyAdvertiseToken(token, namespace string) (bool, error)

Given a token and a location in the namespace to advertise in, see if the entity is authorized to advertise an origin for the namespace

Types

type CredentialGeneration

type CredentialGeneration struct {
	BasePath      string `json:"base_path"`
	Issuer        string `json:"issuer"`
	MaxScopeDepth int    `json:"max_scope_depth"`
	Strategy      string `json:"strategy"`
	VaultIssuer   string `json:"vault_issuer"`
	VaultServer   string `json:"vault_server"`
}

type Namespace

type Namespace struct {
	Caches               []Server             `json:"caches"`
	Origins              []Server             `json:"origins"`
	CredentialGeneration CredentialGeneration `json:"credential_generation"`
	DirlistHost          string               `json:"dirlisthost"`
	Path                 string               `json:"path"`
	ReadHTTPS            bool                 `json:"readhttps"`
	UseTokenOnRead       bool                 `json:"usetokenonread"`
	WritebackHost        string               `json:"writebackhost"`
}

type NamespaceAd

type NamespaceAd struct {
	RequireToken  bool
	Path          string
	Issuer        url.URL
	MaxScopeDepth uint
	Strategy      StrategyType
	BasePath      string
	VaultServer   string
}

type NamespaceJSON

type NamespaceJSON struct {
	Caches     []Server    `json:"caches"`
	Namespaces []Namespace `json:"namespaces"`
}

type OriginAdvertise

type OriginAdvertise struct {
	Name       string        `json:"name"`
	URL        string        `json:"url"`
	Namespaces []NamespaceAd `json:"namespaces"`
}

type Server

type Server struct {
	AuthEndpoint string `json:"auth_endpoint"`
	Endpoint     string `json:"endpoint"`
	Resource     string `json:"resource"`
}

type ServerAd

type ServerAd struct {
	Name      string
	AuthURL   url.URL
	URL       url.URL
	Type      ServerType
	Latitude  float64
	Longitude float64
}

func SortServers

func SortServers(addr netip.Addr, ads []ServerAd) ([]ServerAd, error)

type ServerType

type ServerType string
const (
	CacheType  ServerType = "Cache"
	OriginType ServerType = "Origin"
)

type StrategyType

type StrategyType string
const (
	OAuthStrategy StrategyType = "OAuth2"
	VaultStrategy StrategyType = "Vault"
)

type SwapMap

type SwapMap struct {
	Distance float64
	Index    int
}

type SwapMaps

type SwapMaps []SwapMap

func (SwapMaps) Len

func (me SwapMaps) Len() int

func (SwapMaps) Less

func (me SwapMaps) Less(left, right int) bool

func (SwapMaps) Swap

func (me SwapMaps) Swap(left, right int)

Jump to

Keyboard shortcuts

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