browscap

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultPatternName = "defaultproperties"

Variables

View Source
var DefaultBrowser = &BrowserNode{
	Comment:                    StringPtr("Default Browser"),
	Browser:                    StringPtr("Default Browser"),
	BrowserType:                StringPtr("unknown"),
	BrowserBits:                IntPtr(0),
	BrowserMaker:               StringPtr("unknown"),
	BrowserModus:               StringPtr("unknown"),
	Version:                    StringPtr("0.0"),
	MajorVer:                   StringPtr("0"),
	MinorVer:                   StringPtr("0"),
	Platform:                   StringPtr("unknown"),
	PlatformVersion:            StringPtr("unknown"),
	PlatformDescription:        StringPtr("unknown"),
	PlatformBits:               IntPtr(0),
	PlatformMaker:              StringPtr("unknown"),
	Alpha:                      BoolPtr(false),
	Beta:                       BoolPtr(false),
	Win16:                      BoolPtr(false),
	Win32:                      BoolPtr(false),
	Win64:                      BoolPtr(false),
	Frames:                     BoolPtr(false),
	Iframes:                    BoolPtr(false),
	Tables:                     BoolPtr(false),
	Cookies:                    BoolPtr(false),
	BackgroundSounds:           BoolPtr(false),
	Javascript:                 BoolPtr(false),
	VBScript:                   BoolPtr(false),
	JavaApplets:                BoolPtr(false),
	ActiveXControls:            BoolPtr(false),
	IsMobileDevice:             BoolPtr(false),
	IsTablet:                   BoolPtr(false),
	IsSyndicationReader:        BoolPtr(false),
	Crawler:                    BoolPtr(false),
	IsFake:                     BoolPtr(false),
	IsAnonymized:               BoolPtr(false),
	IsModified:                 BoolPtr(false),
	CSSVersion:                 IntPtr(0),
	AolVersion:                 IntPtr(0),
	DeviceName:                 StringPtr("unknown"),
	DeviceMaker:                StringPtr("unknown"),
	DeviceType:                 StringPtr("unknown"),
	DevicePointingMethod:       StringPtr("unknown"),
	DeviceCodeName:             StringPtr("unknown"),
	DeviceBrandName:            StringPtr("unknown"),
	RenderingEngineName:        StringPtr("unknown"),
	RenderingEngineVersion:     StringPtr("unknown"),
	RenderingEngineDescription: StringPtr("unknown"),
	RenderingEngineMaker:       StringPtr("unknown"),
}
View Source
var ErrEmptyCache = fmt.Errorf("cache is empty")
View Source
var ErrNotFound = fmt.Errorf("browser not found")

Functions

func Bool

func Bool(v *bool) bool

func BoolPtr added in v0.1.3

func BoolPtr(v bool) *bool

func Int

func Int(v *int) int

func Int64ToStringHookFunc

func Int64ToStringHookFunc() mapstructure.DecodeHookFunc

func IntPtr added in v0.1.3

func IntPtr(v int) *int

func String

func String(v *string) string

func StringPtr added in v0.1.3

func StringPtr(v string) *string

Types

type AbstractDBStorage

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

func NewAbstractDBStorage

func NewAbstractDBStorage(
	db *sqlx.DB,
	inserter Inserter,
	metaQuoter MetaQuoter,
	tableExistenceChecker TableExistenceChecker,
	tableCreator TableCreator,
	placeholderMaker PlaceholderMaker,
) *AbstractDBStorage

func (*AbstractDBStorage) Get

func (s *AbstractDBStorage) Get(pattern string) (*BrowserNode, error)

func (*AbstractDBStorage) GetVersion

func (s *AbstractDBStorage) GetVersion() (*Version, error)

func (*AbstractDBStorage) Patterns

func (s *AbstractDBStorage) Patterns() iter.Seq2[string, error]

func (*AbstractDBStorage) Prepare

func (s *AbstractDBStorage) Prepare() error

func (*AbstractDBStorage) Save

func (s *AbstractDBStorage) Save(node *BrowserNode) error

func (*AbstractDBStorage) SaveVersion

func (s *AbstractDBStorage) SaveVersion(ver *Version) error

type Browscap

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

