catalog

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package catalog loads and validates the target lists (targets/*.yaml).

Index

Constants

View Source
const (
	TestDNS      = "dns"
	TestTCP      = "tcp"
	TestTLS      = "tls"
	TestTLSNoSNI = "tls_nosni"
	TestHTTP     = "http"
	TestQUIC     = "quic"
	TestECH      = "ech"
)

Test names.

Variables

This section is empty.

Functions

This section is empty.

Types

type Catalog

type Catalog struct {
	Categories []*Category
	DNS        *DNSConfig
	Whitelist  *WhitelistConfig
}

Catalog is the full set of loaded lists.

func Load

func Load(fsys fs.FS) (*Catalog, error)

Load reads every *.yaml from fsys (non-recursive).

func LoadWithOverrides

func LoadWithOverrides(base fs.FS, dir string) (*Catalog, error)

LoadWithOverrides loads the embedded lists and then the *.yaml files of dir; a file in dir replaces the embedded file of the same name.

func (*Catalog) Category

func (c *Catalog) Category(id string) *Category

Category returns a category by id.

func (*Catalog) Select

func (c *Catalog) Select(sel Selection) ([]Target, []*Category, error)

Select returns the targets matching sel. Without explicit categories or targets, every default category is used. Baseline targets are always included so throttling can be judged.

func (*Catalog) Target

func (c *Catalog) Target(id string) (*Target, *Category)

Target returns a target by id.

func (*Catalog) Validate

func (c *Catalog) Validate() error

Validate checks ids, hosts, tests and references for consistency.

type Category

type Category struct {
	Version int      `yaml:"version"`
	Kind    string   `yaml:"kind"`
	ID      string   `yaml:"category"`
	Title   Text     `yaml:"title"`
	Default bool     `yaml:"default"`
	Order   int      `yaml:"order"`
	Consent Text     `yaml:"consent"`
	Refs    []string `yaml:"refs"`
	Targets []Target `yaml:"targets"`

	File string `yaml:"-"`
}

Category is one targets/*.yaml file with `targets:`.

type DNSConfig

type DNSConfig struct {
	Version       int            `yaml:"version"`
	Kind          string         `yaml:"kind"`
	ID            string         `yaml:"category"`
	Title         Text           `yaml:"title"`
	Default       bool           `yaml:"default"`
	Resolvers     []Resolver     `yaml:"resolvers"`
	ReferenceDoH  []string       `yaml:"doh_reference_order"`
	ProbeDomains  []ProbeDomain  `yaml:"probe_domains"`
	Interceptions []Interception `yaml:"interception"`
}

DNSConfig is dns.yaml.

func (*DNSConfig) Resolver

func (d *DNSConfig) Resolver(id string) *Resolver

Resolver returns the resolver with the given id.

type Endpoint

type Endpoint struct {
	Host         string   `yaml:"host"`
	Addr         string   `yaml:"addr"`
	Port         int      `yaml:"port"`
	Path         string   `yaml:"path"`
	QUIC         bool     `yaml:"quic"`
	HTTP80       bool     `yaml:"http80"`
	Tests        []string `yaml:"tests"`
	QUICVersions []int    `yaml:"quic_versions"`
	Note         string   `yaml:"note"`
}

Endpoint is one host or address of a target.

func (Endpoint) EffectivePath

func (e Endpoint) EffectivePath() string

EffectivePath returns the HTTP path ("/" by default).

func (Endpoint) EffectivePort

func (e Endpoint) EffectivePort() int

EffectivePort returns the configured port (443 by default).

func (Endpoint) EffectiveQUICVersions

func (e Endpoint) EffectiveQUICVersions() []int

EffectiveQUICVersions returns the QUIC versions to probe ([1] by default).

func (Endpoint) EffectiveTests

func (e Endpoint) EffectiveTests() []string

EffectiveTests returns the tests that run for this endpoint.

func (Endpoint) Has

func (e Endpoint) Has(test string) bool

Has reports whether the endpoint runs the given test.

func (Endpoint) Name

func (e Endpoint) Name() string

Name returns the host, or the IP for address endpoints.

type Interception

type Interception struct {
	ID       string `yaml:"id"`
	Resolver string `yaml:"resolver"`
	QName    string `yaml:"qname"`
	QClass   string `yaml:"qclass"`
	QType    string `yaml:"qtype"`
	Expect   string `yaml:"expect"`
}

Interception is a transparent DNS proxy probe.

type ProbeDomain

type ProbeDomain struct {
	Name string `yaml:"name"`
	Role string `yaml:"role"`
	Note string `yaml:"note"`
}

ProbeDomain is a domain compared across resolvers.

type Resolver

type Resolver struct {
	ID   string   `yaml:"id"`
	Name Text     `yaml:"name"`
	Type string   `yaml:"type"`
	Role string   `yaml:"role"`
	Refs []string `yaml:"refs"`
	UDP  []string `yaml:"udp"`
	DoT  *struct {
		Host string `yaml:"host"`
		Addr string `yaml:"addr"`
	} `yaml:"dot"`
	DoH string `yaml:"doh"`
}

Resolver is a DNS resolver definition from dns.yaml.

type Selection

type Selection struct {
	Categories []string
	Targets    []string
	All        bool // include opt-in categories
}

Selection describes which targets to scan.

type Target

type Target struct {
	ID          string     `yaml:"id"`
	Name        string     `yaml:"name"`
	Role        string     `yaml:"role"`
	Expect      string     `yaml:"expect"`
	Since       string     `yaml:"since"`
	Refs        []string   `yaml:"refs"`
	Notes       Text       `yaml:"notes"`
	ThrottleURL string     `yaml:"throttle_url"`
	Verified    *bool      `yaml:"verified"`
	Endpoints   []Endpoint `yaml:"endpoints"`

	// Category is filled in by the loader.
	Category string `yaml:"-"`
}

Target is one service.

func (Target) IsBaseline

func (t Target) IsBaseline() bool

IsBaseline reports whether the target is a domestic speed reference.

type Text

type Text map[string]string

Text is a localised string map ({ru: ..., en: ...}).

func (Text) Get

func (t Text) Get(lang string) string

Get returns the text for lang, falling back to English and then to any value.

func (*Text) UnmarshalYAML

func (t *Text) UnmarshalYAML(n *yaml.Node) error

UnmarshalYAML accepts both a plain string and a {lang: text} map.

type WhitelistConfig

type WhitelistConfig struct {
	Version    int      `yaml:"version"`
	Kind       string   `yaml:"kind"`
	ID         string   `yaml:"category"`
	Title      Text     `yaml:"title"`
	Default    bool     `yaml:"default"`
	Refs       []string `yaml:"refs"`
	Thresholds struct {
		DomesticOK float64 `yaml:"domestic_ok"`
		ForeignMax float64 `yaml:"foreign_max"`
		Dead       float64 `yaml:"dead"`
		Normal     float64 `yaml:"normal"`
	} `yaml:"thresholds"`
	Domestic []WhitelistHost `yaml:"domestic"`
	Foreign  []WhitelistHost `yaml:"foreign"`
}

WhitelistConfig is whitelist.yaml.

type WhitelistHost

type WhitelistHost struct {
	Host string `yaml:"host"`
	Org  string `yaml:"org"`
	CA   string `yaml:"ca"`
}

WhitelistHost is one host of whitelist.yaml.

Jump to

Keyboard shortcuts

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