Documentation ¶
Index ¶
- Constants
- Variables
- func ArrayContainsString(list []string, v string) bool
- func BuildByMatch(item string, matches []string) string
- func BuildModel(m string, matches []string) string
- func BuildVersion(versionString string, matches []string) string
- func FindBrand(key string) string
- func GetAvailableDeviceTypeNames() []string
- func GetBotCreater(name string) func(string) BotParser
- func GetDeviceName(deviceType int) string
- func GetDeviceType(deviceName string) int
- func GetFullName(brandId string) string
- func GetOsFamily(osLabel string) string
- func GetOsNameFromId(os, ver string) string
- func GetShortName(name string) string
- func IsDesktopOS(os string) bool
- func MatchUserAgent(ua, regex string) []string
- func NameEqual(a string, b string) bool
- func ReadYamlFile(file string, v interface{}) error
- func RegBotParser(name string, f func(string) BotParser)
- func SetVersionTruncation(t int)
- func StringContainsLetter(ua string) bool
- func StringEqualIgnoreCase(a string, b string) bool
- type Bot
- type BotMatchResult
- type BotParser
- type BotParserAbstract
- type BotReg
- type MatchResult
- type OsMatchResult
- type OsParser
- type OsReg
- type Oss
- type PlatformReg
- type Producer
- type Regular
- type VendorFragments
Constants ¶
const ( DEVICE_TYPE_INVALID = -1 DEVICE_TYPE_DESKTOP = 0 DEVICE_TYPE_SMARTPHONE = 1 DEVICE_TYPE_TABLET = 2 DEVICE_TYPE_FEATURE_PHONE = 3 DEVICE_TYPE_CONSOLE = 4 DEVICE_TYPE_TV = 5 // including set top boxes, blu-ray players,... DEVICE_TYPE_CAR_BROWSER = 6 DEVICE_TYPE_SMART_DISPLAY = 7 DEVICE_TYPE_CAMERA = 8 DEVICE_TYPE_PORTABLE_MEDIA_PAYER = 9 DEVICE_TYPE_PHABLET = 10 DEVICE_TYPE_SMART_SPEAKER = 11 DEVICE_TYPE_WEARABLE = 12 // including set watches, headsets DEVICE_TYPE_PERIPHERAL = 13 // including portable terminal, portable projector )
const ( PlatformTypeARM = "ARM" PlatformTypeX64 = "x64" PlatformTypeX86 = "x86" PlatformTypeNONE = "" )
const FixtureFileBot = `bots.yml`
const FixtureFileOs = "oss.yml"
const FixtureFileVendor = "vendorfragments.yml"
const ParserNameBot = `bot`
const ParserNameOs = "os"
const ParserNameVendor = "vendorfragments"
const Unknown = "Unknown"
const UnknownShort = "UNK"
const VERSION_TRUNCATION_BUILD = 3
Versioning constant used to set versioning to build number Version examples are: 3.4.0.12, 5.6.334.0, 6.234.2.3, 0.200.3.1, 1.2.3.0, ...
const VERSION_TRUNCATION_MAJOR = 0
Versioning constant used to set max versioning to major version only Version examples are: 3, 5, 6, 200, 123, ...
const VERSION_TRUNCATION_MINOR = 1
Versioning constant used to set max versioning to minor version Version examples are: 3.4, 5.6, 6.234, 0.200, 1.23, ...
const VERSION_TRUNCATION_NONE = -1
Versioning constant used to set versioning to unlimited (no truncation)
const VERSION_TRUNCATION_PATCH = 2
Versioning constant used to set max versioning to path level Version examples are: 3.4.0, 5.6.344, 6.234.2, 0.200.3, 1.2.3, ...
Variables ¶
var DesktopOS = map[string]bool{ `AmigaOS`: true, `IBM`: true, `GNU/Linux`: true, `Mac`: true, `Unix`: true, `Windows`: true, `BeOS`: true, `Chrome OS`: true, `Chromium OS`: true, }
var EmptyBotMatchResult = new(BotMatchResult)
var OperatingSystems = map[string]string{}/* 126 elements not displayed */
Known operating systems mapped to their internal short codes
var OsFamilies = map[string][]string{ `Android`: []string{`AND`, `CYN`, `FIR`, `REM`, `RZD`, `MLD`, `MCD`, `YNS`, `GRI`, `HAR`, `ADR`, `CLR`, `BOS`, `REV`, `LEN`}, `AmigaOS`: {`AMG`, `MOR`}, `Apple TV`: {`ATV`}, `BlackBerry`: {`BLB`, `QNX`}, `Brew`: {`BMP`}, `BeOS`: {`BEO`, `HAI`}, `Chrome OS`: {`COS`, `CRS`, `FYD`, `SEE`}, `Firefox OS`: {`FOS`, `KOS`}, `Gaming Console`: {`WII`, `PS3`}, `Google TV`: {`GTV`}, `IBM`: {`OS2`}, `iOS`: {`IOS`, `ATV`, `WAS`, `IPA`}, `RISC OS`: {`ROS`}, `GNU/Linux`: {`LIN`, `ARL`, `DEB`, `KNO`, `MIN`, `UBT`, `KBT`, `XBT`, `LBT`, `FED`, `RHT`, `VLN`, `MDR`, `GNT`, `SAB`, `SLW`, `SSE`, `CES`, `BTR`, `SAF`, `ORD`, `TOS`, `RSO`, `DEE`, `FRE`, `MAG`, `FEN`, `CAI`, `PCL`, `HAS`, `LOS`, `DVK`, `ROK`, `OWR`, `OTV`, `KTV`, `PUR`, `PLA`, `FUC`, `PAR`, `FOR`, `MON`, `KAN`, `ZEN`, `LND`, `LNS`, `CHN`, `AMZ`, `TEN`, `CST`}, `Mac`: {`MAC`}, `Mobile Gaming Console`: {`PSP`, `NDS`, `XBX`}, `Real-time OS`: {`MTK`, `TDX`, `MRE`, `JME`, `REX`}, `Other Mobile`: {`WOS`, `POS`, `SBA`, `TIZ`, `SMG`, `MAE`}, `Symbian`: {`SYM`, `SYS`, `SY3`, `S60`, `S40`}, `Unix`: {`SOS`, `AIX`, `HPX`, `BSD`, `NBS`, `OBS`, `DFB`, `SYL`, `IRI`, `T64`, `INF`}, `WebTV`: {`WTV`}, `Windows`: {`WIN`}, `Windows Mobile`: {`WPH`, `WMO`, `WCE`, `WRT`, `WIO`}, `Other Smart TV`: {`WHS`}, }
Operating system families mapped to the short codes of the associated operating systems
Functions ¶
func ArrayContainsString ¶
func BuildByMatch ¶
func BuildModel ¶
func BuildVersion ¶
func GetAvailableDeviceTypeNames ¶
func GetAvailableDeviceTypeNames() []string
Returns names of all available device types
func GetBotCreater ¶
func GetDeviceName ¶
Returns the name of the given device type
func GetDeviceType ¶
func GetFullName ¶
Returns the full brand name for the given short name
func GetOsFamily ¶
func GetOsNameFromId ¶
func GetShortName ¶
func IsDesktopOS ¶
func MatchUserAgent ¶
func ReadYamlFile ¶
func RegBotParser ¶
func SetVersionTruncation ¶
func SetVersionTruncation(t int)
func StringContainsLetter ¶
func StringEqualIgnoreCase ¶
Types ¶
type BotMatchResult ¶
type BotMatchResult struct { Name string `yaml:"name" json:"name"` Category string `yaml:"category" json:"category"` Url string `yaml:"url" json:"url"` Producer Producer `yaml:"producer" json:"producer"` }
func (*BotMatchResult) Equal ¶
func (b *BotMatchResult) Equal(a *BotMatchResult) bool
type BotParser ¶
type BotParser interface { PreMatch(string) bool Parse(string) *BotMatchResult DiscardDetails(bool) }
func NewBotParser ¶
type BotParserAbstract ¶
type BotParserAbstract struct { Regexes []*BotReg ParserName string // contains filtered or unexported fields }
Abstract class for all bot parsers
func (*BotParserAbstract) DiscardDetails ¶
func (b *BotParserAbstract) DiscardDetails(v bool)
func (*BotParserAbstract) Load ¶
func (b *BotParserAbstract) Load(file string) error
func (*BotParserAbstract) Parse ¶
func (b *BotParserAbstract) Parse(ua string) *BotMatchResult
Parses the current UA and checks whether it contains bot information
func (*BotParserAbstract) PreMatch ¶
func (b *BotParserAbstract) PreMatch(ua string) bool
type BotReg ¶
type BotReg struct { Regular `yaml:",inline" json:",inline"` BotMatchResult `yaml:",inline" json:",inline"` }
type MatchResult ¶
type OsMatchResult ¶
type Oss ¶
type Oss struct { Regexes []*OsReg // contains filtered or unexported fields }
Parses the useragent for operating system information
func (*Oss) Parse ¶
func (o *Oss) Parse(ua string) *OsMatchResult
func (*Oss) ParsePlatform ¶
type PlatformReg ¶
type VendorFragments ¶
type VendorFragments struct {
// contains filtered or unexported fields
}
Device parser for vendor fragment detection
func NewVendor ¶
func NewVendor(file string) (*VendorFragments, error)
func (*VendorFragments) Parse ¶
func (v *VendorFragments) Parse(ua string) string