helper

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2025 License: Unlicense Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FetchGooglebotIPs added in v1.12.0

func FetchGooglebotIPs(log *slog.Logger, httpClient *http.Client, url string) ([]string, error)

FetchGooglebotIPs fetches the list of Googlebot IPs from Google's official endpoint, parses the JSON response, and returns a slice of CIDR strings.

func GetDefaultTmpl

func GetDefaultTmpl() string

need to hardcode a default template given yaegi's constraints on finding files on disk provided by this plugin

func GetPojJS added in v1.11.0

func GetPojJS() string

GetPojJS returns the proof-of-javascript JavaScript implementation

func IsIpExcluded

func IsIpExcluded(clientIP string, exemptIps []*net.IPNet) bool

func IsIpGoodBot

func IsIpGoodBot(clientIP string, goodBots []string) bool

func ParseCIDR

func ParseCIDR(cidr string) (*net.IPNet, error)

Types

type GooglebotIPs added in v1.12.0

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

GooglebotIPs holds the list of Googlebot IP ranges, providing a thread-safe way to check if an IP is a Googlebot.

func NewGooglebotIPs added in v1.12.0

func NewGooglebotIPs() *GooglebotIPs

NewGooglebotIPs creates and initializes a new GooglebotIPs object.

func (*GooglebotIPs) Contains added in v1.12.0

func (g *GooglebotIPs) Contains(ip net.IP) bool

Contains checks if the given IP address is within any of the stored Googlebot IP ranges.

func (*GooglebotIPs) Update added in v1.12.0

func (g *GooglebotIPs) Update(cidrs []string, log *slog.Logger)

Update parses a slice of CIDR strings and replaces the existing IP ranges with the new ones. It logs an error for any CIDR string that fails to parse.

Jump to

Keyboard shortcuts

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