func NewBrowscap

func NewBrowscap(tree *radix.Node, browserStorage BrowserStorage) *Browscap

func (*Browscap) GetBrowser

func (b *Browscap) GetBrowser(ua string) (*Browser, error)

type Browser

type Browser struct {
	Pattern                    string
	Comment                    string
	Browser                    string
	BrowserType                string
	BrowserBits                int
	BrowserMaker               string
	BrowserModus               string
	Version                    string
	MajorVer                   string
	MinorVer                   string
	Platform                   string
	PlatformVersion            string
	PlatformDescription        string
	PlatformBits               int
	PlatformMaker              string
	Alpha                      bool
	Beta                       bool
	Win16                      bool
	Win32                      bool
	Win64                      bool
	Frames                     bool
	Iframes                    bool
	Tables                     bool
	Cookies                    bool
	BackgroundSounds           bool
	Javascript                 bool
	VBScript                   bool
	JavaApplets                bool
	ActiveXControls            bool
	IsMobileDevice             bool
	IsTablet                   bool
	IsSyndicationReader        bool
	Crawler                    bool
	IsFake                     bool
	IsAnonymized               bool
	IsModified                 bool
	CSSVersion                 int
	AolVersion                 int
	DeviceName                 string
	DeviceMaker                string
	DeviceType                 string
	DevicePointingMethod       string
	DeviceCodeName             string
	DeviceBrandName            string
	RenderingEngineName        string
	RenderingEngineVersion     string
	RenderingEngineDescription string
	RenderingEngineMaker       string
}

type BrowserNode

type BrowserNode struct {
	ID                         int     `db:"id"`
	Parent                     string  `mapstructure:"Parent" db:"parent"`
	Pattern                    string  `mapstructure:"Pattern" db:"pattern"`
	Comment                    *string `mapstructure:"Comment" db:"comment" browscap:""`
	Browser                    *string `mapstructure:"Browser" db:"browser"`
	BrowserType                *string `mapstructure:"Browser_Type" db:"browser_type"`
	BrowserBits                *int    `mapstructure:"Browser_Bits" db:"browser_bits"`
	BrowserMaker               *string `mapstructure:"Browser_Maker" db:"browser_maker"`
	BrowserModus               *string `mapstructure:"Browser_Modus" db:"browser_modus"`
	Version                    *string `mapstructure:"Version" db:"version"`
	MajorVer                   *string `mapstructure:"MajorVer" db:"major_ver"`
	MinorVer                   *string `mapstructure:"MinorVer" db:"minor_ver"`
	Platform                   *string `mapstructure:"Platform" db:"platform"`
	PlatformVersion            *string `mapstructure:"Platform_Version" db:"platform_version"`
	PlatformDescription        *string `mapstructure:"Platform_Description" db:"platform_description"`
	PlatformBits               *int    `mapstructure:"Platform_Bits" db:"platform_bits"`
	PlatformMaker              *string `mapstructure:"Platform_Maker" db:"platform_maker"`
	Alpha                      *bool   `mapstructure:"Alpha" db:"alpha"`
	Beta                       *bool   `mapstructure:"Beta" db:"beta"`
	Win16                      *bool   `mapstructure:"Win16" db:"win16"`
	Win32                      *bool   `mapstructure:"Win32" db:"win32"`
	Win64                      *bool   `mapstructure:"Win64" db:"win64"`
	Frames                     *bool   `mapstructure:"Frames" db:"frames"`
	Iframes                    *bool   `mapstructure:"IFrames" db:"iframes"`
	Tables                     *bool   `mapstructure:"Tables" db:"tables"`
	Cookies                    *bool   `mapstructure:"Cookies" db:"cookies"`
	BackgroundSounds           *bool   `mapstructure:"BackgroundSounds" db:"background_sounds"`
	Javascript                 *bool   `mapstructure:"JavaScript" db:"javascript"`
	VBScript                   *bool   `mapstructure:"VBScript" db:"vbscript"`
	JavaApplets                *bool   `mapstructure:"JavaApplets" db:"java_applets"`
	ActiveXControls            *bool   `mapstructure:"ActiveXControls" db:"activex_controls"`
	IsMobileDevice             *bool   `mapstructure:"isMobileDevice" db:"is_mobile_device"`
	IsTablet                   *bool   `mapstructure:"isTablet" db:"is_tablet"`
	IsSyndicationReader        *bool   `mapstructure:"isSyndicationReader" db:"is_syndication_reader"`
	Crawler                    *bool   `mapstructure:"Crawler" db:"crawler"`
	IsFake                     *bool   `mapstructure:"isFake" db:"is_fake"`
	IsAnonymized               *bool   `mapstructure:"isAnonymized" db:"is_anonymized"`
	IsModified                 *bool   `mapstructure:"isModified" db:"is_modified"`
	CSSVersion                 *int    `mapstructure:"CssVersion" db:"css_version"`
	AolVersion                 *int    `mapstructure:"AolVersion" db:"aol_version"`
	DeviceName                 *string `mapstructure:"Device_Name" db:"device_name"`
	DeviceMaker                *string `mapstructure:"Device_Maker" db:"device_maker"`
	DeviceType                 *string `mapstructure:"Device_Type" db:"device_type"`
	DevicePointingMethod       *string `mapstructure:"Device_Pointing_Method" db:"device_pointing_method"`
	DeviceCodeName             *string `mapstructure:"Device_Code_Name" db:"device_code_name"`
	DeviceBrandName            *string `mapstructure:"Device_Brand_Name" db:"device_brand_name"`
	RenderingEngineName        *string `mapstructure:"RenderingEngine_Name" db:"rendering_engine_name"`
	RenderingEngineVersion     *string `mapstructure:"RenderingEngine_Version" db:"rendering_engine_version"`
	RenderingEngineDescription *string `mapstructure:"RenderingEngine_Description" db:"rendering_engine_description"`
	RenderingEngineMaker       *string `mapstructure:"RenderingEngine_Maker" db:"rendering_engine_maker"`
}

