proxy

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: AGPL-3.0 Imports: 50 Imported by: 0 modules, 0 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

Overview

Package proxy serves proxy repositories: files are fetched from the repository's upstream on first request, cached content-addressed in the blob store, recorded in proxy_cache_entries (which also backs the repository's package listing) and served from the cache until their TTL expires. When an expired entry cannot be revalidated because the upstream is down, it is served stale for up to the repository's max_stale_seconds.

Index

Constants

View Source
const (
	// DefaultMaxBody caps any single file fetched from an upstream.
	DefaultMaxBody int64 = 4 << 30 // 4 GiB

)

Variables

This section is empty.

Functions

func CleanPath added in v0.4.0

func CleanPath(p string) (string, bool)

CleanPath validates a client-supplied repository-relative path and returns it without the leading slash. Empty paths, directory paths (trailing slash), empty/dot/dot-dot segments, backslashes and control characters are refused: the path is appended to the upstream URL and must not be able to escape it.

func Immutable added in v0.4.0

func Immutable(format, key string) bool

Immutable reports whether the file at key never changes once published, so a cached copy never needs revalidation. Formats whose bodies are verified against a published digest (see fetchOpts) pin by name alone; the three that have no such check here (Maven, deb, rpm) pin only under layouts whose file names are never reused, and everything else is cached for the repository TTL so a wrong copy is replaced on revalidation:

  • maven: released artifacts, not maven-metadata*.xml, archetype-catalog.xml (both are regenerated in place) or -SNAPSHOT files; a checksum or signature file (.md5 .sha1 .sha256 .sha512 .asc) is as immutable as the file it belongs to.
  • deb: .deb/.udeb below a pool/ directory (the Debian archive layout, where a file name is never reused); the same names in a flat repository, where a publisher may overwrite a package, use the repository TTL.
  • rpm: .rpm below a Packages/ directory (the layout of Fedora, CentOS, RHEL and most vendor repositories, whose NEVRA-named files are not rebuilt in place); flat or other layouts use the repository TTL. No cheap integrity signal (the repodata checksums are not checked by this proxy) exists to pin the rest.

Types

type Service added in v0.4.0

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

Service fetches and caches upstream files for proxy repositories.

func NewService added in v0.4.0

func NewService(log *logger.Logger, db database.Database, blobStore storage.BlobStore) *Service

NewService creates the proxy service. Upstream requests use an SSRF-safe client: blocked destination addresses are refused at dial time and on every redirect hop.

func (*Service) Serve added in v0.4.0

func (s *Service) Serve(w http.ResponseWriter, r *http.Request, repo *models.Repository, relPath string)

Serve answers a GET/HEAD for relPath (the path below the repository root) of proxy repo.

func (*Service) ServeOCI added in v0.6.0

func (s *Service) ServeOCI(w http.ResponseWriter, r *http.Request, repo *models.Repository, req ocipath.Request)

ServeOCI answers a request under /v2/ for the docker proxy repository repo: manifests and blobs are pulled through (and cached), tag and referrer listings are passed through, anything that would write is refused. req is the parsed /v2/<repo>/<image>/... path.

func (*Service) SetBaseURL added in v0.6.0

func (s *Service) SetBaseURL(baseURL string)

SetBaseURL sets the server base URL that rewritten tarball URLs point at (the value hosted npm repositories use). Call it before serving requests.

Jump to

Keyboard shortcuts

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