Documentation
¶
Index ¶
- Variables
- func CHBool(val bool) string
- func CHBrandList(brands []Brand) string
- func CHList(list []string) string
- func CHString(val string) string
- func Contains(slice []string, val string) bool
- type AndroidVersion
- type AndroidVersionSpec
- type Brand
- type ChromiumVersion
- type ChromiumVersionSpec
- type ClientHints
- type FormatOption
- type GenerateConfig
- type GeneratorData
- type Headers
- type IntOrRange
- type Navigator
- type Options
- type SafariVersion
- type SafariVersionSpec
- type UserAgent
- type Version
- type VersionRange
- type VersionSpec
- type WindowsVersion
- type WindowsVersionSpec
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidDevice = errors.New("uagenerator: invalid device type") ErrInvalidPlatform = errors.New("uagenerator: invalid platform") ErrInvalidBrowser = errors.New("uagenerator: invalid browser") )
var ( Fixed = core.Fixed Range = core.Range NewVersion = core.NewVersion WithPartitions = core.WithPartitions WithLimit = core.WithLimit WithSeparator = core.WithSeparator WithTrimZero = core.WithTrimZero NewVersionRange = core.NewVersionRange )
Re-exported constructors and options — delegate to core.
var Browsers = []string{"chrome", "edge", "firefox", "safari"}
Valid browsers.
var BrowsersSupportCH = []string{"chrome", "edge"}
BrowsersSupportCH lists browsers that support Client Hints.
var Devices = []string{"desktop", "mobile"}
Valid device types.
var Platforms = []string{"windows", "macos", "ios", "linux", "android"}
Valid platforms.
var PlatformsDesktop = []string{"windows", "macos", "linux"}
PlatformsDesktop lists platforms available on desktop devices.
var PlatformsMobile = []string{"ios", "android"}
PlatformsMobile lists platforms available on mobile devices.
Functions ¶
func CHBrandList ¶
CHBrandList formats a list of brands as a Client Hints brand list. Example output: `"Not A(Brand";v="99", "Chromium";v="103", "Google Chrome";v="103"`
func CHList ¶
CHList formats a string slice as a quoted comma-separated Client Hints list. Example: CHList([]string{"Desktop"}) returns `"Desktop"`.
Types ¶
type AndroidVersion ¶
type AndroidVersion = core.AndroidVersion
Type aliases — fully transparent to all external code.
type AndroidVersionSpec ¶
type AndroidVersionSpec = core.AndroidVersionSpec
Type aliases — fully transparent to all external code.
type ChromiumVersion ¶
type ChromiumVersion = core.ChromiumVersion
Type aliases — fully transparent to all external code.
type ChromiumVersionSpec ¶
type ChromiumVersionSpec = core.ChromiumVersionSpec
Type aliases — fully transparent to all external code.
type ClientHints ¶
type ClientHints struct {
Mobile string // "?0" or "?1"
Platform string // e.g., `"Windows"` (quoted)
PlatformVersion string // e.g., `"13.0.0"` (quoted)
Brands string // e.g., `"Not A(Brand";v="99", "Chromium";v="129", "Google Chrome";v="129"`
BrandsFullVersionList string // full version list
BrowserVersion string // e.g., `"129"` (quoted, major only)
BrowserFullVersion string // e.g., `"129.0.6668.116"` (quoted)
Bitness string // e.g., `"64"` (quoted)
Architecture string // e.g., `"x86"` (quoted)
FormFactors string // e.g., `"Desktop"`
Model string // e.g., `"SM-G998U"` (quoted, Android only)
Wow64 string // "?0" or "?1"
// contains filtered or unexported fields
}
ClientHints contains computed Sec-CH-UA header field values.
func NewClientHints ¶
func NewClientHints(gen *GeneratorData) *ClientHints
NewClientHints creates a ClientHints by eagerly computing all fields from the given Generator.
type FormatOption ¶
type FormatOption = core.FormatOption
Type aliases — fully transparent to all external code.
type GenerateConfig ¶
type GenerateConfig struct {
Device []string // e.g., []string{"desktop"}, []string{"desktop", "mobile"}
Platform []string // e.g., []string{"windows", "macos"}
Browser []string // e.g., []string{"chrome", "edge"}
Options *Options
}
GenerateConfig holds parameters for user-agent generation. All fields are optional. Nil or zero value means no constraint.
type GeneratorData ¶
type GeneratorData = core.GeneratorData
GeneratorData holds the subset of generator fields needed by ClientHints.
type Headers ¶
type Headers struct {
// contains filtered or unexported fields
}
Headers manages HTTP headers including User-Agent and Client Hints.
func NewHeaders ¶
func NewHeaders(userAgent, browser string, ch *ClientHints) *Headers
NewHeaders creates a Headers instance with default headers populated.
func (*Headers) AcceptCH ¶
AcceptCH parses a comma-separated Accept-CH header value and adds the corresponding Client Hints headers. This resets existing headers first. If the browser doesn't support Client Hints, this is a no-op (only resets).
type IntOrRange ¶
type IntOrRange = core.IntOrRange
Type aliases — fully transparent to all external code.
type Navigator ¶
type Navigator struct {
// contains filtered or unexported fields
}
Navigator provides data matching the JavaScript navigator.userAgentData API.
func NewNavigator ¶
func NewNavigator(ch *ClientHints) *Navigator
NewNavigator creates a Navigator from a ClientHints.
type SafariVersion ¶
type SafariVersion = core.SafariVersion
Type aliases — fully transparent to all external code.
type SafariVersionSpec ¶
type SafariVersionSpec = core.SafariVersionSpec
Type aliases — fully transparent to all external code.
type UserAgent ¶
type UserAgent struct {
Device string
Platform string
Browser string
Text string
CH *ClientHints
Headers *Headers
}
UserAgent is the result of user-agent generation.
func Generate ¶
func Generate(cfg *GenerateConfig) (*UserAgent, error)
Generate creates a random UserAgent. Pass nil for default (fully random) config.
type VersionRange ¶
type VersionRange = core.VersionRange
Type aliases — fully transparent to all external code.
type VersionSpec ¶
type VersionSpec = core.VersionSpec
Type aliases — fully transparent to all external code.
type WindowsVersion ¶
type WindowsVersion = core.WindowsVersion
Type aliases — fully transparent to all external code.
type WindowsVersionSpec ¶
type WindowsVersionSpec = core.WindowsVersionSpec
Type aliases — fully transparent to all external code.