func (*BrowserNode) ToBrowser

func (n *BrowserNode) ToBrowser() *Browser

type BrowserStorage

type BrowserStorage interface {
	Prepare() error
	GetVersion() (*Version, error)
	SaveVersion(ver *Version) error
	Save(node *BrowserNode) error
	Get(pattern string) (*BrowserNode, error)
	Patterns() iter.Seq2[string, error]
}

type FixedPlaceholderMaker

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

func NewFixedPlaceholderMaker

func NewFixedPlaceholderMaker(char string) *FixedPlaceholderMaker

func (*FixedPlaceholderMaker) MakePlaceholder

func (f *FixedPlaceholderMaker) MakePlaceholder(from int) string

type Inserter

type Inserter interface {
	InsertIgnore(table string, columns []string, data any) error
}

type LRUCachedStorage

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

func NewLRUCachedStorage

func NewLRUCachedStorage(storage BrowserStorage, cacheSize int) (*LRUCachedStorage, error)

func (*LRUCachedStorage) Get

func (s *LRUCachedStorage) Get(pattern string) (*BrowserNode, error)

func (*LRUCachedStorage) GetVersion

func (s *LRUCachedStorage) GetVersion() (*Version, error)

func (*LRUCachedStorage) Patterns

func (s *LRUCachedStorage) Patterns() iter.Seq2[string, error]

func (*LRUCachedStorage) Prepare

func (s *LRUCachedStorage) Prepare() error

func (*LRUCachedStorage) Save

func (s *LRUCachedStorage) Save(node *BrowserNode) error

func (*LRUCachedStorage) SaveVersion

func (s *LRUCachedStorage) SaveVersion(ver *Version) error

type Loader

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

func NewLoader

func NewLoader(browserStorage BrowserStorage) *Loader

func (*Loader) Compile

func (l *Loader) Compile(filename string) error

func (*Loader) Load

func (l *Loader) Load() (*Browscap, error)

type MemoryBrowserStorage added in v0.1.3

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

func NewMemoryBrowserStorage added in v0.1.3

func NewMemoryBrowserStorage() *MemoryBrowserStorage

func (*MemoryBrowserStorage) Get added in v0.1.3

func (s *MemoryBrowserStorage) Get(pattern string) (*BrowserNode, error)

