Documentation
¶
Overview ¶
Package mirava is the entrypoint for mirava-core: a library for probing package and container mirrors — whether they respond, how fast they move bytes, whether a package is present, and (for the website) a direct download URL.
Construct once with New, then use Mirava.Prober for the uniform per-ecosystem interface:
m := mirava.New() p, _ := m.Prober(mirava.TypeApt) res, err := p.Status(ctx, "https://archive.ubuntu.com/ubuntu/")
Index ¶
- Constants
- Variables
- func CustomDNS(addr string) dns.Provider
- func CustomDNSDoH(url string) dns.Provider
- func WithDNSProviders(ps ...dns.Provider) func(*options)
- func WithHTTPClient(c *http.Client) func(*options)
- func WithLogger(l *slog.Logger) func(*options)
- type AptQueryOptions
- type DownloadResult
- type Duration
- type Envelope
- type Mirava
- type MirrorType
- type PackageQuery
- type PackageResult
- type ParseError
- type Prober
- type Progress
- type RequestError
- type ResultDetail
- type SpeedError
- type SpeedOptions
- type SpeedResult
- type StatusError
- type StatusResult
- type ValidationError
Constants ¶
const ( TypeApt = core.TypeApt TypeYum = core.TypeYum TypeDnf = core.TypeDnf TypePacman = core.TypePacman TypeNpm = core.TypeNpm TypeGo = core.TypeGo TypeCargo = core.TypeCargo TypePypi = core.TypePypi TypeNuget = core.TypeNuget TypeDocker = core.TypeDocker TypeComposer = core.TypeComposer )
Mirror type constants.
const Version = "0.4.6"
Version is the latest tagged release of mirava-core. Consumers display it (e.g. a CLI version banner); keep in sync with the git tag.
Variables ¶
var ( ErrNotFound = core.ErrNotFound ErrTimeout = core.ErrTimeout ErrInvalidMirror = core.ErrInvalidMirror ErrUnreachable = core.ErrUnreachable ErrNotImplemented = core.ErrNotImplemented )
Sentinel errors.
var ( DNSSystem = dns.System{} DNSCloudflareUDP = dns.CloudflareUDP DNSCloudflareDoH = dns.CloudflareDoH DNSCloudflareDoT = dns.CloudflareDoT DNSGoogleUDP = dns.GoogleUDP DNSGoogleDoH = dns.GoogleDoH DNSQuad9UDP = dns.Quad9UDP DNSQuad9DoH = dns.Quad9DoH DNSOpenDNSUDP = dns.OpenDNSUDP DNSAdGuardUDP = dns.AdGuardUDP DNSAdGuardDoH = dns.AdGuardDoH )
DNS provider shorthands for the preset public resolvers.
var SpeedRating = core.SpeedRating
SpeedRating maps MB/s to a coarse label (Slow/Average/Good/Excellent).
Functions ¶
func CustomDNSDoH ¶
CustomDNSDoH builds a custom DoH provider from a RFC 8484 endpoint URL.
func WithDNSProviders ¶
WithDNSProviders sets the default providers used by Mirava.DNSProbe. Nil uses the dns package defaults (System, Cloudflare, Google, Quad9).
func WithHTTPClient ¶
WithHTTPClient overrides the shared HTTP client.
func WithLogger ¶
WithLogger sets the diagnostic logger; diagnostics are discarded by default.
Types ¶
type AptQueryOptions ¶ added in v0.4.1
type AptQueryOptions = apt.QueryOptions
AptQueryOptions narrows an apt package lookup. It is an alias for apt.QueryOptions, re-exported because ecosystem-specific option structs live in internal/ packages that other modules cannot import: callers pass &AptQueryOptions{...} as PackageQuery.Options when querying apt mirrors.
type DownloadResult ¶
type DownloadResult = core.DownloadResult
Re-exported API. The interface, result types and errors live in internal/core and are re-exported here as the public surface.
type Duration ¶
Re-exported API. The interface, result types and errors live in internal/core and are re-exported here as the public surface.
type Envelope ¶
Re-exported API. The interface, result types and errors live in internal/core and are re-exported here as the public surface.
type Mirava ¶
type Mirava struct {
Apt *apt.Service
AptDebian *apt.Service
AptUbuntu *apt.Service
Npm *npm.Service
PyPi *pypi.Service
Docker *docker.Service
Pacman *pacman.Service
Go *gomod.Service
Cargo *cargo.Service
Composer *composer.Service
// contains filtered or unexported fields
}
Mirava bundles the ecosystem backends behind one configuration. Create it once with New; the zero value is not usable.
func New ¶
func New(opts ...func(*options)) *Mirava
New builds a Mirava instance with defaults (shared HTTP client, silent logger, memory+disk cache) overridden by opts.
func (*Mirava) DNSProbe ¶
func (m *Mirava) DNSProbe(ctx context.Context, mirror string, providers ...dns.Provider) (*dns.ProbeResult, error)
DNSProbe resolves the mirror's hostname through each configured DNS provider and checks TCP reachability to the mirror via each provider's IPs. Diverging answers across providers suggest poisoning, filtering or broken geo-DNS.
Pass explicit providers to override the defaults (see WithDNSProviders).
type MirrorType ¶
type MirrorType = core.MirrorType
Re-exported API. The interface, result types and errors live in internal/core and are re-exported here as the public surface.
type PackageQuery ¶
type PackageQuery = core.PackageQuery
Re-exported API. The interface, result types and errors live in internal/core and are re-exported here as the public surface.
type PackageResult ¶
type PackageResult = core.PackageResult
Re-exported API. The interface, result types and errors live in internal/core and are re-exported here as the public surface.
type ParseError ¶
type ParseError = core.ParseError
Re-exported API. The interface, result types and errors live in internal/core and are re-exported here as the public surface.
type Prober ¶
Re-exported API. The interface, result types and errors live in internal/core and are re-exported here as the public surface.
type Progress ¶
Re-exported API. The interface, result types and errors live in internal/core and are re-exported here as the public surface.
type RequestError ¶
type RequestError = core.RequestError
Re-exported API. The interface, result types and errors live in internal/core and are re-exported here as the public surface.
type ResultDetail ¶
type ResultDetail = core.ResultDetail
Re-exported API. The interface, result types and errors live in internal/core and are re-exported here as the public surface.
type SpeedError ¶
type SpeedError = core.SpeedError
Re-exported API. The interface, result types and errors live in internal/core and are re-exported here as the public surface.
type SpeedOptions ¶
type SpeedOptions = core.SpeedOptions
Re-exported API. The interface, result types and errors live in internal/core and are re-exported here as the public surface.
type SpeedResult ¶
type SpeedResult = core.SpeedResult
Re-exported API. The interface, result types and errors live in internal/core and are re-exported here as the public surface.
type StatusError ¶
type StatusError = core.StatusError
Re-exported API. The interface, result types and errors live in internal/core and are re-exported here as the public surface.
type StatusResult ¶
type StatusResult = core.StatusResult
Re-exported API. The interface, result types and errors live in internal/core and are re-exported here as the public surface.
type ValidationError ¶
type ValidationError = core.ValidationError
Re-exported API. The interface, result types and errors live in internal/core and are re-exported here as the public surface.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
mirrorscan
command
Command mirrorscan runs mirava-core's Prober logic against a parsed mirror catalog (by ecosystem) and prints a per-mirror report.
|
Command mirrorscan runs mirava-core's Prober logic against a parsed mirror catalog (by ecosystem) and prints a per-mirror report. |
|
internal
|
|
|
apt
Package apt implements the apt mirror backend: Debian and Ubuntu repositories.
|
Package apt implements the apt mirror backend: Debian and Ubuntu repositories. |
|
cache
Package cache provides the storage layer behind mirava-core probes: a small interface implemented by a bounded in-memory LRU and an atomic-write disk layer, plus a singleflight guard so concurrent lookups share one upstream fetch.
|
Package cache provides the storage layer behind mirava-core probes: a small interface implemented by a bounded in-memory LRU and an atomic-write disk layer, plus a singleflight guard so concurrent lookups share one upstream fetch. |
|
cargo
Package cargo implements the Cargo sparse-index mirror backend.
|
Package cargo implements the Cargo sparse-index mirror backend. |
|
composer
Package composer implements the Composer / Packagist mirror backend.
|
Package composer implements the Composer / Packagist mirror backend. |
|
dns
Package dns implements DNS-provider-based mirror testing: resolve a mirror's hostname through different resolvers (UDP, DoH, DoT, or the system) and probe connectivity to the mirror via each provider's IPs.
|
Package dns implements DNS-provider-based mirror testing: resolve a mirror's hostname through different resolvers (UDP, DoH, DoT, or the system) and probe connectivity to the mirror via each provider's IPs. |
|
docker
Package docker implements the OCI / Docker registry mirror backend.
|
Package docker implements the OCI / Docker registry mirror backend. |
|
gomod
Package gomod implements the Go module proxy (GOPROXY protocol) backend.
|
Package gomod implements the Go module proxy (GOPROXY protocol) backend. |
|
httpx
Package httpx provides shared HTTP plumbing for mirava-core backends: URL joining, the shared default client, User-Agent construction, and a single speed-measurement loop used by every backend's Speed probe.
|
Package httpx provides shared HTTP plumbing for mirava-core backends: URL joining, the shared default client, User-Agent construction, and a single speed-measurement loop used by every backend's Speed probe. |
|
npm
Package npm implements the npm registry mirror backend.
|
Package npm implements the npm registry mirror backend. |
|
pacman
Package pacman implements the Arch Linux mirror backend.
|
Package pacman implements the Arch Linux mirror backend. |
|
pypi
Package pypi implements the PyPI (PEP 503 simple index) mirror backend.
|
Package pypi implements the PyPI (PEP 503 simple index) mirror backend. |