listing

package
v0.25.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package listing turns the entries of the published lists into the keys their snapshot rows are looked up by: a site's normalised host and path, an address, an E.164 phone number or a SIREN, normalised by the domain value objects. Lists that share entries, such as the AMF and ACPR blacklists, give them the same key, so a check can name both sources.

Index

Constants

View Source
const (
	// ColumnKind is the kind of the key: "domain", "email", "phone" or
	// "siren".
	ColumnKind = "kind"
	// ColumnKey is the normalised host, address, number or SIREN the entry
	// is looked up by.
	ColumnKey = "key"
	// ColumnPath is the path and query of a site entry that targets one
	// page, "" when it targets the whole site or the key is not a site.
	ColumnPath = "path"
	// ColumnEntry is the value as the publisher lists it.
	ColumnEntry = "entry"
)

Columns every snapshot row of a listing starts with.

View Source
const (
	// ColumnCategories are the publisher's categories, separated by
	// CategorySeparator.
	ColumnCategories = "categories"
	// ColumnListedOn is the listing date, AAAA-MM-JJ.
	ColumnListedOn = "listed_on"
)

Columns a blacklist row adds to the common ones, for every blacklist.

View Source
const CategorySeparator = "|"

CategorySeparator separates the categories of a blacklist row.

Variables

View Source
var ErrSnapshot = errors.New("malformed blacklist snapshot")

ErrSnapshot means a blacklist snapshot departs from the rows the connectors write. Errors locate the row, never quote a value: it may hold an address.

Functions

func BlacklistColumns added in v0.25.0

func BlacklistColumns() []string

BlacklistColumns returns the columns of every blacklist snapshot.

func Columns

func Columns(rest ...string) []string

Columns returns the common columns followed by rest, the source's own.

Types

type Key

type Key struct {
	Kind  string // a domain.Kind name: "domain", "email", "phone" or "siren"
	Value string // normalised by the domain value object
	Path  string // path and query of a site entry that targets one page
	Entry string // the value as the publisher lists it
}

Key is what an entry is looked up by: the first four columns of every snapshot row.

func Classify

func Classify(nom string) (Key, bool)

Classify reads one entry of a blacklist: an address, a site, or a free-text name, which may name a natural person and is not ok.

func Email

func Email(s string) (Key, bool)

Email reads an address. A final dot, as in "prénom.nom@lgt-bp.com.", is a typo of the lists.

func Phone

func Phone(s string) (Key, bool)

Phone reads a phone number; the key is its E.164 form.

func SIREN

func SIREN(s string) (Key, bool)

SIREN reads a SIREN.

func Site

func Site(s string) (Key, bool)

Site reads a site or web URL; the key is its normalised host. A missing "h", as in "ttps://www.alphacap.fr/", is a typo of the lists.

func (Key) Fields

func (k Key) Fields(rest ...string) []string

Fields returns the key as the first columns of a row, followed by rest.

type Reader added in v0.25.0

type Reader struct {
	// contains filtered or unexported fields
}

Reader is the app.BlacklistReader of one blacklist. It indexes each snapshot in service once, at the first read after it is swapped in, and is safe for concurrent use.

func NewReader added in v0.25.0

func NewReader(snapshots Snapshots, source domain.Source) *Reader

NewReader returns the Reader of the blacklist of source in snapshots.

func (*Reader) Blacklist added in v0.25.0

func (r *Reader) Blacklist() (*domain.Blacklist, time.Time, error)

Blacklist returns the blacklist in service and when it was fetched, app.ErrNoSnapshot when none is, or ErrSnapshot when it is malformed.

type Snapshots added in v0.25.0

type Snapshots interface {
	Snapshot(source domain.Source) (domain.Snapshot, bool)
}

Snapshots returns the snapshot in service for a source; *app.Sync is one.

Jump to

Keyboard shortcuts

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