geolocate

package
v3.16.3 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2022 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package geolocate implements IP lookup, resolver lookup, and geolocation.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrAllIPLookuppersFailed indicates that we failed with looking
	// up the probe IP for with all the lookuppers that we tried.
	ErrAllIPLookuppersFailed = errors.New("all IP lookuppers failed")

	// ErrInvalidIPAddress indicates that the code returned to us a
	// string that actually isn't a valid IP address.
	ErrInvalidIPAddress = errors.New("lookupper did not return a valid IP")
)
View Source
var (
	// ErrNoIPAddressReturned indicates that no IP address was
	// returned by a specific DNS resolver.
	ErrNoIPAddressReturned = errors.New("geolocate: no IP address returned")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	// Resolver is the resolver we should use when
	// making requests for discovering the IP. When
	// this field is not set, we use the stdlib.
	Resolver model.Resolver

	// Logger is the logger to use. If not set, then we will
	// use a logger that discards all messages.
	Logger model.Logger

	// UserAgent is the user agent to use. If not set, then
	// we will use a default user agent.
	UserAgent string
}

Config contains configuration for a geolocate Task.

type Results

type Results struct {
	// ASN is the autonomous system number.
	ASN uint

	// CountryCode is the country code.
	CountryCode string

	// NetworkName is the network name.
	NetworkName string

	// IP is the probe IP.
	ProbeIP string

	// ResolverASN is the resolver ASN.
	ResolverASN uint

	// ResolverIP is the resolver IP.
	ResolverIP string

	// ResolverNetworkName is the resolver network name.
	ResolverNetworkName string
	// contains filtered or unexported fields
}

Results contains geolocate results.

func (*Results) ASNString

func (r *Results) ASNString() string

ASNString returns the ASN as a string.

type Task

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

Task performs a geolocation. You must create a new instance of Task using the NewTask factory.

func NewTask

func NewTask(config Config) *Task

NewTask creates a new instance of Task from config.

func (Task) Run

func (op Task) Run(ctx context.Context) (*Results, error)

Run runs the task.

Jump to

Keyboard shortcuts

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