Documentation
¶
Overview ¶
Package useragent recognizes the user agents of machines that fetch email images and follow links: security scanners, link checkers, HTTP libraries, crawlers and link previews (review AN-9). It matches whole product tokens rather than substrings, so a phone called CUBOT or a browser build with "bot" inside a word is still a person.
The patterns are a list the instance keeps (tracking_user_agents, review AN-2): the built-in ones come with releases, and instance admins add the ones they meet. Words that mark any machine (a word ending in "bot", "crawler", "spider", "slurp", a "preview") are rules, not patterns; a person's device whose word a rule takes for a machine is listed as a person.
Index ¶
Constants ¶
const ( Headless = "a headless browser" Script = "a script" AnyBot = "a bot" Preview = "a link preview" )
Kinds of machines, as Bot names them when it isn't a product.
const ( // KindScanner: a mail-security scanner or link checker, by its name. KindScanner = "scanner" // KindScript: an HTTP library or a script. KindScript = "script" // KindHeadless: a headless browser. KindHeadless = "headless" // KindPreview: a chat app's or social network's link preview. KindPreview = "preview" // KindPerson: a word of a person's device or app that a rule would // take for a machine's ("CUBOT" phones end in "bot"). KindPerson = "person" )
Kinds of patterns (tracking_user_agents.kind).
Variables ¶
var Kinds = []string{KindScanner, KindScript, KindHeadless, KindPreview, KindPerson}
Kinds are the pattern kinds, machines first.
Functions ¶
func Bot ¶
Bot returns what kind of machine a user agent is by the built-in list ("Barracuda", "a script", "a bot", "a link preview"), or "" for a browser or mail client.
func TakesPeople ¶
TakesPeople reports whether a machine pattern is found in the user agent of a browser or mail client people read email with.
Types ¶
type List ¶
type List struct {
// contains filtered or unexported fields
}
List is a user agent list: machines found by their patterns, and the words of people's devices the rules would take for machines.
type Pattern ¶
type Pattern struct {
// Text is lower case. A machine's is found anywhere in the user agent;
// a person's is a whole word of it.
Text string
Kind string
// Name is the product or who runs it ("Barracuda"); a script, headless
// browser or link preview may have none.
Name string
}
Pattern is one entry of a user agent list.