Documentation
¶
Overview ¶
Package classify says what kind of email infrastructure an address or domain is: a free consumer mailbox, a private mailbox, an alias service, a throwaway inbox, a school, a government, or not known yet. It answers from intelligence Outflare maintains (data/), plus DNS when asked.
The data is global: the same for every workspace. Workspace input (overrides, feedback, results from a workspace's paid verifier) never changes it.
Confidence is null until it is calibrated against a reviewed set of domains; ConfidenceStatus says what the answer rests on instead.
Index ¶
- Constants
- Variables
- func ResearchPrompt(res Result, p Page) string
- func ResearchSystem() string
- func RoleLocal(local string) bool
- func VerdictSchema() map[string]any
- type Address
- type Analysis
- type Assessment
- type Attributes
- type Classifier
- type Domain
- type Effective
- type Evidence
- type Input
- type Intel
- type Page
- type PageFetcher
- type Provider
- type Ref
- type Research
- type Resolver
- type Result
- type Risk
- type Tri
- type Verdict
Constants ¶
const ( AnalysisComplete = "complete" // nothing more to find out AnalysisNotQueued = "not_queued" // research could help, but none was asked for AnalysisQueued = "queued" // research is running; ask again shortly AnalysisResearched = "researched" // the workspace's own research answered )
Analysis statuses: where the answer is in its life.
const ( SourceOutflare = "outflare" // data/providers.yaml, reviewed by Outflare SourceDisposable = "disposable-email-domains" // CC0 SourceFakeFilter = "fakefilter" // BSD 3-Clause SourceDNS = "dns" SourceSuffix = "public_suffix" )
Sources, as they appear in evidence.
const ( SiteOffersTemporaryAddresses = "site_offers_temporary_addresses" SiteOffersFreeMailboxes = "site_offers_free_mailboxes" SiteOffersPaidMailboxes = "site_offers_paid_mailboxes" SiteOffersForwarding = "site_offers_forwarding" SiteIsOrganisation = "site_is_organisation" SiteIsSchoolOrGovernment = "site_is_school_or_government" SiteIsParked = "site_is_parked" SiteSaysNothingAboutEmail = "site_says_nothing_about_email" SiteCouldNotBeRead = "site_could_not_be_read" )
Signals a verdict may carry. The model picks from this list, so the signals stay comparable across workspaces and carry nothing personal.
const ( Business = "business" FreePersonal = "free_personal" PrivateMailbox = "private_mailbox" Disposable = "disposable" RelayAlias = "relay_alias" Education = "education" Government = "government" NonprofitInstitutional = "nonprofit_institutional" PersonalCustom = "personal_custom" ManagedOther = "managed_other" Unknown = "unknown" )
Categories: what an email domain is.
const ( ShortLivedMailbox = "short_lived_mailbox" ThrowawayPersistent = "throwaway_persistent" TemporaryForwarder = "temporary_forwarder" RotatingDomainProvider = "rotating_domain_provider" AnonymousAlias = "anonymous_alias" PermanentAlias = "permanent_alias" UnknownDisposableSubtype = "unknown_disposable_subtype" )
Subcategories of disposable and relay_alias.
const ( Verified = "verified" // a provider Outflare reviewed Corroborated = "corroborated" // two or more independent sources agree Inferred = "inferred" // one source or one indicator, such as a .edu suffix InsufficientEvidence = "insufficient_evidence" // nothing to go on yet Conflicted = "conflicted" // sources disagree and none outranks the others )
Confidence statuses: what an answer rests on.
const ( Allow = "allow" Verify = "verify" Review = "review" Block = "block" )
Recommended actions.
const DataVersion = "2026-10-26.1"
DataVersion names the snapshot of data/ built into this binary. Bump it whenever a file in data/ changes.
const ResearchTask = "classify_domain"
ResearchTask names the model task, so a workspace can give research a cheaper model than its missions use.
const SourceResearch = "research"
SourceResearch marks evidence a workspace's own research produced.
const TaxonomyVersion = "1.0"
TaxonomyVersion versions the category and attribute codes below. Codes are added, never renamed; a deprecated code maps to its replacement.
Variables ¶
var ( ErrInvalidEmail = errors.New("email must be a valid email address, such as name@example.com") ErrInvalidDomain = errors.New("domain must be a valid domain name, such as example.com") ErrPublicSuffix = errors.New("domain must be a domain someone can register, not a public suffix such as co.uk") )
Errors from parsing. Their text starts with the field name, so the API can pass it on as a field error.
var Builtin = sync.OnceValue(func() *Intel { in, err := load(providersYAML, disposableList, fakeFilterList) if err != nil { panic("classify: embedded data: " + err.Error()) } return in })
Builtin returns the intelligence embedded in this binary.
var Categories = []string{Business, FreePersonal, PrivateMailbox, Disposable, RelayAlias, Education, Government, NonprofitInstitutional, PersonalCustom, ManagedOther, Unknown}
Categories lists every category code.
var ErrInput = errors.New("email or domain is required, but not both")
ErrInput is returned when Input has both or neither.
var ErrVerdict = errors.New("the model's answer did not fit the taxonomy")
ErrVerdict means the model's answer could not be used.
var ResearchSignals = []string{SiteOffersTemporaryAddresses, SiteOffersFreeMailboxes, SiteOffersPaidMailboxes, SiteOffersForwarding, SiteIsOrganisation, SiteIsSchoolOrGovernment, SiteIsParked, SiteSaysNothingAboutEmail, SiteCouldNotBeRead}
ResearchSignals lists every signal, in the order the prompt gives them.
var Subcategories = []string{ShortLivedMailbox, ThrowawayPersistent, SharedPublicInbox, TemporaryForwarder, RotatingDomainProvider, AnonymousAlias, PermanentAlias, UnknownDisposableSubtype}
Subcategories lists every subcategory code.
Functions ¶
func ResearchPrompt ¶
ResearchPrompt is the question for the model about one domain: what the lists and DNS found, and the words on the domain's own homepage.
func ResearchSystem ¶
func ResearchSystem() string
ResearchSystem is the instruction that goes with ResearchPrompt.
func RoleLocal ¶
RoleLocal reports whether a local part is a role or shared inbox, such as info@ or support@, ignoring a +tag.
func VerdictSchema ¶
VerdictSchema is the JSON shape the model must answer in.
Types ¶
type Address ¶
Address is a parsed email address. Local is kept as given: the classifier never rewrites dots or +tags into a different identity.
func ParseEmail ¶
ParseEmail splits and checks an address. The domain is canonicalised; the local part is checked but kept as given.
type Assessment ¶
type Assessment struct {
Category string `json:"category"`
Subcategory *string `json:"subcategory"`
// Confidence is a calibrated probability the category is right. It is
// null until calibration exists; ConfidenceStatus says what the
// category rests on.
Confidence *float64 `json:"confidence"`
ConfidenceStatus string `json:"confidence_status"`
Provider *Ref `json:"provider"`
Attributes Attributes `json:"attributes"`
Risk Risk `json:"risk"`
Evidence []Evidence `json:"evidence"`
// LastCheckedAt is when DNS was last asked, or null.
LastCheckedAt *time.Time `json:"last_checked_at"`
}
Assessment is the global classification of the domain.
type Attributes ¶
type Attributes struct {
IsDisposable Tri `json:"is_disposable"`
IsPublicInbox Tri `json:"is_public_inbox"`
IsForwarder Tri `json:"is_forwarder"`
IsAliasService Tri `json:"is_alias_service"`
IsPrivacyProvider Tri `json:"is_privacy_provider"`
IsFreeProvider Tri `json:"is_free_provider"`
IsRoleAddress *Tri `json:"is_role_address,omitempty"`
IsCatchAllDomain Tri `json:"is_catch_all_domain"`
IsNewDomain Tri `json:"is_new_domain"`
HasMX Tri `json:"has_mx"`
HasMailReceivingPath Tri `json:"has_mail_receiving_path"`
HasValidSyntax Tri `json:"has_valid_syntax"`
IsInternationalizedDomain Tri `json:"is_internationalized_domain"`
MXProviderID *string `json:"mx_provider_id"`
}
Attributes are independent of the category. Address-only ones are left out for a domain lookup.
type Classifier ¶
type Classifier struct {
Intel *Intel // nil uses Builtin()
// Resolver checks mail servers; nil leaves the mail attributes unknown.
Resolver Resolver
Timeout time.Duration // per DNS lookup; 0 means 3 seconds
// contains filtered or unexported fields
}
Classifier answers what kind of email infrastructure an address or domain is. The zero value uses the built-in data and no DNS.
type Domain ¶
type Domain struct {
Name string // mail.example.co.uk
Registrable string // example.co.uk
Suffix string // co.uk
// ICANN is true when Suffix is an ICANN suffix rather than a private
// one (github.io) or the catch-all for unknown TLDs.
ICANN bool
}
Domain is a canonical domain: lowercase ASCII (punycode for internationalised names), no trailing dot.
func ParseDomain ¶
ParseDomain canonicalises a domain name.
type Effective ¶
type Effective struct {
Category string `json:"category"`
Subcategory *string `json:"subcategory"`
OverrideApplied bool `json:"override_applied"`
OverrideID *string `json:"override_id"`
Action string `json:"action"` // allow, verify, review or block
MatchedPolicyID string `json:"matched_policy_id"`
}
Effective is the workspace's view: the global category after its overrides, and the action its rules recommend. Until workspaces have overrides and rules, it is the global category and Outflare's default rules.
type Evidence ¶
type Evidence struct {
Source string `json:"source"`
Signal string `json:"signal"`
// Detail is a fixed, non-personal note, such as the list entry matched.
Detail string `json:"detail,omitempty"`
}
Evidence is one fact behind the answer.
type Input ¶
Input is an email address or a domain, never both. A domain alone keeps the person's address out of the request.
type Intel ¶
type Intel struct {
Version string
// contains filtered or unexported fields
}
Intel is the global intelligence: reviewed providers and open lists, keyed by canonical domain.
func (*Intel) MailboxProvider ¶ added in v0.14.0
MailboxProvider reports whether domain belongs to a mailbox or alias service (Gmail, iCloud, a relay, a disposable domain) rather than to the company its people work at, so two people on it never share a company.
type Page ¶
type Page struct {
// URL is where the fetch ended up, Status the site's HTTP answer.
URL string
Status int
HTML string
// Fetched is false when there was no page to read: the fetch failed,
// or the site answered with an error.
Fetched bool
}
Page is a domain's homepage, as the workspace's fetcher read it.
type PageFetcher ¶
type PageFetcher interface {
// FetchHomepage reads https://<domain>/, following the site's
// redirects. It returns a Page with Fetched false, and no error, when
// the site simply has no readable homepage.
FetchHomepage(ctx context.Context, domain string) (Page, error)
}
PageFetcher reads a domain's homepage through the workspace's own connection. The classifier never fetches pages itself: a workspace's research goes out on the workspace's own account.
type Provider ¶
type Provider struct {
ID string `yaml:"id"`
Name string `yaml:"name"`
Category string `yaml:"category"`
Subcategory string `yaml:"subcategory"`
Domains []string `yaml:"domains"`
// Subdomains: addresses live on subdomains too (alias@you.example.com).
Subdomains bool `yaml:"subdomains"`
}
Provider is a mailbox or alias service Outflare has reviewed.
type Research ¶
type Research struct {
Category string `json:"category"`
Subcategory *string `json:"subcategory"`
ConfidenceStatus string `json:"confidence_status"`
Signals []string `json:"signals"`
Evidence []Evidence `json:"evidence"`
Note string `json:"note,omitempty"`
Model string `json:"model"`
ResearchedAt time.Time `json:"researched_at"`
}
Research is what a workspace's own research made of a domain. It sits beside the global assessment, which research never changes.
type Resolver ¶
type Resolver interface {
LookupMX(ctx context.Context, name string) ([]*net.MX, error)
LookupHost(ctx context.Context, host string) ([]string, error)
}
Resolver looks up mail servers. *net.Resolver satisfies it.
type Result ¶
type Result struct {
Scope string `json:"scope"` // email or domain
NormalizedDomain string `json:"normalized_domain"`
RegistrableDomain string `json:"registrable_domain"`
TaxonomyVersion string `json:"taxonomy_version"`
IntelligenceVersion string `json:"intelligence_version"`
Global Assessment `json:"global"`
// Research is what this workspace's own research made of the domain,
// when it has researched it. It is absent for every other workspace.
Research *Research `json:"research,omitempty"`
Effective Effective `json:"effective"`
Analysis Analysis `json:"analysis"`
}
Result is the answer. Global is the same for every workspace; Effective is what this workspace's rules make of it.
type Risk ¶
type Risk struct {
Status string `json:"status"` // assessed or not_assessed
Score *int `json:"score"`
Level string `json:"level"` // low, medium, high or unknown
Signals []string `json:"signals"`
}
Risk is how much a domain should concern a sign-up flow, separate from what it is. Scores are rule-based until calibrated: 0 to 100, higher is more concern, never a probability that a person is fraudulent.
type Tri ¶
type Tri int8
Tri is an attribute that is true, false or not known. Absence of evidence is Unknown, never false.
func (Tri) MarshalJSON ¶
MarshalJSON writes true, false or "unknown".
func (*Tri) UnmarshalJSON ¶
UnmarshalJSON reads true, false or "unknown".
type Verdict ¶
type Verdict struct {
Category string
Subcategory string
Signals []string
// Attributes the page settles. Anything the page does not say stays
// TriUnknown: research never guesses an attribute into place.
IsDisposable Tri
IsPublicInbox Tri
IsFreeProvider Tri
IsForwarder Tri
IsAliasService Tri
IsPrivacyProvider Tri
// Note is the model's own one-line reason, kept for a person reading
// the record. It never goes into an event.
Note string
}
Verdict is what the model made of the evidence.
func ParseVerdict ¶
ParseVerdict reads the model's answer, keeping only codes the taxonomy has. A model that invents a category gets ErrVerdict; one that invents a signal or an attribute value loses that field, not the answer.