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 ¶
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
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
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
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
SetBaseURL sets the server base URL that rewritten tarball URLs point at (the value hosted npm repositories use). Call it before serving requests.