broker

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: MIT Imports: 15 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

Index

Constants

View Source
const DefaultUpdateURL = "https://raw.githubusercontent.com/drumandbytes/eraser/main/data/brokers.yaml"

DefaultUpdateURL is where `update-brokers` and the web UI's update button fetch the current list from. Every 1.x release reads it, so the format may only gain optional fields (docs/stability.md).

View Source
const MinSaneBrokerCount = 200

MinSaneBrokerCount is the floor below which the main broker database is assumed to be truncated or corrupt rather than legitimately small. Used both by `update-brokers` (before replacing the local copy) and by Validate.

View Source
const MinVerifiedBrokerCount = 20

MinVerifiedBrokerCount is the equivalent floor for the hand-built, registry-sourced verified list (data/brokers-verified.yaml), which is deliberately a fraction of the size of the main list.

Variables

This section is empty.

Functions

func CurrentCount added in v1.2.0

func CurrentCount() int

CurrentCount is the size of the published list (without the user's own entries), 0 if it can't load.

func LocalPath added in v1.2.0

func LocalPath() string

LocalPath holds brokers the user added or corrected themselves. It's kept apart from UserBrokersPath because update-brokers replaces that file wholesale - additions written there were silently lost on the next update. Entries are merged over whichever list is in use (except an explicit --brokers file); same id = the local entry wins.

func NewID added in v1.2.0

func NewID(name string) string

NewID derives an id from a broker name, folding diacritics so EU company names stay readable ("Corner Shop OÜ" -> "corner-shop-ou").

func SaveLocal added in v1.2.0

func SaveLocal(b Broker) error

SaveLocal adds b to the user's own entries, replacing one with the same id.

func UserBrokersPath

func UserBrokersPath() string

UserBrokersPath is where `eraser update-brokers` writes a refreshed copy of the list; Load() prefers it over the embedded default when it exists.

Types

type Broker

type Broker struct {
	ID        string `yaml:"id"`
	Name      string `yaml:"name"`
	Email     string `yaml:"email"`
	Website   string `yaml:"website,omitempty"`
	OptOutURL string `yaml:"opt_out_url,omitempty"`
	Region    string `yaml:"region"`             // "us", "eu", "global"
	Category  string `yaml:"category,omitempty"` // "people-search", "marketing", "background-check", etc.
	Notes     string `yaml:"notes,omitempty"`
}

func (Broker) Problems added in v1.2.0

func (b Broker) Problems() []string

Problems lists what's wrong with one entry's fields (not id uniqueness, which needs the whole list). Shared by Validate and the add-broker paths.

type BrokerDatabase

type BrokerDatabase struct {
	Brokers []Broker `yaml:"brokers"`
}

func Load

func Load(overridePath string) (*BrokerDatabase, error)

Load resolves the broker database from, in order: overridePath (the --brokers flag) when set, then ~/.eraser/brokers.yaml when it exists, then the copy embedded in the binary. Except for an explicit --brokers file, the user's own entries (LocalPath) are merged on top. There is no implicit ./data or <exe-dir>/data scanning any more.

func LoadFromFile

func LoadFromFile(path string) (*BrokerDatabase, error)

LoadFromFile parses a broker YAML file from an explicit path.

func LoadList added in v0.7.0

func LoadList(overridePath, configPath, listName string) (*BrokerDatabase, error)

LoadList resolves the broker database for send-family commands: --brokers, then options.broker_file, then the embedded verified list for "verified", else Load(). audit, guides, update-brokers and reply processing call Load directly.

func LoadLocal added in v1.2.0

func LoadLocal() (*BrokerDatabase, error)

LoadLocal returns the user's own entries; a missing file is an empty list.

func Parse

func Parse(raw []byte) (*BrokerDatabase, error)

Parse unmarshals and sanitizes a broker YAML document. Used to validate a freshly downloaded list before it replaces the local copy.

func Validate

func Validate(raw []byte, minCount int) (*BrokerDatabase, error)

Validate checks raw broker YAML (min count, id/name, unique ids, known regions, plausible emails, http(s) URLs) without sanitizing, and reports every problem in one error. CI runs it; the parsed db is returned too.

func (*BrokerDatabase) Add

func (db *BrokerDatabase) Add(broker Broker) error

func (*BrokerDatabase) Filter

func (db *BrokerDatabase) Filter(regions []string, excluded []string, excludedCategories []string) []Broker

Filter returns brokers matching the given regions (empty means "all"), excluding any broker whose ID/name is in excluded or whose category (case-insensitive) is in excludedCategories - e.g. "requires-id" to skip brokers that demand a government ID document before acting on a request.

func (*BrokerDatabase) FindByEmail

func (db *BrokerDatabase) FindByEmail(email string) *Broker

FindByEmail finds a broker by their email address

func (*BrokerDatabase) FindByID

func (db *BrokerDatabase) FindByID(id string) *Broker

func (*BrokerDatabase) FindByName added in v1.2.0

func (db *BrokerDatabase) FindByName(name string) *Broker

FindByName finds a broker by name, ignoring case and surrounding spaces.

func (*BrokerDatabase) MarkEmailUnreachable

func (db *BrokerDatabase) MarkEmailUnreachable(email, reason string) *Broker

MarkEmailUnreachable clears a broker's email (old address and reason go to Notes) instead of deleting it: a bounce usually means a changed address, not a gone company. Returns the broker, or nil if none matched.

func (*BrokerDatabase) RemoveByEmail

func (db *BrokerDatabase) RemoveByEmail(email string) *Broker

RemoveByEmail removes a broker by their email address Returns the removed broker, or nil if not found

func (*BrokerDatabase) RemoveByID

func (db *BrokerDatabase) RemoveByID(id string) *Broker

RemoveByID removes a broker by their ID Returns the removed broker, or nil if not found

func (*BrokerDatabase) Save

func (db *BrokerDatabase) Save(path string) error

func (*BrokerDatabase) SaveWithBackup

func (db *BrokerDatabase) SaveWithBackup(path string) error

SaveWithBackup saves the database to file, creating a backup first

func (*BrokerDatabase) Select added in v0.7.0

func (db *BrokerDatabase) Select(ids, regions, categories, excluded, excludedCategories []string) []Broker

func (*BrokerDatabase) UnknownIDs added in v0.7.0

func (db *BrokerDatabase) UnknownIDs(ids []string) []string

type UpdateResult added in v1.2.0

type UpdateResult struct {
	Changed bool
	Before  int // entries in the published list before the update
	Count   int // entries in the downloaded list (0 unless written)
	Own     int // the user's own entries (LocalPath), kept across updates
	Path    string
}

UpdateResult reports what Update did. Changed is false when the server answered 304 (nothing new); with checkOnly, Changed means "an update is available" and nothing was written.

func Update added in v1.2.0

func Update(ctx context.Context, url string, checkOnly bool) (UpdateResult, error)

Update fetches url into UserBrokersPath, conditionally (If-None-Match on the last ETag), and only after Validate accepts it - a truncated or malformed download never replaces the working copy.

Jump to

Keyboard shortcuts

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