probe

package
v0.0.0-...-da44132 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: LGPL-3.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache caches probe lookup results

func NewCache

func NewCache(ttl time.Duration) *Cache

NewCache creates a probe cache

func (*Cache) Add

func (c *Cache) Add(id int, p *Probe)

Add adds a probe to the cache

func (*Cache) CleanUp

func (c *Cache) CleanUp() int

CleanUp removes expired cache items

func (*Cache) Get

func (c *Cache) Get(id int) (*Probe, bool)

Get retrieves a probe from the cache (if exists, else returns false)

type Probe

type Probe struct {
	ID          int    `json:"id"`
	Asn4        int    `json:"asn_v4"`
	Asn6        int    `json:"asn_v6"`
	CountryCode string `json:"country_code"`
	Geometry    struct {
		Coordinates []float64 `json:"coordinates"`
	} `json:"geometry"`
}

Probe holds information about a single Atlas probe

func FromJSON

func FromJSON(body []byte) (*Probe, error)

FromJSON parses json and returns a probe

func Get

func Get(id int) (*Probe, error)

Get probe information from API

func (*Probe) ASNForIPVersion

func (p *Probe) ASNForIPVersion(v int) int

ASNForIPVersion return the ASN for the given IP Version

func (*Probe) Latitude

func (p *Probe) Latitude() string

Latitude of the geo location of the probe

func (*Probe) Longitude

func (p *Probe) Longitude() string

Longitude of the geo location of the probe

Jump to

Keyboard shortcuts

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