ua

package
v6.8.5 Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Blacklist = []string{}/* 1199 elements not displayed */

Blacklist is a list of User-Agents to ignore.

Functions

func ContainsNonASCIICharacters

func ContainsNonASCIICharacters(ua string) bool

ContainsNonASCIICharacters returns true if the string only consists out of ASCII characters.

Types

type UserAgent added in v6.7.0

type UserAgent struct {
	// Time is the creation date for the database record.
	Time time.Time

	// UserAgent is the raw User-Agent string.
	UserAgent string

	// Browser is the browser name.
	Browser string

	// BrowserVersion is the browser (non-technical) version number.
	BrowserVersion string

	// OS is the operating system.
	OS string

	// OSVersion is the operating system version number.
	OSVersion string

	// Mobile indicated whether this is a mobile device from client hint headers.
	// It'll be set to null if the header is not present or empty.
	Mobile null.Bool
}

UserAgent contains information extracted from the User-Agent header. The creation time and User-Agent are stored in the database to find bots.

func Parse

func Parse(r *http.Request) UserAgent

Parse parses the User-Agent header for given request and returns the extracted information. This supports major browsers and operating systems.

func (*UserAgent) IsDesktop added in v6.7.0

func (ua *UserAgent) IsDesktop() bool

IsDesktop returns true if the user agent is a desktop device.

func (*UserAgent) IsMobile added in v6.7.0

func (ua *UserAgent) IsMobile() bool

IsMobile returns true if the user agent is a mobile device.

Jump to

Keyboard shortcuts

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