validate

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Allowlist

func Allowlist(host string, allowed []string) bool

Allowlist checks if host is in the allowed list. Each entry can be:

  • a hostname: "gghstats.com"
  • an IP: "192.168.1.1"
  • a CIDR range: "10.0.0.0/8"

Empty allowlist = accept all.

func IgnoreIP added in v0.4.0

func IgnoreIP(ip string, ignore []string) bool

IgnoreIP returns true when ip should be excluded from stats (operator traffic).

func IsBot

func IsBot(ua string) bool

IsBot returns true if the request looks like a bot.

func Prefetch

func Prefetch(ua, purpose, secPurpose string) bool

Prefetch returns true if the request is a prefetch/prerender.

func ReferrerSpam added in v0.4.0

func ReferrerSpam(referrer string) bool

ReferrerSpam reports known spam referrer hostnames.

Types

type DatacenterBlocklist added in v0.4.0

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

DatacenterBlocklist matches cloud/hosting CIDR ranges.

func NewDatacenterBlocklist added in v0.4.0

func NewDatacenterBlocklist(extra []string) (*DatacenterBlocklist, error)

NewDatacenterBlocklist builds a blocklist from embedded defaults plus optional extra CIDR strings.

func (*DatacenterBlocklist) Contains added in v0.4.0

func (b *DatacenterBlocklist) Contains(ip string) bool

Contains reports whether ip falls in a blocked datacenter range.

Jump to

Keyboard shortcuts

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