routeservice

package
v0.0.0-...-a602bb6 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2025 License: Apache-2.0, BSD-2-Clause-Views, BSD-3-Clause, + 1 more Imports: 8 Imported by: 10 modules, 25 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	HeaderKeySignature    = "X-CF-Proxy-Signature"
	HeaderKeyForwardedURL = "X-CF-Forwarded-Url"
	HeaderKeyMetadata     = "X-CF-Proxy-Metadata"
)

Variables

View Source
var ErrExpired = errors.New("route service request expired")

Functions

func BuildSignatureAndMetadata

func BuildSignatureAndMetadata(
	crypto secure.Crypto,
	signatureContents *SignatureContents,
) (string, string, error)

Types

type Metadata

type Metadata struct {
	Nonce []byte `json:"nonce"`
}

type RequestReceivedFromRouteService

type RequestReceivedFromRouteService struct {
	Metadata  string
	Signature string
	AppUrl    string
}

type RequestToSendToRouteService

type RequestToSendToRouteService struct {
	URLString      string
	ParsedUrl      *url.URL
	Signature      string
	Metadata       string
	ForwardedURL   string
	RecommendHttps bool
}

type RouteServiceConfig

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

func NewRouteServiceConfig

func NewRouteServiceConfig(
	logger *slog.Logger,
	enabled bool,
	hairpinning bool,
	hairpinningAllowlist []string,
	timeout time.Duration,
	crypto secure.Crypto,
	cryptoPrev secure.Crypto,
	recommendHttps bool,
	strictSignatureValidation bool,
) *RouteServiceConfig

func (*RouteServiceConfig) CreateRequest

func (rs *RouteServiceConfig) CreateRequest(rsUrl, forwardedUrl string) (RequestToSendToRouteService, error)

func (*RouteServiceConfig) RouteServiceEnabled

func (rs *RouteServiceConfig) RouteServiceEnabled() bool

func (*RouteServiceConfig) RouteServiceHairpinning

func (rs *RouteServiceConfig) RouteServiceHairpinning() bool

func (*RouteServiceConfig) RouteServiceHairpinningAllowlist

func (rs *RouteServiceConfig) RouteServiceHairpinningAllowlist() []string

func (*RouteServiceConfig) RouteServiceRecommendHttps

func (rs *RouteServiceConfig) RouteServiceRecommendHttps() bool

func (*RouteServiceConfig) StrictSignatureValidation

func (rs *RouteServiceConfig) StrictSignatureValidation() bool

func (*RouteServiceConfig) ValidateRequest

type SignatureContents

type SignatureContents struct {
	ForwardedUrl  string    `json:"forwarded_url"`
	RequestedTime time.Time `json:"requested_time"`
}

func SignatureContentsFromHeaders

func SignatureContentsFromHeaders(signatureHeader, metadataHeader string, crypto secure.Crypto) (SignatureContents, error)

Jump to

Keyboard shortcuts

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