speedtestdotnet

package
v0.0.0-...-2acbbe9 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2023 License: MIT Imports: 12 Imported by: 4

Documentation

Index

Constants

View Source
const (
	KB = 1024 * bits
	MB = 1024 * KB
	GB = 1024 * MB
	TB = 1024 * GB
	PB = 1024 * TB
)

Variables

View Source
var (
	ErrTimeout = errors.New("Timeout")
)

Functions

func GetServerList

func GetServerList() ([]server, error)

GetServerList returns a list of servers in the native speedtest.net structure

func HumanSpeed

func HumanSpeed(bps uint64) string

Types

type Config

type Config struct {
	LicenseKey string
	IP         net.IP
	Lat        float64
	Long       float64
	ISP        string
	Servers    []Testserver
}

func GetConfig

func GetConfig() (*Config, error)

GetConfig returns a configuration containing information about our client and a list of acceptable servers sorted by distance

type Testserver

type Testserver struct {
	Name     string
	Sponsor  string
	Country  string
	Lat      float64
	Long     float64
	Distance float64 //distance from server in KM
	URLs     []string
	Host     string
	Latency  time.Duration //latency in ms
}

func (*Testserver) Downstream

func (ts *Testserver) Downstream(duration int, interface_id string) (uint64, error)

Downstream measures upstream bandwidth in bps

func (*Testserver) MedianPing

func (ts *Testserver) MedianPing(count int) (time.Duration, error)

MedianPing runs a latency test against the server and stores the median latency

func (*Testserver) Ping

func (ts *Testserver) Ping(count int) ([]time.Duration, error)

Ping will run count number of latency tests and return the results of each

func (*Testserver) Upstream

func (ts *Testserver) Upstream(duration int, interface_id string) (uint64, error)

Upstream measures upstream bandwidth in bps

Jump to

Keyboard shortcuts

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