info

package
v0.0.0-...-b72711b Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTooManyRequests = errors.New("too many requests sent")
	ErrBadHTTPStatus   = errors.New("bad HTTP status received")
)
View Source
var ErrUnknownProvider = errors.New("unknown public IP information provider")

Functions

func ValidateProvider

func ValidateProvider(provider Provider) error

Types

type Info

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

func New

func New(client *http.Client, options ...Option) (info *Info, err error)

func (*Info) Get

func (i *Info) Get(ctx context.Context, ip netip.Addr) (result Result, err error)

Get finds IP information for the given IP address using one of the ip data provider picked at random. A `nil` IP address can be given to signal to fetch information on the current public IP address.

func (*Info) GetMultiple

func (i *Info) GetMultiple(ctx context.Context, ips []netip.Addr) (results []Result, err error)

GetMultiple finds IP information for the given IP addresses, each using one of the ip data provider picked at random. It returns a slice of results matching the order of the IP addresses given as argument.

type Option

type Option func(s *settings) error

func SetProviders

func SetProviders(first Provider, providers ...Provider) Option

type Provider

type Provider string
const (
	Ipinfo      Provider = "ipinfo"
	IP2Location Provider = "ip2location"
)

func ListProviders

func ListProviders() []Provider

type Result

type Result struct {
	IP      netip.Addr
	Country *string
	Region  *string
	City    *string
	Source  string
}

Jump to

Keyboard shortcuts

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