proxy

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RoutePrefix added in v1.0.0

func RoutePrefix(ctx context.Context) string

RoutePrefix returns the registry prefix the mux stripped from the request path ("npm", "yarn", ...), or "" for a request that did not come through the mux. Links a handler writes back to its client must carry it: one handler serves several prefixes.

Types

type Handler

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

Handler is the main HTTP handler: intercepts downloads, applies SC filter, caches, proxies.

func NewHandler

func NewHandler(cfg HandlerConfig) *Handler

NewHandler creates a new ProxyHandler.

func (*Handler) ServeHTTP

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

type HandlerConfig

type HandlerConfig struct {
	Adapter    gate.RegistryAdapter
	Filter     gate.SCFilter
	Cache      gate.ArtifactCache
	Logger     zerolog.Logger
	CVEScanner gate.CVEScanner    // optional; nil disables CVE scanning
	Policy     gate.PolicyDecider // optional; nil allows all when CVEScanner is set
	AVScanner  gate.AVScanner     // optional; nil disables malware scanning
	Recorder   gate.Recorder      // optional; nil disables telemetry
	// CVERecheckTTL / MalwareRecheckTTL: a cache hit whose respective check is
	// older than this re-runs that gate before serving (0 disables). A scanner
	// failure serves the stale entry and leaves the timestamp untouched.
	CVERecheckTTL     time.Duration
	MalwareRecheckTTL time.Duration
	// MetadataFilterMaxMB caps the decompressed size of a metadata document the
	// handler buffers to hide versions policy would block at download time and
	// to point its download links at the proxy. A larger document fails the
	// request. Zero means no cap.
	MetadataFilterMaxMB int
	// PublicBase derives the client-facing base URL written into rewritten
	// metadata links. Optional: nil uses the request's own Host and TLS state
	// and trusts no forwarding header.
	PublicBase *httpx.PublicBaseResolver
	// HTTPClient downloads artifacts and serves transparent proxy requests.
	// Optional; nil uses a private client with a 60s timeout. Pass a client whose
	// transport caps per-host concurrency (shared with the adapters) so artifact
	// downloads count against the same upstream rate limit as metadata fetches.
	HTTPClient *http.Client
	// IndexMaxMB caps a decoded index document an IndexRewriter adapter's
	// requests may return (0 = 64). An index over the cap fails the request:
	// it cannot be served unrewritten.
	IndexMaxMB int
	// MaxArtifactBytes caps a downloaded artifact (0 = unlimited). A larger
	// one is refused before it can fill the cache volume.
	MaxArtifactBytes int64
	// TempDir holds artifact downloads while they are checked. Empty uses
	// os.TempDir(); point it at the cache volume so multi-GB downloads do not
	// land on the container's root filesystem.
	TempDir string
	// Throttles reports upstream hosts in a post-throttle cooldown (the shared
	// transport's circuit breaker). Optional: it only supplies Retry-After and
	// the 429-versus-503 choice for circuit-open mirrors on a throttled answer.
	Throttles upstream.ThrottleLookup
}

HandlerConfig groups dependencies for the ProxyHandler.

type Mux

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

Mux routes requests to per-registry handlers by URL path prefix. A request to /<prefix>/... is dispatched to the handler registered for <prefix> with the prefix stripped, so each registry adapter sees the same paths it would without the proxy wrapper.

func NewMux

func NewMux(handlers map[string]*Handler, raw map[string]http.Handler, logger zerolog.Logger) *Mux

NewMux creates a Mux. raw may be nil; it holds prefixes served by a plain http.Handler (e.g. the Docker V2 proxy).

func (*Mux) ServeHTTP

func (m *Mux) ServeHTTP(w http.ResponseWriter, r *http.Request)

Directories

Path Synopsis
Package adapters implements per-registry RegistryAdapter implementations.
Package adapters implements per-registry RegistryAdapter implementations.
Package dockerproxy implements a pull-through Docker Registry V2 proxy that gates images on Trivy (CVE/secrets) and ClamAV (signature malware) before serving them.
Package dockerproxy implements a pull-through Docker Registry V2 proxy that gates images on Trivy (CVE/secrets) and ClamAV (signature malware) before serving them.

Jump to

Keyboard shortcuts

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