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 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 )
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 EmptyBotMatchResult = new(BotMatchResult)
var OperatingSystems = map[string]string{
`AIX`: `AIX`,
`AND`: `Android`,
`AMG`: `AmigaOS`,
`ATV`: `Apple TV`,
`ARL`: `Arch Linux`,
`BTR`: `BackTrack`,
`SBA`: `Bada`,
`BEO`: `BeOS`,
`BLB`: `BlackBerry OS`,
`QNX`: `BlackBerry Tablet OS`,
`BMP`: `Brew`,
`CES`: `CentOS`,
`COS`: `Chrome OS`,
`CYN`: `CyanogenMod`,
`DEB`: `Debian`,
`DFB`: `DragonFly`,
`FED`: `Fedora`,
`FOS`: `Firefox OS`,
`FIR`: `Fire OS`,
`BSD`: `FreeBSD`,
`GNT`: `Gentoo`,
`GTV`: `Google TV`,
`HPX`: `HP-UX`,
`HAI`: `Haiku OS`,
`IRI`: `IRIX`,
`INF`: `Inferno`,
`KOS`: `KaiOS`,
`KNO`: `Knoppix`,
`KBT`: `Kubuntu`,
`LIN`: `GNU/Linux`,
`LBT`: `Lubuntu`,
`VLN`: `VectorLinux`,
`MAC`: `Mac`,
`MAE`: `Maemo`,
`MDR`: `Mandriva`,
`SMG`: `MeeGo`,
`MCD`: `MocorDroid`,
`MIN`: `Mint`,
`MLD`: `MildWild`,
`MOR`: `MorphOS`,
`NBS`: `NetBSD`,
`MTK`: `MTK / Nucleus`,
`WII`: `Nintendo`,
`NDS`: `Nintendo Mobile`,
`OS2`: `OS/2`,
`T64`: `OSF1`,
`OBS`: `OpenBSD`,
`ORD`: `Ordissimo`,
`PSP`: `PlayStation Portable`,
`PS3`: `PlayStation`,
`RHT`: `Red Hat`,
`ROS`: `RISC OS`,
`REM`: `Remix OS`,
`RZD`: `RazoDroiD`,
`SAB`: `Sabayon`,
`SSE`: `SUSE`,
`SAF`: `Sailfish OS`,
`SLW`: `Slackware`,
`SOS`: `Solaris`,
`SYL`: `Syllable`,
`SYM`: `Symbian`,
`SYS`: `Symbian OS`,
`S40`: `Symbian OS Series 40`,
`S60`: `Symbian OS Series 60`,
`SY3`: `Symbian^3`,
`TDX`: `ThreadX`,
`TIZ`: `Tizen`,
`TOS`: `TmaxOS`,
`UBT`: `Ubuntu`,
`WTV`: `WebTV`,
`WIN`: `Windows`,
`WCE`: `Windows CE`,
`WIO`: `Windows IoT`,
`WMO`: `Windows Mobile`,
`WPH`: `Windows Phone`,
`WRT`: `Windows RT`,
`XBX`: `Xbox`,
`XBT`: `Xubuntu`,
`YNS`: `YunOs`,
`IOS`: `iOS`,
`POS`: `palmOS`,
`WOS`: `webOS`,
}
Known operating systems mapped to their internal short codes
var OsFamilies = map[string][]string{ `Android`: []string{`AND`, `CYN`, `FIR`, `REM`, `RZD`, `MLD`, `MCD`, `YNS`}, `AmigaOS`: []string{`AMG`, `MOR`}, `Apple TV`: []string{`ATV`}, `BlackBerry`: []string{`BLB`, `QNX`}, `Brew`: []string{`BMP`}, `BeOS`: []string{`BEO`, `HAI`}, `Chrome OS`: []string{`COS`}, `Firefox OS`: []string{`FOS`, `KOS`}, `Gaming Console`: []string{`WII`, `PS3`}, `Google TV`: []string{`GTV`}, `IBM`: []string{`OS2`}, `iOS`: []string{`IOS`}, `RISC OS`: []string{`ROS`}, `GNU/Linux`: []string{`LIN`, `ARL`, `DEB`, `KNO`, `MIN`, `UBT`, `KBT`, `XBT`, `LBT`, `FED`, `RHT`, `VLN`, `MDR`, `GNT`, `SAB`, `SLW`, `SSE`, `CES`, `BTR`, `SAF`, `ORD`, `TOS`}, `Mac`: []string{`MAC`}, `Mobile Gaming Console`: []string{`PSP`, `NDS`, `XBX`}, `Real-time OS`: []string{`MTK`, `TDX`}, `Other Mobile`: []string{`WOS`, `POS`, `SBA`, `TIZ`, `SMG`, `MAE`}, `Symbian`: []string{`SYM`, `SYS`, `SY3`, `S60`, `S40`}, `Unix`: []string{`SOS`, `AIX`, `HPX`, `BSD`, `NBS`, `OBS`, `DFB`, `SYL`, `IRI`, `T64`, `INF`}, `WebTV`: []string{`WTV`}, `Windows`: []string{`WIN`}, `Windows Mobile`: []string{`WPH`, `WMO`, `WCE`, `WRT`, `WIO`}, }
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 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