proxy

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: AGPL-3.0 Imports: 24 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: released Maven artifacts (not maven-metadata.xml, not -SNAPSHOT files) and deb/rpm package files.

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.

Jump to

Keyboard shortcuts

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