func (*MemoryBrowserStorage) GetVersion added in v0.1.3

func (s *MemoryBrowserStorage) GetVersion() (*Version, error)

func (*MemoryBrowserStorage) Patterns added in v0.1.3

func (s *MemoryBrowserStorage) Patterns() iter.Seq2[string, error]

func (*MemoryBrowserStorage) Prepare added in v0.1.3

func (s *MemoryBrowserStorage) Prepare() error

func (*MemoryBrowserStorage) Save added in v0.1.3

func (s *MemoryBrowserStorage) Save(node *BrowserNode) error

func (*MemoryBrowserStorage) SaveVersion added in v0.1.3

func (s *MemoryBrowserStorage) SaveVersion(ver *Version) error

type MetaQuoter

type MetaQuoter interface {
	QuoteMeta(string) string
}

type MysqlBrowserStorage

type MysqlBrowserStorage struct {
	*AbstractDBStorage
}

func NewMysqlBrowserStorage

func NewMysqlBrowserStorage(db *sqlx.DB) *MysqlBrowserStorage

func (*MysqlBrowserStorage) CreateTable

func (s *MysqlBrowserStorage) CreateTable(name string, columns string) error

func (*MysqlBrowserStorage) InsertIgnore

func (s *MysqlBrowserStorage) InsertIgnore(table string, columns []string, data any) error

func (*MysqlBrowserStorage) QuoteMeta

func (s *MysqlBrowserStorage) QuoteMeta(m string) string

func (*MysqlBrowserStorage) TableExists

func (s *MysqlBrowserStorage) TableExists(table string) (bool, error)

type NumberedPlaceholderMaker

type NumberedPlaceholderMaker struct{}

func NewNumberedPlaceholderMaker

func NewNumberedPlaceholderMaker() *NumberedPlaceholderMaker

func (*NumberedPlaceholderMaker) MakePlaceholder

func (n *NumberedPlaceholderMaker) MakePlaceholder(from int) string

type Patterns

type Patterns []string

func (Patterns) Len

func (p Patterns) Len() int

func (Patterns) Less

func (p Patterns) Less(i, j int) bool

func (Patterns) Swap

func (p Patterns) Swap(i, j int)

type PlaceholderMaker

type PlaceholderMaker interface {
	MakePlaceholder(from int) string
}

type PostgresBrowserStorage

type PostgresBrowserStorage struct {
	*AbstractDBStorage
}

func NewPostgresBrowserStorage

func NewPostgresBrowserStorage(db *sqlx.DB) *PostgresBrowserStorage

func (*PostgresBrowserStorage) CreateTable

func (s *PostgresBrowserStorage) CreateTable(name string, columns string) error

func (*PostgresBrowserStorage) InsertIgnore

func (s *PostgresBrowserStorage) InsertIgnore(table string, columns []string, data any) error

func (*PostgresBrowserStorage) QuoteMeta

func (s *PostgresBrowserStorage) QuoteMeta(m string) string

func (*PostgresBrowserStorage) TableExists

func (s *PostgresBrowserStorage) TableExists(table string) (bool, error)

type SqliteBrowserStorage

type SqliteBrowserStorage struct {
	*AbstractDBStorage
}

func NewSqliteBrowserStorage

func NewSqliteBrowserStorage(db *sqlx.DB) *SqliteBrowserStorage

func (*SqliteBrowserStorage) CreateTable

func (s *SqliteBrowserStorage) CreateTable(name string, columns string) error

func (*SqliteBrowserStorage) InsertIgnore

func (s *SqliteBrowserStorage) InsertIgnore(table string, columns []string, data any) error

func (*SqliteBrowserStorage) QuoteMeta

func (s *SqliteBrowserStorage) QuoteMeta(m string) string

func (*SqliteBrowserStorage) TableExists

func (s *SqliteBrowserStorage) TableExists(table string) (bool, error)

type TableCreator

type TableCreator interface {
	CreateTable(name string, columns string) error
}

type TableExistenceChecker

type TableExistenceChecker interface {
	TableExists(table string) (bool, error)
}

type Version

type Version struct {
	Version int    `db:"version"`
	Type    string `db:"type"`
}

Jump to

Keyboard shortcuts

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