Documentation
¶
Index ¶
- Constants
- func CurrentCount() int
- func LocalPath() string
- func NewID(name string) string
- func SaveLocal(b Broker) error
- func UserBrokersPath() string
- type Broker
- type BrokerDatabase
- func Load(overridePath string) (*BrokerDatabase, error)
- func LoadFromFile(path string) (*BrokerDatabase, error)
- func LoadList(overridePath, configPath, listName string) (*BrokerDatabase, error)
- func LoadLocal() (*BrokerDatabase, error)
- func Parse(raw []byte) (*BrokerDatabase, error)
- func Validate(raw []byte, minCount int) (*BrokerDatabase, error)
- func (db *BrokerDatabase) Add(broker Broker) error
- func (db *BrokerDatabase) Filter(regions []string, excluded []string, excludedCategories []string) []Broker
- func (db *BrokerDatabase) FindByEmail(email string) *Broker
- func (db *BrokerDatabase) FindByID(id string) *Broker
- func (db *BrokerDatabase) FindByName(name string) *Broker
- func (db *BrokerDatabase) MarkEmailUnreachable(email, reason string) *Broker
- func (db *BrokerDatabase) RemoveByEmail(email string) *Broker
- func (db *BrokerDatabase) RemoveByID(id string) *Broker
- func (db *BrokerDatabase) Save(path string) error
- func (db *BrokerDatabase) SaveWithBackup(path string) error
- func (db *BrokerDatabase) Select(ids, regions, categories, excluded, excludedCategories []string) []Broker
- func (db *BrokerDatabase) UnknownIDs(ids []string) []string
- type UpdateResult
Constants ¶
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).
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.
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
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
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"`
// Countries limits a broker to people connected to these countries (ISO 3166-1
// alpha-2, e.g. ["DE"]) - for brokers that only hold data on one market and ask
// not to be sent requests from elsewhere. Empty means everyone.
Countries []string `yaml:"countries,omitempty"`
// Optional research, shown on the site's guide page. Only facts the broker's own pages
// state; Sources are those pages and Researched the date they were read (YYYY-MM-DD).
Parent string `yaml:"parent,omitempty"` // operating company or owner
HQ string `yaml:"hq,omitempty"` // country or city of the operator
Holds string `yaml:"holds,omitempty"` // categories of data they say they hold
Verification string `yaml:"verification,omitempty"` // what they ask for before acting
ResponseTime string `yaml:"response_time,omitempty"` // what their policy says
Sources []string `yaml:"sources,omitempty"`
Researched string `yaml:"researched,omitempty"`
Guide bool `yaml:"guide,omitempty"` // give a long-tail broker its own guide page
}
func ForCountry ¶ added in v1.8.0
ForCountry drops brokers whose countries list excludes the given country.
func (Broker) AppliesTo ¶ added in v1.8.0
AppliesTo reports whether a request from someone in country (a profile's free-text country: name or ISO code) is in scope for the broker. Brokers without a countries list apply to everyone, and so does an empty or unrecognised country - an unset profile never hides brokers.
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.